Exemple #1
0
def _draw_right_status(screen: Screen, is_last: bool) -> int:
    if not is_last:
        return 0

    draw_attributed_string(Formatter.reset, screen)
    date = datetime.datetime.now().strftime(" %H:%M")
    utc_date = datetime.datetime.now(
        datetime.timezone.utc).strftime(" (UTC %H:%M)")

    right_status_length = calc_draw_spaces(date + " " + utc_date + " ")

    draw_spaces = screen.columns - screen.cursor.x - right_status_length
    if draw_spaces > 0:
        screen.draw(" " * draw_spaces)

    cells = [
        (Color(135, 192, 149), date),
        (Color(113, 115, 116), utc_date),
    ]

    screen.cursor.fg = 0
    for color, status in cells:
        screen.cursor.fg = as_rgb(color_as_int(color))
        screen.draw(status)
    screen.cursor.bg = 0

    if screen.columns - screen.cursor.x > right_status_length:
        screen.cursor.x = screen.columns - right_status_length

    return screen.cursor.x
Exemple #2
0
def _draw_icon(screen: Screen, index: int, symbol: str = "") -> int:
    if index != 1:
        return 0

    fg, bg = screen.cursor.fg, screen.cursor.bg
    screen.cursor.fg = as_rgb(color_as_int(Color(255, 250, 205)))
    screen.cursor.bg = as_rgb(color_as_int(Color(60, 71, 77)))
    screen.draw(symbol)
    screen.cursor.fg, screen.cursor.bg = fg, bg
    screen.cursor.x = len(symbol)
    return screen.cursor.x
Exemple #3
0
 def __getattr__(self, key: str) -> typing.Any:
     if key.startswith("color"):
         q = key[5:]
         if q.isdigit():
             k = int(q)
             if 0 <= k <= 255:
                 x = self.color_table[k]
                 return Color((x >> 16) & 255, (x >> 8) & 255, x & 255)
     raise AttributeError(key)
Exemple #4
0
 def response_from_kitty(self, boss: Boss, window: Optional[Window], payload_get: PayloadGetType) -> ResponseType:
     windows = self.windows_for_payload(boss, window, payload_get)
     colors = payload_get('colors')
     cursor_text_color = payload_get('cursor_text_color', missing=False)
     if payload_get('reset'):
         colors = {k: color_as_int(v) for k, v in boss.startup_colors.items()}
         cursor_text_color = boss.startup_cursor_text_color
     profiles = tuple(w.screen.color_profile for w in windows)
     if isinstance(cursor_text_color, (tuple, list, Color)):
         cursor_text_color = color_as_int(Color(*cursor_text_color))
     patch_color_profiles(colors, cursor_text_color, profiles, payload_get('configured'))
     boss.patch_colors(colors, cursor_text_color, payload_get('configured'))
     default_bg_changed = 'background' in colors
     for w in windows:
         if default_bg_changed:
             boss.default_bg_changed_for(w.id)
         w.refresh()
