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.

config: ui_colors, a light Apple System Colors, and preview palettes

RoversX617ea35c8558
diff --git a/config/src/color.rs b/config/src/color.rs
index c58dec29..0a56083a 100644
--- a/config/src/color.rs
+++ b/config/src/color.rs
@@ -332,6 +332,135 @@ impl TabBarColor {
}
}
+/// Overrides for ThinkTerm's own interface colours: the sidebars, the tab
+/// bar, the pane nav bars, the settings window and the menus.
+///
+/// Every field is optional and overrides exactly one slot; whatever is left
+/// unset keeps the colour the interface would have used, so a file that names
+/// two colours changes two colours. Distinct from `colors` and `color_scheme`,
+/// which are the *terminal's* palette.
+///
+/// ```lua
+/// config.ui_colors = {
+/// sidebar_bg = '#282828',
+/// accent = '#d79921',
+/// }
+/// ```
+#[derive(Default, Debug, Clone, PartialEq, FromDynamic, ToDynamic)]
+pub struct UiColors {
+ /// The window's own ground, behind everything else.
+ #[dynamic(default)]
+ pub window_bg: Option<RgbaColor>,
+
+ /// The left sidebar's ground.
+ #[dynamic(default)]
+ pub sidebar_bg: Option<RgbaColor>,
+
+ /// The Spaces strip, recessed from `sidebar_bg`.
+ #[dynamic(default)]
+ pub workspace_sidebar_bg: Option<RgbaColor>,
+
+ /// The strip above the tabs.
+ #[dynamic(default)]
+ pub header_bg: Option<RgbaColor>,
+
+ /// Hairline rules. Usually translucent.
+ #[dynamic(default)]
+ pub separator: Option<RgbaColor>,
+
+ /// A button or field at rest.
+ #[dynamic(default)]
+ pub control_bg: Option<RgbaColor>,
+
+ /// ...under the pointer.
+ #[dynamic(default)]
+ pub control_hover_bg: Option<RgbaColor>,
+
+ /// ...while held.
+ #[dynamic(default)]
+ pub control_pressed_bg: Option<RgbaColor>,
+
+ /// A control's hairline outline.
+ #[dynamic(default)]
+ pub control_border: Option<RgbaColor>,
+
+ /// The round sidebar buttons at rest.
+ #[dynamic(default)]
+ pub sidebar_button_bg: Option<RgbaColor>,
+
+ /// ...under the pointer.
+ #[dynamic(default)]
+ pub sidebar_button_hover_bg: Option<RgbaColor>,
+
+ /// A thread row under the pointer.
+ #[dynamic(default)]
+ pub sidebar_row_hover_bg: Option<RgbaColor>,
+
+ /// ...while held.
+ #[dynamic(default)]
+ pub sidebar_row_pressed_bg: Option<RgbaColor>,
+
+ /// The row whose thread is on show.
+ #[dynamic(default)]
+ pub sidebar_row_active_bg: Option<RgbaColor>,
+
+ /// That row's outline.
+ #[dynamic(default)]
+ pub sidebar_row_active_border: Option<RgbaColor>,
+
+ /// The fill behind a selected item.
+ #[dynamic(default)]
+ pub selected_bg: Option<RgbaColor>,
+
+ /// The accent: focus rings, switches, the active state.
+ #[dynamic(default)]
+ pub accent: Option<RgbaColor>,
+
+ /// The accent under the pointer.
+ #[dynamic(default)]
+ pub accent_hover: Option<RgbaColor>,
+
+ /// Text and icons drawn on top of `accent`.
+ #[dynamic(default)]
+ pub on_accent: Option<RgbaColor>,
+
+ /// Destructive actions and error text.
+ #[dynamic(default)]
+ pub danger: Option<RgbaColor>,
+
+ /// The off half of a switch track.
+ #[dynamic(default)]
+ pub track_off: Option<RgbaColor>,
+
+ /// A grouped card floating on `window_bg`.
+ #[dynamic(default)]
+ pub card_bg: Option<RgbaColor>,
+
+ /// Primary text.
+ #[dynamic(default)]
+ pub text: Option<RgbaColor>,
+
+ /// Text that supports the primary.
+ #[dynamic(default)]
+ pub secondary_text: Option<RgbaColor>,
+
+ /// Text that is present but not being read.
+ #[dynamic(default)]
+ pub muted_text: Option<RgbaColor>,
+
+ /// Text on a selected row.
+ #[dynamic(default)]
+ pub selected_text: Option<RgbaColor>,
+
+ /// The overlay scrollbar's thumb.
+ #[dynamic(default)]
+ pub scrollbar_thumb: Option<RgbaColor>,
+
+ /// The squiggle under a misspelling.
+ #[dynamic(default)]
+ pub spelling_error: Option<RgbaColor>,
+}
+
/// Specifies the colors to use for the tab bar portion of the UI.
/// These are not part of the terminal model and cannot be updated
/// in the same way that the dynamic color schemes are.
diff --git a/config/src/config.rs b/config/src/config.rs
index 3b1cd043..0cff87e8 100644
--- a/config/src/config.rs
+++ b/config/src/config.rs
@@ -1,7 +1,7 @@
use crate::background::{BackgroundLayer, Gradient};
use crate::bell::{AudibleBell, EasingFunction, VisualBell};
use crate::color::{
- ColorSchemeFile, HsbTransform, Palette, SrgbaTuple, TabBarStyle, WindowFrameConfig,
+ ColorSchemeFile, HsbTransform, Palette, SrgbaTuple, TabBarStyle, UiColors, WindowFrameConfig,
};
use crate::daemon::DaemonOptions;
use crate::web::WebServer;
@@ -49,7 +49,14 @@ use wezterm_input_types::{
};
use wezterm_term::TerminalSize;
-const MACOS_DEFAULT_COLOR_SCHEME: &str = "Apple System Colors";
+/// What macOS gets when the configuration names no scheme. Public because
+/// the settings layer has to tell "the user chose this" apart from "we filled
+/// it in", and by the time it reads a `ConfigHandle` the two look identical.
+pub const MACOS_DEFAULT_COLOR_SCHEME: &str = "Apple System Colors";
+
+/// The light half of the above, for when the interface is on that side. See
+/// `native_settings::effective_color_scheme`.
+pub const MACOS_LIGHT_COLOR_SCHEME: &str = "Apple System Colors (Light)";
const PRODUCT_DIR_NAME: &str = "thinkterm";
const LEGACY_PRODUCT_DIR_NAME: &str = "wezterm";
const DURABLE_LEGACY_DATA_ITEMS: &[&str] = &[
@@ -141,6 +148,12 @@ pub struct Config {
/// The color palette
pub colors: Option<Palette>,
+ /// Overrides for ThinkTerm's own interface colours -- the sidebars, the
+ /// tab bar, the settings window -- as opposed to `colors` above, which is
+ /// the terminal's palette. Each field overrides one slot and the rest are
+ /// left as they were.
+ pub ui_colors: Option<UiColors>,
+
#[dynamic(default)]
pub switch_to_last_active_tab_when_closing_tab: bool,
diff --git a/config/src/lib.rs b/config/src/lib.rs
index 7bd1bc93..9287d60f 100644
--- a/config/src/lib.rs
+++ b/config/src/lib.rs
@@ -34,6 +34,7 @@ mod keys;
pub mod lua;
pub mod meta;
pub mod scheme_data;
+mod thinkterm_schemes;
mod serial;
mod ssh;
mod terminal;
@@ -187,7 +188,10 @@ fn json_to_dynamic(value: &serde_json::Value) -> Value {
pub fn build_default_schemes() -> HashMap<String, Palette> {
let mut color_schemes = HashMap::new();
- for (scheme_name, data) in scheme_data::SCHEMES.iter() {
+ for (scheme_name, data) in scheme_data::SCHEMES
+ .iter()
+ .chain(thinkterm_schemes::SCHEMES.iter())
+ {
let scheme_name = scheme_name.to_string();
let scheme = ColorSchemeFile::from_toml_str(data).unwrap();
color_schemes.insert(scheme_name, scheme.colors.clone());
@@ -903,3 +907,4 @@ mod runtime_file_name_tests {
}
}
}
+
diff --git a/config/src/terminal.rs b/config/src/terminal.rs
index cbb4385c..242c3f13 100644
--- a/config/src/terminal.rs
+++ b/config/src/terminal.rs
@@ -10,6 +10,9 @@ use wezterm_term::config::BidiMode;
pub struct TermConfig {
config: Mutex<Option<ConfigHandle>>,
client_palette: Mutex<Option<ColorPalette>>,
+ /// True while `client_palette` is a scheme being *shown* rather than
+ /// chosen. See [`TermConfig::set_preview_palette`].
+ client_palette_is_preview: Mutex<bool>,
}
impl TermConfig {
@@ -17,6 +20,7 @@ impl TermConfig {
Self {
config: Mutex::new(None),
client_palette: Mutex::new(None),
+ client_palette_is_preview: Mutex::new(false),
}
}
@@ -24,6 +28,7 @@ impl TermConfig {
Self {
config: Mutex::new(Some(config)),
client_palette: Mutex::new(None),
+ client_palette_is_preview: Mutex::new(false),
}
}
@@ -33,10 +38,28 @@ impl TermConfig {
pub fn set_client_palette(&self, palette: ColorPalette) {
self.client_palette.lock().unwrap().replace(palette);
+ *self.client_palette_is_preview.lock().unwrap() = false;
+ }
+
+ /// A palette the window is *showing* rather than choosing.
+ ///
+ /// Rendered like any other client palette, but a remote pane must not
+ /// carry it any further: telling the mux server would leave a scheme the
+ /// user may abandon with Escape installed as the server's answer to OSC
+ /// colour queries, and would spend a round trip per pane on every arrow
+ /// key through a thousand-entry list.
+ pub fn set_preview_palette(&self, palette: ColorPalette) {
+ self.client_palette.lock().unwrap().replace(palette);
+ *self.client_palette_is_preview.lock().unwrap() = true;
+ }
+
+ pub fn client_palette_is_preview(&self) -> bool {
+ *self.client_palette_is_preview.lock().unwrap()
}
pub fn clear_client_palette(&self) {
self.client_palette.lock().unwrap().take();
+ *self.client_palette_is_preview.lock().unwrap() = false;
}
fn configuration(&self) -> ConfigHandle {
diff --git a/config/src/thinkterm_schemes.rs b/config/src/thinkterm_schemes.rs
new file mode 100644
index 00000000..cf5fbaf7
--- /dev/null
+++ b/config/src/thinkterm_schemes.rs
@@ -0,0 +1,55 @@
+//! Colour schemes ThinkTerm ships itself.
+//!
+//! Separate from `scheme_data.rs`, which `sync-color-schemes` regenerates from
+//! upstream and would drop anything added by hand.
+
+/// The light half of `Apple System Colors`.
+///
+/// The dark one upstream ships is built from macOS's *dark appearance* system
+/// colours -- its bright row is `systemRed`, `systemGreen`, `systemBlue` and
+/// friends verbatim. This is the same construction on the other side: the
+/// bright row is the *light appearance* values, and the normal row is each of
+/// them walked down in OkLab until it clears 4.5:1 on white, which is what a
+/// light ground needs and what the vivid values do not give (`#ffcc00` on
+/// white is 1.5:1). Hue and chroma are untouched, so a yellow still reads as
+/// that yellow.
+const APPLE_SYSTEM_COLORS_LIGHT: &str = r##"[colors]
+ansi = [
+ "#000000",
+ "#e9281f",
+ "#008a00",
+ "#9d6d00",
+ "#0070f4",
+ "#a84bd7",
+ "#007fae",
+ "#c7c7cc",
+]
+background = "#ffffff"
+brights = [
+ "#8e8e93",
+ "#ff3b30",
+ "#28cd41",
+ "#ffcc00",
+ "#007aff",
+ "#af52de",
+ "#55bef0",
+ "#ffffff",
+]
+cursor_bg = "#8e8e93"
+cursor_border = "#8e8e93"
+cursor_fg = "#ffffff"
+foreground = "#000000"
+selection_bg = "#b5d5ff"
+selection_fg = "#000000"
+
+[colors.indexed]
+
+[metadata]
+aliases = []
+name = "Apple System Colors (Light)"
+"##;
+
+pub const SCHEMES: [(&'static str, &'static str); 1] = [(
+ "Apple System Colors (Light)",
+ APPLE_SYSTEM_COLORS_LIGHT,
+)];
diff --git a/wezterm-client/src/pane/clientpane.rs b/wezterm-client/src/pane/clientpane.rs
index 12e02bc0..5cac9c2a 100644
--- a/wezterm-client/src/pane/clientpane.rs
+++ b/wezterm-client/src/pane/clientpane.rs
@@ -311,7 +311,6 @@ impl ClientPane {
was_application_palette,
palette,
);
-
*self.application_palette.lock() = transition.application_palette;
if transition.palette_changed {
*self.palette.lock() = transition.palette;
@@ -1085,6 +1084,16 @@ impl Pane for ClientPane {
fn set_config(&self, config: Arc<dyn TerminalConfiguration>) {
let palette = config.color_palette();
+ // A scheme the window is showing rather than choosing stops here: it
+ // is adopted for rendering below, but the server is not told and the
+ // configured palette -- what this pane falls back to when an
+ // application clears its own -- is left as it was. Otherwise every
+ // arrow key through the colour-scheme list would spend a round trip
+ // per remote pane and leave an abandoned scheme installed on the
+ // server as the answer to its OSC colour queries.
+ let is_preview = config
+ .downcast_ref::<config::TermConfig>()
+ .is_some_and(|term_config| term_config.client_palette_is_preview());
// Skip the send only when the SERVER is known to hold this exact
// palette. "The value didn't change locally" is not that: the
// initial advisory can be lost in attach races, and comparing
@@ -1101,9 +1110,11 @@ impl Pane for ClientPane {
if !*self.application_palette.lock() {
*self.palette.lock() = palette.clone();
}
- *self.configured_palette.lock() = palette.clone();
+ if !is_preview {
+ *self.configured_palette.lock() = palette.clone();
+ }
- if send {
+ if send && !is_preview {
Self::advise_server_palette(
Arc::clone(&self.client),
self.remote_pane_id,