Skip to content

Commit

Permalink
allow disabling tabs, new tab button in tab bar
Browse files Browse the repository at this point in the history
refs: #2082
  • Loading branch information
wez committed Nov 19, 2022
1 parent aa72cd2 commit 2dd3968
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 17 deletions.
6 changes: 6 additions & 0 deletions config/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
4 changes: 4 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
28 changes: 28 additions & 0 deletions docs/config/lua/config/show_new_tab_button_in_tab_bar.md
Original file line number Diff line number Diff line change
@@ -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,
}
```

26 changes: 26 additions & 0 deletions docs/config/lua/config/show_tabs_in_tab_bar.md
Original file line number Diff line number Diff line change
@@ -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,
}
```
38 changes: 21 additions & 17 deletions wezterm-gui/src/tabbar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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 };
Expand Down

0 comments on commit 2dd3968

Please sign in to comment.