#!/usr/bin/env python3 # vim:fileencoding=utf-8 # License: GPL v3 Copyright: 2018, Kovid Goyal import os from functools import lru_cache, partial, wraps from typing import ( Any, Callable, Dict, List, NamedTuple, Optional, Sequence, Tuple ) from .config import build_ansi_color_table from .constants import config_dir from .fast_data_types import ( DECAWM, Screen, cell_size_for_window, get_options, pt_to_px, set_tab_bar_render_data, viewport_for_window ) from .layout.base import Rect from .rgb import Color, alpha_blend, color_as_sgr, color_from_int, to_color from .types import WindowGeometry, run_once from .typing import EdgeLiteral, PowerlineStyle from .utils import color_as_int, log_error from .window import calculate_gl_geometry class TabBarData(NamedTuple): title: str is_active: bool needs_attention: bool num_windows: int num_window_groups: int layout_name: str has_activity_since_last_focus: bool class DrawData(NamedTuple): leading_spaces: int sep: str trailing_spaces: int bell_on_tab: bool bell_fg: int alpha: Sequence[float] active_fg: Color active_bg: Color inactive_fg: Color inactive_bg: Color default_bg: Color title_template: str active_title_template: Optional[str] tab_activity_symbol: Optional[str] powerline_style: PowerlineStyle tab_bar_edge: EdgeLiteral def as_rgb(x: int) -> int: return (x << 8) | 2 @lru_cache() def report_template_failure(template: str, e: str) -> None: log_error('Invalid tab title template: "{}" with error: {}'.format(template, e)) @lru_cache() def compile_template(template: str) -> Any: try: return compile('f"""' + template + '"""', '