Skip to content

A modern terminal with a built-in multiplexer: close it and your sessions keep running. Run shells and tons of AI agents across your machines, then pick them up from desktop, browser, TUI and more. Written in Rust with no UI framework: interface drawn straight on the GPU. No Electron, GPUI or webview.

feat(tab-bar): show wezterm's tab bar inside the terminal area

RoversXa426d997800d
diff --git a/wezterm-gui/src/scripting/guiwin.rs b/wezterm-gui/src/scripting/guiwin.rs
index 06f50aab..6a0cea73 100644
--- a/wezterm-gui/src/scripting/guiwin.rs
+++ b/wezterm-gui/src/scripting/guiwin.rs
@@ -179,7 +179,7 @@ impl UserData for GuiWin {
.map_err(|e| anyhow::anyhow!("{:#}", e))
.map_err(luaerr)?;
- Ok((*config).clone())
+ Ok(config)
});
methods.add_async_method("get_config_overrides", |lua, this, _: ()| async move {
let (tx, rx) = smol::channel::bounded(1);
diff --git a/wezterm-gui/src/tabbar.rs b/wezterm-gui/src/tabbar.rs
index 30a41544..0add6df3 100644
--- a/wezterm-gui/src/tabbar.rs
+++ b/wezterm-gui/src/tabbar.rs
@@ -2,7 +2,7 @@ use crate::termwindow::content_view::ContentViewId;
use crate::termwindow::ui::status_icon::UiStatusKind;
use crate::termwindow::ui::terminal_title_for_display;
use crate::termwindow::{PaneInformation, TabInformation, UIItem, UIItemType};
-use config::{ConfigHandle, TabBarColors};
+use config::{Config, ConfigHandle, TabBarColors};
use finl_unicode::grapheme_clusters::Graphemes;
use mlua::FromLua;
use termwiz::cell::{unicode_column_width, Cell, CellAttributes};
@@ -40,6 +40,47 @@ pub enum TabBarItem {
},
}
+/// Which bar a [`TabBarState`] describes. The wezterm tab bar options and
+/// `format-tab-title` configure the terminal bar only: Lua sees the terminal
+/// area, and the window tab row around it is ThinkTerm's chrome.
+#[derive(Clone, Copy, Debug, PartialEq, Eq)]
+pub enum TabBarKind {
+ /// ThinkTerm's window tab row, with its own titles.
+ WindowTabs,
+ /// The wezterm tab bar, drawn inside the terminal area.
+ TerminalBar,
+ /// The same place when only status text asked for it: no tabs.
+ TerminalStatus,
+}
+
+impl TabBarKind {
+ /// Whether titles take the fancy row's form rather than the retro one.
+ fn fancy(self) -> bool {
+ self == Self::WindowTabs
+ }
+}
+
+/// Whether the terminal bar shows, and as what. The wezterm tab bar options
+/// decide, as they would for wezterm's own bar: a retro bar shows its tabs; a
+/// fancy one -- which the window tab row already is -- earns a line only for
+/// status text.
+pub(crate) fn terminal_bar_kind(
+ config: &Config,
+ num_tabs: usize,
+ has_status: bool,
+) -> Option<TabBarKind> {
+ if !config.enable_tab_bar || (config.hide_tab_bar_if_only_one_tab && num_tabs <= 1) {
+ return None;
+ }
+ if !config.use_fancy_tab_bar {
+ Some(TabBarKind::TerminalBar)
+ } else if has_status {
+ Some(TabBarKind::TerminalStatus)
+ } else {
+ None
+ }
+}
+
#[derive(Clone, Debug, PartialEq)]
pub struct TabEntry {
pub item: TabBarItem,
@@ -55,11 +96,27 @@ struct TitleText {
len: usize,
}
+/// The configuration as handed to Lua. `resolved_palette.tab_bar` is empty
+/// unless the file or its scheme names tab bar colours, yet the bar is always
+/// painted with some; plugins read them, so give them the ones in use.
+pub(crate) fn config_for_lua(config: &ConfigHandle, tab_bar: Option<&TabBarColors>) -> Config {
+ let mut config = (**config).clone();
+ fill_tab_bar_colors(&mut config, tab_bar);
+ config
+}
+
+fn fill_tab_bar_colors(config: &mut Config, tab_bar: Option<&TabBarColors>) {
+ if config.resolved_palette.tab_bar.is_none() {
+ config.resolved_palette.tab_bar = tab_bar.cloned();
+ }
+}
+
fn call_format_tab_title(
tab: &TabInformation,
tab_info: &[TabInformation],
pane_info: &[PaneInformation],
config: &ConfigHandle,
+ tab_bar: &TabBarColors,
hover: bool,
tab_max_width: usize,
) -> Option<TitleText> {
@@ -76,7 +133,7 @@ fn call_format_tab_title(
tab.clone(),
tabs,
panes,
- (**config).clone(),
+ config_for_lua(config, Some(tab_bar)),
hover,
tab_max_width,
),
@@ -174,10 +231,25 @@ fn compute_tab_title(
tab_info: &[TabInformation],
pane_info: &[PaneInformation],
config: &ConfigHandle,
+ tab_bar: &TabBarColors,
+ kind: TabBarKind,
hover: bool,
tab_max_width: usize,
) -> TitleText {
- let title = call_format_tab_title(tab, tab_info, pane_info, config, hover, tab_max_width);
+ let fancy = kind.fancy();
+ let title = if kind == TabBarKind::WindowTabs {
+ None
+ } else {
+ call_format_tab_title(
+ tab,
+ tab_info,
+ pane_info,
+ config,
+ tab_bar,
+ hover,
+ tab_max_width,
+ )
+ };
match title {
Some(title) => title,
@@ -187,7 +259,7 @@ fn compute_tab_title(
if let Some(pane) = &tab.active_pane {
let mut title = if tab.tab_title.is_empty() {
- if config.use_fancy_tab_bar {
+ if fancy {
"Terminal".to_string()
} else {
terminal_title_for_display(&pane.title).to_string()
@@ -196,8 +268,8 @@ fn compute_tab_title(
tab.tab_title.clone()
};
- let classic_spacing = if config.use_fancy_tab_bar { "" } else { " " };
- if config.show_tab_index_in_tab_bar && !config.use_fancy_tab_bar {
+ let classic_spacing = if fancy { "" } else { " " };
+ if config.show_tab_index_in_tab_bar && !fancy {
let index = format!(
"{classic_spacing}{}: ",
tab.tab_index
@@ -213,7 +285,7 @@ fn compute_tab_title(
title = format!("{}{classic_spacing}", title);
}
- if !config.use_fancy_tab_bar {
+ if !fancy {
match pane.progress {
Progress::None => {}
Progress::Percentage(pct) | Progress::Error(pct) => {
@@ -234,7 +306,7 @@ fn compute_tab_title(
}
}
- if !config.use_fancy_tab_bar {
+ if !fancy {
len += unicode_column_width(TERMINAL_TAB_ICON, None);
items.push(FormatItem::Text(TERMINAL_TAB_ICON.to_string()));
}
@@ -243,7 +315,7 @@ 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 {
+ if !fancy {
while len + unicode_column_width(&title, None) < 5 {
title.push(' ');
}
@@ -338,17 +410,18 @@ impl TabBarState {
mouse_x: Option<usize>,
x: &mut usize,
config: &ConfigHandle,
+ fancy: bool,
items: &mut Vec<TabEntry>,
line: &mut Line,
colors: &TabBarColors,
) {
- let default_cell = if config.use_fancy_tab_bar {
+ let default_cell = if fancy {
CellAttributes::default()
} else {
colors.new_tab().as_cell_attributes()
};
- let default_cell_hover = if config.use_fancy_tab_bar {
+ let default_cell_hover = if fancy {
CellAttributes::default()
} else {
colors.new_tab_hover().as_cell_attributes()
@@ -437,18 +510,30 @@ impl TabBarState {
tab_scroll_offset: f32,
left_status: &str,
right_status: &str,
+ kind: TabBarKind,
+ themed: bool,
) -> Self {
let colors = colors.cloned().unwrap_or_else(TabBarColors::default);
+ let fancy = kind.fancy();
+ // Colours derived from the terminal are its own ground: leave those
+ // cells on the default background, painted exactly as the terminal's.
+ let ground = |attrs: CellAttributes| {
+ let mut attrs = attrs;
+ if themed {
+ attrs.set_background(ColorSpec::Default);
+ }
+ attrs
+ };
- let active_cell_attrs = colors.active_tab().as_cell_attributes();
- let inactive_hover_attrs = colors.inactive_tab_hover().as_cell_attributes();
- let inactive_cell_attrs = colors.inactive_tab().as_cell_attributes();
- let new_tab_hover_attrs = colors.new_tab_hover().as_cell_attributes();
- let new_tab_attrs = colors.new_tab().as_cell_attributes();
+ let active_cell_attrs = ground(colors.active_tab().as_cell_attributes());
+ let inactive_hover_attrs = ground(colors.inactive_tab_hover().as_cell_attributes());
+ let inactive_cell_attrs = ground(colors.inactive_tab().as_cell_attributes());
+ let new_tab_hover_attrs = ground(colors.new_tab_hover().as_cell_attributes());
+ let new_tab_attrs = ground(colors.new_tab().as_cell_attributes());
let new_tab = parse_status_text(
&config.tab_bar_style.new_tab,
- if config.use_fancy_tab_bar {
+ if fancy {
CellAttributes::default()
} else {
new_tab_attrs.clone()
@@ -456,7 +541,7 @@ impl TabBarState {
);
let new_tab_hover = parse_status_text(
&config.tab_bar_style.new_tab_hover,
- if config.use_fancy_tab_bar {
+ if fancy {
CellAttributes::default()
} else {
new_tab_hover_attrs.clone()
@@ -471,7 +556,14 @@ impl TabBarState {
let mut active_tab_no = 0;
- let tab_titles: Vec<TitleText> = if config.show_tabs_in_tab_bar {
+ // `show_tabs_in_tab_bar` is a wezterm option: the window tab row keeps
+ // its tabs whatever it says.
+ let show_tabs = match kind {
+ TabBarKind::WindowTabs => true,
+ TabBarKind::TerminalBar => config.show_tabs_in_tab_bar,
+ TabBarKind::TerminalStatus => false,
+ };
+ let tab_titles: Vec<TitleText> = if show_tabs {
tab_info
.iter()
.map(|tab| {
@@ -483,6 +575,8 @@ impl TabBarState {
tab_info,
pane_info,
config,
+ &colors,
+ kind,
false,
config.tab_max_width,
)
@@ -494,8 +588,17 @@ impl TabBarState {
let number_of_tabs = tab_titles.len();
let show_new_tab_button = false;
+ let black_cell = Cell::blank_with_attrs(ground(
+ CellAttributes::default()
+ .set_background(ColorSpec::TrueColor(*colors.background()))
+ .clone(),
+ ));
+ // The left status leads the line; the tabs get what it leaves.
+ let left_status_line = parse_status_text(left_status, black_cell.attrs().clone());
+
let available_cells = title_width.saturating_sub(
- number_of_tabs.saturating_sub(1)
+ left_status_line.len()
+ + number_of_tabs.saturating_sub(1)
+ if show_new_tab_button {
new_tab.len()
} else {
@@ -503,15 +606,24 @@ impl TabBarState {
},
);
let tab_width_max = config.tab_max_width;
- let visible_tab_range = if config.use_fancy_tab_bar {
+ let visible_tab_range = if fancy {
0..tab_titles.len()
} else {
- visible_tab_range_from_scroll(
- &tab_titles,
- tab_scroll_offset.max(0.0).floor() as usize,
- tab_width_max,
- available_cells,
- )
+ // Nothing scrolls the terminal bar, so it follows the active tab:
+ // the first offset that keeps it in view.
+ let mut offset = tab_scroll_offset.max(0.0).floor() as usize;
+ let mut range =
+ visible_tab_range_from_scroll(&tab_titles, offset, tab_width_max, available_cells);
+ while !range.contains(&active_tab_no) && offset < active_tab_no {
+ offset += 1;
+ range = visible_tab_range_from_scroll(
+ &tab_titles,
+ offset,
+ tab_width_max,
+ available_cells,
+ );
+ }
+ range
};
let mut line = Line::with_width(0, SEQ_ZERO);
@@ -519,31 +631,15 @@ impl TabBarState {
let mut x = 0;
let mut items = vec![];
- let black_cell = Cell::blank_with_attrs(
- CellAttributes::default()
- .set_background(ColorSpec::TrueColor(*colors.background()))
- .clone(),
- );
-
- if use_integrated_title_buttons
- && config.integrated_title_button_style == IntegratedTitleButtonStyle::MacOsNative
- && config.use_fancy_tab_bar == false
- && config.tab_bar_at_bottom == false
- {
- for _ in 0..10 as usize {
- line.insert_cell(0, black_cell.clone(), title_width, SEQ_ZERO);
- x += 1;
- }
- }
-
if use_integrated_title_buttons
&& config.integrated_title_button_style != IntegratedTitleButtonStyle::MacOsNative
&& config.integrated_title_button_alignment == IntegratedTitleButtonAlignment::Left
{
- Self::integrated_title_buttons(mouse_x, &mut x, config, &mut items, &mut line, &colors);
+ Self::integrated_title_buttons(
+ mouse_x, &mut x, config, fancy, &mut items, &mut line, &colors,
+ );
}
- let left_status_line = parse_status_text(left_status, black_cell.attrs().clone());
if left_status_line.len() > 0 {
items.push(TabEntry {
item: TabBarItem::LeftStatus,
@@ -572,6 +668,8 @@ impl TabBarState {
tab_info,
pane_info,
config,
+ &colors,
+ kind,
hover,
tab_title_len,
);
@@ -589,7 +687,7 @@ impl TabBarState {
let esc = format_as_escapes(tab_title.items.clone()).expect("already parsed ok above");
let mut tab_line = parse_status_text(
&esc,
- if config.use_fancy_tab_bar {
+ if fancy {
CellAttributes::default()
} else {
cell_attrs.clone()
@@ -597,7 +695,7 @@ impl TabBarState {
);
let title = tab_line.clone();
- let status = if config.use_fancy_tab_bar {
+ let status = if fancy {
tab_info[tab_idx]
.active_pane
.as_ref()
@@ -722,7 +820,9 @@ impl TabBarState {
&& config.integrated_title_button_alignment == IntegratedTitleButtonAlignment::Right
{
x = title_width;
- Self::integrated_title_buttons(mouse_x, &mut x, config, &mut items, &mut line, &colors);
+ Self::integrated_title_buttons(
+ mouse_x, &mut x, config, fancy, &mut items, &mut line, &colors,
+ );
}
Self { line, items }
@@ -743,7 +843,7 @@ impl TabBarState {
width: entry.width * cell_width,
y,
height: cell_height,
- item_type: UIItemType::TabBar(entry.item),
+ item_type: UIItemType::TerminalBar(entry.item),
});
}
@@ -855,3 +955,59 @@ pub fn parse_status_text(text: &str, default_cell: CellAttributes) -> Line {
flush_print(&mut print_buffer, &mut cells, &pen);
Line::from_cells(cells, SEQ_ZERO)
}
+
+#[cfg(test)]
+mod test {
+ use super::*;
+ use config::RgbaColor;
+
+ fn colors(rgb: (u8, u8, u8)) -> TabBarColors {
+ TabBarColors {
+ background: Some(RgbaColor::from(rgb)),
+ ..Default::default()
+ }
+ }
+
+ #[test]
+ fn lua_sees_the_tab_bar_colours_in_use_when_none_are_configured() {
+ let mut config = Config::default_config();
+ config.resolved_palette.tab_bar = None;
+ fill_tab_bar_colors(&mut config, Some(&colors((1, 2, 3))));
+ assert_eq!(config.resolved_palette.tab_bar, Some(colors((1, 2, 3))));
+ }
+
+ #[test]
+ fn terminal_bar_shows_what_the_wezterm_options_ask_for() {
+ let mut config = Config::default_config();
+ config.enable_tab_bar = true;
+ config.hide_tab_bar_if_only_one_tab = false;
+ config.use_fancy_tab_bar = true;
+ // A fancy bar is the window tab row already; only status text adds a line.
+ assert_eq!(terminal_bar_kind(&config, 2, false), None);
+ assert_eq!(
+ terminal_bar_kind(&config, 2, true),
+ Some(TabBarKind::TerminalStatus)
+ );
+ config.use_fancy_tab_bar = false;
+ assert_eq!(
+ terminal_bar_kind(&config, 2, false),
+ Some(TabBarKind::TerminalBar)
+ );
+ config.hide_tab_bar_if_only_one_tab = true;
+ assert_eq!(terminal_bar_kind(&config, 1, true), None);
+ assert_eq!(
+ terminal_bar_kind(&config, 2, true),
+ Some(TabBarKind::TerminalBar)
+ );
+ config.enable_tab_bar = false;
+ assert_eq!(terminal_bar_kind(&config, 2, true), None);
+ }
+
+ #[test]
+ fn configured_tab_bar_colours_reach_lua_unchanged() {
+ let mut config = Config::default_config();
+ config.resolved_palette.tab_bar = Some(colors((9, 9, 9)));
+ fill_tab_bar_colors(&mut config, Some(&colors((1, 2, 3))));
+ assert_eq!(config.resolved_palette.tab_bar, Some(colors((9, 9, 9))));
+ }
+}
diff --git a/wezterm-gui/src/termwindow/charselect.rs b/wezterm-gui/src/termwindow/charselect.rs
index d32574e8..36556180 100644
--- a/wezterm-gui/src/termwindow/charselect.rs
+++ b/wezterm-gui/src/termwindow/charselect.rs
@@ -392,11 +392,7 @@ impl CharSelector {
.expect("to resolve char selection font");
let metrics = RenderMetrics::with_font_metrics(&font.metrics());
- let top_bar_height = if term_window.show_tab_bar && !term_window.config.tab_bar_at_bottom {
- term_window.tab_bar_pixel_height().unwrap()
- } else {
- 0.
- };
+ let top_bar_height = term_window.pane_area_insets().0;
let (padding_left, padding_top) = term_window.padding_left_top();
let border = term_window.get_os_border();
let top_pixel_y = top_bar_height + padding_top + border.top.get() as f32;
diff --git a/wezterm-gui/src/termwindow/mod.rs b/wezterm-gui/src/termwindow/mod.rs
index 34d70983..f2336ee4 100644
--- a/wezterm-gui/src/termwindow/mod.rs
+++ b/wezterm-gui/src/termwindow/mod.rs
@@ -15,7 +15,7 @@ use crate::scripting::guiwin::GuiWin;
use crate::scrollbar::*;
use crate::selection::Selection;
use crate::shapecache::*;
-use crate::tabbar::{TabBarItem, TabBarState};
+use crate::tabbar::{TabBarItem, TabBarKind, TabBarState};
use crate::termwindow::background::{
load_background_image, reload_background_image, LoadedBackgroundLayer,
};
@@ -173,12 +173,15 @@ pub(crate) mod transfer_walk;
pub mod ui;
pub mod webgpu;
-pub(crate) fn theme_aligned_tab_bar_colors_from_palette(palette: &ColorPalette) -> TabBarColors {
+/// Tab bar colours taken from the terminal: its foreground, on `background`.
+pub(crate) fn theme_aligned_tab_bar_colors_from_palette(
+ palette: &ColorPalette,
+ background: LinearRgba,
+) -> TabBarColors {
fn rgba(color: LinearRgba) -> RgbaColor {
color.to_srgb().into()
}
- let background = palette.resolve_bg(ColorAttribute::Default).to_linear();
let foreground = palette.foreground.to_linear();
let muted = foreground.mul_alpha(0.68);
@@ -563,7 +566,7 @@ pub enum TermWindowNotif {
pane_id: PaneId,
tx: Sender<String>,
},
- GetEffectiveConfig(Sender<ConfigHandle>),
+ GetEffectiveConfig(Sender<config::Config>),
FinishWindowEvent {
name: String,
again: bool,
@@ -738,6 +741,9 @@ pub struct ScrollTrack {
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum UIItemType {
TabBar(TabBarItem),
+ /// An item of the terminal bar: the tab or status bar a wezterm
+ /// configuration draws, which lives inside the terminal area.
+ TerminalBar(TabBarItem),
CloseTab(usize),
PaneNav {
pane_id: PaneId,
@@ -2429,9 +2435,13 @@ pub struct TermWindow {
leader_is_down: Option<std::time::Instant>,
dead_key_status: DeadKeyStatus,
key_table_state: KeyTableState,
- show_tab_bar: bool,
show_scroll_bar: bool,
tab_bar: TabBarState,
+ /// What the terminal bar holds while it shows; it takes room from the
+ /// pane tree, so this changes only through a reload (see
+ /// `tabbar::terminal_bar_kind`).
+ terminal_bar_kind: Option<TabBarKind>,
+ terminal_bar: TabBarState,
fancy_tab_bar: Option<box_model::ComputedElement>,
tab_bar_scroll_offset: f32,
tab_bar_scroll_target: f32,
@@ -2557,6 +2567,10 @@ pub struct TermWindow {
/// Refreshed in `config_was_reloaded`, which is also where a colour scheme
/// override and an appearance change both land.
chrome_palette: crate::ui::UiPalette,
+ /// The interface appearance `chrome_palette` was resolved for. A palette
+ /// following the terminal takes its own from the scheme instead, so the
+ /// two can differ.
+ chrome_appearance: ::window::Appearance,
shape_generation: usize,
shape_cache: RefCell<LfuCache<ShapeCacheKey, anyhow::Result<Rc<Vec<ShapedInfo>>>>>,
/// Per-domain shaping caches for proportional UI text (chrome / Note /
@@ -3945,14 +3959,13 @@ impl TermWindow {
let render_metrics = RenderMetrics::new(&fontconfig)?;
log::trace!("using render_metrics {:#?}", render_metrics);
- // Initially we have only a single tab, so take that into account
- // for the tab bar state.
- let show_tab_bar = config.enable_tab_bar && !config.hide_tab_bar_if_only_one_tab;
- let tab_bar_height = if show_tab_bar {
- Self::tab_bar_pixel_height_impl(&config, &fontconfig, &render_metrics)? as usize
- } else {
- 0
- };
+ // Initially we have only a single tab, and no status text yet.
+ let terminal_bar_kind = crate::tabbar::terminal_bar_kind(&config, 1, false);
+ let tab_bar_height = Self::tab_bar_pixel_height_impl(&fontconfig)? as usize
+ + crate::termwindow::render::tab_bar::terminal_bar_height(
+ terminal_bar_kind,
+ &render_metrics,
+ );
let terminal_size = TerminalSize {
rows: physical_rows,
@@ -4103,9 +4116,10 @@ impl TermWindow {
input_map: InputMap::new(&config),
leader_is_down: None,
dead_key_status: DeadKeyStatus::None,
- show_tab_bar,
show_scroll_bar: config.enable_scroll_bar,
tab_bar: TabBarState::default(),
+ terminal_bar_kind,
+ terminal_bar: TabBarState::default(),
fancy_tab_bar: None,
tab_bar_scroll_offset: 0.0,
tab_bar_scroll_target: 0.0,
@@ -4155,6 +4169,7 @@ impl TermWindow {
&config,
None,
),
+ chrome_appearance: crate::native_settings::effective_appearance(),
shape_generation: 0,
shape_cache: RefCell::new(LfuCache::new_weighted(
"shape_cache.hit.rate",
@@ -5223,9 +5238,18 @@ impl TermWindow {
.context("send GetTerminalSize response")?;
}
TermWindowNotif::GetEffectiveConfig(tx) => {
- tx.try_send(self.config.clone())
- .map_err(chan_err)
- .context("send GetEffectiveConfig response")?;
+ let tab_bar = self
+ .config
+ .resolved_palette
+ .tab_bar
+ .is_none()
+ .then(|| self.theme_aligned_tab_bar_colors());
+ tx.try_send(crate::tabbar::config_for_lua(
+ &self.config,
+ tab_bar.as_ref(),
+ ))
+ .map_err(chan_err)
+ .context("send GetEffectiveConfig response")?;
}
TermWindowNotif::FinishWindowEvent { name, again } => {
self.finish_window_event(&name, again);
@@ -6734,9 +6758,10 @@ impl TermWindow {
/// too; this is the direct route, for when the appearance moved without a
/// configuration reload behind it.
pub(crate) fn refresh_chrome(&mut self) {
+ self.chrome_appearance = crate::native_settings::effective_appearance();
self.chrome_palette = crate::native_settings::chrome_palette(
crate::native_settings::load_shared().appearance.theme_mode,
- crate::native_settings::effective_appearance(),
+ self.chrome_appearance,
&self.config,
self.scheme_preview_ground,
);
@@ -6928,9 +6953,10 @@ impl TermWindow {
// outlives its mux window still paints, and nothing else re-resolves
// these two -- the settings-window routes reach them only through
// their own notifies.
+ self.chrome_appearance = crate::native_settings::effective_appearance();
self.chrome_palette = crate::native_settings::chrome_palette(
crate::native_settings::load_shared().appearance.theme_mode,
- crate::native_settings::effective_appearance(),
+ self.chrome_appearance,
&config,
self.scheme_preview_ground,
);
@@ -6958,11 +6984,7 @@ impl TermWindow {
Some(window) => window,
_ => return,
};
- if window.len() == 1 {
- self.show_tab_bar = config.enable_tab_bar && !config.hide_tab_bar_if_only_one_tab;
- } else {
- self.show_tab_bar = config.enable_tab_bar;
- }
+ self.terminal_bar_kind = self.wanted_terminal_bar_kind(&config, window.len());
*self.cursor_blink_state.borrow_mut() = ColorEase::new(
config.cursor_blink_rate,
config.cursor_blink_ease_in,
@@ -7134,62 +7156,29 @@ impl TermWindow {
.saturating_sub(border.bottom.get() as usize) as f32;
return euclid::rect(left, top, (right - left).max(0.0), (bottom - top).max(0.0));
}
- let top_tab_h = if self.show_tab_bar && !self.config.tab_bar_at_bottom {
- self.tab_bar_pixel_height().unwrap_or(0.0)
- } else {
- 0.0
- };
- let bottom_tab_h = if self.show_tab_bar && self.config.tab_bar_at_bottom {
- self.tab_bar_pixel_height().unwrap_or(0.0)
- } else {
- 0.0
- };
- // Deliberately *not* inset by `window_padding`: that padding belongs to
- // the terminal grid, and content views are UI panels that own the whole
- // area. Applying it only added a left/top gap (the right/bottom edges
- // never subtracted it) that nothing painted, so the window background
+ // The whole terminal area, terminal bar included. Deliberately *not*
+ // inset by `window_padding`: that padding belongs to the terminal
+ // grid, and content views are UI panels that own the whole area.
+ // Applying it only added a left/top gap (the right/bottom edges never
+ // subtracted it) that nothing painted, so the window background
// showed through as an L-shaped border.
- let left = self.workspace_sidebar_width() as f32 + border.left.get() as f32;
- let top = border.top.get() as f32 + top_tab_h;
- let right = self
- .dimensions
- .pixel_width
- .saturating_sub(border.right.get() as usize)
- .saturating_sub(self.right_sidebar_width()) as f32;
- let bottom =
- (self.dimensions.pixel_height as f32 - border.bottom.get() as f32 - bottom_tab_h)
- .max(top);
- euclid::rect(left, top, (right - left).max(0.0), (bottom - top).max(0.0))
+ self.terminal_content_rect()
}
/// Where the terminal grid itself lives: the window minus the sidebars,
- /// the tab bar and the borders.
+ /// the window tab row and the borders.
///
/// Unlike [`Self::content_view_area`] this ignores whether a full-window
/// view is currently open, because it answers a question about the
/// terminal rather than about the view sitting on top of it.
pub(crate) fn terminal_content_rect(&self) -> RectF {
let border = self.get_os_border();
- let top_tab_h = if self.show_tab_bar && !self.config.tab_bar_at_bottom {
- self.tab_bar_pixel_height().unwrap_or(0.0)
- } else {
- 0.0
- };
- let bottom_tab_h = if self.show_tab_bar && self.config.tab_bar_at_bottom {
- self.tab_bar_pixel_height().unwrap_or(0.0)
- } else {
- 0.0
- };
+ // The terminal bar is part of the terminal, and the top panes' nav
+ // bars rise into its band: only the window tab row is outside.
let left = self.workspace_sidebar_width() as f32 + border.left.get() as f32;
- let top = border.top.get() as f32 + top_tab_h;
- let right = self
- .dimensions
- .pixel_width
- .saturating_sub(border.right.get() as usize)
- .saturating_sub(self.right_sidebar_width()) as f32;
- let bottom =
- (self.dimensions.pixel_height as f32 - border.bottom.get() as f32 - bottom_tab_h)
- .max(top);
+ let top = border.top.get() as f32 + self.tab_bar_pixel_height().unwrap_or(0.0);
+ let right = self.terminal_viewport_right();
+ let bottom = (self.dimensions.pixel_height as f32 - border.bottom.get() as f32).max(top);
euclid::rect(left, top, (right - left).max(0.0), (bottom - top).max(0.0))
}
@@ -7954,9 +7943,70 @@ impl TermWindow {
self.update_title_impl();
}
- fn theme_aligned_tab_bar_colors(&mut self) -> TabBarColors {
- let palette = self.palette().clone();
- theme_aligned_tab_bar_colors_from_palette(&palette)
+ /// Whether the status text shows anything: plugins clear it with bare
+ /// formatting as often as with "".
+ fn has_status_text(&self) -> bool {
+ [&self.left_status, &self.right_status]
+ .iter()
+ .any(|status| crate::tabbar::parse_status_text(status, Default::default()).len() > 0)
+ }
+
+ /// Bring the terminal bar up to date ahead of a layout, which then makes
+ /// room for the bar it is about to show; `update_title` finds nothing
+ /// left to change and so does not lay the window out a second time.
+ pub(crate) fn settle_terminal_bar_kind(&mut self) {
+ let Some(num_tabs) = Mux::get()
+ .get_window(self.mux_window_id)
+ .map(|window| window.len())
+ else {
+ return;
+ };
+ self.terminal_bar_kind = self.wanted_terminal_bar_kind(&self.config, num_tabs);
+ }
+
+ /// The terminal bar `config` asks for. A status-only bar stays once
+ /// shown: status text that comes and goes (a LEADER marker, a mode name)
+ /// must not resize the terminal every time, nor a reload drop it.
+ fn wanted_terminal_bar_kind(
+ &self,
+ config: &config::Config,
+ num_tabs: usize,
+ ) -> Option<TabBarKind> {
+ crate::tabbar::terminal_bar_kind(
+ config,
+ num_tabs,
+ self.has_status_text() || self.terminal_bar_kind == Some(TabBarKind::TerminalStatus),
+ )
+ }
+
+ /// Tab bar colours for a configuration that names none, on the terminal
+ /// background as painted -- the terminal bar sits inside the terminal.
+ pub(crate) fn theme_aligned_tab_bar_colors(&mut self) -> TabBarColors {
+ let background = self.terminal_default_background();
+ theme_aligned_tab_bar_colors_from_palette(&self.palette().clone(), background)
+ }
+
+ /// The terminal's ground in a dark interface: the chrome's colour rather
+ /// than the scheme's background. `None` in a light one, where the scheme's
+ /// background shows. Read off the appearance cached with the chrome
+ /// palette; asking for it anew is costly (see `chrome_palette`).
+ pub(crate) fn dark_terminal_ground(&self) -> Option<LinearRgba> {
+ matches!(
+ self.chrome_appearance,
+ ::window::Appearance::Dark | ::window::Appearance::DarkHighContrast
+ )
+ .then(|| self.chrome().sidebar_bg)
+ }
+
+ /// The terminal's default background as painted.
+ pub(crate) fn terminal_default_background(&mut self) -> LinearRgba {
+ match self.dark_terminal_ground() {
+ Some(ground) => ground,
+ None => self
+ .palette()
+ .resolve_bg(ColorAttribute::Default)
+ .to_linear(),
+ }
}
fn update_title_impl(&mut self) {
@@ -7970,30 +8020,20 @@ impl TermWindow {
let active_tab = tabs.iter().find(|t| t.is_active).cloned();
let active_pane = panes.iter().find(|p| p.is_active).cloned();
- let border = self.get_os_border();
- let tab_bar_height = self.tab_bar_pixel_height().unwrap_or(0.);
- let tab_bar_y = if self.config.tab_bar_at_bottom {
- ((self.dimensions.pixel_height as f32) - (tab_bar_height + border.bottom.get() as f32))
- .max(0.)
- } else {
- border.top.get() as f32
- };
+ // Decided before the bar is built, so one that has just appeared
+ // paints its content at once. Without a window yet the change waits
+ // for the first layout, which settles it (`settle_terminal_bar_kind`).
+ let terminal_bar_kind = self.wanted_terminal_bar_kind(&self.config, window.len());
+ let terminal_bar_moved =
+ self.window.is_some() && terminal_bar_kind != self.terminal_bar_kind;
+ if terminal_bar_moved {
+ self.terminal_bar_kind = terminal_bar_kind;
+ }
- let tab_bar_height = self.tab_bar_pixel_height().unwrap_or(0.);
+ let cell_width = self.render_metrics.cell_size.width.max(1) as usize;
let tab_bar_x = self.tab_bar_left_edge();
let tab_bar_width = self.dimensions.pixel_width.saturating_sub(tab_bar_x).max(1);
- let hovering_in_tab_bar = match &self.current_mouse_event {
- Some(event) => {
- let mouse_y = event.coords.y as f32;
- let mouse_x = event.coords.x.max(0) as usize;
- mouse_x >= tab_bar_x
- && mouse_y >= tab_bar_y as f32
- && mouse_y < tab_bar_y as f32 + tab_bar_height
- }
- None => false,
- };
-
let has_explicit_tab_colors = self.config.resolved_palette.tab_bar.is_some();
let themed_tab_bar_colors = if has_explicit_tab_colors {
None
@@ -8001,32 +8041,29 @@ impl TermWindow {
Some(self.theme_aligned_tab_bar_colors())
};
let tab_bar_colors = if has_explicit_tab_colors {
- self.config.resolved_palette.tab_bar.as_ref()
+ self.config.resolved_palette.tab_bar.clone()
} else {
- themed_tab_bar_colors.as_ref()
+ themed_tab_bar_colors.clone()
};
+ // The window tab row lays its tabs out itself; this supplies their
+ // titles and progress.
let new_tab_bar = TabBarState::new(
- (tab_bar_width / self.render_metrics.cell_size.width as usize).max(1),
- if hovering_in_tab_bar {
- self.current_mouse_event.as_ref().map(|event| {
- event.coords.x.saturating_sub(tab_bar_x as isize).max(0) as usize
- / self.render_metrics.cell_size.width as usize
- })
- } else {
- None
- },
+ (tab_bar_width / cell_width).max(1),
+ None,
&tabs,
&panes,
- tab_bar_colors,
+ tab_bar_colors.as_ref(),
&self.config,
crate::termwindow::ui::platform_chrome::uses_integrated_window_buttons(
self.config.window_decorations,
self.window_state,
),
self.tab_bar_scroll_offset,
- &self.left_status,
- &self.right_status,
+ "",
+ "",
+ TabBarKind::WindowTabs,
+ !has_explicit_tab_colors,
);
if new_tab_bar != self.tab_bar {
self.tab_bar = new_tab_bar;
@@ -8037,11 +8074,48 @@ impl TermWindow {
}
}
+ if let (Some(kind), Some(rect)) = (self.terminal_bar_kind, self.terminal_bar_rect()) {
+ let bar_x = rect.origin.x.max(0.) as usize;
+ let mouse_x = self.current_mouse_event.as_ref().and_then(|event| {
+ rect.contains(euclid::point2(event.coords.x as f32, event.coords.y as f32))
+ .then(|| (event.coords.x.max(0) as usize).saturating_sub(bar_x) / cell_width)
+ });
+ let new_terminal_bar = TabBarState::new(
+ (rect.size.width.max(0.) as usize / cell_width).max(1),
+ mouse_x,
+ &tabs,
+ &panes,
+ tab_bar_colors.as_ref(),
+ &self.config,
+ false,
+ 0.,
+ &self.left_status,
+ &self.right_status,
+ kind,
+ !has_explicit_tab_colors,
+ );
+ if new_terminal_bar != self.terminal_bar {
+ self.terminal_bar = new_terminal_bar;
+ if let Some(window) = self.window.as_ref() {
+ window.invalidate();
+ }
+ }
+ }
+
let num_tabs = window.len();
+ drop(window);
+ // The terminal bar took its row from the pane tree or gave it back.
+ // Lay the window out again -- not through a config reload, which
+ // would also cancel a pending leader and clear the shape caches.
+ if terminal_bar_moved {
+ if let Some(window) = self.window.as_ref().cloned() {
+ let dimensions = self.dimensions;
+ self.apply_dimensions(&dimensions, None, &window);
+ }
+ }
if num_tabs == 0 {
return;
}
- drop(window);
let title = match config::run_immediate_with_lua_config(|lua| {
if let Some(lua) = lua {
@@ -8057,7 +8131,10 @@ impl TermWindow {
active_pane.clone(),
tabs,
panes,
- (*self.config).clone(),
+ crate::tabbar::config_for_lua(
+ &self.config,
+ themed_tab_bar_colors.as_ref(),
+ ),
),
),
)?;
@@ -8146,20 +8223,6 @@ impl TermWindow {
if let Some(window) = self.window.as_ref() {
window.set_title(&title);
-
- let show_tab_bar = if num_tabs == 1 {
- self.config.enable_tab_bar && !self.config.hide_tab_bar_if_only_one_tab
- } else {
- self.config.enable_tab_bar
- };
-
- // If the number of tabs changed and caused the tab bar to
- // hide/show, then we'll need to resize things. It is simplest
- // to piggy back on the config reloading code for that, so that
- // is what we're doing.
- if show_tab_bar != self.show_tab_bar {
- self.config_was_reloaded();
- }
}
self.schedule_next_status_update();
}
diff --git a/wezterm-gui/src/termwindow/mouseevent.rs b/wezterm-gui/src/termwindow/mouseevent.rs
index eee349ef..97f529de 100644
--- a/wezterm-gui/src/termwindow/mouseevent.rs
+++ b/wezterm-gui/src/termwindow/mouseevent.rs
@@ -432,11 +432,7 @@ impl super::TermWindow {
/// The gap the window tab row leaves between neighbouring tabs.
pub(super) fn window_tab_gap_pixels(&self) -> f32 {
- if self.config.use_fancy_tab_bar {
- self.ui_px(WINDOW_TAB_GAP) as f32
- } else {
- 0.0
- }
+ self.ui_px(WINDOW_TAB_GAP) as f32
}
/// How many surfaces the window tab row paints: the mux tabs plus the
@@ -477,7 +473,6 @@ impl super::TermWindow {
pub(crate) fn window_tab_chrome_params(&self) -> WindowTabChromeParams {
WindowTabChromeParams {
- use_fancy_tab_bar: self.config.use_fancy_tab_bar,
workspace_sidebar_width: self.workspace_sidebar_width(),
window_state: self.window_state,
window_decorations: self.config.window_decorations,
@@ -485,17 +480,11 @@ impl super::TermWindow {
integrated_title_button_style: self.config.integrated_title_button_style,
cell_width: self.render_metrics.cell_size.width.max(1) as f32,
dpi: self.dimensions.dpi,
- top_fancy_row_height: if self.show_tab_bar
- && self.config.use_fancy_tab_bar
- && !self.config.tab_bar_at_bottom
- {
- self.tab_bar_pixel_height()
- .ok()
- .map(|h| h.ceil() as usize)
- .filter(|h| *h > 0)
- } else {
- None
- },
+ top_fancy_row_height: self
+ .tab_bar_pixel_height()
+ .ok()
+ .map(|h| h.ceil() as usize)
+ .filter(|h| *h > 0),
}
}
@@ -532,16 +521,12 @@ impl super::TermWindow {
pub(super) fn window_tab_trailing_action_reserved_width(&self) -> usize {
let configured_button_size = self.ui_px(WINDOW_TAB_LEADING_ACTION_BUTTON_SIZE);
- let action_button_size = if self.config.use_fancy_tab_bar {
+ let action_button_size = {
let row_height = self
.tab_bar_pixel_height()
.unwrap_or(configured_button_size as f32)
.ceil() as usize;
- let content_top_spacer = if self.config.tab_bar_at_bottom {
- 0
- } else {
- self.ui_px(WINDOW_TAB_TOP_SPACER).min(row_height)
- };
+ let content_top_spacer = self.ui_px(WINDOW_TAB_TOP_SPACER).min(row_height);
let content_height = row_height.saturating_sub(content_top_spacer);
let tab_font_cell_height_upper_bound = content_height.div_ceil(2);
content_height
@@ -549,8 +534,6 @@ impl super::TermWindow {
.max(tab_font_cell_height_upper_bound)
.max(1)
.max(configured_button_size)
- } else {
- configured_button_size
};
let action_button_count = if !self.right_sidebar_has_panels() {
// Every sidebar panel is off, so fancy_tab_bar paints no toggle;
@@ -605,11 +588,10 @@ impl super::TermWindow {
// derived from this number, so a one-pixel disagreement would clip
// the last tab in a row that otherwise fits exactly.
.saturating_sub(left_padding.max(0.0).ceil() as usize)
- .saturating_sub(if self.config.use_fancy_tab_bar {
- self.ui_px(TAB_ROW_START_PADDING) + self.window_tab_trailing_action_reserved_width()
- } else {
- 0
- })
+ .saturating_sub(
+ self.ui_px(TAB_ROW_START_PADDING)
+ + self.window_tab_trailing_action_reserved_width(),
+ )
.max(1) as f32
}
@@ -838,11 +820,7 @@ impl super::TermWindow {
};
let border = self.get_os_border();
- let top_bar_height = if self.show_tab_bar && !self.config.tab_bar_at_bottom {
- self.tab_bar_pixel_height().unwrap_or(0.)
- } else {
- 0.0
- };
+ let (top_bar_height, _) = self.pane_area_insets();
let cell_height = self.render_metrics.cell_size.height as f32;
let x = event.coords.x as f32;
let y = event.coords.y as f32;
@@ -857,7 +835,8 @@ impl super::TermWindow {
let Ok((pane_x, pane_width)) = self.pane_chrome_span(&pos) else {
continue;
};
- let pane_y = top_bar_height + border.top.get() as f32 + pos.top as f32 * cell_height;
+ let pane_y = top_bar_height + border.top.get() as f32 + pos.top as f32 * cell_height
+ - self.pane_nav_lift(&pos);
if x >= pane_x && x < pane_x + pane_width && y >= pane_y && y < pane_y + nav_height {
// The zoomed branch of iter_panes fills pane_stack_id with
// the pane's own id, not the real stack id; resolve through
@@ -870,19 +849,14 @@ impl super::TermWindow {
}
}
- if self.show_tab_bar {
- let tab_bar_height = self.tab_bar_pixel_height().unwrap_or(0.);
- let tab_bar_y = if self.config.tab_bar_at_bottom {
- self.dimensions.pixel_height as f32 - tab_bar_height - border.bottom.get() as f32
- } else {
- border.top.get() as f32
- };
- if event.coords.x >= self.tab_bar_left_edge() as isize
- && y >= tab_bar_y
- && y < tab_bar_y + tab_bar_height
- {
- return Some(TabWheelSurface::Window);
- }
+ let tab_bar_height = self.tab_bar_pixel_height().unwrap_or(0.);
+ let tab_bar_y = border.top.get() as f32;
+ if event.coords.x >= self.tab_bar_left_edge() as isize
+ && (event.coords.x as f32) < self.terminal_viewport_right()
+ && y >= tab_bar_y
+ && y < tab_bar_y + tab_bar_height
+ {
+ return Some(TabWheelSurface::Window);
}
None
@@ -1580,7 +1554,7 @@ impl super::TermWindow {
fn leave_ui_item(&mut self, item: &UIItem) {
match item.item_type {
- UIItemType::TabBar(_) => {
+ UIItemType::TabBar(_) | UIItemType::TerminalBar(_) => {
self.update_title_post_status();
}
UIItemType::CloseTab(_)
@@ -1707,7 +1681,7 @@ impl super::TermWindow {
fn enter_ui_item(&mut self, item: &UIItem) {
match item.item_type {
- UIItemType::TabBar(_) => {}
+ UIItemType::TabBar(_) | UIItemType::TerminalBar(_) => {}
UIItemType::CloseTab(_)
| UIItemType::PaneNav { .. }
| UIItemType::ProjectNew
@@ -1805,11 +1779,7 @@ impl super::TermWindow {
pos: &PositionedPane,
) -> ClickPosition {
let border = self.get_os_border();
- let first_line_offset = if self.show_tab_bar && !self.config.tab_bar_at_bottom {
- self.tab_bar_pixel_height().unwrap_or(0.) as isize
- } else {
- 0
- } + border.top.get() as isize;
+ let first_line_offset = self.pane_area_insets().0 as isize + border.top.get() as isize;
let (padding_left, padding_top) = self.padding_left_top();
let global_cell_size = self.render_metrics.cell_size;
@@ -2059,11 +2029,7 @@ impl super::TermWindow {
let border = self.get_os_border();
- let first_line_offset = if self.show_tab_bar && !self.config.tab_bar_at_bottom {
- self.tab_bar_pixel_height().unwrap_or(0.) as isize
- } else {
- 0
- } + border.top.get() as isize;
+ let first_line_offset = self.pane_area_insets().0 as isize + border.top.get() as isize;
let (padding_left, padding_top) = self.padding_left_top();
@@ -2369,7 +2335,7 @@ impl super::TermWindow {
match (self.last_ui_item.take(), &ui_item) {
(Some(prior), Some(item)) => {
- if prior != *item || !self.config.use_fancy_tab_bar {
+ if prior != *item {
self.leave_ui_item(&prior);
self.enter_ui_item(item);
context.invalidate();
@@ -3707,6 +3673,9 @@ impl super::TermWindow {
UIItemType::TabBar(item) => {
self.mouse_event_tab_bar(item, event, context);
}
+ UIItemType::TerminalBar(item) => {
+ self.mouse_event_terminal_bar(item, event, context);
+ }
UIItemType::AboveScrollThumb(track) => {
let pane = self.scroll_track_pane(track).unwrap_or(pane);
self.mouse_event_above_scroll_thumb(item, pane, event, context);
@@ -4275,6 +4244,9 @@ impl super::TermWindow {
UIItemType::TabBar(item) => {
self.mouse_event_tab_bar(item, event, context);
}
+ UIItemType::TerminalBar(item) => {
+ self.mouse_event_terminal_bar(item, event, context);
+ }
UIItemType::CloseTab(idx) => {
self.mouse_event_close_tab(idx, event, context);
}
@@ -8305,6 +8277,26 @@ impl super::TermWindow {
context.set_cursor(Some(MouseCursor::Arrow));
}
+ /// The terminal bar lives inside the terminal area: its tabs and new tab
+ /// button press like the window tab row's, but it is no title bar, so
+ /// its blank and status cells neither move nor maximize the window.
+ pub fn mouse_event_terminal_bar(
+ &mut self,
+ item: TabBarItem,
+ event: MouseEvent,
+ context: &dyn WindowOps,
+ ) {
+ let pressable = matches!(
+ item,
+ TabBarItem::Tab { .. } | TabBarItem::NewTabButton { .. }
+ );
+ if pressable && matches!(event.kind, WMEK::Press(_)) {
+ self.mouse_event_tab_bar(item, event, context);
+ } else {
+ context.set_cursor(Some(MouseCursor::Arrow));
+ }
+ }
+
pub fn mouse_event_above_scroll_thumb(
&mut self,
_item: UIItem,
diff --git a/wezterm-gui/src/termwindow/paneselect.rs b/wezterm-gui/src/termwindow/paneselect.rs
index 733449a3..675652ab 100644
--- a/wezterm-gui/src/termwindow/paneselect.rs
+++ b/wezterm-gui/src/termwindow/paneselect.rs
@@ -61,11 +61,7 @@ impl PaneSelector {
.expect("to resolve pane selection font");
let metrics = RenderMetrics::with_font_metrics(&font.metrics());
- let top_bar_height = if term_window.show_tab_bar && !term_window.config.tab_bar_at_bottom {
- term_window.tab_bar_pixel_height().unwrap()
- } else {
- 0.
- };
+ let top_bar_height = term_window.pane_area_insets().0;
let (padding_left, padding_top) = term_window.padding_left_top();
let border = term_window.get_os_border();
let top_pixel_y = top_bar_height + padding_top + border.top.get() as f32;
diff --git a/wezterm-gui/src/termwindow/render/fancy_tab_bar.rs b/wezterm-gui/src/termwindow/render/fancy_tab_bar.rs
index 0ca9f0a4..8673059c 100644
--- a/wezterm-gui/src/termwindow/render/fancy_tab_bar.rs
+++ b/wezterm-gui/src/termwindow/render/fancy_tab_bar.rs
@@ -60,18 +60,8 @@ impl crate::TermWindow {
let border = self.get_os_border();
let row_x = self.tab_bar_left_edge();
- let row_y = if self.config.tab_bar_at_bottom {
- self.dimensions
- .pixel_height
- .saturating_sub(row_height + border.bottom.get() as usize)
- } else {
- border.top.get() as usize
- };
- let content_top_spacer = if self.config.tab_bar_at_bottom {
- 0
- } else {
- self.ui_px(WINDOW_TAB_TOP_SPACER).min(row_height)
- };
+ let row_y = border.top.get() as usize;
+ let content_top_spacer = self.ui_px(WINDOW_TAB_TOP_SPACER).min(row_height);
let content_row_y = row_y + content_top_spacer;
let content_row_height = row_height.saturating_sub(content_top_spacer);
let icon_size = self.ui_px(TAB_ICON_SIZE).min(content_row_height);
@@ -126,11 +116,7 @@ impl crate::TermWindow {
.get_active_tab_for_window(self.mux_window_id)
.is_some_and(|tab| tab.iter_panes_ignoring_zoom().len() > 1);
if show_pane_layer_divider {
- let divider_y = if self.config.tab_bar_at_bottom {
- row_y
- } else {
- row_y + row_height
- };
+ let divider_y = row_y + row_height;
self.filled_rectangle(
layers,
1,
@@ -508,9 +494,7 @@ impl crate::TermWindow {
let icon_size = action_icon_size.min(button_size.saturating_sub(2));
if is_sidebar_toggle {
- let button_y = if self.config.tab_bar_at_bottom {
- row_y + (row_height.saturating_sub(button_size) / 2)
- } else if is_fullscreen_sidebar_toggle {
+ let button_y = if is_fullscreen_sidebar_toggle {
row_y.saturating_sub(self.ui_px(WINDOW_TAB_TOP_SPACER))
+ self.ui_px(SIDEBAR_INSET)
+ self.ui_px(WINDOW_TAB_FULLSCREEN_SIDEBAR_BUTTON_Y_OFFSET)
diff --git a/wezterm-gui/src/termwindow/render/mod.rs b/wezterm-gui/src/termwindow/render/mod.rs
index 4a38dfd1..b8e1879e 100644
--- a/wezterm-gui/src/termwindow/render/mod.rs
+++ b/wezterm-gui/src/termwindow/render/mod.rs
@@ -501,10 +501,9 @@ impl crate::TermWindow {
- self.terminal_size.pixel_height as f32
- padding_top
- padding_bottom
- - if self.show_tab_bar {
- self.tab_bar_pixel_height().unwrap_or(0.)
- } else {
- 0.
+ - {
+ let (top, bottom) = self.pane_area_insets();
+ top + bottom
};
let left_gap = match self.config.window_content_alignment.horizontal {
HorizontalWindowContentAlignment::Left => 0.,
diff --git a/wezterm-gui/src/termwindow/render/paint.rs b/wezterm-gui/src/termwindow/render/paint.rs
index cda030d3..74371483 100644
--- a/wezterm-gui/src/termwindow/render/paint.rs
+++ b/wezterm-gui/src/termwindow/render/paint.rs
@@ -1562,7 +1562,7 @@ impl crate::TermWindow {
self.paint_right_sidebar(&mut right)
.context("record right sidebar")?;
}
- if self.show_tab_bar {
+ {
let mut top = TripleLayerQuadAllocator::Heap(&mut chrome.top);
self.paint_tab_bar(&mut top).context("record tab bar")?;
}
@@ -2996,16 +2996,7 @@ impl crate::TermWindow {
let (padding_left, padding_top) = self.padding_left_top();
let border = self.get_os_border();
- let tab_bar_height = if self.show_tab_bar {
- self.tab_bar_pixel_height().unwrap_or(0.0)
- } else {
- 0.0
- };
- let (top_tab_height, bottom_tab_height) = if self.config.tab_bar_at_bottom {
- (0.0, tab_bar_height)
- } else {
- (tab_bar_height, 0.0)
- };
+ let (top_tab_height, bottom_tab_height) = self.pane_area_insets();
let grid_left = padding_left + border.left.get() as f32;
let grid_top = border.top.get() as f32 + top_tab_height + padding_top;
@@ -4106,13 +4097,8 @@ impl crate::TermWindow {
if paint_terminal_background {
// Regular window background color
- let background = if matches!(
- crate::native_settings::effective_appearance(),
- window::Appearance::Dark | window::Appearance::DarkHighContrast
- ) {
- self.chrome()
- .sidebar_bg
- .mul_alpha(self.config.window_background_opacity)
+ let background = if let Some(ground) = self.dark_terminal_ground() {
+ ground.mul_alpha(self.config.window_background_opacity)
} else if panes.len() == 1 {
// If we're the only pane, use the pane's palette
// to draw the padding background
@@ -4212,11 +4198,16 @@ impl crate::TermWindow {
}
}
self.paint_pane(&pos, &mut layers).context("paint_pane")?;
- if let Ok(frame) = self.pane_frame_rect(&pos) {
+ if let Ok(frame) = self.pane_mask_frame(&pos) {
self.paint_pane_recording_masks(pos.pane.pane_id(), frame, &mut layers)?;
}
}
+ // Part of the terminal, gone with the panes wherever they are:
+ // after them, and before their dividers, which run through it
+ // and take the pointer there.
+ self.paint_terminal_bar(&mut layers)
+ .context("paint_terminal_bar")?;
if let Some(pane) = self.get_active_pane_or_overlay() {
let splits = self.get_splits();
for split in &splits {
@@ -4501,10 +4492,8 @@ impl crate::TermWindow {
.context("paint_right_sidebar")?;
}
- if self.show_tab_bar {
- self.paint_tab_bar(&mut chrome_layers)
- .context("paint_tab_bar")?;
- }
+ self.paint_tab_bar(&mut chrome_layers)
+ .context("paint_tab_bar")?;
drop(chrome_layers);
if let Some((overlay, hidden, items)) = hover_overlay {
diff --git a/wezterm-gui/src/termwindow/render/pane.rs b/wezterm-gui/src/termwindow/render/pane.rs
index c437ddc0..8c9ad9e0 100644
--- a/wezterm-gui/src/termwindow/render/pane.rs
+++ b/wezterm-gui/src/termwindow/render/pane.rs
@@ -245,17 +245,7 @@ impl crate::TermWindow {
}
fn pane_content_origin(&self, pos: &PositionedPane) -> anyhow::Result<(f32, f32)> {
- let tab_bar_height = if self.show_tab_bar {
- self.tab_bar_pixel_height()
- .context("tab_bar_pixel_height")?
- } else {
- 0.
- };
- let top_bar_height = if self.config.tab_bar_at_bottom {
- 0.0
- } else {
- tab_bar_height
- };
+ let (top_bar_height, _) = self.pane_area_insets();
let border = self.get_os_border();
let (padding_left, _) = self.padding_left_top();
Ok((
@@ -302,8 +292,29 @@ impl crate::TermWindow {
if self.collapsed_pane_layouts.contains_key(&pos.pane_stack_id) && pos.top > 0 {
height = height.max(self.pane_nav_bar_height() as f32);
}
+ // The frame starts at the nav bar, lifted for panes along the top.
+ let lift = self.pane_nav_lift(pos);
+
+ Ok(euclid::rect(
+ pane_x,
+ pane_y - lift,
+ pane_width,
+ height + lift,
+ ))
+ }
- Ok(euclid::rect(pane_x, pane_y, pane_width, height))
+ /// The pane's rectangle without that lift. Recording masks are kept as
+ /// fractions of it, so it has to move with the pane's rows when a
+ /// terminal bar comes or goes, as the whole frame did before the lift.
+ pub(crate) fn pane_mask_frame(&self, pos: &PositionedPane) -> anyhow::Result<RectF> {
+ let frame = self.pane_frame_rect(pos)?;
+ let lift = self.pane_nav_lift(pos);
+ Ok(euclid::rect(
+ frame.origin.x,
+ frame.origin.y + lift,
+ frame.size.width,
+ frame.size.height - lift,
+ ))
}
fn paint_collapsed_pane_nav_bar(
@@ -348,7 +359,15 @@ impl crate::TermWindow {
.clamp(24, 30);
let icon_size = button_size.saturating_sub(8).clamp(16, 22);
let x = strip_left + (strip_width.saturating_sub(button_size) / 2);
- let mut y = strip_top + COLLAPSED_EDGE_PADDING;
+ // A terminal bar across the top runs through a strip lifted to the
+ // top edge (see `pane_nav_lift`): its chips start below the bar.
+ let chips_top = match self.terminal_bar_rect() {
+ Some(bar) if self.pane_nav_lift(pos) > 0. => {
+ (bar.max_y().max(0.0) as usize).max(strip_top)
+ }
+ _ => strip_top,
+ };
+ let mut y = chips_top + COLLAPSED_EDGE_PADDING;
if let Some(tab) = &active_tab {
if y.saturating_add(button_size) <= strip_bottom {
@@ -757,6 +776,7 @@ impl crate::TermWindow {
}
let (_, pane_y) = self.pane_content_origin(pos)?;
+ let pane_y = pane_y - self.pane_nav_lift(pos);
if pos.width == 0 {
return Ok(0);
}
@@ -1403,17 +1423,7 @@ impl crate::TermWindow {
let (padding_left, padding_top) = self.padding_left_top();
- let tab_bar_height = if self.show_tab_bar {
- self.tab_bar_pixel_height()
- .context("tab_bar_pixel_height")?
- } else {
- 0.
- };
- let (top_bar_height, bottom_bar_height) = if self.config.tab_bar_at_bottom {
- (0.0, tab_bar_height)
- } else {
- (tab_bar_height, 0.0)
- };
+ let (top_bar_height, bottom_bar_height) = self.pane_area_insets();
let border = self.get_os_border();
let top_pixel_y = top_bar_height + padding_top + border.top.get() as f32;
@@ -1488,13 +1498,7 @@ impl crate::TermWindow {
let window_is_transparent =
!self.window_background.is_empty() || config.window_background_opacity != 1.0;
- let dark_chrome_background = matches!(
- crate::native_settings::effective_appearance(),
- window::Appearance::Dark | window::Appearance::DarkHighContrast
- )
- .then(|| {
- self.chrome().sidebar_bg
- });
+ let dark_chrome_background = self.dark_terminal_ground();
let default_bg = dark_chrome_background
.unwrap_or_else(|| palette.resolve_bg(ColorAttribute::Default).to_linear())
.mul_alpha(if window_is_transparent {
@@ -1544,7 +1548,7 @@ impl crate::TermWindow {
width,
// Go all the way to the bottom if we're bottom-most
if pos.top + pos.height >= self.terminal_size.rows as usize {
- self.dimensions.pixel_height as f32 - y
+ self.pane_area_bottom() - y
} else {
(pos.height as f32 * cell_height) + height_delta as f32
},
@@ -1738,7 +1742,8 @@ impl crate::TermWindow {
/// the smooth-scroll remainder. Only the rows at the pane's top
/// and bottom can poke out of it, so only those pay for
/// cropping; the rest are moved as they are. With no remainder
- /// this is the plain replay it always was.
+ /// this is the plain replay it always was. The first `cut_rows`
+ /// reach under a terminal bar and are cropped at its edge.
fn replay_line(
layers: &mut dyn TripleLayerQuadAllocatorTrait,
heap: &HeapQuadAllocator,
@@ -1746,7 +1751,11 @@ impl crate::TermWindow {
pane_clip: QuadClipRect,
line_idx: usize,
row_count: usize,
+ cut_rows: usize,
) -> anyhow::Result<()> {
+ if line_idx < cut_rows {
+ return heap.apply_to_clipped_at(layers, 0.0, -scroll_px, pane_clip, 1.0);
+ }
if scroll_px == 0.0 {
return heap.apply_to(layers);
}
@@ -1762,6 +1771,7 @@ impl crate::TermWindow {
scroll_px: f32,
pane_clip: QuadClipRect,
row_count: usize,
+ cut_rows: usize,
term_window: &'a mut crate::TermWindow,
selrange: Option<SelectionRange>,
rectangular: bool,
@@ -1795,7 +1805,7 @@ impl crate::TermWindow {
+ (pos.top as f32 * global_render_metrics.cell_size.height as f32)
+ pane_nav_height as f32;
- if let Ok(frame) = self.pane_frame_rect(pos) {
+ if let Ok(frame) = self.pane_mask_frame(pos) {
self.update_recording_mask_grid(
pane_id,
frame,
@@ -1823,9 +1833,26 @@ impl crate::TermWindow {
);
}
+ // A top pane too short for its whole nav bar starts its rows
+ // inside the terminal bar's band (see `pane_nav_lift`). The bar
+ // covers them there and takes their clicks, so they are cut at
+ // its lower edge rather than drawn through it.
+ let content_top = if self.pane_nav_lift(pos) > 0. {
+ self.terminal_bar_rect()
+ .map_or(pane_top_pixel_y, |bar| pane_top_pixel_y.max(bar.max_y()))
+ } else {
+ pane_top_pixel_y
+ };
+ let cut_rows = if content_top > pane_top_pixel_y {
+ ((content_top - pane_top_pixel_y + scroll_px)
+ / pane_render_metrics.cell_size.height.max(1) as f32)
+ .ceil() as usize
+ } else {
+ 0
+ };
let pane_clip = QuadClipRect::from_top_left_pixels(
left_pixel_x,
- pane_top_pixel_y,
+ content_top,
left_pixel_x
+ render_dims.cols as f32 * pane_render_metrics.cell_size.width as f32,
pane_top_pixel_y
@@ -1837,6 +1864,7 @@ impl crate::TermWindow {
scroll_px,
pane_clip,
row_count,
+ cut_rows,
term_window: self,
selrange,
rectangular,
@@ -1968,6 +1996,7 @@ impl crate::TermWindow {
self.pane_clip,
line_idx,
self.row_count,
+ self.cut_rows,
)
.context("cached_quad.layers.apply_to")?;
self.term_window.update_next_frame_time(cached_quad.expires);
@@ -2071,6 +2100,7 @@ impl crate::TermWindow {
self.pane_clip,
line_idx,
self.row_count,
+ self.cut_rows,
)
.context("HeapQuadAllocator::apply_to")?;
@@ -2143,7 +2173,7 @@ impl crate::TermWindow {
current_viewport,
scroll_px / pane_render_metrics.cell_size.height.max(1) as f32,
pane_content_right,
- pane_top_pixel_y,
+ content_top,
content_bottom,
)?;
}
@@ -2172,16 +2202,7 @@ impl crate::TermWindow {
let cell_width = self.render_metrics.cell_size.width as f32;
let cell_height = self.render_metrics.cell_size.height as f32;
let (padding_left, padding_top) = self.padding_left_top();
- let tab_bar_height = if self.show_tab_bar {
- self.tab_bar_pixel_height()?
- } else {
- 0.
- };
- let (top_bar_height, _bottom_bar_height) = if self.config.tab_bar_at_bottom {
- (0.0, tab_bar_height)
- } else {
- (tab_bar_height, 0.0)
- };
+ let (top_bar_height, _bottom_bar_height) = self.pane_area_insets();
let border = self.get_os_border();
let top_pixel_y = top_bar_height + padding_top + border.top.get() as f32;
@@ -2229,7 +2250,7 @@ impl crate::TermWindow {
background_width,
// Go all the way to the bottom if we're bottom-most
if pos.top + pos.height >= self.terminal_size.rows as usize {
- self.dimensions.pixel_height as f32 - y
+ self.pane_area_bottom() - y
} else {
(pos.height as f32 * cell_height) + height_delta as f32
},
diff --git a/wezterm-gui/src/termwindow/render/split.rs b/wezterm-gui/src/termwindow/render/split.rs
index 5626d027..ebf4c7b5 100644
--- a/wezterm-gui/src/termwindow/render/split.rs
+++ b/wezterm-gui/src/termwindow/render/split.rs
@@ -17,11 +17,7 @@ impl crate::TermWindow {
let cell_height = self.render_metrics.cell_size.height as f32;
let border = self.get_os_border();
- let first_row_offset = if self.show_tab_bar && !self.config.tab_bar_at_bottom {
- self.tab_bar_pixel_height()?
- } else {
- 0.
- } + border.top.get() as f32;
+ let first_row_offset = self.pane_area_insets().0 + border.top.get() as f32;
let (padding_left, padding_top) = self.padding_left_top();
@@ -29,26 +25,40 @@ impl crate::TermWindow {
let pos_x = split.left as f32 * cell_width + padding_left + border.left.get() as f32;
if split.direction == SplitDirection::Horizontal {
+ let x = pos_x + (cell_width / 2.0);
+ let width = self.render_metrics.underline_height as f32;
+ let mut top = pos_y - (cell_height / 2.0);
+ let mut bottom = top + (1. + split.size as f32) * cell_height;
+ // Between the top panes the line reaches up beside their lifted
+ // nav bars (see `pane_nav_lift`), straight through the terminal
+ // bar under them; along the bottom it stops short of the bar.
+ let mut lift = 0.;
+ match self.terminal_bar_placement() {
+ Some(bar) if !bar.at_bottom && split.top == 0 => lift = bar.height,
+ Some(bar) if bar.at_bottom => bottom = bottom.min(self.pane_area_bottom()),
+ _ => {}
+ }
+ // Never above the terminal area: with no top padding (tabline.wez
+ // zeroes it) the half-cell overhang reached into the window tab
+ // row.
+ let area_top = border.top.get() as f32 + self.tab_bar_pixel_height().unwrap_or(0.);
+ top = (top - lift).max(area_top);
self.filled_rectangle(
layers,
2,
- euclid::rect(
- pos_x + (cell_width / 2.0),
- pos_y - (cell_height / 2.0),
- self.render_metrics.underline_height as f32,
- (1. + split.size as f32) * cell_height,
- ),
+ euclid::rect(x, top, width, (bottom - top).max(0.)),
foreground,
)?;
+ // The drag area follows it up.
+ let item_top =
+ padding_top as usize + first_row_offset as usize + split.top * cell_height as usize;
self.ui_items.push(UIItem {
x: border.left.get() as usize
+ padding_left as usize
+ (split.left * cell_width as usize),
width: cell_width as usize,
- y: padding_top as usize
- + first_row_offset as usize
- + split.top * cell_height as usize,
- height: split.size * cell_height as usize,
+ y: item_top.saturating_sub(lift as usize),
+ height: split.size * cell_height as usize + lift as usize,
item_type: UIItemType::Split(split.clone()),
});
} else {
diff --git a/wezterm-gui/src/termwindow/render/tab_bar.rs b/wezterm-gui/src/termwindow/render/tab_bar.rs
index 2f1fac0a..0e9fbb66 100644
--- a/wezterm-gui/src/termwindow/render/tab_bar.rs
+++ b/wezterm-gui/src/termwindow/render/tab_bar.rs
@@ -1,13 +1,12 @@
use crate::quad::TripleLayerQuadAllocator;
use crate::termwindow::render::RenderScreenLineParams;
-use crate::termwindow::theme_aligned_tab_bar_colors_from_palette;
use crate::termwindow::ui::tokens::WINDOW_TAB_TOP_SPACER;
use crate::ui::scale_ui_usize;
use crate::utilsprites::RenderMetrics;
-use config::ConfigHandle;
use mux::renderable::RenderableDimensions;
-use wezterm_term::color::ColorAttribute;
+use mux::tab::PositionedPane;
use window::color::LinearRgba;
+use window::RectF;
fn fancy_tab_bar_pixel_height(cell_height: usize, dpi: usize) -> usize {
crate::termwindow::ui::tokens::tab_row_height_for_cell(cell_height)
@@ -37,51 +36,134 @@ mod tests {
}
}
+/// Height of the terminal bar while it shows: one terminal row.
+pub(crate) fn terminal_bar_height(
+ kind: Option<crate::tabbar::TabBarKind>,
+ render_metrics: &RenderMetrics,
+) -> usize {
+ kind.map_or(0, |_| render_metrics.cell_size.height.max(0) as usize)
+}
+
+/// Where the terminal bar sits while it shows: the bar wezterm
+/// configurations draw, which lives inside the terminal area.
+#[derive(Clone, Copy, Debug, PartialEq)]
+pub(crate) struct TerminalBarPlacement {
+ pub at_bottom: bool,
+ pub height: f32,
+}
+
impl crate::TermWindow {
+ /// ThinkTerm's window tab row. The wezterm tab bar options configure the
+ /// terminal bar instead (see `tabbar::TabBarKind`).
pub fn paint_tab_bar(&mut self, layers: &mut TripleLayerQuadAllocator) -> anyhow::Result<()> {
- if self.config.use_fancy_tab_bar {
- let mut tab_bar_items = self.paint_fancy_tab_bar(layers)?;
- self.ui_items.append(&mut tab_bar_items);
- return Ok(());
+ let mut tab_bar_items = self.paint_fancy_tab_bar(layers)?;
+ self.ui_items.append(&mut tab_bar_items);
+ Ok(())
+ }
+
+ pub(crate) fn terminal_bar_placement(&self) -> Option<TerminalBarPlacement> {
+ self.terminal_bar_kind?;
+ Some(TerminalBarPlacement {
+ at_bottom: self.config.tab_bar_at_bottom,
+ height: terminal_bar_height(self.terminal_bar_kind, &self.render_metrics) as f32,
+ })
+ }
+
+ /// Pixels the window tab row and the terminal bar take above and below
+ /// the pane tree.
+ pub(crate) fn pane_area_insets(&self) -> (f32, f32) {
+ let window_tabs = self.tab_bar_pixel_height().unwrap_or(0.);
+ match self.terminal_bar_placement() {
+ Some(bar) if bar.at_bottom => (window_tabs, bar.height),
+ Some(bar) => (window_tabs + bar.height, 0.),
+ None => (window_tabs, 0.),
}
+ }
- let border = self.get_os_border();
+ /// Where the bottom-most panes' backgrounds end: the window's bottom
+ /// edge, or the top of a terminal bar along it -- a bar that leaves its
+ /// background to the window (bar.wezterm's is "transparent") must not
+ /// show the panes through it.
+ pub(crate) fn pane_area_bottom(&self) -> f32 {
+ let window_bottom = self.dimensions.pixel_height as f32;
+ match self.terminal_bar_placement() {
+ Some(bar) if bar.at_bottom => {
+ (window_bottom - self.get_os_border().bottom.get() as f32 - bar.height).max(0.)
+ }
+ _ => window_bottom,
+ }
+ }
- let palette = self.palette().clone();
- let tab_bar_height = self.tab_bar_pixel_height()?;
- let tab_bar_y = if self.config.tab_bar_at_bottom {
- ((self.dimensions.pixel_height as f32) - (tab_bar_height + border.bottom.get() as f32))
- .max(0.)
+ /// How far above its pane the nav bar of a pane on the terminal area's
+ /// top edge is drawn. A terminal bar at the top belongs under the nav
+ /// bars, beside the terminal: the pane tree makes room for it, and these
+ /// nav bars move up into that room.
+ pub(crate) fn pane_nav_lift(&self, pos: &PositionedPane) -> f32 {
+ match self.terminal_bar_placement() {
+ Some(bar) if !bar.at_bottom && pos.top == 0 => bar.height,
+ _ => 0.,
+ }
+ }
+
+ /// The terminal bar's rectangle: across the terminal area, under the top
+ /// panes' nav bars or along its bottom edge.
+ pub(crate) fn terminal_bar_rect(&self) -> Option<RectF> {
+ let bar = self.terminal_bar_placement()?;
+ let border = self.get_os_border();
+ let left = self.tab_bar_left_edge() as f32;
+ let width = (self.terminal_viewport_right() - left).max(1.);
+ let y = if bar.at_bottom {
+ self.pane_area_bottom()
} else {
- border.top.get() as f32
+ let (top, _) = self.pane_area_insets();
+ border.top.get() as f32 + top - bar.height + self.pane_nav_bar_height() as f32
+ };
+ Some(euclid::rect(left, y, width, bar.height))
+ }
+
+ pub fn paint_terminal_bar(
+ &mut self,
+ layers: &mut TripleLayerQuadAllocator,
+ ) -> anyhow::Result<()> {
+ let Some(rect) = self.terminal_bar_rect() else {
+ return Ok(());
};
- let tab_bar_x = self.tab_bar_left_edge();
- let tab_bar_width = self.dimensions.pixel_width.saturating_sub(tab_bar_x).max(1);
+ let palette = self.palette().clone();
+ let tab_bar_height = rect.size.height;
+ let tab_bar_y = rect.origin.y;
+ let tab_bar_x = rect.origin.x as usize;
+ let tab_bar_width = rect.size.width as usize;
- // Register the tab bar location
- self.ui_items.append(&mut self.tab_bar.compute_ui_items(
+ // Cut to the bar: a left status wider than it lays its items past
+ // the right edge, over the right sidebar, whose clicks they would
+ // take -- they are registered after it.
+ let bar_right = tab_bar_x + tab_bar_width;
+ let items = self.terminal_bar.compute_ui_items(
tab_bar_y as usize,
self.render_metrics.cell_size.height as usize,
self.render_metrics.cell_size.width as usize,
tab_bar_x,
- ));
+ );
+ self.ui_items
+ .extend(items.into_iter().filter_map(|mut item| {
+ item.width = item.width.min(bar_right.saturating_sub(item.x));
+ (item.width > 0).then_some(item)
+ }));
let window_is_transparent =
!self.window_background.is_empty() || self.config.window_background_opacity != 1.0;
+ let terminal_bg = self.terminal_default_background();
+ // Without colours of its own the bar is on the terminal's ground.
+ let tab_bar_bg = match self.config.resolved_palette.tab_bar.as_ref() {
+ Some(colors) => colors.background().to_linear(),
+ None => terminal_bg,
+ }
+ .mul_alpha(self.config.window_background_opacity);
let gl_state = self.render_state.as_ref().unwrap();
let white_space = gl_state.util_sprites.white_space.texture_coords();
let filled_box = gl_state.util_sprites.filled_box.texture_coords();
- let tab_bar_colors = self
- .config
- .resolved_palette
- .tab_bar
- .as_ref()
- .cloned()
- .unwrap_or_else(|| theme_aligned_tab_bar_colors_from_palette(&palette));
- let tab_bar_bg = tab_bar_colors
- .background()
- .to_linear()
- .mul_alpha(self.config.window_background_opacity);
+ // Layer 0, like the cell backgrounds drawn over it; painted after the
+ // panes, so it still covers what it crosses of theirs.
self.filled_rectangle(
layers,
0,
@@ -93,14 +175,11 @@ impl crate::TermWindow {
),
tab_bar_bg,
)?;
- let default_bg = palette
- .resolve_bg(ColorAttribute::Default)
- .to_linear()
- .mul_alpha(if window_is_transparent {
- 0.
- } else {
- self.config.text_background_opacity
- });
+ let default_bg = terminal_bg.mul_alpha(if window_is_transparent {
+ 0.
+ } else {
+ self.config.text_background_opacity
+ });
self.render_screen_line(
RenderScreenLineParams {
@@ -108,7 +187,7 @@ impl crate::TermWindow {
left_pixel_x: tab_bar_x as f32,
pixel_width: tab_bar_width as f32,
stable_line_idx: None,
- line: self.tab_bar.line(),
+ line: self.terminal_bar.line(),
selection: 0..0,
cursor: &Default::default(),
palette: &palette,
@@ -154,28 +233,23 @@ impl crate::TermWindow {
Ok(())
}
+ /// Height of the window tab row.
pub fn tab_bar_pixel_height_impl(
- config: &ConfigHandle,
fontconfig: &wezterm_font::FontConfiguration,
- render_metrics: &RenderMetrics,
) -> anyhow::Result<f32> {
- if config.use_fancy_tab_bar {
- // Fancy tabs use their own UI font. Basing their height on the
- // terminal font made the chrome unexpectedly tall whenever the
- // terminal font was enlarged, even though the tab text stayed at
- // its configured size.
- let font = fontconfig.title_font_with_size(crate::native_settings::tab_font_size())?;
- let tab_metrics = RenderMetrics::with_font_metrics(&font.metrics());
- Ok(fancy_tab_bar_pixel_height(
- tab_metrics.cell_size.height.max(1) as usize,
- fontconfig.get_dpi(),
- ) as f32)
- } else {
- Ok(render_metrics.cell_size.height as f32)
- }
+ // The row uses its own UI font. Basing its height on the terminal
+ // font made the chrome unexpectedly tall whenever the terminal font
+ // was enlarged, even though the tab text stayed at its configured
+ // size.
+ let font = fontconfig.title_font_with_size(crate::native_settings::tab_font_size())?;
+ let tab_metrics = RenderMetrics::with_font_metrics(&font.metrics());
+ Ok(fancy_tab_bar_pixel_height(
+ tab_metrics.cell_size.height.max(1) as usize,
+ fontconfig.get_dpi(),
+ ) as f32)
}
pub fn tab_bar_pixel_height(&self) -> anyhow::Result<f32> {
- Self::tab_bar_pixel_height_impl(&self.config, &self.fonts, &self.render_metrics)
+ Self::tab_bar_pixel_height_impl(&self.fonts)
}
}
diff --git a/wezterm-gui/src/termwindow/resize.rs b/wezterm-gui/src/termwindow/resize.rs
index 7587a28f..842f6c3d 100644
--- a/wezterm-gui/src/termwindow/resize.rs
+++ b/wezterm-gui/src/termwindow/resize.rs
@@ -2283,10 +2283,11 @@ impl super::TermWindow {
) -> (TerminalSize, Dimensions, ResizeIncrementCalculator) {
let config = &self.config;
- let tab_bar_height = if self.show_tab_bar {
- self.tab_bar_pixel_height().unwrap_or(0.)
- } else {
- 0.
+ // Everything above and below the pane tree: the window tab row and
+ // the terminal bar.
+ let tab_bar_height = {
+ let (top, bottom) = self.pane_area_insets();
+ top + bottom
};
let border = self.get_os_border();
@@ -2831,6 +2832,7 @@ impl super::TermWindow {
// final size, which in that case should result in a NOP
// change to the tab size.
+ self.settle_terminal_bar_kind();
let (size, dims, ri_calc) =
self.resize_layout_for_dimensions(dimensions, scale_changed_cells);
@@ -3128,12 +3130,11 @@ impl super::TermWindow {
dpi: size.dpi,
};
- let show_tab_bar = config.enable_tab_bar && !config.hide_tab_bar_if_only_one_tab;
- let tab_bar_height = if show_tab_bar {
- self.tab_bar_pixel_height()? as usize
- } else {
- 0
- };
+ let tab_bar_height = self.tab_bar_pixel_height()? as usize
+ + crate::termwindow::render::tab_bar::terminal_bar_height(
+ self.terminal_bar_kind,
+ &render_metrics,
+ );
let h_context = DimensionContext {
dpi: self.dimensions.dpi as f32,
diff --git a/wezterm-gui/src/termwindow/ui/platform_chrome.rs b/wezterm-gui/src/termwindow/ui/platform_chrome.rs
index fe044f61..dd094a7c 100644
--- a/wezterm-gui/src/termwindow/ui/platform_chrome.rs
+++ b/wezterm-gui/src/termwindow/ui/platform_chrome.rs
@@ -12,7 +12,6 @@ use window::{
#[derive(Debug, Clone, Copy)]
pub struct WindowTabChromeParams {
- pub use_fancy_tab_bar: bool,
pub workspace_sidebar_width: usize,
pub window_state: WindowState,
pub window_decorations: WindowDecorations,
@@ -98,7 +97,7 @@ impl WindowTabChromeParams {
}
pub fn leading_action_slot_count(self) -> usize {
- if !self.use_fancy_tab_bar || self.workspace_sidebar_width > 0 {
+ if self.workspace_sidebar_width > 0 {
return 0;
}
@@ -118,8 +117,7 @@ impl WindowTabChromeParams {
}
pub fn shows_sidebar_toggle_action(self) -> bool {
- self.use_fancy_tab_bar
- && self.workspace_sidebar_width == 0
+ self.workspace_sidebar_width == 0
&& (self.window_state.contains(WindowState::FULL_SCREEN) || !cfg!(target_os = "macos"))
}
@@ -270,7 +268,6 @@ mod tests {
top_fancy_row_height: Option<usize>,
) -> WindowTabChromeParams {
WindowTabChromeParams {
- use_fancy_tab_bar: true,
workspace_sidebar_width,
window_state,
window_decorations: WindowDecorations::INTEGRATED_BUTTONS | WindowDecorations::RESIZE,
diff --git a/wezterm-gui/src/termwindow/ui/recording_overlay.rs b/wezterm-gui/src/termwindow/ui/recording_overlay.rs
index 96b2a8d5..b09a95b9 100644
--- a/wezterm-gui/src/termwindow/ui/recording_overlay.rs
+++ b/wezterm-gui/src/termwindow/ui/recording_overlay.rs
@@ -424,7 +424,7 @@ impl crate::TermWindow {
self.get_panes_to_render()
.iter()
.find(|pos| pos.pane.pane_id() == pane_id)
- .and_then(|pos| self.pane_frame_rect(pos).ok())
+ .and_then(|pos| self.pane_mask_frame(pos).ok())
}
pub(crate) fn active_pane_recording_masks_empty(&self) -> bool {