Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature] tab min width #5035

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions config/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,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,
Expand Down Expand Up @@ -1790,6 +1797,10 @@ fn default_tab_max_width() -> usize {
16
}

fn default_tab_min_width() -> usize {
5
}

fn default_update_interval() -> u64 {
86400
}
Expand Down
14 changes: 14 additions & 0 deletions docs/config/lua/config/tab_min_width.md
Original file line number Diff line number Diff line change
@@ -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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be tab_min_width

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, thanks! Fixed in cb36903

```
9 changes: 5 additions & 4 deletions wezterm-gui/src/tabbar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -338,6 +337,7 @@ impl TabBarState {
config,
false,
config.tab_max_width,
config.tab_min_width,
)
})
.collect()
Expand Down Expand Up @@ -413,6 +413,7 @@ impl TabBarState {
config,
hover,
tab_title_len,
config.tab_min_width,
);

let cell_attrs = if active {
Expand Down