From 86e6691bb664d60b9135d302fda1a8ffdf8c9ffd Mon Sep 17 00:00:00 2001 From: Matthew Berryman Date: Mon, 19 Feb 2024 12:51:13 +1030 Subject: [PATCH 1/2] tab min width --- config/src/config.rs | 11 +++++++++++ docs/config/lua/config/tab_min_width.md | 14 ++++++++++++++ wezterm-gui/src/tabbar.rs | 9 +++++---- 3 files changed, 30 insertions(+), 4 deletions(-) create mode 100644 docs/config/lua/config/tab_min_width.md diff --git a/config/src/config.rs b/config/src/config.rs index 8f52b91e5eb..c490ceadabd 100644 --- a/config/src/config.rs +++ b/config/src/config.rs @@ -473,6 +473,13 @@ pub struct Config { #[dynamic(default = "default_tab_max_width")] pub tab_max_width: usize, + /// Specifies the minimum width that a tab can have + /// in the tab bar. Defaults to 5 glyphs in width. + /// If the tab title is shorter than this, the tab will + /// be sized to fit the title. + #[dynamic(default = "default_tab_min_width")] + pub tab_min_width: usize, + /// If true, hide the tab bar if the window only has a single tab. #[dynamic(default)] pub hide_tab_bar_if_only_one_tab: bool, @@ -1777,6 +1784,10 @@ fn default_tab_max_width() -> usize { 16 } +fn default_tab_min_width() -> usize { + 5 +} + fn default_update_interval() -> u64 { 86400 } diff --git a/docs/config/lua/config/tab_min_width.md b/docs/config/lua/config/tab_min_width.md new file mode 100644 index 00000000000..ecffe9ae1d2 --- /dev/null +++ b/docs/config/lua/config/tab_min_width.md @@ -0,0 +1,14 @@ +--- +tags: + - tab_bar +--- +# `tab_min_width` + +Specifies the minimum width that a tab can have in the +tab bar when using either the of the tab modes. + +Defaults to 5 glyphs in width. + +```lua +config.tab_max_width = 5 +``` diff --git a/wezterm-gui/src/tabbar.rs b/wezterm-gui/src/tabbar.rs index 5e007f54a42..a014ca318cf 100644 --- a/wezterm-gui/src/tabbar.rs +++ b/wezterm-gui/src/tabbar.rs @@ -110,6 +110,7 @@ fn compute_tab_title( config: &ConfigHandle, hover: bool, tab_max_width: usize, + tab_min_width: usize ) -> TitleText { let title = call_format_tab_title(tab, tab_info, pane_info, config, hover, tab_max_width); @@ -141,10 +142,8 @@ fn compute_tab_title( // easier to click on tab titles, but we'll still go below // this if there are too many tabs to fit the window at // this width. - if !config.use_fancy_tab_bar { - while unicode_column_width(&title, None) < 5 { - title.push(' '); - } + while unicode_column_width(&title, None) < tab_min_width { + title.push(' '); } title } else { @@ -338,6 +337,7 @@ impl TabBarState { config, false, config.tab_max_width, + config.tab_min_width, ) }) .collect() @@ -413,6 +413,7 @@ impl TabBarState { config, hover, tab_title_len, + config.tab_min_width, ); let cell_attrs = if active { From cb3690335d6b9dfaa4856f336f836246ed1afece Mon Sep 17 00:00:00 2001 From: Matthew Berryman Date: Mon, 5 Aug 2024 10:46:25 +0930 Subject: [PATCH 2/2] fix reference in docs --- docs/config/lua/config/tab_min_width.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/config/lua/config/tab_min_width.md b/docs/config/lua/config/tab_min_width.md index ecffe9ae1d2..cb436a440a4 100644 --- a/docs/config/lua/config/tab_min_width.md +++ b/docs/config/lua/config/tab_min_width.md @@ -10,5 +10,5 @@ tab bar when using either the of the tab modes. Defaults to 5 glyphs in width. ```lua -config.tab_max_width = 5 +config.tab_min_width = 5 ```