1
1
mirror of https://github.com/wez/wezterm.git synced 2024-11-23 15:04:36 +03:00

allow disabling tabs, new tab button in tab bar

refs: https://github.com/wez/wezterm/issues/2082
This commit is contained in:
Wez Furlong 2022-11-19 13:51:45 -07:00
parent aa72cd24d0
commit 2dd3968b9e
No known key found for this signature in database
5 changed files with 85 additions and 17 deletions

View File

@ -389,6 +389,12 @@ pub struct Config {
#[dynamic(default = "default_true")]
pub show_tab_index_in_tab_bar: bool,
#[dynamic(default = "default_true")]
pub show_tabs_in_tab_bar: bool,
#[dynamic(default = "default_true")]
pub show_new_tab_button_in_tab_bar: bool,
/// If true, show_tab_index_in_tab_bar uses a zero-based index.
/// The default is false and the tab shows a one-based index.
#[dynamic(default)]

View File

@ -46,6 +46,10 @@ As features stabilize some brief notes about them will accumulate here.
* [ActivateKeyTable](config/lua/keyassignment/ActivateKeyTable.md) now also
supports `prevent_fallback = true` as a parameter.
[#2702](https://github.com/wez/wezterm/issues/2702)
* [show_tabs_in_tab_bar](config/lua/config/show_tabs_in_tab_bar.md) and
[show_new_tab_button_in_tab_bar](config/lua/config/show_new_tab_button_in_tab_bar.md)
config options to customize the tab bar appearance.
[#2082](https://github.com/wez/wezterm/issues/2082)
#### Fixed
* Wayland: key repeat gets stuck after pressing two keys in quick succession.

View File

@ -0,0 +1,28 @@
# `show_new_tab_button_in_tab_bar = true`
*Since: nightly builds only*
When set to `true` (the default), the tab bar will display the new-tab button,
which can be left-clicked to create a new tab, or right-clicked to display the
[Launcher Menu](../../launch.md).
When set to `false`, the new-tab button will not be drawn into the tab bar.
This example turns off the tabs and new-tab button, leaving just the left and
right status areas:
```lua
local wezterm = require 'wezterm'
wezterm.on('update-right-status', function(window, pane)
window:set_left_status 'left'
window:set_right_status 'right'
end)
return {
use_fancy_tab_bar = false,
show_tabs_in_tab_bar = false,
show_new_tab_button_in_tab_bar = false,
}
```

View File

@ -0,0 +1,26 @@
# `show_tabs_in_tab_bar = true`
*Since: nightly builds only*
When set to `true` (the default), the tab bar will display the tabs associated
with the current window.
When set to `false`, the tabs will not be drawn into the tab bar.
This example turns off the tabs and new-tab button, leaving just the left and
right status areas:
```lua
local wezterm = require 'wezterm'
wezterm.on('update-right-status', function(window, pane)
window:set_left_status 'left'
window:set_right_status 'right'
end)
return {
use_fancy_tab_bar = false,
show_tabs_in_tab_bar = false,
show_new_tab_button_in_tab_bar = false,
}
```

View File

@ -226,22 +226,26 @@ impl TabBarState {
let mut active_tab_no = 0;
let tab_titles: Vec<TitleText> = tab_info
.iter()
.map(|tab| {
if tab.is_active {
active_tab_no = tab.tab_index;
}
compute_tab_title(
tab,
tab_info,
pane_info,
config,
false,
config.tab_max_width,
)
})
.collect();
let tab_titles: Vec<TitleText> = if config.show_tabs_in_tab_bar {
tab_info
.iter()
.map(|tab| {
if tab.is_active {
active_tab_no = tab.tab_index;
}
compute_tab_title(
tab,
tab_info,
pane_info,
config,
false,
config.tab_max_width,
)
})
.collect()
} else {
vec![]
};
let titles_len: usize = tab_titles.iter().map(|s| s.len).sum();
let number_of_tabs = tab_titles.len();
@ -334,7 +338,7 @@ impl TabBarState {
}
// New tab button
{
if config.show_new_tab_button_in_tab_bar {
let hover = is_tab_hover(mouse_x, x, new_tab_hover.len());
let new_tab_button = if hover { &new_tab_hover } else { &new_tab };