1
1
mirror of https://github.com/wez/wezterm.git synced 2024-09-20 19:27:22 +03:00

wezterm: add tab_max_width config option

This allows setting the maximum width of a tab in the tab tab.
It defaults to 16 glyphs in width.

refs: https://github.com/wez/wezterm/issues/255
This commit is contained in:
Wez Furlong 2020-08-29 10:45:01 -07:00
parent 124fe559cd
commit 99b8fb2612
5 changed files with 20 additions and 2 deletions

View File

@ -25,6 +25,9 @@ brief notes about them may accumulate here.
client-side window decoration so let's just make it opt-in so
that the default experience is better.
* Fixed a crash on Linux/X11 when using `wezterm connect HOST`
* Added `tab_max_width` config setting to limit the maximum
width of tabs in the tab tab. This defaults to 16 glyphs
in width.
### 20200718-095447-d2315640

View File

@ -65,7 +65,10 @@ return {
-- `SteadyUnderline`, `BlinkingUnderline`, `SteadyBar`,
-- and `BlinkingBar`.
default_cursor_style = "SteadyBlock",
-- Specifies the maximum width that a tab can have in the
-- tab bar. Defaults to 16 glyphs in width.
tab_max_width = 16,
}
```

View File

@ -461,6 +461,11 @@ pub struct Config {
#[serde(default = "default_true")]
pub enable_tab_bar: bool,
/// Specifies the maximum width that a tab can have in the
/// tab bar. Defaults to 16 glyphs in width.
#[serde(default = "default_tab_max_width")]
pub tab_max_width: usize,
/// If true, hide the tab bar if the window only has a single tab.
#[serde(default)]
pub hide_tab_bar_if_only_one_tab: bool,
@ -539,6 +544,10 @@ pub struct Config {
pub enable_csi_u_key_encoding: bool,
}
fn default_tab_max_width() -> usize {
16
}
fn default_update_interval() -> u64 {
86400
}

View File

@ -48,6 +48,7 @@ impl TabBarState {
mouse_x: Option<usize>,
window: &Ref<MuxWindow>,
colors: Option<&TabBarColors>,
tab_width_max: usize,
) -> Self {
// We ultimately want to produce a line looking like this:
// ` | tab1-title x | tab2-title x | + . - X `
@ -82,7 +83,8 @@ impl TabBarState {
} else {
// We need to clamp the length to balance them out
available_cells / number_of_tabs
};
}
.min(tab_width_max);
let colors = colors.cloned().unwrap_or_else(TabBarColors::default);

View File

@ -1139,6 +1139,7 @@ impl TermWindow {
},
&window,
config.colors.as_ref().and_then(|c| c.tab_bar.as_ref()),
config.tab_max_width,
);
if new_tab_bar != self.tab_bar {
self.tab_bar = new_tab_bar;