diff --git a/kitty/layout/base.py b/kitty/layout/base.py index 3d7abdcc7..91d3c6761 100644 --- a/kitty/layout/base.py +++ b/kitty/layout/base.py @@ -369,12 +369,12 @@ class Layout: self.blank_rects = [] # Set show_title_bar flag on each visible window before layout opts = get_options() - title_bar_enabled = opts.window_title_bar != 'none' + min_windows = opts.window_title_bar_min_windows visible_groups = list(all_windows.iter_all_layoutable_groups(only_visible=True)) num_visible = len(visible_groups) for wg in visible_groups: for w in wg.windows: - w.show_title_bar = title_bar_enabled and num_visible > 1 + w.show_title_bar = min_windows > 0 and num_visible >= min_windows self.do_layout(all_windows) def layout_single_window_group(self, wg: WindowGroup, add_blank_rects: bool = True) -> None: diff --git a/kitty/options/definition.py b/kitty/options/definition.py index 66ca814d6..780abf9e7 100644 --- a/kitty/options/definition.py +++ b/kitty/options/definition.py @@ -1467,16 +1467,24 @@ actually resize the window itself, but instead, the layout row/column/slot, whic in multiple windows getting resized. ''') -opt('window_title_bar', 'none', - choices=('none', 'top', 'bottom'), +opt('window_title_bar', 'top', + choices=('top', 'bottom'), long_text=''' -Show a title bar for each window when there are multiple windows in a tab. -The title bar displays the window title and is hidden when only a single window -is visible. The value controls the position of the title bar relative to the -window content. Set to :code:`none` to disable. +Control the position of the window title bar relative to the window content. +Use :opt:`window_title_bar_min_windows` to control when title bars are shown. ''' ) +opt('window_title_bar_min_windows', '0', + option_type='positive_int', + long_text=''' +The minimum number of visible windows in a tab before window title bars +are shown. A value of :code:`0` means never show. :code:`1` means always +show. :code:`2` or more means show only when at least that many windows +are visible. Similar to :opt:`tab_bar_min_tabs` for the tab bar. +''' +) + opt('window_title_template', '"{fmt.fg.red}{bell_symbol}{activity_symbol}{fmt.fg.window}{progress_percent}{title}"', option_type='tab_title_template', long_text=''' diff --git a/kitty/options/parse.py b/kitty/options/parse.py index 2bf282acb..37c1c7572 100644 --- a/kitty/options/parse.py +++ b/kitty/options/parse.py @@ -1513,7 +1513,10 @@ class Parser: raise ValueError(f"The value {val} is not a valid choice for window_title_bar") ans["window_title_bar"] = val - choices_for_window_title_bar = frozenset(('none', 'top', 'bottom')) + choices_for_window_title_bar = frozenset(('top', 'bottom')) + + def window_title_bar_min_windows(self, val: str, ans: dict[str, typing.Any]) -> None: + ans['window_title_bar_min_windows'] = positive_int(val) def window_title_bar_active_background(self, val: str, ans: dict[str, typing.Any]) -> None: ans['window_title_bar_active_background'] = to_color_or_none(val) diff --git a/kitty/options/types.py b/kitty/options/types.py index 8cf5bb2d6..81e3d2b94 100644 --- a/kitty/options/types.py +++ b/kitty/options/types.py @@ -37,7 +37,7 @@ choices_for_terminfo_type = typing.Literal['path', 'direct', 'none'] choices_for_undercurl_style = typing.Literal['thin-sparse', 'thin-dense', 'thick-sparse', 'thick-dense'] choices_for_underline_hyperlinks = typing.Literal['hover', 'always', 'never'] choices_for_window_logo_position = choices_for_placement_strategy -choices_for_window_title_bar = typing.Literal['none', 'top', 'bottom'] +choices_for_window_title_bar = typing.Literal['top', 'bottom'] choices_for_window_title_bar_align = choices_for_tab_bar_align option_names = ( @@ -501,6 +501,7 @@ option_names = ( 'window_resize_step_cells', 'window_resize_step_lines', 'window_title_bar', + 'window_title_bar_min_windows', 'window_title_bar_active_background', 'window_title_bar_active_foreground', 'window_title_bar_align', @@ -700,7 +701,8 @@ class Options: 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 - window_title_bar: choices_for_window_title_bar = 'none' + window_title_bar: choices_for_window_title_bar = 'top' + window_title_bar_min_windows: int = 0 window_title_bar_active_background: kitty.fast_data_types.Color | None = None window_title_bar_active_foreground: kitty.fast_data_types.Color | None = None window_title_bar_align: choices_for_window_title_bar_align = 'center' diff --git a/kitty/window.py b/kitty/window.py index 4ef2c8130..ddc257d4c 100644 --- a/kitty/window.py +++ b/kitty/window.py @@ -1078,8 +1078,8 @@ class Window: ) rendered_title = pts.render(data, progress_percent) - # If template evaluates to empty/whitespace, zero title bar geometry to hide it - if not rendered_title or not rendered_title.strip(): + # If template evaluates to empty string, zero title bar geometry to hide it + if not rendered_title: set_window_title_bar_render_data( self.os_window_id, self.tab_id, self.id, pts.screen, 0, 0, 0, 0,