Exemple #5
0
class Options:
    active_border_color: typing.Optional[kitty.rgb.Color] = Color(red=0,
                                                                  green=255,
                                                                  blue=0)
    active_tab_background: Color = Color(red=238, green=238, blue=238)
    active_tab_font_style: typing.Tuple[bool, bool] = (True, True)
    active_tab_foreground: Color = Color(red=0, green=0, blue=0)
    active_tab_title_template: typing.Optional[str] = None
    adjust_baseline: typing.Union[int, float] = 0
    adjust_column_width: typing.Union[int, float] = 0
    adjust_line_height: typing.Union[int, float] = 0
    allow_hyperlinks: int = 1
    allow_remote_control: str = 'n'
    background: Color = Color(red=0, green=0, blue=0)
    background_image: typing.Optional[str] = None
    background_image_layout: choices_for_background_image_layout = 'tiled'
    background_image_linear: bool = False
    background_opacity: float = 1.0
    background_tint: float = 0
    bell_border_color: Color = Color(red=255, green=90, blue=0)
    bell_on_tab: bool = True
    bold_font: str = 'auto'
    bold_italic_font: str = 'auto'
    box_drawing_scale: typing.Tuple[float, float, float,
                                    float] = (0.001, 1.0, 1.5, 2.0)
    clear_all_shortcuts: bool = False
    click_interval: float = -1.0
    clipboard_control: typing.Tuple[str,
                                    ...] = ('write-clipboard', 'write-primary')
    close_on_child_death: bool = False
    command_on_bell: typing.List[str] = ['none']
    confirm_os_window_close: int = 0
    copy_on_select: str = ''
    cursor: Color = Color(red=204, green=204, blue=204)
    cursor_beam_thickness: float = 1.5
    cursor_blink_interval: float = -1.0
    cursor_shape: int = 1
    cursor_stop_blinking_after: float = 15.0
    cursor_text_color: typing.Optional[kitty.rgb.Color] = Color(red=17,
                                                                green=17,
                                                                blue=17)
    cursor_underline_thickness: float = 2.0
    default_pointer_shape: choices_for_default_pointer_shape = 'beam'
    detect_urls: bool = True
    dim_opacity: float = 0.75
    disable_ligatures: int = 0
    draw_minimal_borders: bool = True
    dynamic_background_opacity: bool = False
    editor: str = '.'
    enable_audio_bell: bool = True
    enabled_layouts: typing.List[str] = [
        'fat', 'grid', 'horizontal', 'splits', 'stack', 'tall', 'vertical'
    ]
    focus_follows_mouse: bool = False
    font_family: str = 'monospace'
    font_size: float = 11.0
    force_ltr: bool = False
    foreground: Color = Color(red=221, green=221, blue=221)
    hide_window_decorations: int = 0
    inactive_border_color: Color = Color(red=204, green=204, blue=204)
    inactive_tab_background: Color = Color(red=153, green=153, blue=153)
    inactive_tab_font_style: typing.Tuple[bool, bool] = (False, False)
    inactive_tab_foreground: Color = Color(red=68, green=68, blue=68)
    inactive_text_alpha: float = 1.0
    initial_window_height: typing.Tuple[int, str] = (400, 'px')
    initial_window_width: typing.Tuple[int, str] = (640, 'px')
    input_delay: int = 3
    italic_font: str = 'auto'
    kitty_mod: int = 5
    linux_display_server: choices_for_linux_display_server = 'auto'
    listen_on: str = 'none'
    macos_custom_beam_cursor: bool = False
    macos_hide_from_tasks: bool = False
    macos_option_as_alt: int = 0
    macos_quit_when_last_window_closed: bool = False
    macos_show_window_title_in: choices_for_macos_show_window_title_in = 'all'
    macos_thicken_font: float = 0
    macos_titlebar_color: int = 0
    macos_traditional_fullscreen: bool = False
    macos_window_resizable: bool = True
    mark1_background: Color = Color(red=152, green=211, blue=203)
    mark1_foreground: Color = Color(red=0, green=0, blue=0)
    mark2_background: Color = Color(red=242, green=220, blue=211)
    mark2_foreground: Color = Color(red=0, green=0, blue=0)
    mark3_background: Color = Color(red=242, green=116, blue=188)
    mark3_foreground: Color = Color(red=0, green=0, blue=0)
    mouse_hide_wait: float = 0.0 if is_macos else 3.0
    open_url_with: typing.List[str] = ['default']
    placement_strategy: choices_for_placement_strategy = 'center'
    pointer_shape_when_dragging: choices_for_pointer_shape_when_dragging = 'beam'
    pointer_shape_when_grabbed: choices_for_pointer_shape_when_grabbed = 'arrow'
    remember_window_size: bool = True
    repaint_delay: int = 10
    resize_debounce_time: float = 0.1
    resize_draw_strategy: int = 0
    resize_in_steps: bool = False
    scrollback_fill_enlarged_window: bool = False
    scrollback_lines: int = 2000
    scrollback_pager: typing.List[str] = [
        'less', '--chop-long-lines', '--RAW-CONTROL-CHARS',
        '+INPUT_LINE_NUMBER'
    ]
    scrollback_pager_history_size: int = 0
    select_by_word_characters: str = '@-./_~?&=%+#'
    selection_background: Color = Color(red=255, green=250, blue=205)
    selection_foreground: typing.Optional[kitty.rgb.Color] = Color(red=0,
                                                                   green=0,
                                                                   blue=0)
    shell: str = '.'
    single_window_margin_width: FloatEdges = FloatEdges(left=-1.0,
                                                        top=-1.0,
                                                        right=-1.0,
                                                        bottom=-1.0)
    startup_session: typing.Optional[str] = None
    strip_trailing_spaces: choices_for_strip_trailing_spaces = 'never'
    sync_to_monitor: bool = True
    tab_activity_symbol: typing.Optional[str] = None
    tab_bar_background: typing.Optional[kitty.rgb.Color] = None
    tab_bar_edge: int = 3
    tab_bar_margin_height: TabBarMarginHeight = TabBarMarginHeight(outer=0,
                                                                   inner=0)
    tab_bar_margin_width: float = 0
    tab_bar_min_tabs: int = 2
    tab_bar_style: choices_for_tab_bar_style = 'fade'
    tab_fade: typing.Tuple[float, ...] = (0.25, 0.5, 0.75, 1.0)
    tab_powerline_style: choices_for_tab_powerline_style = 'angled'
    tab_separator: str = ' ┇'
    tab_switch_strategy: choices_for_tab_switch_strategy = 'previous'
    tab_title_template: str = '{title}'
    term: str = 'xterm-kitty'
    touch_scroll_multiplier: float = 1.0
    update_check_interval: float = 24.0
    url_color: Color = Color(red=0, green=135, blue=189)
    url_excluded_characters: str = ''
    url_prefixes: typing.Tuple[str, ...] = ('http', 'https', 'file', 'ftp',
                                            'gemini', 'irc', 'gopher',
                                            'mailto', 'news', 'git')
    url_style: int = 3
    visual_bell_duration: float = 0
    wayland_titlebar_color: int = 0
    wheel_scroll_multiplier: float = 5.0
    window_alert_on_bell: bool = True
    window_border_width: typing.Tuple[float, str] = (0.5, 'pt')
    window_margin_width: FloatEdges = FloatEdges(left=0,
                                                 top=0,
                                                 right=0,
                                                 bottom=0)
    window_padding_width: FloatEdges = FloatEdges(left=0,
                                                  top=0,
                                                  right=0,
                                                  bottom=0)
    window_resize_step_cells: int = 2
    window_resize_step_lines: int = 2
    env: typing.Dict[str, str] = {}
    font_features: typing.Dict[str, typing.Tuple[kitty.fonts.FontFeature,
                                                 ...]] = {}
    kitten_alias: typing.Dict[str, typing.List[str]] = {}
    symbol_map: typing.Dict[typing.Tuple[int, int], str] = {}
    map: typing.List[kitty.options.utils.KeyDefinition] = []
    keymap: KeyMap = {}
    sequence_map: SequenceMap = {}
    mouse_map: typing.List[kitty.options.utils.MouseMapping] = []
    mousemap: MouseMap = {}
    color_table: array = array("L", (
        0x000000,
        0xcc0403,
        0x19cb00,
        0xcecb00,
        0x0d73cc,
        0xcb1ed1,
        0x0dcdcd,
        0xdddddd,
        0x767676,
        0xf2201f,
        0x23fd00,
        0xfffd00,
        0x1a8fff,
        0xfd28ff,
        0x14ffff,
        0xffffff,
        0x000000,
        0x00005f,
        0x000087,
        0x0000af,
        0x0000d7,
        0x0000ff,
        0x005f00,
        0x005f5f,
        0x005f87,
        0x005faf,
        0x005fd7,
        0x005fff,
        0x008700,
        0x00875f,
        0x008787,
        0x0087af,
        0x0087d7,
        0x0087ff,
        0x00af00,
        0x00af5f,
        0x00af87,
        0x00afaf,
        0x00afd7,
        0x00afff,
        0x00d700,
        0x00d75f,
        0x00d787,
        0x00d7af,
        0x00d7d7,
        0x00d7ff,
        0x00ff00,
        0x00ff5f,
        0x00ff87,
        0x00ffaf,
        0x00ffd7,
        0x00ffff,
        0x5f0000,
        0x5f005f,
        0x5f0087,
        0x5f00af,
        0x5f00d7,
        0x5f00ff,
        0x5f5f00,
        0x5f5f5f,
        0x5f5f87,
        0x5f5faf,
        0x5f5fd7,
        0x5f5fff,
        0x5f8700,
        0x5f875f,
        0x5f8787,
        0x5f87af,
        0x5f87d7,
        0x5f87ff,
        0x5faf00,
        0x5faf5f,
        0x5faf87,
        0x5fafaf,
        0x5fafd7,
        0x5fafff,
        0x5fd700,
        0x5fd75f,
        0x5fd787,
        0x5fd7af,
        0x5fd7d7,
        0x5fd7ff,
        0x5fff00,
        0x5fff5f,
        0x5fff87,
        0x5fffaf,
        0x5fffd7,
        0x5fffff,
        0x870000,
        0x87005f,
        0x870087,
        0x8700af,
        0x8700d7,
        0x8700ff,
        0x875f00,
        0x875f5f,
        0x875f87,
        0x875faf,
        0x875fd7,
        0x875fff,
        0x878700,
        0x87875f,
        0x878787,
        0x8787af,
        0x8787d7,
        0x8787ff,
        0x87af00,
        0x87af5f,
        0x87af87,
        0x87afaf,
        0x87afd7,
        0x87afff,
        0x87d700,
        0x87d75f,
        0x87d787,
        0x87d7af,
        0x87d7d7,
        0x87d7ff,
        0x87ff00,
        0x87ff5f,
        0x87ff87,
        0x87ffaf,
        0x87ffd7,
        0x87ffff,
        0xaf0000,
        0xaf005f,
        0xaf0087,
        0xaf00af,
        0xaf00d7,
        0xaf00ff,
        0xaf5f00,
        0xaf5f5f,
        0xaf5f87,
        0xaf5faf,
        0xaf5fd7,
        0xaf5fff,
        0xaf8700,
        0xaf875f,
        0xaf8787,
        0xaf87af,
        0xaf87d7,
        0xaf87ff,
        0xafaf00,
        0xafaf5f,
        0xafaf87,
        0xafafaf,
        0xafafd7,
        0xafafff,
        0xafd700,
        0xafd75f,
        0xafd787,
        0xafd7af,
        0xafd7d7,
        0xafd7ff,
        0xafff00,
        0xafff5f,
        0xafff87,
        0xafffaf,
        0xafffd7,
        0xafffff,
        0xd70000,
        0xd7005f,
        0xd70087,
        0xd700af,
        0xd700d7,
        0xd700ff,
        0xd75f00,
        0xd75f5f,
        0xd75f87,
        0xd75faf,
        0xd75fd7,
        0xd75fff,
        0xd78700,
        0xd7875f,
        0xd78787,
        0xd787af,
        0xd787d7,
        0xd787ff,
        0xd7af00,
        0xd7af5f,
        0xd7af87,
        0xd7afaf,
        0xd7afd7,
        0xd7afff,
        0xd7d700,
        0xd7d75f,
        0xd7d787,
        0xd7d7af,
        0xd7d7d7,
        0xd7d7ff,
        0xd7ff00,
        0xd7ff5f,
        0xd7ff87,
        0xd7ffaf,
        0xd7ffd7,
        0xd7ffff,
        0xff0000,
        0xff005f,
        0xff0087,
        0xff00af,
        0xff00d7,
        0xff00ff,
        0xff5f00,
        0xff5f5f,
        0xff5f87,
        0xff5faf,
        0xff5fd7,
        0xff5fff,
        0xff8700,
        0xff875f,
        0xff8787,
        0xff87af,
        0xff87d7,
        0xff87ff,
        0xffaf00,
        0xffaf5f,
        0xffaf87,
        0xffafaf,
        0xffafd7,
        0xffafff,
        0xffd700,
        0xffd75f,
        0xffd787,
        0xffd7af,
        0xffd7d7,
        0xffd7ff,
        0xffff00,
        0xffff5f,
        0xffff87,
        0xffffaf,
        0xffffd7,
        0xffffff,
        0x080808,
        0x121212,
        0x1c1c1c,
        0x262626,
        0x303030,
        0x3a3a3a,
        0x444444,
        0x4e4e4e,
        0x585858,
        0x626262,
        0x6c6c6c,
        0x767676,
        0x808080,
        0x8a8a8a,
        0x949494,
        0x9e9e9e,
        0xa8a8a8,
        0xb2b2b2,
        0xbcbcbc,
        0xc6c6c6,
        0xd0d0d0,
        0xdadada,
        0xe4e4e4,
        0xeeeeee,
    ))
    config_paths: typing.Tuple[str, ...] = ()
    config_overrides: typing.Tuple[str, ...] = ()

    def __init__(
        self,
        options_dict: typing.Optional[typing.Dict[str, typing.Any]] = None
    ) -> None:
        if options_dict is not None:
            for key in option_names:
                setattr(self, key, options_dict[key])

    @property
    def _fields(self) -> typing.Tuple[str, ...]:
        return option_names

    def __iter__(self) -> typing.Iterator[str]:
        return iter(self._fields)

    def __len__(self) -> int:
        return len(self._fields)

    def _copy_of_val(self, name: str) -> typing.Any:
        ans = getattr(self, name)
        if isinstance(ans, dict):
            ans = ans.copy()
        elif isinstance(ans, list):
            ans = ans[:]
        return ans

    def _asdict(self) -> typing.Dict[str, typing.Any]:
        return {k: self._copy_of_val(k) for k in self}

    def _replace(self, **kw: typing.Any) -> "Options":
        ans = Options()
        for name in self:
            setattr(ans, name, self._copy_of_val(name))
        for name, val in kw.items():
            setattr(ans, name, val)
        return ans

    def __getitem__(self, key: typing.Union[int, str]) -> typing.Any:
        k = option_names[key] if isinstance(key, int) else key
        try:
            return getattr(self, k)
        except AttributeError:
            pass
        raise KeyError(f"No option named: {k}")

    def __getattr__(self, key: str) -> typing.Any:
        if key.startswith("color"):
            q = key[5:]
            if q.isdigit():
                k = int(q)
                if 0 <= k <= 255:
                    x = self.color_table[k]
                    return Color((x >> 16) & 255, (x >> 8) & 255, x & 255)
        raise AttributeError(key)

    def __setattr__(self, key: str, val: typing.Any) -> typing.Any:
        if key.startswith("color"):
            q = key[5:]
            if q.isdigit():
                k = int(q)
                if 0 <= k <= 255:
                    self.color_table[k] = int(val)
                    return
        object.__setattr__(self, key, val)
Exemple #6
0
class Options:
    added_bg: Color = Color(red=230, green=255, blue=237)
    added_margin_bg: Color = Color(red=205, green=255, blue=216)
    background: Color = Color(red=255, green=255, blue=255)
    diff_cmd: str = 'auto'
    filler_bg: Color = Color(red=250, green=251, blue=252)
    foreground: Color = Color(red=0, green=0, blue=0)
    highlight_added_bg: Color = Color(red=172, green=242, blue=189)
    highlight_removed_bg: Color = Color(red=253, green=184, blue=192)
    hunk_bg: Color = Color(red=241, green=248, blue=255)
    hunk_margin_bg: Color = Color(red=219, green=237, blue=255)
    margin_bg: Color = Color(red=250, green=251, blue=252)
    margin_fg: Color = Color(red=170, green=170, blue=170)
    margin_filler_bg: typing.Optional[kitty.rgb.Color] = None
    num_context_lines: int = 3
    pygments_style: str = 'default'
    removed_bg: Color = Color(red=255, green=238, blue=240)
    removed_margin_bg: Color = Color(red=255, green=220, blue=224)
    replace_tab_by: str = '    '
    search_bg: Color = Color(red=68, green=68, blue=68)
    search_fg: Color = Color(red=255, green=255, blue=255)
    select_bg: Color = Color(red=180, green=213, blue=254)
    select_fg: typing.Optional[kitty.rgb.Color] = Color(red=0, green=0, blue=0)
    syntax_aliases: typing.Dict[str, str] = {
        'pyj': 'py',
        'pyi': 'py',
        'recipe': 'py'
    }
    title_bg: Color = Color(red=255, green=255, blue=255)
    title_fg: Color = Color(red=0, green=0, blue=0)
    map: typing.List[typing.Tuple[kitty.types.ParsedShortcut,
                                  kitty.conf.utils.KeyAction]] = []
    key_definitions: KittensKeyMap = {}
    config_paths: typing.Tuple[str, ...] = ()
    config_overrides: typing.Tuple[str, ...] = ()

    def __init__(
        self,
        options_dict: typing.Optional[typing.Dict[str, typing.Any]] = None
    ) -> None:
        if options_dict is not None:
            null = object()
            for key in option_names:
                val = options_dict.get(key, null)
                if val is not null:
                    setattr(self, key, val)

    @property
    def _fields(self) -> typing.Tuple[str, ...]:
        return option_names

    def __iter__(self) -> typing.Iterator[str]:
        return iter(self._fields)

    def __len__(self) -> int:
        return len(self._fields)

    def _copy_of_val(self, name: str) -> typing.Any:
        ans = getattr(self, name)
        if isinstance(ans, dict):
            ans = ans.copy()
        elif isinstance(ans, list):
            ans = ans[:]
        return ans

    def _asdict(self) -> typing.Dict[str, typing.Any]:
        return {k: self._copy_of_val(k) for k in self}

    def _replace(self, **kw: typing.Any) -> "Options":
        ans = Options()
        for name in self:
            setattr(ans, name, self._copy_of_val(name))
        for name, val in kw.items():
            setattr(ans, name, val)
        return ans

    def __getitem__(self, key: typing.Union[int, str]) -> typing.Any:
        k = option_names[key] if isinstance(key, int) else key
        try:
            return getattr(self, k)
        except AttributeError:
            pass
        raise KeyError(f"No option named: {k}")