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.
Rust agentagent-orchestrationaiai-agentsclaude-codecodexcoding-agentlinuxmacosmultiplayermultiplexerrustterminalterminal-emulatorterminal-multiplexertmuxtuiweztermwindows
Introduce ThinkTerm native settings, UI
RoversX26b69e695ad6
diff --git a/Cargo.toml b/Cargo.tomlindex d7991631..2040f619 100644--- a/Cargo.toml+++ b/Cargo.toml@@ -28,6 +28,7 @@ opt-level = 3# debug = 2[profile.dev]+debug = 1# https://jakedeichert.com/blog/reducing-rust-incremental-compilation-times-on-macos-by-70-percent/# Disabled because it breaks builds on Windows#split-debuginfo = "unpacked"diff --git a/README.md b/README.mdindex 863fcd35..48f4bd0b 100644--- a/README.md+++ b/README.md@@ -1,40 +1,35 @@-# Wez's Terminal+# ThinkTerm-<img height="128" alt="WezTerm Icon" src="https://raw.githubusercontent.com/wezterm/wezterm/main/assets/icon/wezterm-icon.svg" align="left"> *A GPU-accelerated cross-platform terminal emulator and multiplexer written by <a href="https://github.com/wez">@wez</a> and implemented in <a href="https://www.rust-lang.org/">Rust</a>*+ThinkTerm is a macOS-focused terminal app based on WezTerm, with workspace and session management built into the main window. It is built for heavy AI workflows while maintaining high performance and low RAM usage.-User facing docs and guide at: https://wezterm.org/+## Build-+```bash+make build BUILD_OPTS=--release+TAG_NAME=v0.1.0 bash ci/deploy.sh+```-*Screenshot of wezterm on macOS, running vim*+This creates:-## Installation+```text+ThinkTerm-macos-v0.1.0/ThinkTerm.app+ThinkTerm-macos-v0.1.0.zip+```-https://wezterm.org/installation+Upload the `.zip` file to GitHub Releases. The `.app` bundle is inside the zip.-## Getting help+## macOS Security Note-This is a spare time project, so please bear with me. There are a couple of channels for support:+If macOS blocks the app, run this in Terminal:-* You can use the [GitHub issue tracker](https://github.com/wezterm/wezterm/issues) to see if someone else has a similar issue, or to file a new one.-* Start or join a thread in our [GitHub Discussions](https://github.com/wezterm/wezterm/discussions); if you have general- questions or want to chat with other wezterm users, you're welcome here!-* There is a [Matrix room via Element.io](https://app.element.io/#/room/#wezterm:matrix.org)- for (potentially!) real time discussions.+```bash+sudo xattr -r -d com.apple.quarantine /Applications/ThinkTerm.app+```-The GitHub Discussions and Element/Gitter rooms are better suited for questions-than bug reports, but don't be afraid to use whichever you are most comfortable-using and we'll work it out.+Why: I can't afford Apple's developer certificate ($99/year), so macOS may block the unsigned app. This command removes the quarantine flag and lets it run. Only use this command on apps you trust.-## Supporting the Project+## Notes-If you use and like WezTerm, please consider sponsoring it: your support helps-to cover the fees required to maintain the project and to validate the time-spent working on it!--[Read more about sponsoring](https://wezterm.org/sponsor.html).--* [](https://github.com/sponsors/wez)-* [Patreon](https://patreon.com/WezFurlong)-* [Ko-Fi](https://ko-fi.com/wezfurlong)-* [Liberapay](https://liberapay.com/wez)+- The package script uses the binaries from `target/release/`.+- The macOS app template lives in `assets/macos/ThinkTerm.app`.+- Change `TAG_NAME` for each release version.diff --git a/config/src/config.rs b/config/src/config.rsindex 5b302735..c3d095c2 100644--- a/config/src/config.rs+++ b/config/src/config.rs@@ -1819,7 +1819,7 @@ fn default_anim_fps() -> u8 {}fn default_max_fps() -> u64 {- 60+ 120}fn default_tiling_desktop_environments() -> Vec<String> {diff --git a/config/src/keyassignment.rs b/config/src/keyassignment.rsindex 86afd627..9fed3239 100644--- a/config/src/keyassignment.rs+++ b/config/src/keyassignment.rs@@ -575,7 +575,11 @@ pub enum KeyAssignment {ShowTabNavigator,PromptRenameTab,PromptRenamePaneTab(usize),+ PromptRenameProject(String),PromptRenameProjectSession(String),+ CreateProjectSession(String),+ ToggleProjectSessionsCollapsed(String),+ RemoveProject(String),ToggleProjectSessionPinned(String),ArchiveProjectSession(String),DeleteProjectSession(String),diff --git a/config/src/lib.rs b/config/src/lib.rsindex 802059c4..96d55cf3 100644--- a/config/src/lib.rs+++ b/config/src/lib.rs@@ -467,8 +467,13 @@ pub fn configuration_warnings_and_errors() -> Vec<String> {CONFIG.get_warnings_and_errors()}+pub fn configuration_file() -> Option<PathBuf> {+ CONFIG.config_file()+}+struct ConfigInner {config: Arc<Config>,+ config_file: Option<PathBuf>,error: Option<String>,warnings: Vec<String>,generation: usize,@@ -480,6 +485,7 @@ impl ConfigInner {fn new() -> Self {Self {config: Arc::new(Config::default_config()),+ config_file: None,error: None,warnings: vec![],generation: 0,@@ -588,6 +594,7 @@ impl ConfigInner {// Before we process the success/failure, extract and update// any paths that we should be watchinglet mut watch_paths = vec![];+ let loaded_file_name = file_name.clone();if let Some(path) = file_name {// Let's also watch the parent directory for folks that do// things with symlinks:@@ -609,6 +616,7 @@ impl ConfigInner {match config {Ok(config) => {self.config = Arc::new(config);+ self.config_file = loaded_file_name;self.error.take();self.generation += 1;@@ -645,12 +653,14 @@ impl ConfigInner {/// configurationfn use_defaults(&mut self) {self.config = Arc::new(Config::default_config());+ self.config_file = None;self.error.take();self.generation += 1;}fn use_this_config(&mut self, cfg: Config) {self.config = Arc::new(cfg);+ self.config_file = None;self.error.take();self.generation += 1;}@@ -755,6 +765,11 @@ impl Configuration {inner.error.as_ref().cloned()}+ pub fn config_file(&self) -> Option<PathBuf> {+ let inner = self.inner.lock().unwrap();+ inner.config_file.clone()+ }+pub fn get_warnings_and_errors(&self) -> Vec<String> {let mut result = vec![];let inner = self.inner.lock().unwrap();diff --git a/wezterm-font/src/lib.rs b/wezterm-font/src/lib.rsindex f2d5fde7..2d868d9b 100644--- a/wezterm-font/src/lib.rs+++ b/wezterm-font/src/lib.rs@@ -452,7 +452,7 @@ impl FallbackResolveInfo {}}-#[derive(PartialEq, Eq)]+#[derive(Clone, Copy, Hash, PartialEq, Eq)]enum Entity {Title,CommandPalette,@@ -473,6 +473,7 @@ struct FontConfigInner {pane_select_font: RefCell<Option<Rc<LoadedFont>>>,char_select_font: RefCell<Option<Rc<LoadedFont>>>,command_palette_font: RefCell<Option<Rc<LoadedFont>>>,+ entity_font_overrides: RefCell<HashMap<(Entity, u64, u16), Rc<LoadedFont>>>,fallback_channel: RefCell<Option<Sender<FallbackResolveInfo>>>,}@@ -494,6 +495,7 @@ impl FontConfigInner {pane_select_font: RefCell::new(None),char_select_font: RefCell::new(None),command_palette_font: RefCell::new(None),+ entity_font_overrides: RefCell::new(HashMap::new()),font_scale: RefCell::new(1.0),dpi: RefCell::new(dpi),config: RefCell::new(config.clone()),@@ -512,6 +514,7 @@ impl FontConfigInner {self.pane_select_font.borrow_mut().take();self.char_select_font.borrow_mut().take();self.command_palette_font.borrow_mut().take();+ self.entity_font_overrides.borrow_mut().clear();self.metrics.borrow_mut().take();*self.font_dirs.borrow_mut() = Arc::new(FontDatabase::with_font_dirs(config)?);Ok(())@@ -622,12 +625,14 @@ impl FontConfigInner {&self,myself: &Rc<Self>,entity: Entity,+ override_font_size: Option<f64>,+ override_weight: Option<config::FontWeight>,) -> anyhow::Result<Rc<LoadedFont>> {let config = self.config.borrow();let make_bold = entity != Entity::CommandPalette;let (sys_font, sys_size) = self.compute_title_font(&config, make_bold);- let (font_size, text_style) = match entity {+ let (configured_font_size, text_style) = match entity {Entity::Title => (config.window_frame.font_size.unwrap_or(sys_size), None),Entity::CommandPalette => (config.command_palette_font_size,@@ -642,9 +647,23 @@ impl FontConfigInner {config.pane_select_font.as_ref(),),};+ let font_size = override_font_size.unwrap_or(configured_font_size);let text_style =text_style.unwrap_or(config.window_frame.font.as_ref().unwrap_or(&sys_font));+ let override_style;+ let text_style = if let Some(weight) = override_weight {+ override_style = {+ let mut style = text_style.clone();+ for attr in &mut style.font {+ attr.weight = weight;+ }+ style+ };+ &override_style+ } else {+ text_style+ };let dpi = *self.dpi.borrow() as u32;let pixel_size = (font_size * dpi as f64 / 72.0) as u16;@@ -686,7 +705,7 @@ impl FontConfigInner {return Ok(Rc::clone(entry));}- let loaded = self.make_entity_font_impl(myself, Entity::Title)?;+ let loaded = self.make_entity_font_impl(myself, Entity::Title, None, None)?;title_font.replace(Rc::clone(&loaded));@@ -700,7 +719,7 @@ impl FontConfigInner {return Ok(Rc::clone(entry));}- let loaded = self.make_entity_font_impl(myself, Entity::CommandPalette)?;+ let loaded = self.make_entity_font_impl(myself, Entity::CommandPalette, None, None)?;command_palette_font.replace(Rc::clone(&loaded));@@ -714,7 +733,7 @@ impl FontConfigInner {return Ok(Rc::clone(entry));}- let loaded = self.make_entity_font_impl(myself, Entity::CharSelect)?;+ let loaded = self.make_entity_font_impl(myself, Entity::CharSelect, None, None)?;char_select_font.replace(Rc::clone(&loaded));@@ -728,13 +747,38 @@ impl FontConfigInner {return Ok(Rc::clone(entry));}- let loaded = self.make_entity_font_impl(myself, Entity::PaneSelect)?;+ let loaded = self.make_entity_font_impl(myself, Entity::PaneSelect, None, None)?;pane_select_font.replace(Rc::clone(&loaded));Ok(loaded)}+ fn entity_font_with_size(+ &self,+ myself: &Rc<Self>,+ entity: Entity,+ font_size: f64,+ font_weight: Option<u16>,+ ) -> anyhow::Result<Rc<LoadedFont>> {+ let font_size = font_size.clamp(6.0, 72.0);+ let font_weight = font_weight.unwrap_or(0);+ let key = (entity, font_size.to_bits(), font_weight);+ if let Some(entry) = self.entity_font_overrides.borrow().get(&key) {+ return Ok(Rc::clone(entry));+ }+ let loaded = self.make_entity_font_impl(+ myself,+ entity,+ Some(font_size),+ (font_weight > 0).then(|| config::FontWeight::from_opentype_weight(font_weight)),+ )?;+ self.entity_font_overrides+ .borrow_mut()+ .insert(key, Rc::clone(&loaded));+ Ok(loaded)+ }+fn resolve_font_helper_impl(&self,attributes: &[FontAttributes],@@ -1100,10 +1144,42 @@ impl FontConfiguration {self.inner.title_font(&self.inner)}+ pub fn title_font_with_size(&self, font_size: f64) -> anyhow::Result<Rc<LoadedFont>> {+ self.inner+ .entity_font_with_size(&self.inner, Entity::Title, font_size, None)+ }++ pub fn title_font_with_size_and_weight(+ &self,+ font_size: f64,+ font_weight: u16,+ ) -> anyhow::Result<Rc<LoadedFont>> {+ self.inner+ .entity_font_with_size(&self.inner, Entity::Title, font_size, Some(font_weight))+ }+pub fn command_palette_font(&self) -> anyhow::Result<Rc<LoadedFont>> {self.inner.command_palette_font(&self.inner)}+ pub fn command_palette_font_with_size(&self, font_size: f64) -> anyhow::Result<Rc<LoadedFont>> {+ self.inner+ .entity_font_with_size(&self.inner, Entity::CommandPalette, font_size, None)+ }++ pub fn command_palette_font_with_size_and_weight(+ &self,+ font_size: f64,+ font_weight: u16,+ ) -> anyhow::Result<Rc<LoadedFont>> {+ self.inner.entity_font_with_size(+ &self.inner,+ Entity::CommandPalette,+ font_size,+ Some(font_weight),+ )+ }+pub fn pane_select_font(&self) -> anyhow::Result<Rc<LoadedFont>> {self.inner.pane_select_font(&self.inner)}diff --git a/wezterm-gui/src/commands.rs b/wezterm-gui/src/commands.rsindex 2614c793..4fe66936 100644--- a/wezterm-gui/src/commands.rs+++ b/wezterm-gui/src/commands.rs@@ -840,6 +840,14 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option<Commmenubar: &[],icon: Some("md_edit"),},+ PromptRenameProject(_) => CommandDef {+ brief: "Rename Workspace".into(),+ doc: "Prompts for a new name for the ThinkTerm workspace".into(),+ keys: vec![],+ args: &[ArgType::ActiveWindow],+ menubar: &[],+ icon: Some("md_edit"),+ },PromptRenameProjectSession(_) => CommandDef {brief: "Rename Session".into(),doc: "Prompts for a new name for the ThinkTerm session".into(),@@ -848,6 +856,30 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option<Commmenubar: &[],icon: Some("md_edit"),},+ CreateProjectSession(_) => CommandDef {+ brief: "New Session".into(),+ doc: "Creates a new ThinkTerm session for the workspace".into(),+ keys: vec![],+ args: &[ArgType::ActiveWindow],+ menubar: &[],+ icon: Some("md_add"),+ },+ ToggleProjectSessionsCollapsed(_) => CommandDef {+ brief: "Collapse or Expand Sessions".into(),+ doc: "Toggles the ThinkTerm workspace session list".into(),+ keys: vec![],+ args: &[ArgType::ActiveWindow],+ menubar: &[],+ icon: None,+ },+ RemoveProject(_) => CommandDef {+ brief: "Remove Workspace".into(),+ doc: "Removes the ThinkTerm workspace from the sidebar".into(),+ keys: vec![],+ args: &[ArgType::ActiveWindow],+ menubar: &[],+ icon: Some("md_delete"),+ },ToggleProjectSessionPinned(_) => CommandDef {brief: "Pin Session".into(),doc: "Toggles the pinned state for the ThinkTerm session".into(),diff --git a/wezterm-gui/src/frontend.rs b/wezterm-gui/src/frontend.rsindex 0f85e27a..128a99f2 100644--- a/wezterm-gui/src/frontend.rs+++ b/wezterm-gui/src/frontend.rs@@ -36,6 +36,7 @@ impl GuiFrontEnd {pub fn try_new() -> anyhow::Result<Rc<GuiFrontEnd>> {let connection = Connection::init()?;connection.set_event_handler(Self::app_event_handler);+ crate::native_settings::apply_to_app(&crate::native_settings::load());let mux = Mux::get();let client_id = mux.active_identity().expect("to have set my own id");@@ -474,6 +475,12 @@ impl GuiFrontEnd {}}+ pub fn invalidate_all_windows(&self) {+ for window in self.known_windows.borrow().keys() {+ window.invalidate();+ }+ }+pub fn is_switching_workspace(&self) -> bool {*self.switching_workspaces.borrow()}diff --git a/wezterm-gui/src/main.rs b/wezterm-gui/src/main.rsindex e3535523..40d7f35d 100644--- a/wezterm-gui/src/main.rs+++ b/wezterm-gui/src/main.rs@@ -41,7 +41,9 @@ mod download;mod frontend;mod glyphcache;mod inputmap;+mod native_settings;mod overlay;+mod perf;mod project_sessions;mod quad;mod renderstate;@@ -55,6 +57,7 @@ mod spawn;mod stats;mod tabbar;mod termwindow;+mod ui;mod unicode_names;mod uniforms;mod update;diff --git a/wezterm-gui/src/native_settings.rs b/wezterm-gui/src/native_settings.rsnew file mode 100644index 00000000..511c4b73--- /dev/null+++ b/wezterm-gui/src/native_settings.rs@@ -0,0 +1,197 @@+use serde::{Deserialize, Serialize};+use std::fs;+use std::io;+use std::path::PathBuf;+use window::{Appearance, Connection, ConnectionOps};++pub(crate) const DEFAULT_SETTINGS_FONT_SIZE: f64 = 14.0;+pub(crate) const DEFAULT_SETTINGS_FONT_WEIGHT: u16 = 600;+pub(crate) const DEFAULT_SIDEBAR_FONT_SIZE: f64 = 15.0;+pub(crate) const DEFAULT_TAB_FONT_SIZE: f64 = 14.0;+pub(crate) const DEFAULT_PANE_HEADER_FONT_SIZE: f64 = 14.0;++#[derive(Debug, Clone, Copy, PartialEq, Eq, Deserialize, Serialize)]+#[serde(rename_all = "lowercase")]+pub(crate) enum NativeThemeMode {+ System,+ Light,+ Dark,+}++impl Default for NativeThemeMode {+ fn default() -> Self {+ Self::System+ }+}++impl NativeThemeMode {+ pub(crate) fn label(self) -> &'static str {+ match self {+ Self::System => "System",+ Self::Light => "Light",+ Self::Dark => "Dark",+ }+ }++ pub(crate) fn effective_appearance(self, system: Appearance) -> Appearance {+ match self {+ Self::System => system,+ Self::Light => Appearance::Light,+ Self::Dark => Appearance::Dark,+ }+ }++ pub(crate) fn preferred_app_appearance(self) -> Option<Appearance> {+ match self {+ Self::System => None,+ Self::Light => Some(Appearance::Light),+ Self::Dark => Some(Appearance::Dark),+ }+ }+}++#[derive(Debug, Clone, Default, Deserialize, Serialize)]+#[serde(default)]+pub(crate) struct NativeAppearanceSettings {+ pub(crate) theme_mode: NativeThemeMode,+}++#[derive(Debug, Clone, Default, Deserialize, Serialize)]+#[serde(default)]+pub(crate) struct NativeTerminalSettings {+ pub(crate) font_size: Option<f64>,+ pub(crate) font_family: Option<String>,+}++#[derive(Debug, Clone, Default, Deserialize, Serialize)]+#[serde(default)]+pub(crate) struct NativeChromeSettings {+ pub(crate) settings_font_size: Option<f64>,+ pub(crate) settings_font_weight: Option<u16>,+ pub(crate) sidebar_font_size: Option<f64>,+ pub(crate) tab_font_size: Option<f64>,+ pub(crate) pane_header_font_size: Option<f64>,+}++#[derive(Debug, Clone, Deserialize, Serialize)]+#[serde(default)]+pub(crate) struct ThinkTermNativeSettings {+ pub(crate) version: u32,+ pub(crate) appearance: NativeAppearanceSettings,+ pub(crate) terminal: NativeTerminalSettings,+ pub(crate) chrome: NativeChromeSettings,+}++impl Default for ThinkTermNativeSettings {+ fn default() -> Self {+ Self {+ version: 1,+ appearance: NativeAppearanceSettings::default(),+ terminal: NativeTerminalSettings::default(),+ chrome: NativeChromeSettings::default(),+ }+ }+}++pub(crate) fn settings_path() -> PathBuf {+ config::HOME_DIR+ .join(".config")+ .join("thinkterm")+ .join("settings.json")+}++pub(crate) fn load() -> ThinkTermNativeSettings {+ let path = settings_path();+ match fs::read_to_string(&path) {+ Ok(data) => match serde_json::from_str(&data) {+ Ok(settings) => settings,+ Err(err) => {+ log::warn!(+ "Unable to parse ThinkTerm native settings {}: {err:#}",+ path.display()+ );+ ThinkTermNativeSettings::default()+ }+ },+ Err(err) if err.kind() == io::ErrorKind::NotFound => ThinkTermNativeSettings::default(),+ Err(err) => {+ log::warn!(+ "Unable to read ThinkTerm native settings {}: {err:#}",+ path.display()+ );+ ThinkTermNativeSettings::default()+ }+ }+}++pub(crate) fn save(settings: &ThinkTermNativeSettings) -> anyhow::Result<()> {+ let path = settings_path();+ if let Some(parent) = path.parent() {+ fs::create_dir_all(parent)?;+ }+ let data = serde_json::to_vec_pretty(settings)?;+ let tmp = path.with_extension("json.tmp");+ fs::write(&tmp, data)?;+ fs::rename(tmp, path)?;+ Ok(())+}++pub(crate) fn system_appearance() -> Appearance {+ Connection::get()+ .map(|conn| conn.get_appearance())+ .unwrap_or(Appearance::Dark)+}++pub(crate) fn effective_appearance() -> Appearance {+ let settings = load();+ settings+ .appearance+ .theme_mode+ .effective_appearance(system_appearance())+}++pub(crate) fn apply_to_app(settings: &ThinkTermNativeSettings) {+ if let Some(conn) = Connection::get() {+ conn.set_preferred_appearance(settings.appearance.theme_mode.preferred_app_appearance());+ }+}++pub(crate) fn settings_font_size(settings: &ThinkTermNativeSettings) -> f64 {+ settings+ .chrome+ .settings_font_size+ .unwrap_or(DEFAULT_SETTINGS_FONT_SIZE)+ .clamp(10.0, 28.0)+}++pub(crate) fn settings_font_weight(settings: &ThinkTermNativeSettings) -> u16 {+ settings+ .chrome+ .settings_font_weight+ .unwrap_or(DEFAULT_SETTINGS_FONT_WEIGHT)+ .clamp(300, 800)+}++pub(crate) fn sidebar_font_size() -> f64 {+ load()+ .chrome+ .sidebar_font_size+ .unwrap_or(DEFAULT_SIDEBAR_FONT_SIZE)+ .clamp(10.0, 28.0)+}++pub(crate) fn tab_font_size() -> f64 {+ load()+ .chrome+ .tab_font_size+ .unwrap_or(DEFAULT_TAB_FONT_SIZE)+ .clamp(10.0, 28.0)+}++pub(crate) fn pane_header_font_size() -> f64 {+ load()+ .chrome+ .pane_header_font_size+ .unwrap_or(DEFAULT_PANE_HEADER_FONT_SIZE)+ .clamp(10.0, 28.0)+}diff --git a/wezterm-gui/src/perf.rs b/wezterm-gui/src/perf.rsnew file mode 100644index 00000000..528eef38--- /dev/null+++ b/wezterm-gui/src/perf.rs@@ -0,0 +1,28 @@+use std::sync::OnceLock;+use std::time::Instant;++static PERF_ENABLED: OnceLock<bool> = OnceLock::new();++pub(crate) fn enabled() -> bool {+ *PERF_ENABLED.get_or_init(|| {+ std::env::var_os("THINKTERM_PERF")+ .map(|value| value != "0" && !value.is_empty())+ .unwrap_or(false)+ })+}++pub(crate) fn now() -> Option<Instant> {+ enabled().then(Instant::now)+}++pub(crate) fn log_duration(label: &str, started: Option<Instant>) {+ if let Some(started) = started {+ log::info!("thinkterm_perf {label}={:.2?}", started.elapsed());+ }+}++pub(crate) fn log_counter(label: &str, value: impl std::fmt::Display) {+ if enabled() {+ log::info!("thinkterm_perf {label}={value}");+ }+}diff --git a/wezterm-gui/src/project_sessions.rs b/wezterm-gui/src/project_sessions.rsindex 45d8ea55..026ad6c6 100644--- a/wezterm-gui/src/project_sessions.rs+++ b/wezterm-gui/src/project_sessions.rs@@ -65,6 +65,8 @@ pub struct SessionLayoutSnapshot {pub struct TerminalSpecEntry {pub pane_id: PaneId,pub spec: TerminalSpawnSpec,+ #[serde(default)]+ pub font_scale: Option<f64>,}#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]@@ -76,6 +78,7 @@ pub struct TerminalSpawnSpec {#[derive(Debug, Clone)]pub struct ProjectSessionView {+ pub pinned_sessions: Vec<SessionView>,pub projects: Vec<ProjectView>,}@@ -113,6 +116,13 @@ pub struct DeletedSession {pub materialized_workspace_name: Option<String>,}+#[derive(Debug, Clone, PartialEq, Eq)]+pub struct RemovedProject {+ pub was_active: bool,+ pub next_session_id: Option<SessionId>,+ pub materialized_workspace_names: Vec<String>,+}+lazy_static::lazy_static! {static ref SESSION_STORE: Mutex<SessionStore> =Mutex::new(load_session_store().unwrap_or_else(|err| {@@ -247,15 +257,6 @@ pub fn create_project_from_path(path: &str) -> Result<SessionId> {Ok(session_id)}-pub fn active_session_for_project(project_id: &str) -> Option<SessionId> {- let mut store = SESSION_STORE.lock();- let session_id = store.active_session_for_project(project_id);- if session_id.is_some() {- persist_locked(&store);- }- session_id-}-pub fn activate_session_record(session_id: &str,live_workspaces: &[String],@@ -266,8 +267,14 @@ pub fn activate_session_record(plan}-pub fn snapshot_workspace_layout(workspace: &str, window_id: MuxWindowId) {- let Some(snapshot) = snapshot_window_layout(window_id) else {+pub fn snapshot_workspace_layout_with_font_scales<F>(+ workspace: &str,+ window_id: MuxWindowId,+ pane_font_scale: F,+) where+ F: Fn(PaneId) -> Option<f64>,+{+ let Some(snapshot) = snapshot_window_layout(window_id, &pane_font_scale) else {return;};@@ -276,9 +283,14 @@ pub fn snapshot_workspace_layout(workspace: &str, window_id: MuxWindowId) {persist_locked(&store);}-pub fn snapshot_active_session_layout(window_id: MuxWindowId) {+pub fn snapshot_active_session_layout_with_font_scales<F>(+ window_id: MuxWindowId,+ pane_font_scale: F,+) where+ F: Fn(PaneId) -> Option<f64>,+{let workspace = Mux::get().active_workspace();- snapshot_workspace_layout(&workspace, window_id);+ snapshot_workspace_layout_with_font_scales(&workspace, window_id, pane_font_scale);}pub async fn materialize_session(@@ -343,6 +355,51 @@ pub fn session_name(session_id: &str) -> Option<String> {.map(|session| session.name.clone())}+pub fn session_is_pinned(session_id: &str) -> bool {+ let store = SESSION_STORE.lock();+ store+ .projects+ .iter()+ .flat_map(|project| project.sessions.iter())+ .find(|session| session.id == session_id)+ .is_some_and(|session| session.is_pinned)+}++pub fn project_name(project_id: &str) -> Option<String> {+ let store = SESSION_STORE.lock();+ store+ .projects+ .iter()+ .find(|project| project.id == project_id)+ .map(|project| project.name.clone())+}++pub fn workspace_pane_font_scales(+ workspace: &str,+ window_id: MuxWindowId,+) -> Option<HashMap<PaneId, Option<f64>>> {+ let store = SESSION_STORE.lock();+ store.workspace_pane_font_scales(workspace, window_id)+}++pub fn rename_project(project_id: &str, name: String) -> bool {+ let mut store = SESSION_STORE.lock();+ let changed = store.rename_project(project_id, name);+ if changed {+ persist_locked(&store);+ }+ changed+}++pub fn remove_project(project_id: &str) -> Option<RemovedProject> {+ let mut store = SESSION_STORE.lock();+ let removed = store.remove_project(project_id);+ if removed.is_some() {+ persist_locked(&store);+ }+ removed+}+pub fn rename_session(session_id: &str, name: String) -> bool {let mut store = SESSION_STORE.lock();let changed = store.rename_session(session_id, name);@@ -454,6 +511,15 @@ impl SessionStore {fn view_for_project(&self, project_id: &str, live_workspaces: &[String]) -> ProjectSessionView {let active_project_id = self.active_project_id.as_deref().unwrap_or(project_id);+ let pinned_sessions = self+ .projects+ .iter()+ .flat_map(|project| {+ session_views_for_project(project, Some(active_project_id), live_workspaces)+ .into_iter()+ .filter(|session| session.is_pinned)+ })+ .collect();let projects = self.projects.iter()@@ -469,7 +535,10 @@ impl SessionStore {),}).collect();- ProjectSessionView { projects }+ ProjectSessionView {+ pinned_sessions,+ projects,+ }}fn sync_active_workspace(&mut self, project_id: &str, active_workspace: &str) -> bool {@@ -526,10 +595,15 @@ impl SessionStore {fn create_project_from_path(&mut self, path: PathBuf) -> SessionId {let project_id = project_id_for_path(&path);- if self.projects.iter().any(|project| project.path == path) {- return self- .active_session_for_project(&project_id)- .expect("existing project should have an active session");+ if let Some(existing_project_id) = self+ .projects+ .iter()+ .find(|project| project.path == path)+ .map(|project| project.id.clone())+ {+ if let Some(session_id) = self.active_session_for_project(&existing_project_id) {+ return session_id;+ }}let name = path@@ -645,6 +719,39 @@ impl SessionStore {}}+ fn workspace_pane_font_scales(+ &self,+ workspace: &str,+ window_id: MuxWindowId,+ ) -> Option<HashMap<PaneId, Option<f64>>> {+ self.projects+ .iter()+ .flat_map(|project| project.sessions.iter())+ .find(|session| session.materialized_workspace_name.as_deref() == Some(workspace))+ .and_then(|session| session.layout.as_ref())+ .and_then(|layout| pane_font_scales_for_window(layout, window_id))+ }++ fn rename_project(&mut self, project_id: &str, name: String) -> bool {+ let name = name.trim();+ if name.is_empty() {+ return false;+ }++ let Some(project) = self+ .projects+ .iter_mut()+ .find(|project| project.id == project_id)+ else {+ return false;+ };+ if project.name == name {+ return false;+ }+ project.name = name.to_string();+ true+ }+fn rename_session(&mut self, session_id: &str, name: String) -> bool {let name = name.trim();if name.is_empty() {@@ -754,6 +861,56 @@ impl SessionStore {None}+ fn remove_project(&mut self, project_id: &str) -> Option<RemovedProject> {+ if self.projects.len() <= 1 {+ return None;+ }++ let index = self+ .projects+ .iter()+ .position(|project| project.id == project_id)?;+ let removed = self.projects.remove(index);+ let was_active = self.active_project_id.as_deref() == Some(project_id);+ let materialized_workspace_names = removed+ .sessions+ .iter()+ .filter_map(|session| session.materialized_workspace_name.clone())+ .collect::<Vec<_>>();++ let next_session_id = if was_active {+ let next_index = index.saturating_sub(1).min(self.projects.len() - 1);+ let project = &mut self.projects[next_index];+ self.active_project_id = Some(project.id.clone());+ let session_id = project+ .active_session_id+ .clone()+ .or_else(|| {+ project+ .sessions+ .iter()+ .find(|session| !session.archived)+ .map(|session| session.id.clone())+ })+ .unwrap_or_else(|| {+ let session = Session::new(project.id.clone(), "main".to_string(), None);+ let session_id = session.id.clone();+ project.sessions.push(session);+ session_id+ });+ project.active_session_id = Some(session_id.clone());+ Some(session_id)+ } else {+ None+ };++ Some(RemovedProject {+ was_active,+ next_session_id,+ materialized_workspace_names,+ })+ }+fn toggle_project_sessions_collapsed(&mut self, project_id: &str) -> bool {let Some(project) = self.projects@@ -783,13 +940,23 @@ impl Session {}}+fn valid_font_scale(font_scale: Option<f64>) -> Option<f64> {+ font_scale.filter(|scale| scale.is_finite() && *scale > 0.0)+}+fn persist_locked(store: &SessionStore) {if let Err(err) = save_session_store(store) {log::warn!("failed to save ThinkTerm session store: {err:#}");}}-fn snapshot_window_layout(window_id: MuxWindowId) -> Option<SessionLayoutSnapshot> {+fn snapshot_window_layout<F>(+ window_id: MuxWindowId,+ pane_font_scale: &F,+) -> Option<SessionLayoutSnapshot>+where+ F: Fn(PaneId) -> Option<f64>,+{let mux = Mux::get();let window = mux.get_window(window_id)?;let active_tab = window.get_active_idx();@@ -798,7 +965,7 @@ fn snapshot_window_layout(window_id: MuxWindowId) -> Option<SessionLayoutSnapsho.iter().filter_map(|tab| {let tree = tab.codec_pane_tree();- collect_terminal_specs(&mux, &tree, &mut terminal_specs);+ collect_terminal_specs(&mux, &tree, &mut terminal_specs, pane_font_scale);serde_json::to_value(tree).ok()}).collect::<Vec<_>>();@@ -809,6 +976,108 @@ fn snapshot_window_layout(window_id: MuxWindowId) -> Option<SessionLayoutSnapsho})}+fn pane_font_scales_for_window(+ layout: &SessionLayoutSnapshot,+ window_id: MuxWindowId,+) -> Option<HashMap<PaneId, Option<f64>>> {+ let mux = Mux::get();+ let window = mux.get_window(window_id)?;+ let spec_scales = layout+ .terminal_specs+ .iter()+ .map(|entry| (entry.pane_id, valid_font_scale(entry.font_scale)))+ .collect::<HashMap<_, _>>();+ let mut font_scales = HashMap::new();+ let mut decoded_tabs = 0usize;++ for (stored_tab, live_tab) in layout.tabs.iter().zip(window.iter()) {+ let Ok(stored_node) = serde_json::from_value::<PaneNode>(stored_tab.clone()) else {+ continue;+ };+ decoded_tabs += 1;+ let live_node = live_tab.codec_pane_tree();+ collect_matching_font_scales(&stored_node, &live_node, &spec_scales, &mut font_scales);+ }++ if decoded_tabs == 0 && !layout.tabs.is_empty() {+ return None;+ }++ for tab in window.iter() {+ for pos in tab.iter_panes_ignoring_zoom() {+ let pane_id = pos.pane.pane_id();+ if let Some(font_scale) = spec_scales.get(&pane_id) {+ font_scales.insert(pane_id, *font_scale);+ }+ }+ }++ Some(font_scales)+}++fn collect_matching_font_scales(+ stored_node: &PaneNode,+ live_node: &PaneNode,+ spec_scales: &HashMap<PaneId, Option<f64>>,+ font_scales: &mut HashMap<PaneId, Option<f64>>,+) {+ match (stored_node, live_node) {+ (PaneNode::Leaf(stored), PaneNode::Leaf(live)) => {+ font_scales.insert(+ live.pane_id,+ spec_scales.get(&stored.pane_id).copied().unwrap_or(None),+ );+ }+ (PaneNode::Stack(stored), PaneNode::Stack(live)) => {+ for (stored, live) in stored.panes.iter().zip(&live.panes) {+ font_scales.insert(+ live.pane_id,+ spec_scales.get(&stored.pane_id).copied().unwrap_or(None),+ );+ }+ }+ (+ PaneNode::Split {+ left: stored_left,+ right: stored_right,+ ..+ },+ PaneNode::Split {+ left: live_left,+ right: live_right,+ ..+ },+ ) => {+ collect_matching_font_scales(stored_left, live_left, spec_scales, font_scales);+ collect_matching_font_scales(stored_right, live_right, spec_scales, font_scales);+ }+ _ => {+ let mut stored_panes = vec![];+ let mut live_panes = vec![];+ collect_pane_entries(stored_node, &mut stored_panes);+ collect_pane_entries(live_node, &mut live_panes);+ for (stored, live) in stored_panes.into_iter().zip(live_panes) {+ font_scales.insert(+ live.pane_id,+ spec_scales.get(&stored.pane_id).copied().unwrap_or(None),+ );+ }+ }+ }+}++fn collect_pane_entries<'a>(node: &'a PaneNode, entries: &mut Vec<&'a PaneEntry>) {+ match node {+ PaneNode::Empty => {}+ PaneNode::Leaf(entry) => entries.push(entry),+ PaneNode::Stack(stack) => entries.extend(stack.panes.iter()),+ PaneNode::Split { left, right, .. } => {+ collect_pane_entries(left, entries);+ collect_pane_entries(right, entries);+ }+ }+}+async fn materialize_layout(mux: Arc<Mux>,workspace_name: String,@@ -984,27 +1253,37 @@ fn working_dir_from_entry(entry: &PaneEntry) -> Option<String> {.and_then(|path| path.to_str().map(|path| path.to_string()))}-fn collect_terminal_specs(mux: &Mux, node: &PaneNode, terminal_specs: &mut Vec<TerminalSpecEntry>) {+fn collect_terminal_specs<F>(+ mux: &Mux,+ node: &PaneNode,+ terminal_specs: &mut Vec<TerminalSpecEntry>,+ pane_font_scale: &F,+) where+ F: Fn(PaneId) -> Option<f64>,+{match node {PaneNode::Empty => {}- PaneNode::Leaf(entry) => collect_terminal_spec(mux, entry, terminal_specs),+ PaneNode::Leaf(entry) => collect_terminal_spec(mux, entry, terminal_specs, pane_font_scale),PaneNode::Stack(stack) => {for entry in &stack.panes {- collect_terminal_spec(mux, entry, terminal_specs);+ collect_terminal_spec(mux, entry, terminal_specs, pane_font_scale);}}PaneNode::Split { left, right, .. } => {- collect_terminal_specs(mux, left, terminal_specs);- collect_terminal_specs(mux, right, terminal_specs);+ collect_terminal_specs(mux, left, terminal_specs, pane_font_scale);+ collect_terminal_specs(mux, right, terminal_specs, pane_font_scale);}}}-fn collect_terminal_spec(+fn collect_terminal_spec<F>(mux: &Mux,entry: &PaneEntry,terminal_specs: &mut Vec<TerminalSpecEntry>,-) {+ pane_font_scale: &F,+) where+ F: Fn(PaneId) -> Option<f64>,+{let domain = mux.get_pane(entry.pane_id).and_then(|pane| mux.get_domain(pane.domain_id()))@@ -1016,6 +1295,7 @@ fn collect_terminal_spec(domain,title: entry.title.clone(),},+ font_scale: valid_font_scale(pane_font_scale(entry.pane_id)),});}@@ -1186,6 +1466,49 @@ mod tests {assert_eq!(plan.workspace_name, workspace_name);}+ #[test]+ fn duplicate_project_path_reuses_existing_session() {+ let dir = tempdir().unwrap();+ let mut store = SessionStore::default();++ let first_session_id = store.create_project_from_path(dir.path().to_path_buf());+ let second_session_id = store.create_project_from_path(dir.path().to_path_buf());++ assert_eq!(second_session_id, first_session_id);+ assert_eq!(store.projects.len(), 1);+ assert_eq!(store.projects[0].sessions.len(), 1);+ }++ #[test]+ fn duplicate_project_path_reuses_stored_project_id() {+ let dir = tempdir().unwrap();+ let mut store = SessionStore::default();++ let project = Project {+ id: "stored-project-id".to_string(),+ name: "existing".to_string(),+ path: dir.path().to_path_buf(),+ sessions: vec![Session::new(+ "stored-project-id".to_string(),+ "main".to_string(),+ None,+ )],+ active_session_id: None,+ sessions_collapsed: false,+ };+ let session_id = project.sessions[0].id.clone();+ store.projects.push(project);++ let reused_session_id = store.create_project_from_path(dir.path().to_path_buf());++ assert_eq!(reused_session_id, session_id);+ assert_eq!(+ store.active_project_id.as_deref(),+ Some("stored-project-id")+ );+ assert_eq!(store.projects.len(), 1);+ }+#[test]fn snapshot_layout_attaches_to_materialized_session() {let mut store = SessionStore::default();@@ -1248,6 +1571,45 @@ mod tests {assert!(view.projects[1].sessions[0].is_active);}+ #[test]+ fn project_menu_metadata_actions_update_store() {+ let mut store = SessionStore::default();+ let first = Session::new("project-1".to_string(), "main".to_string(), None);+ let second = Session::new("project-2".to_string(), "current".to_string(), None);+ let first_id = first.id.clone();+ let second_id = second.id.clone();+ store.projects.push(Project {+ id: "project-1".to_string(),+ name: "thinkterm".to_string(),+ path: PathBuf::from("/tmp/thinkterm"),+ sessions: vec![first],+ active_session_id: Some(first_id),+ sessions_collapsed: false,+ });+ store.projects.push(Project {+ id: "project-2".to_string(),+ name: "agent_dock".to_string(),+ path: PathBuf::from("/tmp/agent_dock"),+ sessions: vec![second],+ active_session_id: Some(second_id.clone()),+ sessions_collapsed: false,+ });+ store.active_project_id = Some("project-2".to_string());++ assert!(store.rename_project("project-2", "Agents".to_string()));+ assert_eq!(store.projects[1].name, "Agents");++ let removed = store.remove_project("project-2").unwrap();+ assert!(removed.was_active);+ assert_eq!(+ removed.next_session_id,+ Some(store.projects[0].sessions[0].id.clone())+ );+ assert_eq!(store.projects.len(), 1);+ assert_eq!(store.active_project_id.as_deref(), Some("project-1"));+ assert!(store.remove_project("project-1").is_none());+ }+#[test]fn session_menu_metadata_actions_update_store() {let mut store = SessionStore::default();diff --git a/wezterm-gui/src/settings_window.rs b/wezterm-gui/src/settings_window.rsindex 913132fa..281c2691 100644--- a/wezterm-gui/src/settings_window.rs+++ b/wezterm-gui/src/settings_window.rs@@ -1,4 +1,3 @@-use crate::colorease::ColorEaseUniform;use crate::customglyph::{BlockKey, Poly};use crate::quad::{QuadTrait, TripleLayerQuadAllocator, TripleLayerQuadAllocatorTrait};use crate::renderstate::{RenderContext, RenderState};@@ -6,36 +5,51 @@ use crate::termwindow::render::corners::{BOTTOM_LEFT_ROUNDED_CORNER, BOTTOM_RIGHT_ROUNDED_CORNER, TOP_LEFT_ROUNDED_CORNER,TOP_RIGHT_ROUNDED_CORNER,};-use crate::uniforms::UniformBuilder;+use crate::termwindow::render::draw::draw_webgpu_layers;+use crate::termwindow::webgpu::WebGpuState;+use crate::ui::{+ rect, ButtonSpec, ControlState, InteractionState, ResizablePaneState, ScrollState,+ ScrollbarSpec, SettingsIcon, SvgIcon, TextInputSpec, TextInputState, UiContext, UiPalette,+ UiTokens, WidgetKind,+};use crate::utilsprites::RenderMetrics;use anyhow::Context;use config::{configuration, Dimension, GeometryOrigin};use std::cell::RefCell;use std::path::PathBuf;use std::rc::Rc;+use std::time::Instant;use wezterm_bidi::Direction;use wezterm_font::{FontConfiguration, LoadedFont};use window::bitmaps::atlas::OutOfTextureSpace;use window::color::LinearRgba;-use window::glium;-use window::glium::texture::SrgbTexture2d;-use window::glium::uniforms::{- MagnifySamplerFilter, MinifySamplerFilter, Sampler, SamplerWrapFunction,-};-use window::glium::{BlendingFunction, LinearBlendingFactor, Surface};use window::{- Appearance, Connection, ConnectionOps, Dimensions, MouseButtons, MouseCursor, MouseEvent,- MouseEventKind, MousePress, RequestedWindowGeometry, Window, WindowEvent, WindowOps,+ Appearance, Clipboard, Connection, ConnectionOps, Dimensions, KeyCode, KeyEvent, Modifiers,+ MouseButtons, MouseCursor, MouseEvent, MouseEventKind, MousePress, RequestedWindowGeometry,+ Window, WindowEvent, WindowOps,+};++use crate::native_settings::{+ NativeThemeMode, ThinkTermNativeSettings, DEFAULT_PANE_HEADER_FONT_SIZE,+ DEFAULT_SETTINGS_FONT_SIZE, DEFAULT_SIDEBAR_FONT_SIZE, DEFAULT_TAB_FONT_SIZE,};-const DEFAULT_WIDTH: usize = 1180;-const DEFAULT_HEIGHT: usize = 760;-const SIDEBAR_WIDTH: f32 = 286.0;-const CONTROL_HEIGHT: f32 = 42.0;-const CONTROL_RADIUS: f32 = 8.0;-const NAV_ROW_RADIUS: f32 = 7.0;-const NAV_ROW_HEIGHT: f32 = 40.0;-const NAV_ROW_STEP: f32 = 44.0;+const DEFAULT_WIDTH: usize = 1840;+const DEFAULT_HEIGHT: usize = 1205;+const SIDEBAR_BRAND_FONT_SIZE: f64 = 17.0;+const SIDEBAR_BRAND_FONT_WEIGHT: u16 = 750;+const CONTROL_HEIGHT: f32 = 56.0;+const CONTROL_RADIUS: f32 = 14.0;+const NAV_ROW_RADIUS: f32 = 14.0;+const NAV_ROW_HEIGHT: f32 = 56.0;+const NAV_ROW_STEP: f32 = 68.0;+const HEADER_HEIGHT: f32 = 132.0;+const SIDEBAR_TITLE_Y: f32 = 78.0;+const SIDEBAR_SEARCH_Y: f32 = 142.0;+const SIDEBAR_LIST_TOP: f32 = 222.0;+const CONTENT_TITLE_Y: f32 = 82.0;+const CONTENT_SECTION_Y: f32 = 168.0;+const CONTENT_RULE_Y: f32 = 202.0;thread_local! {static SETTINGS_WINDOW: RefCell<Option<Rc<RefCell<SettingsWindow>>>> = RefCell::new(None);@@ -48,8 +62,9 @@ enum SettingsSection {Terminal,Workspaces,Keymap,- WezTermSync,+ Compatibility,Developer,+ About,}const SECTIONS: &[SettingsSection] = &[@@ -58,8 +73,9 @@ const SECTIONS: &[SettingsSection] = &[SettingsSection::Terminal,SettingsSection::Workspaces,SettingsSection::Keymap,- SettingsSection::WezTermSync,+ SettingsSection::Compatibility,SettingsSection::Developer,+ SettingsSection::About,];impl SettingsSection {@@ -70,8 +86,77 @@ impl SettingsSection {Self::Terminal => "Terminal",Self::Workspaces => "Workspaces",Self::Keymap => "Keymap",- Self::WezTermSync => "WezTerm Sync",+ Self::Compatibility => "Compatibility",Self::Developer => "Developer",+ Self::About => "About",+ }+ }++ fn icon(self) -> SettingsIcon {+ match self {+ Self::General => SettingsIcon::General,+ Self::Appearance => SettingsIcon::Appearance,+ Self::Terminal => SettingsIcon::Terminal,+ Self::Workspaces => SettingsIcon::Workspaces,+ Self::Keymap => SettingsIcon::Keymap,+ Self::Compatibility => SettingsIcon::Sync,+ Self::Developer => SettingsIcon::Developer,+ Self::About => SettingsIcon::About,+ }+ }++ fn search_terms(self) -> &'static [&'static str] {+ match self {+ Self::General => &[+ "Config Source",+ "ThinkTerm Native Settings",+ "Theme Mode",+ "Native Settings",+ "Configuration",+ ],+ Self::Appearance => &[+ "Theme Mode",+ "Effective Color Scheme",+ "Config Source",+ "Settings UI Font Size",+ "Workspace Sidebar Font Size",+ "Tab Bar Font Size",+ "Pane Header Font Size",+ "Settings UI Font Weight",+ "Typography",+ "Theme",+ "Font",+ "Weight",+ ],+ Self::Terminal => &[+ "Font Size",+ "Font Family",+ "ThinkTerm Font Size",+ "Native Font Family",+ "Terminal",+ ],+ Self::Workspaces => &["Workspace", "Sidebar", "Session", "Layout"],+ Self::Keymap => &["Keymap", "Keyboard", "Shortcut", "Command Palette"],+ Self::Compatibility => &[+ "Active Source",+ "GUI Editing",+ "Open Config File",+ "Compatibility Status",+ "WezTerm",+ "Import",+ ],+ Self::Developer => &[+ "Search Field",+ "Sidebar Rows",+ "Buttons and Controls",+ "Setting Row",+ "Palette",+ "Layout",+ "Typography",+ "Component Preview",+ "Component Styles",+ ],+ Self::About => &["About", "Version", "ThinkTerm"],}}}@@ -79,14 +164,112 @@ impl SettingsSection {#[derive(Debug, Clone, Copy, PartialEq, Eq)]enum SettingsAction {Select(SettingsSection),- OpenWezTermConfig,- PrepareWezTermSync,+ OpenConfigFile,+ ShowCompatibilityStatus,+ ToggleThemeModeMenu,+ SetThemeMode(NativeThemeMode),+ SearchInput,+ DecreaseFontSize,+ IncreaseFontSize,+ ResetFontSize,+ DecreaseChromeFontSize(ChromeFontArea),+ IncreaseChromeFontSize(ChromeFontArea),+ ResetChromeFontSize(ChromeFontArea),+ DecreaseSettingsFontWeight,+ IncreaseSettingsFontWeight,+ ResetSettingsFontWeight,+ FontFamilyInput,+ ClearSearch,+ SidebarResize,+ SidebarScrollArea,+ ContentScrollArea,+}++#[derive(Debug, Clone, Copy)]+enum SettingsDrag {+ SidebarResize { start_x: f32, start_width: f32 },+}++#[derive(Debug, Clone, Copy, PartialEq, Eq)]+enum SettingsDropdown {+ ThemeMode,+}++#[derive(Debug, Clone, Copy, PartialEq, Eq)]+enum ChromeFontArea {+ Settings,+ Sidebar,+ TabBar,+ PaneHeader,+}++impl ChromeFontArea {+ fn label(self) -> &'static str {+ match self {+ Self::Settings => "Settings UI Font Size",+ Self::Sidebar => "Workspace Sidebar Font Size",+ Self::TabBar => "Tab Bar Font Size",+ Self::PaneHeader => "Pane Header Font Size",+ }+ }++ fn description(self) -> &'static str {+ match self {+ Self::Settings => "Controls the Settings window chrome and content text.",+ Self::Sidebar => "Saved separately for the main workspace sidebar.",+ Self::TabBar => "Saved separately for the top terminal tab bar.",+ Self::PaneHeader => "Saved separately for split-pane header labels.",+ }+ }++ fn default_size(self) -> f64 {+ match self {+ Self::Settings => DEFAULT_SETTINGS_FONT_SIZE,+ Self::Sidebar => DEFAULT_SIDEBAR_FONT_SIZE,+ Self::TabBar => DEFAULT_TAB_FONT_SIZE,+ Self::PaneHeader => DEFAULT_PANE_HEADER_FONT_SIZE,+ }+ }}#[derive(Debug, Clone)]-struct HitTarget {- rect: window::RectF,- action: SettingsAction,+struct SettingsUiState {+ tokens: UiTokens,+ sidebar: ResizablePaneState,+ sidebar_scroll: ScrollState,+ content_scroll: ScrollState,+ search: TextInputState,+ font_size_input: TextInputState,+ font_family_input: TextInputState,+ interaction: InteractionState<SettingsAction>,+ drag: Option<SettingsDrag>,+ open_dropdown: Option<SettingsDropdown>,+ sidebar_scrollbar_visible_until: Option<Instant>,+ content_scrollbar_visible_until: Option<Instant>,+}++impl SettingsUiState {+ fn new() -> Self {+ let tokens = UiTokens::default();+ Self {+ sidebar: ResizablePaneState::new(+ tokens.sidebar_default_width,+ tokens.sidebar_min_width,+ tokens.sidebar_max_width,+ ),+ tokens,+ sidebar_scroll: ScrollState::new(),+ content_scroll: ScrollState::new(),+ search: TextInputState::new(),+ font_size_input: TextInputState::new(),+ font_family_input: TextInputState::new(),+ interaction: InteractionState::default(),+ drag: None,+ open_dropdown: None,+ sidebar_scrollbar_visible_until: None,+ content_scrollbar_visible_until: None,+ }+ }}struct StyleToken<'a> {@@ -109,6 +292,7 @@ struct SettingsPalette {control_hover_bg: LinearRgba,control_pressed_bg: LinearRgba,control_border: LinearRgba,+ card_bg: LinearRgba,title: LinearRgba,text: LinearRgba,secondary_text: LinearRgba,@@ -147,13 +331,15 @@ struct SettingsWindow {fonts: Rc<FontConfiguration>,ui_font: Rc<LoadedFont>,title_font: Rc<LoadedFont>,+ sidebar_title_font: Rc<LoadedFont>,metrics: RenderMetrics,render_state: Option<RenderState>,+ webgpu: Option<Rc<WebGpuState>>,appearance: Appearance,selected: SettingsSection,- hit_targets: Vec<HitTarget>,- hovered_action: Option<SettingsAction>,- pressed_action: Option<SettingsAction>,+ native_settings: ThinkTermNativeSettings,+ ui: SettingsUiState,+ ui_context: UiContext<SettingsAction>,status: String,}@@ -162,30 +348,52 @@ impl SettingsWindow {let config = configuration();let dpi = window::default_dpi() as usize;let fonts = Rc::new(FontConfiguration::new(Some(config.clone()), dpi)?);- let title_font = fonts.title_font()?;- let ui_font = Rc::clone(&title_font);+ let native_settings = Self::load_native_settings();+ let settings_font_size = crate::native_settings::settings_font_size(&native_settings);+ let settings_font_weight = crate::native_settings::settings_font_weight(&native_settings);+ let title_font = fonts+ .title_font_with_size_and_weight(settings_font_size + 4.0, settings_font_weight)?;+ let sidebar_title_font = fonts+ .title_font_with_size_and_weight(SIDEBAR_BRAND_FONT_SIZE, SIDEBAR_BRAND_FONT_WEIGHT)?;+ let ui_font = fonts+ .command_palette_font_with_size_and_weight(settings_font_size, settings_font_weight)?;let metrics = RenderMetrics::with_font_metrics(&ui_font.metrics());let appearance = Connection::get().map(|conn| conn.get_appearance()).unwrap_or(Appearance::Dark);+ let dimensions = Dimensions {+ pixel_width: DEFAULT_WIDTH,+ pixel_height: DEFAULT_HEIGHT,+ dpi,+ };++ let mut ui = SettingsUiState::new();+ ui.font_size_input.text = native_settings+ .terminal+ .font_size+ .map(|value| format!("{value:.1}"))+ .unwrap_or_else(|| format!("{:.1}", config.font_size));+ ui.font_family_input.text = native_settings+ .terminal+ .font_family+ .clone()+ .unwrap_or_else(|| Self::effective_font_family(&config));let settings = Rc::new(RefCell::new(Self {window: None,- dimensions: Dimensions {- pixel_width: DEFAULT_WIDTH,- pixel_height: DEFAULT_HEIGHT,- dpi,- },+ dimensions,fonts: Rc::clone(&fonts),ui_font,title_font,+ sidebar_title_font,metrics,render_state: None,+ webgpu: None,appearance,selected: SettingsSection::Appearance,- hit_targets: Vec::new(),- hovered_action: None,- pressed_action: None,+ native_settings,+ ui,+ ui_context: UiContext::default(),status: Self::initial_status(),}));@@ -213,11 +421,13 @@ impl SettingsWindow {.await?;window.set_title("ThinkTerm Settings");- let gl = window.enable_opengl().await?;- settings- .borrow_mut()- .created(RenderContext::Glium(Rc::clone(&gl)))?;- settings.borrow_mut().window.replace(window.clone());+ let webgpu = Rc::new(WebGpuState::new(&window, dimensions, &config).await?);+ {+ let mut settings = settings.borrow_mut();+ settings.created(RenderContext::WebGpu(Rc::clone(&webgpu)))?;+ settings.webgpu.replace(webgpu);+ settings.window.replace(window.clone());+ }SETTINGS_WINDOW.with(|slot| slot.replace(Some(settings)));@@ -247,6 +457,10 @@ impl SettingsWindow {}WindowEvent::Resized { dimensions, .. } => {self.dimensions = dimensions;+ if let Some(webgpu) = self.webgpu.as_ref() {+ webgpu.resize(dimensions);+ }+ self.clamp_sidebar_to_window();window.invalidate();Ok(true)}@@ -255,9 +469,16 @@ impl SettingsWindow {self.mouse_event(event, window);Ok(true)}+ WindowEvent::KeyEvent(event) => {+ if self.key_event(event, window) {+ window.invalidate();+ }+ Ok(true)+ }WindowEvent::MouseLeave => {- self.hovered_action = None;- self.pressed_action = None;+ self.ui.interaction.hovered = None;+ self.ui.interaction.pressed = None;+ self.ui.drag = None;window.set_cursor(Some(MouseCursor::Arrow));window.invalidate();Ok(true)@@ -274,37 +495,84 @@ impl SettingsWindow {fn mouse_event(&mut self, event: MouseEvent, window: &Window) {let x = event.coords.x as f32;let y = event.coords.y as f32;- let action = self.action_at(x, y);+ let hit = self.action_at(x, y);+ let action = hit.map(|target| target.action);match event.kind {MouseEventKind::Move => {- if self.hovered_action != action {- self.hovered_action = action;- window.set_cursor(Some(if action.is_some() {- MouseCursor::Hand- } else {- MouseCursor::Arrow+ if let Some(SettingsDrag::SidebarResize {+ start_x,+ start_width,+ }) = self.ui.drag+ {+ self.ui.sidebar.set_width(start_width + x - start_x);+ window.invalidate();+ return;+ }++ if self.ui.interaction.hovered != action {+ self.ui.interaction.hovered = action;+ window.set_cursor(Some(match hit.map(|target| target.kind) {+ Some(WidgetKind::ResizeHandle) => MouseCursor::SizeLeftRight,+ Some(WidgetKind::TextInput) => MouseCursor::Text,+ Some(+ WidgetKind::Button+ | WidgetKind::SidebarRow+ | WidgetKind::PreviewControl,+ ) => MouseCursor::Hand,+ Some(WidgetKind::ScrollArea) | None => MouseCursor::Arrow,}));window.invalidate();}}MouseEventKind::Press(MousePress::Left) => {- self.hovered_action = action;- self.pressed_action = action;- if action.is_some() {- window.invalidate();+ self.ui.interaction.hovered = action;+ self.ui.interaction.pressed = action;+ match action {+ Some(SettingsAction::SearchInput | SettingsAction::FontFamilyInput) => {+ self.ui.interaction.focused = action;+ self.ui.open_dropdown = None;+ }+ Some(SettingsAction::SidebarResize) => {+ self.ui.drag = Some(SettingsDrag::SidebarResize {+ start_x: x,+ start_width: self.ui.sidebar.width,+ });+ self.ui.open_dropdown = None;+ }+ Some(SettingsAction::ToggleThemeModeMenu | SettingsAction::SetThemeMode(_)) => {+ self.ui.interaction.focused = None;+ }+ Some(_) => {+ self.ui.interaction.focused = None;+ self.ui.open_dropdown = None;+ }+ None => {+ self.ui.interaction.focused = None;+ self.ui.open_dropdown = None;+ }}+ window.invalidate();}MouseEventKind::Release(MousePress::Left) => {- let pressed = self.pressed_action.take();- self.hovered_action = action;+ let pressed = self.ui.interaction.pressed.take();+ self.ui.drag = None;+ self.ui.interaction.hovered = action;if pressed.is_some() && pressed == action {self.perform_action(action.unwrap());}window.invalidate();}+ MouseEventKind::VertWheel(_) | MouseEventKind::HorzWheel(_)+ if matches!(event.kind, MouseEventKind::VertWheel(_))+ || event.precise_scroll_delta.is_some() =>+ {+ if self.scroll_event(&event, window) {+ window.invalidate();+ }+ }_ if event.mouse_buttons == MouseButtons::NONE => {- if self.pressed_action.take().is_some() {+ if self.ui.interaction.pressed.take().is_some() {window.invalidate();}}@@ -312,105 +580,615 @@ impl SettingsWindow {}}- fn action_at(&self, x: f32, y: f32) -> Option<SettingsAction> {- self.hit_targets- .iter()- .find(|target| target.rect.contains(euclid::point2(x, y)))- .map(|target| target.action)+ fn action_at(&self, x: f32, y: f32) -> Option<crate::ui::HitTarget<SettingsAction>> {+ self.ui_context.hit_test(x, y)+ }++ fn scroll_event(&mut self, event: &MouseEvent, window: &Window) -> bool {+ let sidebar_width = self.ui.sidebar.width;+ let sidebar_area = rect(0.0, HEADER_HEIGHT, sidebar_width, self.content_bottom());+ let content_area = rect(+ sidebar_width + 1.0,+ 0.0,+ self.dimensions.pixel_width as f32 - sidebar_width - 1.0,+ self.content_bottom(),+ );+ if crate::ui::apply_wheel_to_area(event, sidebar_area, &mut self.ui.sidebar_scroll) {+ self.show_sidebar_scrollbar(window);+ return true;+ }+ if crate::ui::apply_wheel_to_area(event, content_area, &mut self.ui.content_scroll) {+ self.show_content_scrollbar(window);+ return true;+ }+ false+ }++ fn show_sidebar_scrollbar(&mut self, window: &Window) {+ self.ui.sidebar_scrollbar_visible_until =+ Some(Instant::now() + std::time::Duration::from_millis(900));+ Self::schedule_scrollbar_hide(window);+ }++ fn show_content_scrollbar(&mut self, window: &Window) {+ self.ui.content_scrollbar_visible_until =+ Some(Instant::now() + std::time::Duration::from_millis(900));+ Self::schedule_scrollbar_hide(window);+ }++ fn schedule_scrollbar_hide(window: &Window) {+ let window = window.clone();+ promise::spawn::spawn_into_main_thread(async move {+ smol::Timer::after(std::time::Duration::from_millis(930)).await;+ window.invalidate();+ })+ .detach();+ }++ fn key_event(&mut self, event: KeyEvent, window: &Window) -> bool {+ if !event.key_is_down {+ return false;+ }++ let Some(focused) = self.ui.interaction.focused else {+ return false;+ };++ if event+ .modifiers+ .intersects(Modifiers::SUPER | Modifiers::CTRL)+ && !event.modifiers.intersects(Modifiers::ALT)+ {+ return match event.key {+ KeyCode::Char('a') | KeyCode::Char('A') => self.select_all_focused_input(focused),+ KeyCode::Char('c') | KeyCode::Char('C') => self.copy_focused_input(focused, window),+ KeyCode::Char('v') | KeyCode::Char('V') => {+ self.paste_focused_input_from_clipboard(focused, window)+ }+ _ => false,+ };+ }++ if event+ .modifiers+ .intersects(Modifiers::SUPER | Modifiers::CTRL | Modifiers::ALT)+ {+ return false;+ }++ match event.key {+ KeyCode::Char('\u{8}') | KeyCode::Char('\u{7f}') => {+ self.backspace_focused_input(focused)+ }+ KeyCode::Char('\u{1b}') | KeyCode::Char('\r') => {+ self.ui.interaction.focused = None;+ true+ }+ KeyCode::Char(ch) => {+ if !ch.is_control() {+ self.push_focused_input(focused, &ch.to_string())+ } else {+ false+ }+ }+ KeyCode::Composed(text) => self.push_focused_input(focused, &text),+ _ => false,+ }+ }++ fn focused_input_text(&self, focused: SettingsAction) -> Option<&str> {+ match focused {+ SettingsAction::SearchInput => Some(&self.ui.search.text),+ SettingsAction::FontFamilyInput => Some(&self.ui.font_family_input.text),+ _ => None,+ }+ }++ fn select_all_focused_input(&mut self, focused: SettingsAction) -> bool {+ match focused {+ SettingsAction::SearchInput => {+ self.ui.search.select_all();+ true+ }+ SettingsAction::FontFamilyInput => {+ self.ui.font_family_input.select_all();+ true+ }+ _ => false,+ }+ }++ fn copy_focused_input(&mut self, focused: SettingsAction, window: &Window) -> bool {+ let Some(text) = self.focused_input_text(focused) else {+ return false;+ };+ window.set_clipboard(Clipboard::Clipboard, text.to_string());+ true+ }++ fn paste_focused_input_from_clipboard(+ &mut self,+ focused: SettingsAction,+ window: &Window,+ ) -> bool {+ let future = window.get_clipboard(Clipboard::Clipboard);+ let window = window.clone();+ promise::spawn::spawn(async move {+ if let Ok(text) = future.await {+ promise::spawn::spawn_into_main_thread(async move {+ SETTINGS_WINDOW.with(|slot| {+ let Some(settings) = slot.borrow().as_ref().cloned() else {+ return;+ };+ let mut settings = settings.borrow_mut();+ if settings.ui.interaction.focused == Some(focused)+ && settings.push_focused_input(focused, &text)+ {+ window.invalidate();+ }+ });+ })+ .detach();+ }+ })+ .detach();+ true+ }++ fn backspace_focused_input(&mut self, focused: SettingsAction) -> bool {+ match focused {+ SettingsAction::SearchInput => {+ self.ui.search.backspace();+ self.ui.sidebar_scroll.reset();+ self.sync_selected_section_with_search();+ true+ }+ SettingsAction::FontFamilyInput => {+ self.ui.font_family_input.backspace();+ self.sync_native_terminal_inputs();+ true+ }+ _ => false,+ }+ }++ fn push_focused_input(&mut self, focused: SettingsAction, text: &str) -> bool {+ match focused {+ SettingsAction::SearchInput => {+ self.ui.search.push_text(text);+ self.ui.sidebar_scroll.reset();+ self.sync_selected_section_with_search();+ true+ }+ SettingsAction::FontFamilyInput => {+ self.ui.font_family_input.push_text(text);+ self.sync_native_terminal_inputs();+ true+ }+ _ => false,+ }+ }++ fn sync_native_terminal_inputs(&mut self) {+ let family = self.ui.font_family_input.text.trim();+ self.native_settings.terminal.font_family = if family.is_empty() {+ None+ } else {+ Some(family.to_string())+ };+ self.save_and_apply_native_terminal_settings();+ }++ fn sync_selected_section_with_search(&mut self) {+ let sections = self.filtered_sections();+ if !sections.is_empty() && !sections.contains(&self.selected) {+ self.selected = sections[0];+ self.ui.content_scroll.reset();+ }+ }++ fn current_terminal_font_size_value(&self) -> f64 {+ self.ui+ .font_size_input+ .text+ .trim()+ .parse::<f64>()+ .ok()+ .or(self.native_settings.terminal.font_size)+ .unwrap_or_else(|| configuration().font_size)+ }++ fn step_terminal_font_size(&mut self, delta: f64) {+ let value = (self.current_terminal_font_size_value() + delta).clamp(8.0, 48.0);+ self.ui.font_size_input.text = format!("{value:.1}");+ self.native_settings.terminal.font_size = Some(value);+ self.save_and_apply_native_terminal_settings();+ }++ fn reset_terminal_font_size(&mut self) {+ let config = configuration();+ self.ui.font_size_input.text = format!("{:.1}", config.font_size);+ self.native_settings.terminal.font_size = None;+ self.save_and_apply_native_terminal_settings();+ }++ fn current_chrome_font_size_value(&self, area: ChromeFontArea) -> f64 {+ let value = match area {+ ChromeFontArea::Settings => self.native_settings.chrome.settings_font_size,+ ChromeFontArea::Sidebar => self.native_settings.chrome.sidebar_font_size,+ ChromeFontArea::TabBar => self.native_settings.chrome.tab_font_size,+ ChromeFontArea::PaneHeader => self.native_settings.chrome.pane_header_font_size,+ };+ value.unwrap_or_else(|| area.default_size())+ }++ fn set_chrome_font_size_value(&mut self, area: ChromeFontArea, value: Option<f64>) {+ match area {+ ChromeFontArea::Settings => self.native_settings.chrome.settings_font_size = value,+ ChromeFontArea::Sidebar => self.native_settings.chrome.sidebar_font_size = value,+ ChromeFontArea::TabBar => self.native_settings.chrome.tab_font_size = value,+ ChromeFontArea::PaneHeader => self.native_settings.chrome.pane_header_font_size = value,+ }+ }++ fn step_chrome_font_size(&mut self, area: ChromeFontArea, delta: f64) {+ let value = (self.current_chrome_font_size_value(area) + delta).clamp(10.0, 28.0);+ self.set_chrome_font_size_value(area, Some(value));+ self.save_native_chrome_settings(area);+ }++ fn reset_chrome_font_size(&mut self, area: ChromeFontArea) {+ self.set_chrome_font_size_value(area, None);+ self.save_native_chrome_settings(area);+ }++ fn current_settings_font_weight_value(&self) -> f64 {+ crate::native_settings::settings_font_weight(&self.native_settings) as f64+ }++ fn step_settings_font_weight(&mut self, delta: i16) {+ let current = crate::native_settings::settings_font_weight(&self.native_settings) as i16;+ let value = (current + delta).clamp(300, 800) as u16;+ self.native_settings.chrome.settings_font_weight = Some(value);+ self.save_native_chrome_settings(ChromeFontArea::Settings);+ }++ fn reset_settings_font_weight(&mut self) {+ self.native_settings.chrome.settings_font_weight = None;+ self.save_native_chrome_settings(ChromeFontArea::Settings);+ }++ fn save_native_chrome_settings(&mut self, area: ChromeFontArea) {+ match crate::native_settings::save(&self.native_settings) {+ Ok(()) => {+ if area == ChromeFontArea::Settings {+ if let Err(err) = self.reload_settings_fonts() {+ self.status = format!("Unable to load Settings font: {err:#}");+ return;+ }+ }+ if let Some(front_end) = crate::frontend::try_front_end() {+ front_end.invalidate_all_windows();+ }+ self.status = format!("{} saved.", area.label());+ }+ Err(err) => {+ self.status = format!("Unable to save {}: {err:#}", area.label());+ }+ }+ }++ fn reload_settings_fonts(&mut self) -> anyhow::Result<()> {+ let settings_font_size = crate::native_settings::settings_font_size(&self.native_settings);+ let settings_font_weight =+ crate::native_settings::settings_font_weight(&self.native_settings);+ self.ui_font = self+ .fonts+ .command_palette_font_with_size_and_weight(settings_font_size, settings_font_weight)?;+ self.title_font = self+ .fonts+ .title_font_with_size_and_weight(settings_font_size + 4.0, settings_font_weight)?;+ self.metrics = RenderMetrics::with_font_metrics(&self.ui_font.metrics());+ Ok(())+ }++ fn save_and_apply_native_terminal_settings(&mut self) {+ match crate::native_settings::save(&self.native_settings) {+ Ok(()) => {+ self.apply_terminal_font_size_to_open_windows();+ self.status =+ "Terminal settings saved; font size applied to open windows.".to_string();+ }+ Err(err) => {+ self.status = format!("Unable to save terminal settings: {err:#}");+ }+ }+ }++ fn apply_terminal_font_size_to_open_windows(&self) {+ let font_size = self+ .native_settings+ .terminal+ .font_size+ .unwrap_or_else(|| configuration().font_size);+ let Some(front_end) = crate::frontend::try_front_end() else {+ return;+ };+ for gui_window in front_end.gui_windows() {+ gui_window+ .window+ .notify(crate::termwindow::TermWindowNotif::Apply(Box::new(+ move |term_window| {+ if !font_size.is_finite()+ || font_size <= 0.0+ || term_window.config.font_size <= 0.0+ {+ return;+ }+ let font_scale =+ (font_size / term_window.config.font_size).clamp(0.25, 4.0);+ if let Some(window) = term_window.window.as_ref().cloned() {+ term_window.adjust_font_scale(font_scale, &window);+ }+ },+ )));+ }+ }++ fn effective_appearance(&self) -> Appearance {+ self.native_settings+ .appearance+ .theme_mode+ .effective_appearance(self.appearance)}fn palette(&self) -> SettingsPalette {- match self.appearance {+ let appearance = self.effective_appearance();+ let ui = UiPalette::for_appearance(appearance);+ match appearance {Appearance::Light | Appearance::LightHighContrast => SettingsPalette {- window_bg: rgb(242, 242, 247),- sidebar_bg: rgb(246, 246, 248),- separator: rgba(60, 60, 67, 0.18),- search_bg: rgba(255, 255, 255, 0.92),- search_border: rgba(60, 60, 67, 0.20),- nav_hover_bg: rgba(60, 60, 67, 0.08),- nav_pressed_bg: rgba(60, 60, 67, 0.14),- nav_selected_bg: rgba(0, 122, 255, 0.88),- control_bg: rgba(255, 255, 255, 0.90),- control_hover_bg: rgba(249, 249, 251, 0.96),- control_pressed_bg: rgba(232, 242, 255, 0.98),- control_border: rgba(60, 60, 67, 0.20),- title: rgb(28, 28, 30),- text: rgb(28, 28, 30),- secondary_text: rgb(72, 72, 74),- muted_text: rgb(142, 142, 147),- selected_text: rgb(255, 255, 255),- rule: rgba(60, 60, 67, 0.16),+ window_bg: ui.window_bg,+ sidebar_bg: ui.workspace_sidebar_bg,+ separator: ui.separator,+ search_bg: ui.control_bg,+ search_border: ui.control_border,+ nav_hover_bg: ui.control_hover_bg,+ nav_pressed_bg: ui.control_pressed_bg,+ nav_selected_bg: ui.control_bg,+ control_bg: ui.control_bg,+ control_hover_bg: ui.control_hover_bg,+ control_pressed_bg: ui.control_pressed_bg,+ control_border: ui.control_border,+ card_bg: rgba(255, 255, 255, 0.72),+ title: ui.text,+ text: ui.text,+ secondary_text: ui.secondary_text,+ muted_text: ui.muted_text,+ selected_text: ui.text,+ rule: ui.separator,},Appearance::Dark | Appearance::DarkHighContrast => SettingsPalette {- window_bg: rgb(28, 28, 30),- sidebar_bg: rgb(36, 36, 38),- separator: rgba(84, 84, 88, 0.55),- search_bg: rgba(58, 58, 60, 0.72),- search_border: rgba(99, 99, 102, 0.48),- nav_hover_bg: rgba(99, 99, 102, 0.26),- nav_pressed_bg: rgba(99, 99, 102, 0.36),- nav_selected_bg: rgba(10, 132, 255, 0.86),- control_bg: rgba(58, 58, 60, 0.70),- control_hover_bg: rgba(72, 72, 74, 0.76),- control_pressed_bg: rgba(64, 82, 112, 0.88),- control_border: rgba(99, 99, 102, 0.46),- title: rgb(242, 242, 247),- text: rgb(242, 242, 247),- secondary_text: rgb(199, 199, 204),- muted_text: rgb(142, 142, 147),- selected_text: rgb(255, 255, 255),- rule: rgba(84, 84, 88, 0.46),+ window_bg: ui.window_bg,+ sidebar_bg: ui.workspace_sidebar_bg,+ separator: ui.separator,+ search_bg: ui.control_bg,+ search_border: ui.control_border,+ nav_hover_bg: ui.control_hover_bg,+ nav_pressed_bg: ui.control_pressed_bg,+ nav_selected_bg: ui.control_bg,+ control_bg: ui.control_bg,+ control_hover_bg: ui.control_hover_bg,+ control_pressed_bg: ui.control_pressed_bg,+ control_border: ui.control_border,+ card_bg: rgba(30, 30, 32, 0.78),+ title: ui.text,+ text: ui.text,+ secondary_text: ui.secondary_text,+ muted_text: ui.muted_text,+ selected_text: ui.text,+ rule: ui.separator,},}}+ fn settings_row_step(&self) -> f32 {+ let cell_height = self.metrics.cell_size.height as f32;+ (cell_height * 2.15 + 42.0).max(116.0).ceil()+ }++ fn settings_card_top_padding(&self) -> f32 {+ let cell_height = self.metrics.cell_size.height as f32;+ (cell_height * 0.62).clamp(22.0, 30.0).ceil()+ }++ fn settings_card_bottom_padding(&self) -> f32 {+ let cell_height = self.metrics.cell_size.height as f32;+ (cell_height * 0.72).clamp(26.0, 36.0).ceil()+ }++ fn settings_row_visual_height(&self) -> f32 {+ let cell_height = self.metrics.cell_size.height as f32;+ (cell_height + 46.0).max(CONTROL_HEIGHT + 10.0).ceil()+ }++ fn settings_row_description_y(&self, y: f32) -> f32 {+ let cell_height = self.metrics.cell_size.height as f32;+ y + (cell_height + 8.0).max(34.0)+ }++ fn settings_section_card_gap(&self) -> f32 {+ let cell_height = self.metrics.cell_size.height as f32;+ (cell_height * 1.45).clamp(52.0, 72.0).ceil()+ }++ fn settings_card_height(&self, row_count: usize) -> f32 {+ if row_count == 0 {+ return 0.0;+ }+ self.settings_card_top_padding()+ + self.settings_row_step() * row_count.saturating_sub(1) as f32+ + self.settings_row_visual_height()+ + self.settings_card_bottom_padding()+ }++ fn settings_card_geometry(&self, section_y: f32, _row_count: usize) -> (f32, f32) {+ let card_y = section_y + self.settings_section_card_gap();+ let first_row_y = card_y + self.settings_card_top_padding();+ (card_y, first_row_y)+ }++ fn settings_content_extent(&self, bottom_y: f32) -> f32 {+ (bottom_y + 65.0).max(self.content_bottom())+ }++ fn clamp_sidebar_to_window(&mut self) {+ let dynamic_max = (self.dimensions.pixel_width as f32 * 0.38)+ .max(self.ui.sidebar.min_width)+ .min(self.ui.sidebar.max_width);+ if self.ui.sidebar.width > dynamic_max {+ self.ui.sidebar.width = dynamic_max;+ }+ }+fn perform_action(&mut self, action: SettingsAction) {match action {SettingsAction::Select(section) => {self.selected = section;+ self.ui.content_scroll.reset();+ self.ui.open_dropdown = None;}- SettingsAction::OpenWezTermConfig => {- if let Some(path) = Self::wezterm_config_source() {- self.status = format!("Opening {}", path.display());+ SettingsAction::OpenConfigFile => {+ self.ui.open_dropdown = None;+ if let Some(path) = config::configuration_file() {+ self.status = format!("Opening active config {}", path.display());Self::open_path(path);} else {- self.status = "No wezterm.lua was found yet".to_string();+ self.status = "Using built-in defaults; no config file to open".to_string();}}- SettingsAction::PrepareWezTermSync => {- self.status = match Self::wezterm_config_source() {+ SettingsAction::ShowCompatibilityStatus => {+ self.ui.open_dropdown = None;+ self.status = match config::configuration_file() {Some(path) => format!(- "Ready to sync from {}. Import backend is intentionally pending.",+ "Compatibility view is using {}. GUI import is intentionally pending.",path.display()),- None => "Create or choose a WezTerm config before syncing".to_string(),+ None => {+ "No config file is loaded; ThinkTerm is using built-in defaults".to_string()+ }};}+ SettingsAction::ToggleThemeModeMenu => {+ self.ui.open_dropdown =+ if self.ui.open_dropdown == Some(SettingsDropdown::ThemeMode) {+ None+ } else {+ Some(SettingsDropdown::ThemeMode)+ };+ }+ SettingsAction::SetThemeMode(mode) => {+ self.native_settings.appearance.theme_mode = mode;+ self.ui.open_dropdown = None;+ match crate::native_settings::save(&self.native_settings) {+ Ok(()) => {+ crate::native_settings::apply_to_app(&self.native_settings);+ if let Some(front_end) = crate::frontend::try_front_end() {+ front_end.invalidate_all_windows();+ }+ self.status = format!("Theme mode is now {}.", mode.label());+ }+ Err(err) => {+ self.status = format!("Unable to save theme mode: {err:#}");+ }+ }+ }+ SettingsAction::SearchInput => {+ self.ui.interaction.focused = Some(SettingsAction::SearchInput);+ }+ SettingsAction::DecreaseFontSize => self.step_terminal_font_size(-1.0),+ SettingsAction::IncreaseFontSize => self.step_terminal_font_size(1.0),+ SettingsAction::ResetFontSize => self.reset_terminal_font_size(),+ SettingsAction::DecreaseChromeFontSize(area) => self.step_chrome_font_size(area, -1.0),+ SettingsAction::IncreaseChromeFontSize(area) => self.step_chrome_font_size(area, 1.0),+ SettingsAction::ResetChromeFontSize(area) => self.reset_chrome_font_size(area),+ SettingsAction::DecreaseSettingsFontWeight => self.step_settings_font_weight(-100),+ SettingsAction::IncreaseSettingsFontWeight => self.step_settings_font_weight(100),+ SettingsAction::ResetSettingsFontWeight => self.reset_settings_font_weight(),+ SettingsAction::FontFamilyInput => {+ self.ui.interaction.focused = Some(SettingsAction::FontFamilyInput);+ }+ SettingsAction::ClearSearch => {+ self.ui.search.clear();+ self.ui.sidebar_scroll.reset();+ self.sync_selected_section_with_search();+ self.ui.interaction.focused = Some(SettingsAction::SearchInput);+ }+ SettingsAction::SidebarResize+ | SettingsAction::SidebarScrollArea+ | SettingsAction::ContentScrollArea => {}}}fn do_paint(&mut self, window: &Window) -> bool {- let gl = match self.render_state.as_ref().map(|state| &state.context) {- Some(RenderContext::Glium(gl)) => Rc::clone(gl),- _ => return false,- };+ let paint_start = crate::perf::now();+ let animating = self.advance_scroll_animations(Instant::now());+ match self.do_paint_webgpu() {+ Ok(ok) => {+ crate::perf::log_duration("settings_paint", paint_start);+ if animating {+ window.invalidate();+ }+ ok+ }+ Err(err) => {+ crate::perf::log_duration("settings_paint_failed", paint_start);+ log::error!("settings window webgpu paint failed: {err:#}");+ false+ }+ }+ }- if gl.is_context_lost() {- log::error!("settings window opengl context was lost");- window.close();- return false;+ fn advance_scroll_animations(&mut self, now: Instant) -> bool {+ self.ui.sidebar_scroll.advance_animation(now)+ | self.ui.content_scroll.advance_animation(now)+ }++ fn do_paint_webgpu(&mut self) -> anyhow::Result<bool> {+ let webgpu = Rc::clone(+ self.webgpu+ .as_ref()+ .context("settings webgpu state not initialized")?,+ );+ match self.do_paint_webgpu_impl(&webgpu) {+ Ok(ok) => Ok(ok),+ Err(err) => {+ match err.downcast_ref::<wgpu::SurfaceError>() {+ Some(wgpu::SurfaceError::Lost | wgpu::SurfaceError::Outdated) => {+ webgpu.resize(self.dimensions);+ return self.do_paint_webgpu_impl(&webgpu);+ }+ _ => {}+ }+ Err(err)+ }}+ }+ fn do_paint_webgpu_impl(&mut self, webgpu: &WebGpuState) -> anyhow::Result<bool> {for _ in 0..3 {+ let paint_pass_start = crate::perf::now();match self.paint_pass() {- Ok(()) => match self.render_state.as_mut().unwrap().allocated_more_quads() {- Ok(true) => continue,- Ok(false) => break,- Err(err) => {- log::error!("settings window quad allocation failed: {err:#}");- break;+ Ok(()) => {+ crate::perf::log_duration("settings_paint_pass", paint_pass_start);+ match self.render_state.as_mut().unwrap().allocated_more_quads() {+ Ok(true) => continue,+ Ok(false) => break,+ Err(err) => {+ log::error!("settings window quad allocation failed: {err:#}");+ break;+ }}- },+ }Err(err) => {if let Some(&OutOfTextureSpace {size: Some(size),@@ -418,6 +1196,7 @@ impl SettingsWindow {}) = err.root_cause().downcast_ref::<OutOfTextureSpace>(){let size = size.max(current_size);+ crate::perf::log_counter("settings_atlas_reallocate", size);if let Err(err) = self.render_state.as_mut()@@ -435,15 +1214,20 @@ impl SettingsWindow {}}- let mut frame = glium::Frame::new(- gl,- (- self.dimensions.pixel_width as u32,- self.dimensions.pixel_height as u32,- ),- );- let result = self.call_draw_glium(&mut frame);- result.and_then(|_| window.finish_frame(frame)).is_ok()+ let clear_color = wgpu_color(self.palette().window_bg);+ let render_state = self+ .render_state+ .as_ref()+ .context("settings render state not initialized")?;+ draw_webgpu_layers(+ webgpu,+ render_state,+ self.dimensions,+ [1.0, 1.0, 1.0],+ 0,+ clear_color,+ )?;+ Ok(true)}fn paint_pass(&mut self) -> anyhow::Result<()> {@@ -453,7 +1237,7 @@ impl SettingsWindow {}}- self.hit_targets.clear();+ self.ui_context.clear();let layer = self.render_state.as_ref()@@ -464,7 +1248,6 @@ impl SettingsWindow {self.paint_background(&mut layers)?;self.paint_sidebar(&mut layers)?;self.paint_content(&mut layers)?;- self.paint_status(&mut layers)?;Ok(())}@@ -473,20 +1256,21 @@ impl SettingsWindow {let palette = self.palette();let width = self.dimensions.pixel_width as f32;let height = self.dimensions.pixel_height as f32;+ let sidebar_width = self.ui.sidebar.width;self.draw_rect(layers, 0, 0.0, 0.0, width, height, palette.window_bg)?;self.draw_rect(layers,0,0.0,0.0,- SIDEBAR_WIDTH,+ sidebar_width,height,palette.sidebar_bg,)?;self.draw_rect(layers,0,- SIDEBAR_WIDTH,+ sidebar_width,0.0,1.0,height,@@ -498,48 +1282,153 @@ impl SettingsWindow {fn paint_sidebar(&mut self, layers: &mut TripleLayerQuadAllocator<'_>) -> anyhow::Result<()> {let palette = self.palette();let ui_font = Rc::clone(&self.ui_font);- let title_font = Rc::clone(&self.title_font);+ let sidebar_title_font = Rc::clone(&self.sidebar_title_font);+ let nav_font = Rc::clone(&self.ui_font);+ let tokens = self.ui.tokens;+ let sidebar_width = self.ui.sidebar.width;+ let sidebar_icon_size = ((self.metrics.cell_size.height as f32 + 8.0)+ .clamp(24.0, 34.0)+ .round()) as usize;self.draw_text(layers,- &title_font,- 28.0,- 32.0,- "ThinkTerm Settings",+ &sidebar_title_font,+ tokens.sidebar_padding + 6.0,+ SIDEBAR_TITLE_Y,+ "ThinkTerm",palette.title,- SIDEBAR_WIDTH - 56.0,+ sidebar_width - tokens.sidebar_padding * 2.0,)?;- self.draw_rounded_frame(+ let search_rect = rect(+ tokens.sidebar_padding,+ SIDEBAR_SEARCH_Y,+ sidebar_width - tokens.sidebar_padding * 2.0,+ tokens.control_height,+ );+ let search_text = self.ui.search.text.clone();+ self.paint_text_input(layers,- 0,- 22.0,- 78.0,- SIDEBAR_WIDTH - 44.0,- 42.0,- palette.search_bg,- palette.search_border,- CONTROL_RADIUS,+ TextInputSpec {+ placeholder: "Search settings...",+ text: &search_text,+ rect: search_rect,+ focused: self.ui.interaction.focused == Some(SettingsAction::SearchInput),+ selected_all: self.ui.search.selected_all,+ action: SettingsAction::SearchInput,+ },)?;- self.draw_text(+ self.draw_svg_icon(layers,- &ui_font,- 40.0,- self.control_text_y(78.0, CONTROL_HEIGHT),- "Search settings...",+ SettingsIcon::Search.svg(),+ search_rect.origin.x + 15.0,+ search_rect.origin.y + (search_rect.size.height - sidebar_icon_size as f32) / 2.0,+ sidebar_icon_size as f32,palette.muted_text,- SIDEBAR_WIDTH - 72.0,)?;+ if !self.ui.search.is_empty() {+ let clear_size = 34.0;+ let clear_icon_size = 24.0;+ let clear_rect = rect(+ search_rect.origin.x + search_rect.size.width - clear_size - 10.0,+ search_rect.origin.y + (search_rect.size.height - clear_size) / 2.0,+ clear_size,+ clear_size,+ );+ self.ui_context+ .push(clear_rect, WidgetKind::Button, SettingsAction::ClearSearch);+ if self.ui.interaction.hovered == Some(SettingsAction::ClearSearch)+ || self.ui.interaction.pressed == Some(SettingsAction::ClearSearch)+ {+ self.draw_rounded_rect(+ layers,+ 0,+ clear_rect.origin.x,+ clear_rect.origin.y,+ clear_rect.size.width,+ clear_rect.size.height,+ palette.control_hover_bg,+ 14.0,+ )?;+ }+ self.draw_svg_icon(+ layers,+ SettingsIcon::Clear.svg(),+ clear_rect.origin.x + (clear_rect.size.width - clear_icon_size) / 2.0,+ clear_rect.origin.y + (clear_rect.size.height - clear_icon_size) / 2.0,+ clear_icon_size,+ palette.secondary_text,+ )?;+ }++ let handle_rect = rect(+ sidebar_width - tokens.resize_handle_width / 2.0,+ 0.0,+ tokens.resize_handle_width,+ self.dimensions.pixel_height as f32,+ );+ self.ui_context.push(+ handle_rect,+ WidgetKind::ResizeHandle,+ SettingsAction::SidebarResize,+ );+ let handle_color = if self.ui.interaction.hovered == Some(SettingsAction::SidebarResize)+ || matches!(self.ui.drag, Some(SettingsDrag::SidebarResize { .. }))+ {+ palette.nav_selected_bg+ } else {+ palette.separator+ };+ self.draw_rect(+ layers,+ 0,+ sidebar_width - 1.0,+ 0.0,+ 2.0,+ self.dimensions.pixel_height as f32,+ handle_color,+ )?;++ let sections = self.filtered_sections();+ let list_top = SIDEBAR_LIST_TOP;+ let list_bottom = (self.dimensions.pixel_height as f32 - 16.0).max(list_top);+ let list_height = list_bottom - list_top;+ let content_extent = sections.len() as f32 * NAV_ROW_STEP + 8.0;+ self.ui+ .sidebar_scroll+ .set_extents(list_height, content_extent.max(list_height));+ let list_area = rect(0.0, list_top, sidebar_width, list_height);+ self.ui_context.push(+ list_area,+ WidgetKind::ScrollArea,+ SettingsAction::SidebarScrollArea,+ );++ let mut y = list_top - self.ui.sidebar_scroll.offset;+ if sections.is_empty() {+ self.draw_text(+ layers,+ &ui_font,+ tokens.sidebar_padding + 12.0,+ list_top + 18.0,+ "No settings found",+ palette.muted_text,+ sidebar_width - tokens.sidebar_padding * 2.0 - 24.0,+ )?;+ }- let mut y = 148.0;- for §ion in SECTIONS {+ for section in sections {+ if y + NAV_ROW_HEIGHT < list_top || y > list_bottom {+ y += NAV_ROW_STEP;+ continue;+ }let action = SettingsAction::Select(section);let selected = section == self.selected;- let hovered = self.hovered_action == Some(action);- let pressed = self.pressed_action == Some(action);+ let hovered = self.ui.interaction.hovered == Some(action);+ let pressed = self.ui.interaction.pressed == Some(action);let row_y = y - 6.0;- let row_x = 18.0;- let row_width = SIDEBAR_WIDTH - 36.0;+ let row_x = tokens.sidebar_padding;+ let row_width = sidebar_width - tokens.sidebar_padding * 2.0;let row_bg = if selected {Some(palette.nav_selected_bg)} else if pressed {@@ -562,26 +1451,43 @@ impl SettingsWindow {)?;}- self.hit_targets.push(HitTarget {- rect: euclid::rect(row_x, row_y, row_width, NAV_ROW_HEIGHT),+ self.ui_context.push(+ rect(row_x, row_y, row_width, NAV_ROW_HEIGHT),+ WidgetKind::SidebarRow,action,- });+ );+ let text_color = if selected {+ palette.selected_text+ } else {+ palette.secondary_text+ };+ self.draw_svg_icon(+ layers,+ section.icon().svg(),+ row_x + 14.0,+ row_y + (NAV_ROW_HEIGHT - sidebar_icon_size as f32) / 2.0,+ sidebar_icon_size as f32,+ text_color,+ )?;self.draw_text(layers,- &ui_font,- row_x + 16.0,+ &nav_font,+ row_x + 56.0,self.control_text_y(row_y, NAV_ROW_HEIGHT),section.label(),- if selected {- palette.selected_text- } else {- palette.secondary_text- },- row_width - 32.0,+ text_color,+ row_width - 76.0,)?;y += NAV_ROW_STEP;}+ self.paint_scrollbar(+ layers,+ list_area,+ self.ui.sidebar_scroll,+ self.sidebar_scrollbar_visible(),+ )?;+Ok(())}@@ -589,45 +1495,40 @@ impl SettingsWindow {let palette = self.palette();let ui_font = Rc::clone(&self.ui_font);let title_font = Rc::clone(&self.title_font);- let x = SIDEBAR_WIDTH + 46.0;- let max_width = self.dimensions.pixel_width as f32 - x - 50.0;+ let sidebar_width = self.ui.sidebar.width;+ let window_width = self.dimensions.pixel_width as f32;+ let content_gap = if window_width < 980.0 { 30.0 } else { 46.0 };+ let right_margin = if window_width < 980.0 { 34.0 } else { 50.0 };+ let x = sidebar_width + content_gap;+ let max_width = (window_width - x - right_margin).max(280.0);+ let content_area = rect(+ sidebar_width + 1.0,+ 0.0,+ self.dimensions.pixel_width as f32 - sidebar_width - 1.0,+ self.content_bottom(),+ );+ self.ui_context.push(+ content_area,+ WidgetKind::ScrollArea,+ SettingsAction::ContentScrollArea,+ );+ let scroll = self.ui.content_scroll.offset;self.draw_text(layers,&title_font,x,- 54.0,+ CONTENT_TITLE_Y - scroll,self.selected.label(),palette.title,max_width,)?;- let edit_button_width = 260.0_f32.min((max_width * 0.48).max(210.0));- self.draw_button(- layers,- x + max_width - edit_button_width,- 34.0,- edit_button_width,- "Open wezterm.lua",- SettingsAction::OpenWezTermConfig,- )?;match self.selected {SettingsSection::Appearance => self.paint_appearance(layers, x, max_width)?,- SettingsSection::WezTermSync => self.paint_wezterm_sync(layers, x, max_width)?,- SettingsSection::General => self.paint_placeholder(- layers,- &ui_font,- x,- "Startup behavior, default shell, launch directory, and update policy.",- max_width,- )?,- SettingsSection::Terminal => self.paint_placeholder(- layers,- &ui_font,- x,- "Terminal font, cursor, selection, bell, scrollback, and pane defaults.",- max_width,- )?,+ SettingsSection::Compatibility => self.paint_compatibility(layers, x, max_width)?,+ SettingsSection::General => self.paint_general(layers, x, max_width)?,+ SettingsSection::Terminal => self.paint_terminal(layers, x, max_width)?,SettingsSection::Workspaces => self.paint_placeholder(layers,&ui_font,@@ -643,12 +1544,26 @@ impl SettingsWindow {max_width,)?,SettingsSection::Developer => self.paint_developer(layers, x, max_width)?,+ SettingsSection::About => self.paint_placeholder(+ layers,+ &ui_font,+ x,+ "ThinkTerm version, project information, and app metadata.",+ max_width,+ )?,}+ self.paint_scrollbar(+ layers,+ content_area,+ self.ui.content_scroll,+ self.content_scrollbar_visible(),+ )?;+ self.paint_open_dropdown_overlay(layers, x, max_width)?;Ok(())}- fn paint_appearance(+ fn paint_general(&mut self,layers: &mut TripleLayerQuadAllocator<'_>,x: f32,@@ -656,128 +1571,405 @@ impl SettingsWindow {) -> anyhow::Result<()> {let palette = self.palette();let ui_font = Rc::clone(&self.ui_font);+ let scroll = self.ui.content_scroll.offset;+ let row_step = self.settings_row_step();+ let section_y = CONTENT_SECTION_Y - scroll;+ let (card_y, first_row_y) = self.settings_card_geometry(section_y, 3);+ let card_height = self.settings_card_height(3);+ self.ui.content_scroll.set_extents(+ self.content_bottom(),+ self.settings_content_extent(card_y + scroll + card_height),+ );+ let source = Self::config_source_summary();+ let native_path = Self::native_settings_path();+ let native_status = if native_path.exists() {+ native_path.display().to_string()+ } else {+ format!("Defaults; optional file at {}", native_path.display())+ };self.draw_text(layers,&ui_font,x,- 112.0,- "Theme",+ section_y,+ "Configuration",palette.muted_text,max_width,)?;- self.draw_rect(layers, 0, x, 142.0, max_width, 1.0, palette.rule)?;- let mut y = 186.0;+ let card_x = x;+ let card_padding = 36.0;+ let row_x = card_x + card_padding;+ let row_width = max_width - card_padding * 2.0;+ self.paint_group_card(layers, card_x, card_y, max_width, card_height)?;+ self.paint_setting_row(+ layers,+ row_x,+ first_row_y,+ row_width,+ "Config Source",+ &source,+ if config::configuration_file().is_some() {+ "File"+ } else {+ "Defaults"+ },+ false,+ )?;self.paint_setting_row(layers,+ row_x,+ first_row_y + row_step,+ row_width,+ "ThinkTerm Native Settings",+ &native_status,+ &format!("v{}", self.native_settings.version),+ true,+ )?;+ self.paint_theme_mode_row(+ layers,+ row_x,+ first_row_y + row_step * 2.0,+ row_width,+ "Small ThinkTerm-native state; compatible terminal config stays in wezterm.lua.",+ true,+ )?;+ Ok(())+ }++ fn paint_appearance(+ &mut self,+ layers: &mut TripleLayerQuadAllocator<'_>,+ x: f32,+ max_width: f32,+ ) -> anyhow::Result<()> {+ let palette = self.palette();+ let ui_font = Rc::clone(&self.ui_font);+ let config = configuration();+ let scroll = self.ui.content_scroll.offset;+ let row_step = self.settings_row_step();+ let section_y = CONTENT_SECTION_Y - scroll;+ let theme_row_count = 3;+ let typography_row_count = 5;+ let (theme_card_y, mut y) = self.settings_card_geometry(section_y, theme_row_count);+ let theme_card_height = self.settings_card_height(theme_row_count);+ let typography_title_y =+ theme_card_y + theme_card_height + self.settings_section_card_gap();+ let typography_card_y = typography_title_y + self.settings_section_card_gap().min(54.0);+ let typography_first_row_y = typography_card_y + self.settings_card_top_padding();+ let typography_card_height = self.settings_card_height(typography_row_count);+ self.ui.content_scroll.set_extents(+ self.content_bottom(),+ self.settings_content_extent(typography_card_y + scroll + typography_card_height),+ );++ self.draw_text(+ layers,+ &ui_font,x,- y,+ section_y,+ "Theme",+ palette.muted_text,max_width,- "Theme Mode",- "Follow macOS appearance and choose light/dark schemes automatically.",- "System",)?;- y += 102.0;++ let card_padding = 36.0;+ let row_x = x + card_padding;+ let row_width = max_width - card_padding * 2.0;+ self.paint_group_card(layers, x, theme_card_y, max_width, theme_card_height)?;+ self.paint_theme_mode_row(+ layers,+ row_x,+ y,+ row_width,+ "ThinkTerm-native window appearance preference.",+ false,+ )?;+ y += row_step;self.paint_setting_row(layers,- x,+ row_x,y,- max_width,- "Light Theme",- "Theme used when the system is in light appearance.",- "Apple System Colors Light",+ row_width,+ "Effective Color Scheme",+ "Resolved through the WezTerm-compatible config path.",+ Self::effective_color_scheme_label(&config),+ true,)?;- y += 102.0;+ y += row_step;self.paint_setting_row(layers,- x,+ row_x,y,+ row_width,+ "Config Source",+ &Self::config_source_summary(),+ if config::configuration_file().is_some() {+ "File"+ } else {+ "Defaults"+ },+ true,+ )?;++ self.draw_text(+ layers,+ &ui_font,+ x,+ typography_title_y,+ "Typography",+ palette.muted_text,max_width,- "Dark Theme",- "Theme used when the system is in dark appearance.",- "Apple System Colors",)?;- y += 102.0;- self.paint_setting_row(++ self.paint_group_card(layers,x,+ typography_card_y,+ max_width,+ typography_card_height,+ )?;+ y = typography_first_row_y;+ for area in [+ ChromeFontArea::Settings,+ ChromeFontArea::Sidebar,+ ChromeFontArea::TabBar,+ ChromeFontArea::PaneHeader,+ ] {+ self.paint_font_size_stepper_row(+ layers,+ row_x,+ y,+ row_width,+ area.label(),+ area.description(),+ self.current_chrome_font_size_value(area),+ SettingsAction::ResetChromeFontSize(area),+ SettingsAction::DecreaseChromeFontSize(area),+ SettingsAction::IncreaseChromeFontSize(area),+ area != ChromeFontArea::Settings,+ )?;+ y += row_step;+ }+ self.paint_font_size_stepper_row(+ layers,+ row_x,y,+ row_width,+ "Settings UI Font Weight",+ "Controls the Settings window chrome and content text weight.",+ self.current_settings_font_weight_value(),+ SettingsAction::ResetSettingsFontWeight,+ SettingsAction::DecreaseSettingsFontWeight,+ SettingsAction::IncreaseSettingsFontWeight,+ true,+ )?;++ Ok(())+ }++ fn paint_terminal(+ &mut self,+ layers: &mut TripleLayerQuadAllocator<'_>,+ x: f32,+ max_width: f32,+ ) -> anyhow::Result<()> {+ let palette = self.palette();+ let ui_font = Rc::clone(&self.ui_font);+ let config = configuration();+ let scroll = self.ui.content_scroll.offset;+ let row_step = self.settings_row_step();+ let section_y = CONTENT_SECTION_Y - scroll;+ let row_count = 4;+ let (card_y, first_row_y) = self.settings_card_geometry(section_y, row_count);+ let card_height = self.settings_card_height(row_count);+ self.ui.content_scroll.set_extents(+ self.content_bottom(),+ self.settings_content_extent(card_y + scroll + card_height),+ );+ let font_size = format!("{:.1} pt", config.font_size);+ let font_family = Self::effective_font_family(&config);++ self.draw_text(+ layers,+ &ui_font,+ x,+ section_y,+ "Effective terminal config",+ palette.muted_text,max_width,- "Interface Font",- "Settings and sidebar use the macOS system UI font, separate from terminal text.",- "System UI",)?;+ let card_padding = 36.0;+ let card_x = x;+ let row_x = card_x + card_padding;+ let row_width = max_width - card_padding * 2.0;+ self.paint_group_card(layers, card_x, card_y, max_width, card_height)?;+ self.paint_setting_row(+ layers,+ row_x,+ first_row_y,+ row_width,+ "Font Size",+ "Current effective value from the WezTerm-compatible config.",+ &font_size,+ false,+ )?;+ self.paint_setting_row(+ layers,+ row_x,+ first_row_y + row_step,+ row_width,+ "Font Family",+ "Current primary terminal font family.",+ &font_family,+ true,+ )?;+ self.paint_font_size_stepper_row(+ layers,+ row_x,+ first_row_y + row_step * 2.0,+ row_width,+ "ThinkTerm Font Size",+ "Saved locally and applied immediately to open terminal windows.",+ self.current_terminal_font_size_value(),+ SettingsAction::ResetFontSize,+ SettingsAction::DecreaseFontSize,+ SettingsAction::IncreaseFontSize,+ true,+ )?;+ let native_font_family = self.ui.font_family_input.text.clone();+ self.paint_text_setting_row(+ layers,+ row_x,+ first_row_y + row_step * 3.0,+ row_width,+ "Native Font Family",+ "Local quick-setting draft. Persistence and terminal application are pending.",+ &native_font_family,+ "JetBrains Mono",+ SettingsAction::FontFamilyInput,+ true,+ )?;Ok(())}fn paint_developer(- &self,+ &mut self,layers: &mut TripleLayerQuadAllocator<'_>,x: f32,max_width: f32,) -> anyhow::Result<()> {let palette = self.palette();let ui_font = Rc::clone(&self.ui_font);+ let two_column = max_width >= 940.0;+ let content_extent = if two_column { 1020.0 } else { 1660.0 };+ self.ui+ .content_scroll+ .set_extents(self.content_bottom(), content_extent);+ let scroll = self.ui.content_scroll.offset;self.draw_text(layers,&ui_font,x,- 112.0,+ CONTENT_SECTION_Y - scroll,"Live settings UI components. The left side is rendered with the same primitives as the real window.",palette.secondary_text,max_width,)?;- self.draw_rect(layers, 0, x, 146.0, max_width, 1.0, palette.rule)?;+ self.draw_rect(+ layers,+ 0,+ x,+ CONTENT_RULE_Y - scroll,+ max_width,+ 1.0,+ palette.rule,+ )?;- let preview_width = (max_width * 0.58).min(560.0);- let notes_x = x + preview_width + 34.0;- let notes_width = (max_width - preview_width - 34.0).max(240.0);+ let preview_width = if two_column {+ (max_width * 0.52).min(620.0)+ } else {+ max_width+ };+ let notes_x = if two_column {+ x + preview_width + 42.0+ } else {+ x+ };+ let notes_width = if two_column {+ (max_width - preview_width - 42.0).max(280.0)+ } else {+ max_width+ };+ let notes_top = if two_column { 244.0 } else { 900.0 };self.draw_text(layers,&ui_font,x,- 184.0,+ 244.0 - scroll,"Component Preview",palette.title,preview_width,)?;- self.draw_rect(layers, 0, x, 214.0, preview_width, 1.0, palette.rule)?;- self.paint_preview_search(layers, x, 238.0, preview_width)?;+ self.draw_rect(+ layers,+ 0,+ x,+ 274.0 - scroll,+ preview_width,+ 1.0,+ palette.rule,+ )?;+ self.paint_preview_search(layers, x, 298.0 - scroll, preview_width)?;self.draw_text(layers,&ui_font,x,- 322.0,+ 382.0 - scroll,"Sidebar Rows",palette.title,preview_width,)?;- self.paint_preview_sidebar_row(layers, x, 356.0, preview_width, "General", false)?;- self.paint_preview_sidebar_row(layers, x, 402.0, preview_width, "Appearance", true)?;+ self.paint_preview_sidebar_row(layers, x, 416.0 - scroll, preview_width, "General", false)?;+ self.paint_preview_sidebar_row(+ layers,+ x,+ 470.0 - scroll,+ preview_width,+ "Appearance",+ true,+ )?;self.draw_text(layers,&ui_font,x,- 468.0,+ 540.0 - scroll,"Buttons and Controls",palette.title,preview_width,)?;- self.paint_preview_button(layers, x, 502.0, 176.0, "Normal Button", false)?;- self.paint_preview_button(layers, x + 194.0, 502.0, 162.0, "Accent Button", true)?;- self.paint_preview_control(layers, x, 554.0, 220.0, "System")?;+ self.paint_preview_button(layers, x, 578.0 - scroll, 250.0, "Normal Button", false)?;+ self.paint_preview_button(+ layers,+ x + 270.0,+ 578.0 - scroll,+ 220.0,+ "Accent Button",+ true,+ )?;+ self.paint_preview_control(layers, x, 648.0 - scroll, 280.0, "System")?;self.draw_text(layers,&ui_font,x,- 590.0,+ 730.0 - scroll,"Setting Row",palette.title,preview_width,@@ -785,37 +1977,38 @@ impl SettingsWindow {self.paint_setting_row(layers,x,- 626.0,+ 800.0 - scroll,preview_width,"Theme Mode","Follow macOS appearance.","System",+ false,)?;let component_tokens = [StyleToken {name: "search.field",- value: "h42 bg+top border",+ value: "h56 bg+focus border",swatch: Some(palette.search_bg),},StyleToken {name: "nav.active.row",- value: "h40 system selection",+ value: "h48 system selection",swatch: Some(palette.nav_selected_bg),},StyleToken {name: "button.normal",- value: "h42 rounded hover",+ value: "h56 rounded hover",swatch: Some(palette.control_bg),},StyleToken {name: "button.accent",- value: "h42 active bg",+ value: "h56 active bg",swatch: Some(palette.control_pressed_bg),},StyleToken {name: "control.select",- value: "h42 rounded select",+ value: "h56 rounded select",swatch: Some(palette.control_bg),},StyleToken {@@ -828,22 +2021,22 @@ impl SettingsWindow {let layout_tokens = [StyleToken {name: "window",- value: "1180 x 760",+ value: "1360 x 860",swatch: None,},StyleToken {name: "sidebar",- value: "286 px",+ value: "340 px",swatch: None,},StyleToken {name: "content",- value: "46 gap / 50 margin",+ value: "responsive gap / 132 header",swatch: None,},StyleToken {name: "rows",- value: "nav40/44 setting102",+ value: "nav48/56 setting132",swatch: None,},];@@ -879,7 +2072,7 @@ impl SettingsWindow {self.paint_style_group(layers,notes_x,- 184.0,+ notes_top - scroll,notes_width,"Component Styles",&component_tokens,@@ -887,7 +2080,7 @@ impl SettingsWindow {self.paint_style_group(layers,notes_x,- 410.0,+ notes_top + 330.0 - scroll,notes_width,"Typography",&type_tokens,@@ -895,7 +2088,7 @@ impl SettingsWindow {self.paint_style_group(layers,notes_x,- 552.0,+ notes_top + 590.0 - scroll,notes_width,"Layout",&layout_tokens,@@ -919,7 +2112,7 @@ impl SettingsWindow {0,x,y + 28.0,- width.min(360.0),+ width.min(420.0),CONTROL_HEIGHT,palette.search_bg,palette.search_border,@@ -932,7 +2125,7 @@ impl SettingsWindow {self.control_text_y(y + 28.0, CONTROL_HEIGHT),"Search settings...",palette.muted_text,- width.min(360.0) - 36.0,+ width.min(420.0) - 36.0,)?;Ok(())}@@ -948,7 +2141,7 @@ impl SettingsWindow {) -> anyhow::Result<()> {let palette = self.palette();let ui_font = Rc::clone(&self.ui_font);- let row_width = width.min(360.0);+ let row_width = width.min(420.0);if selected {self.draw_rounded_rect(layers,@@ -956,7 +2149,7 @@ impl SettingsWindow {x,y,row_width,- 36.0,+ NAV_ROW_HEIGHT,palette.nav_selected_bg,NAV_ROW_RADIUS,)?;@@ -967,7 +2160,7 @@ impl SettingsWindow {x,y,row_width,- 36.0,+ NAV_ROW_HEIGHT,palette.nav_hover_bg,NAV_ROW_RADIUS,)?;@@ -976,7 +2169,7 @@ impl SettingsWindow {layers,&ui_font,x + 16.0,- self.control_text_y(y, 36.0),+ self.control_text_y(y, NAV_ROW_HEIGHT),label,if selected {palette.selected_text@@ -998,6 +2191,7 @@ impl SettingsWindow {accent: bool,) -> anyhow::Result<()> {let palette = self.palette();+ let width = width.max(self.button_width_for_label(label, 0.0));let bg = if accent {palette.nav_selected_bg} else {@@ -1017,7 +2211,7 @@ impl SettingsWindow {self.draw_text(layers,&Rc::clone(&self.ui_font),- x + 14.0,+ x + 18.0,self.control_text_y(y, CONTROL_HEIGHT),label,if accent {@@ -1025,7 +2219,7 @@ impl SettingsWindow {} else {palette.text},- width - 28.0,+ width - 36.0,)?;Ok(())}@@ -1090,9 +2284,9 @@ impl SettingsWindow {palette.title,width,)?;- self.draw_rect(layers, 0, x, y + 28.0, width, 1.0, palette.rule)?;+ self.paint_separator(layers, x, y + 28.0, width)?;- let mut row_y = y + 52.0;+ let mut row_y = y + 58.0;for token in tokens {self.paint_style_token(layers,@@ -1103,7 +2297,7 @@ impl SettingsWindow {token.value,token.swatch,)?;- row_y += 26.0;+ row_y += 40.0;}Ok(())@@ -1149,7 +2343,7 @@ impl SettingsWindow {Ok(())}- fn paint_wezterm_sync(+ fn paint_compatibility(&mut self,layers: &mut TripleLayerQuadAllocator<'_>,x: f32,@@ -1157,59 +2351,77 @@ impl SettingsWindow {) -> anyhow::Result<()> {let palette = self.palette();let ui_font = Rc::clone(&self.ui_font);- let source = Self::wezterm_config_source()- .map(|path| path.display().to_string())- .unwrap_or_else(|| "No wezterm.lua found".to_string());+ let scroll = self.ui.content_scroll.offset;+ let row_step = self.settings_row_step();+ let section_y = CONTENT_SECTION_Y - scroll;+ let (card_y, first_row_y) = self.settings_card_geometry(section_y, 2);+ let card_height = self.settings_card_height(2);+ let buttons_y = card_y + card_height + self.settings_section_card_gap();+ self.ui.content_scroll.set_extents(+ self.content_bottom(),+ self.settings_content_extent(buttons_y + scroll + CONTROL_HEIGHT),+ );+ let source = Self::config_source_summary();self.draw_text(layers,&ui_font,x,- 112.0,- "Import and mirror existing WezTerm configuration without overwriting it first.",+ section_y,+ "ThinkTerm keeps the WezTerm-compatible config path as the main terminal configuration.",palette.secondary_text,max_width,)?;+ let card_padding = 36.0;+ let row_x = x + card_padding;+ let row_width = max_width - card_padding * 2.0;+ self.paint_group_card(layers, x, card_y, max_width, card_height)?;self.paint_setting_row(layers,- x,- 166.0,- max_width,- "Detected Source",+ row_x,+ first_row_y,+ row_width,+ "Active Source",&source,- "Read only",+ if config::configuration_file().is_some() {+ "File"+ } else {+ "Defaults"+ },+ false,)?;self.paint_setting_row(layers,- x,- 268.0,- max_width,- "ThinkTerm Target",- "Not connected yet",+ row_x,+ first_row_y + row_step,+ row_width,+ "GUI Editing",+ "Future visual editor will generate a managed compatible config layer.","Pending",+ true,)?;self.draw_button(layers,x,- 390.0,- 240.0,- "Open WezTerm Config",- SettingsAction::OpenWezTermConfig,+ buttons_y,+ self.button_width_for_label("Open Config File", 260.0),+ "Open Config File",+ SettingsAction::OpenConfigFile,)?;self.draw_button(layers,- x + 256.0,- 390.0,- 176.0,- "Prepare Sync",- SettingsAction::PrepareWezTermSync,+ x + 326.0,+ buttons_y,+ self.button_width_for_label("Compatibility Status", 260.0),+ "Compatibility Status",+ SettingsAction::ShowCompatibilityStatus,)?;Ok(())}fn paint_placeholder(- &self,+ &mut self,layers: &mut TripleLayerQuadAllocator<'_>,font: &Rc<LoadedFont>,x: f32,@@ -1217,16 +2429,28 @@ impl SettingsWindow {max_width: f32,) -> anyhow::Result<()> {let palette = self.palette();+ self.ui+ .content_scroll+ .set_extents(self.content_bottom(), 240.0);+ let scroll = self.ui.content_scroll.offset;self.draw_text(layers,font,x,- 118.0,+ CONTENT_SECTION_Y - scroll,body,palette.secondary_text,max_width,)?;- self.draw_rect(layers, 0, x, 166.0, max_width, 1.0, palette.rule)?;+ self.draw_rect(+ layers,+ 0,+ x,+ CONTENT_RULE_Y - scroll,+ max_width,+ 1.0,+ palette.rule,+ )?;Ok(())}@@ -1239,31 +2463,31 @@ impl SettingsWindow {label: &str,description: &str,value: &str,+ draw_top_rule: bool,) -> anyhow::Result<()> {let palette = self.palette();let ui_font = Rc::clone(&self.ui_font);- self.draw_rect(layers, 0, x, y - 24.0, width, 1.0, palette.rule)?;- self.draw_text(- layers,- &ui_font,- x + 22.0,- y,- label,- palette.text,- width * 0.58,- )?;+ if draw_top_rule {+ self.paint_separator(layers, x, y - 28.0, width)?;+ }+ let control_width = if width >= 680.0 {+ 280.0_f32.min(width * 0.36)+ } else {+ 220.0_f32.min(width * 0.44)+ };+ let control_x = x + width - control_width;+ let control_y = y + 4.0;+ let text_width = (control_x - x - 24.0).max(width * 0.45);+ self.draw_text(layers, &ui_font, x, y, label, palette.text, text_width)?;self.draw_text(layers,&ui_font,- x + 22.0,- y + 30.0,+ x,+ self.settings_row_description_y(y),description,palette.secondary_text,- width * 0.62,+ text_width,)?;- let control_width = 220.0_f32.min(width * 0.34);- let control_x = x + width - control_width - 28.0;- let control_y = y + 2.0;self.draw_rounded_frame(layers,0,@@ -1287,71 +2511,684 @@ impl SettingsWindow {Ok(())}- fn paint_status(&self, layers: &mut TripleLayerQuadAllocator<'_>) -> anyhow::Result<()> {+ fn paint_group_card(+ &self,+ layers: &mut TripleLayerQuadAllocator<'_>,+ x: f32,+ y: f32,+ width: f32,+ height: f32,+ ) -> anyhow::Result<()> {let palette = self.palette();- let ui_font = Rc::clone(&self.ui_font);- let y = self.dimensions.pixel_height as f32 - 42.0;- self.draw_rect(+ self.draw_rounded_frame(layers,0,- 22.0,- y - 18.0,- SIDEBAR_WIDTH - 44.0,- 1.0,+ x,+ y,+ width,+ height,+ palette.card_bg,palette.separator,- )?;- self.draw_text(- layers,- &ui_font,28.0,- y,- "Cmd+, Settings",- palette.muted_text,- SIDEBAR_WIDTH - 56.0,- )?;- self.draw_text(- layers,- &ui_font,- SIDEBAR_WIDTH + 46.0,- y,- &self.status,- palette.muted_text,- self.dimensions.pixel_width as f32 - SIDEBAR_WIDTH - 96.0,- )?;- Ok(())+ )}- fn draw_button(+ fn paint_separator(+ &self,+ layers: &mut TripleLayerQuadAllocator<'_>,+ x: f32,+ y: f32,+ width: f32,+ ) -> anyhow::Result<()> {+ let palette = self.palette();+ self.draw_rounded_rect(layers, 0, x, y, width, 2.0, palette.rule, 1.0)+ }++ fn paint_font_size_stepper_row(&mut self,layers: &mut TripleLayerQuadAllocator<'_>,x: f32,y: f32,width: f32,label: &str,- action: SettingsAction,+ description: &str,+ value: f64,+ reset_action: SettingsAction,+ decrease_action: SettingsAction,+ increase_action: SettingsAction,+ draw_top_rule: bool,) -> anyhow::Result<()> {- self.hit_targets.push(HitTarget {- rect: euclid::rect(x, y, width, CONTROL_HEIGHT),- action,- });+ let palette = self.palette();+ let ui_font = Rc::clone(&self.ui_font);+ if draw_top_rule {+ self.paint_separator(layers, x, y - 28.0, width)?;+ }++ let control_width = if width >= 680.0 {+ 280.0_f32.min(width * 0.36)+ } else {+ 220.0_f32.min(width * 0.44)+ };+ let control_x = x + width - control_width;+ let control_y = y + 4.0;+ let dynamic_icon_size = (self.metrics.cell_size.height as f32 + 4.0).clamp(24.0, 34.0);+ let reset_size = CONTROL_HEIGHT;+ let reset_gap = 14.0;+ let reset_x = (control_x - reset_gap - reset_size).max(x + width * 0.62);+ let text_width = (reset_x - x - 24.0).max(width * 0.40);++ self.draw_text(layers, &ui_font, x, y, label, palette.text, text_width)?;+ self.draw_text(+ layers,+ &ui_font,+ x,+ self.settings_row_description_y(y),+ description,+ palette.secondary_text,+ text_width,+ )?;++ self.paint_icon_button(+ layers,+ reset_x,+ control_y,+ reset_size,+ SvgIcon::RotateCcw,+ reset_action,+ )?;++ self.draw_rounded_frame(+ layers,+ 0,+ control_x,+ control_y,+ control_width,+ CONTROL_HEIGHT,+ palette.control_bg,+ palette.control_border,+ CONTROL_RADIUS,+ )?;++ let button_width = 62.0_f32.min(control_width * 0.28);+ let minus_rect = rect(control_x, control_y, button_width, CONTROL_HEIGHT);+ let plus_rect = rect(+ control_x + control_width - button_width,+ control_y,+ button_width,+ CONTROL_HEIGHT,+ );+ self.ui_context+ .push(minus_rect, WidgetKind::Button, decrease_action);+ self.ui_context+ .push(plus_rect, WidgetKind::Button, increase_action);++ for (button_rect, action, icon) in [+ (minus_rect, decrease_action, SvgIcon::Minus),+ (plus_rect, increase_action, SvgIcon::Plus),+ ] {+ if self.ui.interaction.hovered == Some(action)+ || self.ui.interaction.pressed == Some(action)+ {+ self.draw_rounded_rect(+ layers,+ 1,+ button_rect.origin.x + 4.0,+ button_rect.origin.y + 4.0,+ button_rect.size.width - 8.0,+ button_rect.size.height - 8.0,+ palette.control_hover_bg,+ CONTROL_RADIUS - 4.0,+ )?;+ }+ self.draw_svg_icon(+ layers,+ icon,+ button_rect.origin.x + (button_rect.size.width - dynamic_icon_size) / 2.0,+ button_rect.origin.y + (button_rect.size.height - dynamic_icon_size) / 2.0,+ dynamic_icon_size,+ palette.secondary_text,+ )?;+ }+ let value_label = if value >= 100.0 && value.fract().abs() < f64::EPSILON {+ format!("{value:.0}")+ } else {+ format!("{value:.1}")+ };+ let value_width = control_width - button_width * 2.0;+ let value_x = control_x + button_width;+ self.draw_text(+ layers,+ &ui_font,+ value_x + 8.0,+ self.control_text_y(control_y, CONTROL_HEIGHT),+ &value_label,+ palette.text,+ value_width - 16.0,+ )?;++ Ok(())+ }++ fn paint_text_setting_row(+ &mut self,+ layers: &mut TripleLayerQuadAllocator<'_>,+ x: f32,+ y: f32,+ width: f32,+ label: &str,+ description: &str,+ value: &str,+ placeholder: &str,+ action: SettingsAction,+ draw_top_rule: bool,+ ) -> anyhow::Result<()> {let palette = self.palette();- let is_hovered = self.hovered_action == Some(action);- let is_pressed = self.pressed_action == Some(action);- let background = if is_pressed {+ let ui_font = Rc::clone(&self.ui_font);+ if draw_top_rule {+ self.paint_separator(layers, x, y - 28.0, width)?;+ }++ let control_width = if width >= 680.0 {+ 280.0_f32.min(width * 0.36)+ } else {+ 220.0_f32.min(width * 0.44)+ };+ let control_x = x + width - control_width;+ let control_y = y + 4.0;+ let text_width = (control_x - x - 24.0).max(width * 0.45);+ let focused = self.ui.interaction.focused == Some(action);+ let hovered = self.ui.interaction.hovered == Some(action);+ let pressed = self.ui.interaction.pressed == Some(action);+ let bg = if pressed {palette.control_pressed_bg- } else if is_hovered {+ } else if focused || hovered {palette.control_hover_bg} else {palette.control_bg};- let border = if is_pressed {+ let border = if focused {palette.nav_selected_bg- } else if is_hovered {+ } else if hovered || pressed {palette.separator} else {palette.control_border};+ let control_rect = rect(control_x, control_y, control_width, CONTROL_HEIGHT);++ self.ui_context+ .push(control_rect, WidgetKind::TextInput, action);+ self.draw_text(layers, &ui_font, x, y, label, palette.text, text_width)?;+ self.draw_text(+ layers,+ &ui_font,+ x,+ self.settings_row_description_y(y),+ description,+ palette.secondary_text,+ text_width,+ )?;+ self.draw_rounded_frame(+ layers,+ 0,+ control_x,+ control_y,+ control_width,+ CONTROL_HEIGHT,+ bg,+ border,+ CONTROL_RADIUS,+ )?;++ let display = if value.trim().is_empty() {+ placeholder+ } else {+ value+ };+ let text_color = if value.trim().is_empty() {+ palette.muted_text+ } else {+ palette.text+ };+ let selected_all = match action {+ SettingsAction::FontFamilyInput => self.ui.font_family_input.selected_all,+ _ => false,+ };+ if focused && selected_all && !value.is_empty() {+ self.draw_rounded_rect(+ layers,+ 1,+ control_x + 10.0,+ control_y + 8.0,+ control_width - 20.0,+ CONTROL_HEIGHT - 16.0,+ palette.nav_selected_bg.mul_alpha(0.32),+ CONTROL_RADIUS - 4.0,+ )?;+ }+ self.draw_text(+ layers,+ &ui_font,+ control_x + 16.0,+ self.control_text_y(control_y, CONTROL_HEIGHT),+ display,+ text_color,+ control_width - 32.0,+ )?;+ if focused && !selected_all {+ let caret_text = if value.trim().is_empty() { "" } else { value };+ let caret_x = control_x+ + 18.0+ + self+ .measure_text_width(&ui_font, caret_text)+ .min(control_width - 42.0);+ self.draw_rect(+ layers,+ 1,+ caret_x,+ control_y + 12.0,+ 1.5,+ CONTROL_HEIGHT - 24.0,+ palette.nav_selected_bg,+ )?;+ }+ Ok(())+ }++ fn paint_theme_mode_row(+ &mut self,+ layers: &mut TripleLayerQuadAllocator<'_>,+ x: f32,+ y: f32,+ width: f32,+ description: &str,+ draw_top_rule: bool,+ ) -> anyhow::Result<()> {+ let palette = self.palette();+ let ui_font = Rc::clone(&self.ui_font);+ if draw_top_rule {+ self.paint_separator(layers, x, y - 28.0, width)?;+ }++ let (control_x, control_y, control_width) = self.theme_mode_control_geometry(x, y, width);+ let text_width = (control_x - x - 24.0).max(width * 0.45);+ let action = SettingsAction::ToggleThemeModeMenu;+ let control_rect = rect(control_x, control_y, control_width, CONTROL_HEIGHT);+ let open = self.ui.open_dropdown == Some(SettingsDropdown::ThemeMode);+ let hovered = self.ui.interaction.hovered == Some(action);+ let pressed = self.ui.interaction.pressed == Some(action);+ let bg = if pressed || hovered {+ palette.control_hover_bg+ } else {+ palette.control_bg+ };+ let border = if open {+ palette.nav_selected_bg+ } else if hovered || pressed {+ palette.separator+ } else {+ palette.control_border+ };++ self.ui_context+ .push(control_rect, WidgetKind::Button, action);+ self.draw_text(+ layers,+ &ui_font,+ x,+ y,+ "Theme Mode",+ palette.text,+ text_width,+ )?;+ self.draw_text(+ layers,+ &ui_font,+ x,+ self.settings_row_description_y(y),+ description,+ palette.secondary_text,+ text_width,+ )?;+ self.draw_rounded_frame(+ layers,+ 0,+ control_rect.origin.x,+ control_rect.origin.y,+ control_rect.size.width,+ control_rect.size.height,+ bg,+ border,+ CONTROL_RADIUS,+ )?;+ self.draw_text(+ layers,+ &ui_font,+ control_x + 16.0,+ self.control_text_y(control_y, CONTROL_HEIGHT),+ self.native_settings.appearance.theme_mode.label(),+ palette.text,+ control_width - 60.0,+ )?;+ self.draw_svg_icon(+ layers,+ SvgIcon::ChevronDown,+ control_x + control_width - 38.0,+ control_y + (CONTROL_HEIGHT - 22.0) / 2.0,+ 22.0,+ palette.secondary_text,+ )?;++ Ok(())+ }++ fn theme_mode_control_geometry(&self, x: f32, y: f32, width: f32) -> (f32, f32, f32) {+ let control_width = if width >= 680.0 {+ 280.0_f32.min(width * 0.36)+ } else {+ 220.0_f32.min(width * 0.44)+ };+ (x + width - control_width, y + 4.0, control_width)+ }++ fn paint_open_dropdown_overlay(+ &mut self,+ layers: &mut TripleLayerQuadAllocator<'_>,+ x: f32,+ max_width: f32,+ ) -> anyhow::Result<()> {+ if self.ui.open_dropdown != Some(SettingsDropdown::ThemeMode) {+ return Ok(());+ }++ let scroll = self.ui.content_scroll.offset;+ let card_padding = 36.0;+ let section_y = CONTENT_SECTION_Y - scroll;+ let (_, first_row_y) = self.settings_card_geometry(section_y, 3);+ let (row_x, row_y, row_width) = match self.selected {+ SettingsSection::Appearance => (+ x + card_padding,+ first_row_y,+ max_width - card_padding * 2.0,+ ),+ SettingsSection::General => (+ x + card_padding,+ first_row_y + self.settings_row_step() * 2.0,+ max_width - card_padding * 2.0,+ ),+ _ => return Ok(()),+ };+ let (control_x, control_y, control_width) =+ self.theme_mode_control_geometry(row_x, row_y, row_width);+ self.paint_theme_mode_menu(+ layers,+ control_x,+ control_y + CONTROL_HEIGHT + 8.0,+ control_width,+ )+ }++ fn paint_theme_mode_menu(+ &mut self,+ layers: &mut TripleLayerQuadAllocator<'_>,+ x: f32,+ y: f32,+ width: f32,+ ) -> anyhow::Result<()> {+ let palette = self.palette();+ let ui_font = Rc::clone(&self.ui_font);+ let options = [+ NativeThemeMode::System,+ NativeThemeMode::Light,+ NativeThemeMode::Dark,+ ];+ let row_height = 46.0;+ let menu_height = row_height * options.len() as f32 + 12.0;+ let menu_bg = match self.effective_appearance() {+ Appearance::Light | Appearance::LightHighContrast => rgba(248, 248, 250, 1.0),+ Appearance::Dark | Appearance::DarkHighContrast => rgba(34, 34, 36, 1.0),+ };++ self.draw_rounded_frame(+ layers,+ 1,+ x,+ y,+ width,+ menu_height,+ menu_bg,+ palette.control_border,+ CONTROL_RADIUS,+ )?;++ let mut row_y = y + 6.0;+ for mode in options {+ let action = SettingsAction::SetThemeMode(mode);+ let row_rect = rect(x + 6.0, row_y, width - 12.0, row_height);+ self.ui_context.push(row_rect, WidgetKind::Button, action);+ let selected = self.native_settings.appearance.theme_mode == mode;+ let hovered = self.ui.interaction.hovered == Some(action);+ let pressed = self.ui.interaction.pressed == Some(action);+ let row_bg = if selected {+ Some(palette.nav_selected_bg)+ } else if pressed {+ Some(palette.control_pressed_bg)+ } else if hovered {+ Some(palette.control_hover_bg)+ } else {+ None+ };+ if let Some(row_bg) = row_bg {+ self.draw_rounded_rect(+ layers,+ 1,+ row_rect.origin.x,+ row_rect.origin.y,+ row_rect.size.width,+ row_rect.size.height,+ row_bg,+ 9.0,+ )?;+ }+ self.draw_text(+ layers,+ &ui_font,+ row_rect.origin.x + 14.0,+ self.control_text_y(row_rect.origin.y, row_height),+ mode.label(),+ if selected {+ palette.selected_text+ } else {+ palette.text+ },+ row_rect.size.width - 28.0,+ )?;+ row_y += row_height;+ }++ Ok(())+ }++ fn content_bottom(&self) -> f32 {+ self.dimensions.pixel_height as f32+ }++ fn sidebar_scrollbar_visible(&self) -> bool {+ self.ui+ .sidebar_scrollbar_visible_until+ .is_some_and(|until| until > Instant::now())+ || matches!(self.ui.drag, Some(SettingsDrag::SidebarResize { .. }))+ }++ fn content_scrollbar_visible(&self) -> bool {+ self.ui+ .content_scrollbar_visible_until+ .is_some_and(|until| until > Instant::now())+ }++ fn filtered_sections(&self) -> Vec<SettingsSection> {+ let query = self.ui.search.text.trim().to_lowercase();+ if query.is_empty() {+ return SECTIONS.to_vec();+ }+ SECTIONS+ .iter()+ .copied()+ .filter(|section| {+ section.label().to_lowercase().contains(&query)+ || section+ .search_terms()+ .iter()+ .any(|term| term.to_lowercase().contains(&query))+ })+ .collect()+ }++ fn paint_text_input(+ &mut self,+ layers: &mut TripleLayerQuadAllocator<'_>,+ spec: TextInputSpec<'_, SettingsAction>,+ ) -> anyhow::Result<()> {+ let palette = self.palette();+ self.ui_context+ .push(spec.rect, WidgetKind::TextInput, spec.action);+ let border = if spec.focused {+ palette.nav_selected_bg+ } else if self.ui.interaction.hovered == Some(spec.action) {+ palette.separator+ } else {+ palette.search_border+ };+ self.draw_rounded_frame(+ layers,+ 0,+ spec.rect.origin.x,+ spec.rect.origin.y,+ spec.rect.size.width,+ spec.rect.size.height,+ palette.search_bg,+ border,+ self.ui.tokens.control_radius,+ )?;+ if spec.focused {+ self.draw_rounded_rect(+ layers,+ 0,+ spec.rect.origin.x,+ spec.rect.origin.y,+ spec.rect.size.width,+ 2.0,+ palette.nav_selected_bg,+ 1.0,+ )?;+ }++ let text = if spec.text.is_empty() && !spec.focused {+ spec.placeholder+ } else {+ spec.text+ };+ let color = if spec.text.is_empty() && !spec.focused {+ palette.muted_text+ } else {+ palette.text+ };+ if spec.focused && spec.selected_all && !spec.text.is_empty() {+ self.draw_rounded_rect(+ layers,+ 1,+ spec.rect.origin.x + 50.0,+ spec.rect.origin.y + 8.0,+ spec.rect.size.width - 96.0,+ spec.rect.size.height - 16.0,+ palette.nav_selected_bg.mul_alpha(0.32),+ self.ui.tokens.control_radius - 4.0,+ )?;+ }+ self.draw_text(+ layers,+ &Rc::clone(&self.ui_font),+ spec.rect.origin.x + 58.0,+ self.control_text_y(spec.rect.origin.y, spec.rect.size.height),+ text,+ color,+ spec.rect.size.width - 116.0,+ )?;+ if spec.focused && !spec.selected_all {+ let caret_x = spec.rect.origin.x+ + 60.0+ + self+ .measure_text_width(&Rc::clone(&self.ui_font), spec.text)+ .min((spec.rect.size.width - 124.0).max(0.0));+ self.draw_rect(+ layers,+ 1,+ caret_x,+ spec.rect.origin.y + 10.0,+ 1.5,+ spec.rect.size.height - 20.0,+ palette.nav_selected_bg,+ )?;+ }+ Ok(())+ }++ fn paint_scrollbar(+ &self,+ layers: &mut TripleLayerQuadAllocator<'_>,+ area: window::RectF,+ scroll: ScrollState,+ visible: bool,+ ) -> anyhow::Result<()> {+ if !visible {+ return Ok(());+ }+ let ui_palette = UiPalette::for_appearance(self.effective_appearance());+ let spec = ScrollbarSpec::from_area(area, self.ui.tokens);+ if let Some((thumb_y, thumb_h)) = scroll.thumb(spec.y, spec.height) {+ self.draw_rounded_rect(+ layers,+ 0,+ spec.x,+ thumb_y,+ spec.width,+ thumb_h,+ ui_palette.scrollbar_thumb,+ spec.width / 2.0,+ )?;+ }+ Ok(())+ }++ fn draw_button(+ &mut self,+ layers: &mut TripleLayerQuadAllocator<'_>,+ x: f32,+ y: f32,+ width: f32,+ label: &str,+ action: SettingsAction,+ ) -> anyhow::Result<()> {+ let width = width.max(self.button_width_for_label(label, 0.0));+ let button = ButtonSpec {+ label,+ action,+ rect: rect(x, y, width, CONTROL_HEIGHT),+ state: if self.ui.interaction.pressed == Some(action) {+ ControlState::Pressed+ } else if self.ui.interaction.hovered == Some(action) {+ ControlState::Hovered+ } else {+ ControlState::Normal+ },+ kind: WidgetKind::Button,+ };+ self.ui_context+ .push(button.rect, button.kind, button.action);++ let palette = self.palette();+ let ui_palette = UiPalette::for_appearance(self.effective_appearance());+ let (background, border) = button.state.colors(ui_palette);self.draw_rounded_frame(layers,0,@@ -1368,13 +3205,56 @@ impl SettingsWindow {&Rc::clone(&self.ui_font),x + 14.0,self.control_text_y(y, CONTROL_HEIGHT),- label,+ button.label,palette.text,- width - 28.0,+ width - 36.0,)?;Ok(())}+ fn paint_icon_button(+ &mut self,+ layers: &mut TripleLayerQuadAllocator<'_>,+ x: f32,+ y: f32,+ size: f32,+ icon: SvgIcon,+ action: SettingsAction,+ ) -> anyhow::Result<()> {+ let palette = self.palette();+ let rect = rect(x, y, size, size);+ self.ui_context.push(rect, WidgetKind::Button, action);+ let hovered = self.ui.interaction.hovered == Some(action);+ let pressed = self.ui.interaction.pressed == Some(action);+ let bg = if pressed {+ palette.control_pressed_bg+ } else if hovered {+ palette.control_hover_bg+ } else {+ LinearRgba::TRANSPARENT+ };+ if bg.3 > 0.0 {+ self.draw_rounded_rect(layers, 0, x, y, size, size, bg, CONTROL_RADIUS)?;+ }+ let icon_size = (self.metrics.cell_size.height as f32 + 4.0).clamp(24.0, 34.0);+ self.draw_svg_icon(+ layers,+ icon,+ x + (size - icon_size) / 2.0,+ y + (size - icon_size) / 2.0,+ icon_size,+ if hovered || pressed {+ palette.text+ } else {+ palette.muted_text+ },+ )+ }++ fn button_width_for_label(&self, label: &str, min_width: f32) -> f32 {+ (self.measure_text_width(&Rc::clone(&self.ui_font), label) + 44.0).max(min_width)+ }+fn control_text_y(&self, y: f32, height: f32) -> f32 {let cell_height = self.metrics.cell_size.height as f32;y + ((height - cell_height) / 2.0).max(0.0)@@ -1568,6 +3448,43 @@ impl SettingsWindow {Ok(())}+ fn draw_svg_icon(+ &self,+ layers: &mut TripleLayerQuadAllocator<'_>,+ icon: SvgIcon,+ x: f32,+ y: f32,+ size: f32,+ color: LinearRgba,+ ) -> anyhow::Result<()> {+ if size <= 0.0 {+ return Ok(());+ }++ let render_state = self.render_state.as_ref().unwrap();+ let sprite = render_state+ .glyph_cache+ .borrow_mut()+ .cached_svg_icon(icon, size.round() as usize)?+ .texture_coords();+ let mut quad = layers.allocate(2)?;+ let left_offset = self.dimensions.pixel_width as f32 / 2.0;+ let top_offset = self.dimensions.pixel_height as f32 / 2.0;+ quad.set_position(+ x - left_offset,+ y - top_offset,+ x + size - left_offset,+ y + size - top_offset,+ );+ quad.set_texture(sprite);+ quad.set_fg_color(color);+ quad.set_alt_color_and_mix_value(color, 0.0);+ quad.set_hsv(None);+ quad.set_has_color(false);+ quad.set_grayscale();+ Ok(())+ }+fn draw_text(&self,layers: &mut TripleLayerQuadAllocator<'_>,@@ -1582,7 +3499,12 @@ impl SettingsWindow {return Ok(());}- let infos = font.blocking_shape(text, None, Direction::LeftToRight, None, None)?;+ let display_text = self.text_with_ellipsis(font, text, max_width);+ if display_text.is_empty() {+ return Ok(());+ }++ let infos = font.blocking_shape(&display_text, None, Direction::LeftToRight, None, None)?;let render_state = self.render_state.as_ref().unwrap();let mut glyph_cache = render_state.glyph_cache.borrow_mut();let style = font.style();@@ -1595,8 +3517,9 @@ impl SettingsWindow {for info in infos {let glyph = glyph_cache.cached_glyph(&info, style, false, font, &self.metrics, 1)?;if let Some(texture) = glyph.texture.as_ref() {- let glyph_x = pos_x + (glyph.x_offset + glyph.bearing_x).get() as f32;- let glyph_y = y - (glyph.y_offset + glyph.bearing_y).get() as f32 + baseline;+ let glyph_x = (pos_x + (glyph.x_offset + glyph.bearing_x).get() as f32).round();+ let glyph_y =+ (y - (glyph.y_offset + glyph.bearing_y).get() as f32 + baseline).round();let width = texture.coords.size.width as f32 * glyph.scale as f32;let height = texture.coords.size.height as f32 * glyph.scale as f32;@@ -1625,105 +3548,108 @@ impl SettingsWindow {Ok(())}- fn call_draw_glium(&mut self, frame: &mut glium::Frame) -> anyhow::Result<()> {+ fn measure_text_width(&self, font: &Rc<LoadedFont>, text: &str) -> f32 {+ if text.is_empty() {+ return 0.0;+ }+ let Ok(infos) = font.blocking_shape(text, None, Direction::LeftToRight, None, None) else {+ return 0.0;+ };let render_state = self.render_state.as_ref().unwrap();- let tex = render_state.glyph_cache.borrow().atlas.texture();- let tex = tex.downcast_ref::<SrgbTexture2d>().unwrap();-- frame.clear_color(0.0, 0.0, 0.0, 1.0);+ let mut glyph_cache = render_state.glyph_cache.borrow_mut();+ let style = font.style();+ infos+ .into_iter()+ .filter_map(|info| {+ glyph_cache+ .cached_glyph(&info, style, false, font, &self.metrics, 1)+ .ok()+ .map(|glyph| glyph.x_advance.get() as f32)+ })+ .sum()+ }- let projection = euclid::Transform3D::<f32, f32, f32>::ortho(- -(self.dimensions.pixel_width as f32) / 2.0,- self.dimensions.pixel_width as f32 / 2.0,- self.dimensions.pixel_height as f32 / 2.0,- -(self.dimensions.pixel_height as f32) / 2.0,- -1.0,- 1.0,- )- .to_arrays_transposed();+ fn text_with_ellipsis(&self, font: &Rc<LoadedFont>, text: &str, max_width: f32) -> String {+ if max_width <= 0.0 || text.is_empty() {+ return String::new();+ }- let alpha_blending = glium::DrawParameters {- blend: glium::Blend {- color: BlendingFunction::Addition {- source: LinearBlendingFactor::SourceAlpha,- destination: LinearBlendingFactor::OneMinusSourceAlpha,- },- alpha: BlendingFunction::Addition {- source: LinearBlendingFactor::One,- destination: LinearBlendingFactor::OneMinusSourceAlpha,- },- constant_value: (0.0, 0.0, 0.0, 0.0),- },- ..Default::default()- };+ if self.measure_text_width(font, text) <= max_width {+ return text.to_string();+ }- let atlas_nearest_sampler = Sampler::new(&*tex)- .wrap_function(SamplerWrapFunction::Clamp)- .magnify_filter(MagnifySamplerFilter::Nearest)- .minify_filter(MinifySamplerFilter::Nearest);-- let atlas_linear_sampler = Sampler::new(&*tex)- .wrap_function(SamplerWrapFunction::Clamp)- .magnify_filter(MagnifySamplerFilter::Linear)- .minify_filter(MinifySamplerFilter::Linear);-- let foreground_text_hsb = (1.0_f32, 1.0_f32, 1.0_f32);- let milliseconds = 0_u32;- let ease = ColorEaseUniform {- in_function: [0.0, 0.0, 1.0, 1.0],- out_function: [0.0, 0.0, 1.0, 1.0],- in_duration_ms: 0,- out_duration_ms: 0,- };- let subpixel_aa = false;-- for layer in render_state.layers.borrow().iter() {- for idx in 0..3 {- let vb = &layer.vb.borrow()[idx];- let (vertex_count, index_count) = vb.vertex_index_count();- if vertex_count > 0 {- let vertices = vb.current_vb_mut();- let mut uniforms = UniformBuilder::default();-- uniforms.add("projection", &projection);- uniforms.add("atlas_nearest_sampler", &atlas_nearest_sampler);- uniforms.add("atlas_linear_sampler", &atlas_linear_sampler);- uniforms.add("foreground_text_hsb", &foreground_text_hsb);- uniforms.add("subpixel_aa", &subpixel_aa);- uniforms.add("milliseconds", &milliseconds);- uniforms.add_struct("cursor_blink", &ease);- uniforms.add_struct("blink", &ease);- uniforms.add_struct("rapid_blink", &ease);-- frame.draw(- vertices.glium().slice(0..vertex_count).unwrap(),- vb.indices.glium().slice(0..index_count).unwrap(),- render_state.glyph_prog.as_ref().unwrap(),- &uniforms,- &alpha_blending,- )?;- }+ let ellipsis = "...";+ let ellipsis_width = self.measure_text_width(font, ellipsis);+ if ellipsis_width > max_width {+ return String::new();+ }- vb.next_index();+ let mut boundaries = text+ .char_indices()+ .map(|(idx, _)| idx)+ .chain(std::iter::once(text.len()))+ .collect::<Vec<_>>();+ boundaries.dedup();++ let mut low = 0;+ let mut high = boundaries.len().saturating_sub(1);+ let mut best = 0;+ while low <= high {+ let mid = (low + high) / 2;+ let candidate = &text[..boundaries[mid]];+ let width = self.measure_text_width(font, candidate) + ellipsis_width;+ if width <= max_width {+ best = mid;+ low = mid + 1;+ } else if mid == 0 {+ break;+ } else {+ high = mid - 1;}}- Ok(())+ format!("{}{}", text[..boundaries[best]].trim_end(), ellipsis)}- fn initial_status() -> String {- match Self::wezterm_config_source() {- Some(path) => format!("Found WezTerm config at {}", path.display()),- None => "No existing WezTerm config was found yet".to_string(),+ fn native_settings_path() -> PathBuf {+ crate::native_settings::settings_path()+ }++ fn load_native_settings() -> ThinkTermNativeSettings {+ crate::native_settings::load()+ }++ fn config_source_summary() -> String {+ if let Some(path) = config::configuration_file() {+ format!("Loaded from {}", path.display())+ } else if config::is_config_overridden() {+ "No config file loaded; command-line overrides or --skip-config are active".to_string()+ } else {+ "No config file loaded; using built-in defaults".to_string()}}- fn wezterm_config_source() -> Option<PathBuf> {- let mut candidates = vec![config::HOME_DIR.join(".wezterm.lua")];- for dir in config::CONFIG_DIRS.iter() {- candidates.push(dir.join("wezterm.lua"));+ fn effective_color_scheme_label(config: &config::ConfigHandle) -> &str {+ if let Some(name) = config.color_scheme.as_deref() {+ name+ } else if config.colors.is_some() {+ "Custom inline colors"+ } else {+ "Default palette"}- candidates.into_iter().find(|path| path.exists())+ }++ fn effective_font_family(config: &config::ConfigHandle) -> String {+ config+ .font+ .font+ .first()+ .map(|font| font.family.clone())+ .unwrap_or_else(|| "Default font".to_string())+ }++ fn initial_status() -> String {+ Self::config_source_summary()}fn open_path(path: PathBuf) {@@ -1734,10 +3660,17 @@ impl SettingsWindow {}}-fn rgb(r: u8, g: u8, b: u8) -> LinearRgba {- rgba(r, g, b, 1.0)+fn rgba(r: u8, g: u8, b: u8, a: f32) -> LinearRgba {+ let mut color = LinearRgba::with_srgba(r, g, b, 255);+ color.3 = a;+ color}-fn rgba(r: u8, g: u8, b: u8, a: f32) -> LinearRgba {- LinearRgba::with_components(r as f32 / 255.0, g as f32 / 255.0, b as f32 / 255.0, a)+fn wgpu_color(color: LinearRgba) -> wgpu::Color {+ wgpu::Color {+ r: color.0 as f64,+ g: color.1 as f64,+ b: color.2 as f64,+ a: color.3 as f64,+ }}diff --git a/wezterm-gui/src/termwindow/mod.rs b/wezterm-gui/src/termwindow/mod.rsindex 19cb3a61..c820110f 100644--- a/wezterm-gui/src/termwindow/mod.rs+++ b/wezterm-gui/src/termwindow/mod.rs@@ -210,12 +210,15 @@ pub enum UIItemType {ProjectToggleSessions(String),Project(String),ProjectSession(String),- ProjectSessionArchive(String),+ ProjectSessionPin(String),+ ProjectSessionDelete(String),ProjectSessionNew(String),+ WorkspaceSidebarToggle,WorkspaceSidebarScrollTrack,WorkspaceSidebarScrollThumb,WorkspaceSidebarBackground,WorkspaceSidebarResize,+ WorkspaceSidebarSettings,AboveScrollThumb,ScrollThumb,BelowScrollThumb,@@ -242,6 +245,8 @@ pub(crate) enum TabWheelSurface {enum InlineTabRenameTarget {WindowTab(TabId),PaneTab(PaneId),+ Project(String),+ ProjectSession(String),}#[derive(Clone, Debug)]@@ -1159,6 +1164,8 @@ impl TermWindow {myself.webgpu.replace(Rc::clone(&webgpu));myself.created(RenderContext::WebGpu(Rc::clone(&webgpu)))?;}+ myself.apply_native_terminal_settings();+ myself.apply_workspace_session_font_scales();myself.load_os_parameters();window.show();myself.subscribe_to_pane_updates();@@ -1629,6 +1636,7 @@ impl TermWindow {self.clear_all_overlays();self.current_highlight.take();+ self.apply_workspace_session_font_scales();self.invalidate_fancy_tab_bar();self.invalidate_modal();@@ -2144,6 +2152,7 @@ impl TermWindow {self.load_os_parameters();self.apply_scale_change(&dimensions, self.fonts.get_font_scale());self.apply_dimensions(&dimensions, None, &window);+ self.apply_workspace_session_font_scales();window.config_did_change(&config);window.invalidate();}@@ -2712,31 +2721,22 @@ impl TermWindow {self.update_title_impl();}- fn prompt_rename_project_session(&mut self, session_id: String) {- let mux = Mux::get();- let tab = match mux.get_active_tab_for_window(self.mux_window_id) {- Some(tab) => tab,- None => return,- };+ fn prompt_rename_project(&mut self, project_id: String) {+ let initial_title = crate::project_sessions::project_name(&project_id).unwrap_or_default();+ self.inline_tab_rename = Some(InlineTabRename::new(+ InlineTabRenameTarget::Project(project_id),+ initial_title,+ ));+ self.update_title_impl();+ }+ fn prompt_rename_project_session(&mut self, session_id: String) {let initial_title = crate::project_sessions::session_name(&session_id).unwrap_or_default();- let description = "Rename Session".to_string();- let prompt = "Name: ".to_string();-- let (overlay, future) = start_overlay(self, &tab, move |_tab_id, term| {- let line = crate::overlay::prompt::read_line_prompt_overlay(- term,- &description,- &prompt,- Some(&initial_title),- )?;- if let Some(line) = line {- crate::project_sessions::rename_session(&session_id, line);- }- Ok(())- });- self.assign_overlay(tab.tab_id(), overlay);- promise::spawn::spawn(future).detach();+ self.inline_tab_rename = Some(InlineTabRename::new(+ InlineTabRenameTarget::ProjectSession(session_id),+ initial_title,+ ));+ self.update_title_impl();}pub(crate) fn prompt_create_project(&mut self, context: &dyn WindowOps) {@@ -2771,6 +2771,12 @@ impl TermWindow {self.pane_tab_title_overrides.insert(pane_id, title);}}+ InlineTabRenameTarget::Project(project_id) => {+ crate::project_sessions::rename_project(&project_id, title);+ }+ InlineTabRenameTarget::ProjectSession(session_id) => {+ crate::project_sessions::rename_session(&session_id, title);+ }}}@@ -2789,7 +2795,9 @@ impl TermWindow {.as_ref().and_then(|rename| match rename.target {InlineTabRenameTarget::WindowTab(tab_id) => Some(tab_id),- InlineTabRenameTarget::PaneTab(_) => None,+ InlineTabRenameTarget::PaneTab(_)+ | InlineTabRenameTarget::Project(_)+ | InlineTabRenameTarget::ProjectSession(_) => None,})}@@ -2815,6 +2823,28 @@ impl TermWindow {)}+ pub fn sidebar_project_title(&self, project_id: &str, name: &str) -> String {+ self.inline_tab_rename+ .as_ref()+ .filter(|rename| matches!(&rename.target, InlineTabRenameTarget::Project(id) if id == project_id))+ .map(|rename| rename.display_text())+ .unwrap_or_else(|| name.to_string())+ }++ pub fn sidebar_session_title(&self, session_id: &str, name: &str) -> String {+ self.inline_tab_rename+ .as_ref()+ .filter(|rename| matches!(&rename.target, InlineTabRenameTarget::ProjectSession(id) if id == session_id))+ .map(|rename| rename.display_text())+ .unwrap_or_else(|| name.to_string())+ }++ pub fn is_renaming_sidebar_session(&self, session_id: &str) -> bool {+ self.inline_tab_rename.as_ref().is_some_and(+ |rename| matches!(&rename.target, InlineTabRenameTarget::ProjectSession(id) if id == session_id),+ )+ }+fn show_confirmation(&mut self, args: &Confirmation) {let mux = Mux::get();let tab = match mux.get_active_tab_for_window(self.mux_window_id) {@@ -3272,9 +3302,42 @@ impl TermWindow {ShowTabNavigator => self.show_tab_navigator(),PromptRenameTab => self.prompt_rename_current_tab(),PromptRenamePaneTab(pane_id) => self.prompt_rename_pane_tab(*pane_id),+ PromptRenameProject(project_id) => self.prompt_rename_project(project_id.clone()),PromptRenameProjectSession(session_id) => {self.prompt_rename_project_session(session_id.clone())}+ CreateProjectSession(project_id) => {+ let session_id = crate::project_sessions::create_session(project_id, None);+ if let Some(window) = window.as_ref() {+ self.activate_project_session(session_id, window);+ }+ }+ ToggleProjectSessionsCollapsed(project_id) => {+ crate::project_sessions::toggle_project_sessions_collapsed(project_id);+ if let Some(window) = window.as_ref() {+ window.invalidate();+ }+ }+ RemoveProject(project_id) => {+ if let Some(removed) = crate::project_sessions::remove_project(project_id) {+ if removed.was_active {+ if let (Some(next_session_id), Some(window)) =+ (removed.next_session_id, window.as_ref())+ {+ self.activate_project_session(next_session_id, window);+ }+ }+ let mux = Mux::get();+ for workspace in removed.materialized_workspace_names {+ for window_id in mux.iter_windows_in_workspace(&workspace) {+ mux.kill_window(window_id);+ }+ }+ if let Some(window) = window.as_ref() {+ window.invalidate();+ }+ }+ }ToggleProjectSessionPinned(session_id) => {crate::project_sessions::toggle_session_pinned(session_id);if let Some(window) = window.as_ref() {diff --git a/wezterm-gui/src/termwindow/mouseevent.rs b/wezterm-gui/src/termwindow/mouseevent.rsindex 3876006c..5b3c755a 100644--- a/wezterm-gui/src/termwindow/mouseevent.rs+++ b/wezterm-gui/src/termwindow/mouseevent.rs@@ -2,8 +2,11 @@ use crate::frontend::front_end;use crate::tabbar::TabBarItem;use crate::termwindow::ui::pane_nav_bar_height_for_metrics;use crate::termwindow::ui::tokens::{+ MACOS_TRAFFIC_LIGHT_CLEARANCE_WIDTH, MACOS_WINDOW_TAB_RESERVED_ACTION_SLOTS,PANE_NAV_BUTTON_GAP, PANE_NAV_INSET, PANE_NAV_TAB_GAP, TAB_ROW_START_PADDING,- TAB_VERTICAL_PADDING, WINDOW_TAB_ACTION_RESERVED_WIDTH, WINDOW_TAB_GAP,+ TAB_VERTICAL_PADDING, WINDOW_TAB_ACTION_RESERVED_WIDTH,+ WINDOW_TAB_FULLSCREEN_SIDEBAR_BUTTON_SIZE, WINDOW_TAB_FULLSCREEN_SIDEBAR_BUTTON_X,+ WINDOW_TAB_GAP, WINDOW_TAB_LEADING_ACTION_BUTTON_SIZE, WINDOW_TAB_LEADING_ACTION_GAP,};use crate::termwindow::{GuiWin, MouseCapture, PaneNavAction, PositionedSplit, ScrollHit, TabWheelSurface,@@ -65,12 +68,70 @@ impl super::TermWindow {.ceil()}+ pub(super) fn window_tab_leading_action_slot_count(&self) -> usize {+ if !self.config.use_fancy_tab_bar || self.workspace_sidebar_width() > 0 {+ return 0;+ }++ if self.window_state.contains(WindowState::FULL_SCREEN) {+ return 1;+ }++ if cfg!(target_os = "macos") {+ return MACOS_WINDOW_TAB_RESERVED_ACTION_SLOTS;+ }++ 0+ }++ pub(super) fn window_tab_shows_sidebar_toggle_action(&self) -> bool {+ self.config.use_fancy_tab_bar+ && self.workspace_sidebar_width() == 0+ && self.window_state.contains(WindowState::FULL_SCREEN)+ }++ pub(super) fn window_tab_leading_action_start_pixels(&self) -> f32 {+ if self.window_tab_leading_action_slot_count() == 0 {+ 0.0+ } else if self.window_state.contains(WindowState::FULL_SCREEN) {+ WINDOW_TAB_FULLSCREEN_SIDEBAR_BUTTON_X as f32+ } else if cfg!(target_os = "macos") {+ MACOS_TRAFFIC_LIGHT_CLEARANCE_WIDTH as f32+ } else {+ 0.0+ }+ }++ pub(super) fn window_tab_leading_action_area_width_pixels(&self) -> f32 {+ let count = self.window_tab_leading_action_slot_count();+ if count == 0 {+ 0.0+ } else {+ let button_size = if self.window_tab_shows_sidebar_toggle_action() {+ WINDOW_TAB_FULLSCREEN_SIDEBAR_BUTTON_SIZE+ } else {+ WINDOW_TAB_LEADING_ACTION_BUTTON_SIZE+ };+ (count * (button_size + WINDOW_TAB_LEADING_ACTION_GAP)) as f32+ }+ }+pub(super) fn window_tab_left_padding_pixels(&self) -> f32 {if self.workspace_sidebar_width() > 0 {return 0.0;}let cell_width = self.render_metrics.cell_size.width.max(1) as f32;+ let leading_action_slot_count = self.window_tab_leading_action_slot_count();+ let leading_action_padding = if leading_action_slot_count > 0 {+ self.window_tab_leading_action_start_pixels()+ + self.window_tab_leading_action_area_width_pixels()+ } else {+ 0.0+ };+ if cfg!(target_os = "macos") && !self.window_state.contains(WindowState::FULL_SCREEN) {+ return leading_action_padding.max(MACOS_TRAFFIC_LIGHT_CLEARANCE_WIDTH as f32);+ }if self.config.window_decorations@@ -84,15 +145,15 @@ impl super::TermWindow {== window::IntegratedTitleButtonStyle::MacOsNative{if self.window_state.contains(WindowState::FULL_SCREEN) {- cell_width * 0.5+ leading_action_padding + cell_width * 0.5} else {70.0}} else {- 0.0+ leading_action_padding}} else {- cell_width * 0.5+ leading_action_padding + cell_width * 0.5}}@@ -506,12 +567,15 @@ impl super::TermWindow {| UIItemType::ProjectToggleSessions(_)| UIItemType::Project(_)| UIItemType::ProjectSession(_)- | UIItemType::ProjectSessionArchive(_)+ | UIItemType::ProjectSessionPin(_)+ | UIItemType::ProjectSessionDelete(_)| UIItemType::ProjectSessionNew(_)+ | UIItemType::WorkspaceSidebarToggle| UIItemType::WorkspaceSidebarScrollTrack| UIItemType::WorkspaceSidebarScrollThumb| UIItemType::WorkspaceSidebarBackground| UIItemType::WorkspaceSidebarResize+ | UIItemType::WorkspaceSidebarSettings| UIItemType::AboveScrollThumb| UIItemType::BelowScrollThumb| UIItemType::ScrollThumb@@ -528,12 +592,15 @@ impl super::TermWindow {| UIItemType::ProjectToggleSessions(_)| UIItemType::Project(_)| UIItemType::ProjectSession(_)- | UIItemType::ProjectSessionArchive(_)+ | UIItemType::ProjectSessionPin(_)+ | UIItemType::ProjectSessionDelete(_)| UIItemType::ProjectSessionNew(_)+ | UIItemType::WorkspaceSidebarToggle| UIItemType::WorkspaceSidebarScrollTrack| UIItemType::WorkspaceSidebarScrollThumb| UIItemType::WorkspaceSidebarBackground| UIItemType::WorkspaceSidebarResize+ | UIItemType::WorkspaceSidebarSettings| UIItemType::AboveScrollThumb| UIItemType::BelowScrollThumb| UIItemType::ScrollThumb@@ -1013,12 +1080,18 @@ impl super::TermWindow {UIItemType::ProjectSession(session_id) => {self.mouse_event_project_session(session_id, event, context);}- UIItemType::ProjectSessionArchive(session_id) => {- self.mouse_event_project_session_archive(session_id, event, context);+ UIItemType::ProjectSessionPin(session_id) => {+ self.mouse_event_project_session_pin(session_id, event, context);+ }+ UIItemType::ProjectSessionDelete(session_id) => {+ self.mouse_event_project_session_delete(session_id, event, context);}UIItemType::ProjectSessionNew(project_id) => {self.mouse_event_project_session_new(project_id, event, context);}+ UIItemType::WorkspaceSidebarToggle => {+ self.mouse_event_workspace_sidebar_toggle(event, context);+ }UIItemType::WorkspaceSidebarBackground => {context.set_cursor(Some(MouseCursor::Arrow));}@@ -1031,6 +1104,9 @@ impl super::TermWindow {UIItemType::WorkspaceSidebarResize => {self.mouse_event_workspace_sidebar_resize(item, event, context);}+ UIItemType::WorkspaceSidebarSettings => {+ self.mouse_event_workspace_sidebar_settings(event, context);+ }}}@@ -1054,6 +1130,29 @@ impl super::TermWindow {}}+ pub fn mouse_event_workspace_sidebar_toggle(+ &mut self,+ event: MouseEvent,+ context: &dyn WindowOps,+ ) {+ context.set_cursor(Some(MouseCursor::Hand));+ if event.kind == WMEK::Press(MousePress::Left) {+ self.toggle_workspace_sidebar();+ self.reflow_workspace_sidebar(context);+ }+ }++ pub fn mouse_event_workspace_sidebar_settings(+ &mut self,+ event: MouseEvent,+ context: &dyn WindowOps,+ ) {+ context.set_cursor(Some(MouseCursor::Hand));+ if event.kind == WMEK::Press(MousePress::Left) {+ crate::settings_window::show();+ }+ }+pub fn mouse_event_workspace_sidebar_scroll_thumb(&mut self,item: UIItem,@@ -1111,14 +1210,16 @@ impl super::TermWindow {event: MouseEvent,context: &dyn WindowOps,) {- if let WMEK::Press(MousePress::Left) = event.kind {- if let Some(session_id) =- crate::project_sessions::active_session_for_project(&project_id)- {- self.activate_project_session(session_id, context);- } else {+ match event.kind {+ WMEK::Press(MousePress::Left) => {+ crate::project_sessions::toggle_project_sessions_collapsed(&project_id);context.invalidate();}+ WMEK::Press(MousePress::Right) => {+ context+ .show_context_menu(event.coords, self.project_context_menu_items(&project_id));+ }+ _ => {}}context.set_cursor(Some(MouseCursor::Arrow));}@@ -1129,9 +1230,16 @@ impl super::TermWindow {event: MouseEvent,context: &dyn WindowOps,) {- if let WMEK::Press(MousePress::Left) = event.kind {- crate::project_sessions::toggle_project_sessions_collapsed(&project_id);- context.invalidate();+ match event.kind {+ WMEK::Press(MousePress::Left) => {+ crate::project_sessions::toggle_project_sessions_collapsed(&project_id);+ context.invalidate();+ }+ WMEK::Press(MousePress::Right) => {+ context+ .show_context_menu(event.coords, self.project_context_menu_items(&project_id));+ }+ _ => {}}context.set_cursor(Some(MouseCursor::Arrow));}@@ -1157,25 +1265,99 @@ impl super::TermWindow {context.set_cursor(Some(MouseCursor::Arrow));}- pub fn mouse_event_project_session_archive(+ pub fn mouse_event_project_session_pin(&mut self,session_id: String,event: MouseEvent,context: &dyn WindowOps,) {- if let WMEK::Press(MousePress::Left) = event.kind {- if crate::project_sessions::archive_session(&session_id) {+ match event.kind {+ WMEK::Press(MousePress::Left) => {+ crate::project_sessions::toggle_session_pinned(&session_id);context.invalidate();}+ WMEK::Press(MousePress::Right) => {+ context.show_context_menu(+ event.coords,+ self.project_session_context_menu_items(&session_id),+ );+ }+ _ => {}+ }+ context.set_cursor(Some(MouseCursor::Arrow));+ }++ pub fn mouse_event_project_session_delete(+ &mut self,+ session_id: String,+ event: MouseEvent,+ context: &dyn WindowOps,+ ) {+ match event.kind {+ WMEK::Press(MousePress::Left) => {+ if let Some(deleted) = crate::project_sessions::delete_session(&session_id) {+ if deleted.was_active {+ if let Some(next_session_id) = deleted.next_session_id {+ self.activate_project_session(next_session_id, context);+ }+ } else if let Some(workspace) = deleted.materialized_workspace_name {+ let mux = Mux::get();+ for window_id in mux.iter_windows_in_workspace(&workspace) {+ mux.kill_window(window_id);+ }+ }+ context.invalidate();+ }+ }+ WMEK::Press(MousePress::Right) => {+ context.show_context_menu(+ event.coords,+ self.project_session_context_menu_items(&session_id),+ );+ }+ _ => {}}context.set_cursor(Some(MouseCursor::Arrow));}+ fn project_context_menu_items(&self, project_id: &str) -> Vec<ContextMenuItem> {+ let project_id = project_id.to_string();+ vec![+ ContextMenuItem::item_with_icon(+ "Rename Workspace...",+ "pencil",+ KeyAssignment::PromptRenameProject(project_id.clone()),+ ),+ ContextMenuItem::item_with_icon(+ "New Session",+ "plus.square",+ KeyAssignment::CreateProjectSession(project_id.clone()),+ ),+ ContextMenuItem::item_with_icon(+ "Collapse / Expand Sessions",+ "chevron.right",+ KeyAssignment::ToggleProjectSessionsCollapsed(project_id.clone()),+ ),+ ContextMenuItem::Separator,+ ContextMenuItem::item_with_icon(+ "Remove Workspace",+ "folder.badge.minus",+ KeyAssignment::RemoveProject(project_id),+ ),+ ]+ }+fn project_session_context_menu_items(&self, session_id: &str) -> Vec<ContextMenuItem> {let session_id = session_id.to_string();+ let is_pinned = crate::project_sessions::session_is_pinned(&session_id);vec![- ContextMenuItem::item(- "Pin Session",+ ContextMenuItem::item_with_icon(+ if is_pinned {+ "Unpin Session"+ } else {+ "Pin Session"+ },+ if is_pinned { "pin.slash" } else { "pin" },KeyAssignment::ToggleProjectSessionPinned(session_id.clone()),),ContextMenuItem::item_with_icon(@@ -1183,23 +1365,26 @@ impl super::TermWindow {"pencil",KeyAssignment::PromptRenameProjectSession(session_id.clone()),),- ContextMenuItem::item(+ ContextMenuItem::item_with_icon("Archive Session",+ "archivebox",KeyAssignment::ArchiveProjectSession(session_id.clone()),),- ContextMenuItem::item(+ ContextMenuItem::item_with_icon("Delete Session",+ "trash",KeyAssignment::DeleteProjectSession(session_id.clone()),),- ContextMenuItem::item(+ ContextMenuItem::item_with_icon("Mark as Unread",+ "envelope.badge",KeyAssignment::MarkProjectSessionUnread(session_id),),]}pub(crate) fn activate_project_session(&mut self, session_id: String, context: &dyn WindowOps) {- crate::project_sessions::snapshot_active_session_layout(self.mux_window_id);+ self.snapshot_active_project_session_layout();let mux = Mux::get();let live_workspaces = mux.iter_workspaces();diff --git a/wezterm-gui/src/termwindow/render/borders.rs b/wezterm-gui/src/termwindow/render/borders.rsindex 8d7c43cb..68e66d54 100644--- a/wezterm-gui/src/termwindow/render/borders.rs+++ b/wezterm-gui/src/termwindow/render/borders.rs@@ -1,4 +1,5 @@use crate::quad::TripleLayerQuadAllocator;+use crate::ui::UiPalette;use crate::utilsprites::RenderMetrics;use ::window::ULength;use config::{ConfigHandle, DimensionContext};@@ -17,60 +18,75 @@ impl crate::TermWindow {{let height = self.dimensions.pixel_height as f32;let width = self.dimensions.pixel_width as f32;+ let chrome_border_color = self.config.use_fancy_tab_bar.then(|| {+ UiPalette::for_appearance(crate::native_settings::effective_appearance()).sidebar_bg+ });let border_top = border_dimensions.top.get() as f32;if border_top > 0.0 {- self.filled_rectangle(- layers,- 1,- euclid::rect(0.0, 0.0, width, border_top),+ let top_color = chrome_border_color.unwrap_or_else(|| {self.config.window_frame.border_top_color.map(|c| c.to_linear())- .unwrap_or(border_dimensions.color),+ .unwrap_or(border_dimensions.color)+ });+ self.filled_rectangle(+ layers,+ 1,+ euclid::rect(0.0, 0.0, width, border_top),+ top_color,)?;}let border_left = border_dimensions.left.get() as f32;if border_left > 0.0 {- self.filled_rectangle(- layers,- 1,- euclid::rect(0.0, 0.0, border_left, height),+ let left_color = chrome_border_color.unwrap_or_else(|| {self.config.window_frame.border_left_color.map(|c| c.to_linear())- .unwrap_or(border_dimensions.color),+ .unwrap_or(border_dimensions.color)+ });+ self.filled_rectangle(+ layers,+ 1,+ euclid::rect(0.0, 0.0, border_left, height),+ left_color,)?;}let border_bottom = border_dimensions.bottom.get() as f32;if border_bottom > 0.0 {- self.filled_rectangle(- layers,- 1,- euclid::rect(0.0, height - border_bottom, width, height),+ let bottom_color = chrome_border_color.unwrap_or_else(|| {self.config.window_frame.border_bottom_color.map(|c| c.to_linear())- .unwrap_or(border_dimensions.color),+ .unwrap_or(border_dimensions.color)+ });+ self.filled_rectangle(+ layers,+ 1,+ euclid::rect(0.0, height - border_bottom, width, height),+ bottom_color,)?;}let border_right = border_dimensions.right.get() as f32;if border_right > 0.0 {- self.filled_rectangle(- layers,- 1,- euclid::rect(width - border_right, 0.0, border_right, height),+ let right_color = chrome_border_color.unwrap_or_else(|| {self.config.window_frame.border_right_color.map(|c| c.to_linear())- .unwrap_or(border_dimensions.color),+ .unwrap_or(border_dimensions.color)+ });+ self.filled_rectangle(+ layers,+ 1,+ euclid::rect(width - border_right, 0.0, border_right, height),+ right_color,)?;}}diff --git a/wezterm-gui/src/termwindow/render/draw.rs b/wezterm-gui/src/termwindow/render/draw.rsindex e190b650..4c622260 100644--- a/wezterm-gui/src/termwindow/render/draw.rs+++ b/wezterm-gui/src/termwindow/render/draw.rs@@ -1,5 +1,6 @@use crate::colorease::ColorEaseUniform;-use crate::termwindow::webgpu::ShaderUniform;+use crate::renderstate::RenderState;+use crate::termwindow::webgpu::{ShaderUniform, WebGpuState, WebGpuTexture};use crate::termwindow::RenderFrame;use crate::uniforms::UniformBuilder;use ::window::glium;@@ -7,8 +8,139 @@ use ::window::glium::uniforms::{MagnifySamplerFilter, MinifySamplerFilter, Sampler, SamplerWrapFunction,};use ::window::glium::{BlendingFunction, LinearBlendingFactor, Surface};+use ::window::Dimensions;use config::FreeTypeLoadTarget;+pub(crate) fn draw_webgpu_layers(+ webgpu: &WebGpuState,+ render_state: &RenderState,+ dimensions: Dimensions,+ foreground_text_hsb: [f32; 3],+ milliseconds: u32,+ clear_color: wgpu::Color,+) -> anyhow::Result<()> {+ let acquire_start = crate::perf::now();+ let output = webgpu.surface.get_current_texture()?;+ crate::perf::log_duration("webgpu_surface_acquire", acquire_start);+ let view = output+ .texture+ .create_view(&wgpu::TextureViewDescriptor::default());+ let mut encoder = webgpu+ .device+ .create_command_encoder(&wgpu::CommandEncoderDescriptor {+ label: Some("Render Encoder"),+ });+ let tex = render_state.glyph_cache.borrow().atlas.texture();+ let tex = tex.downcast_ref::<WebGpuTexture>().unwrap();+ let texture_view = tex.create_view(&wgpu::TextureViewDescriptor::default());++ let texture_linear_bind_group = webgpu.device.create_bind_group(&wgpu::BindGroupDescriptor {+ layout: &webgpu.texture_bind_group_layout,+ entries: &[+ wgpu::BindGroupEntry {+ binding: 0,+ resource: wgpu::BindingResource::TextureView(&texture_view),+ },+ wgpu::BindGroupEntry {+ binding: 1,+ resource: wgpu::BindingResource::Sampler(&webgpu.texture_linear_sampler),+ },+ ],+ label: Some("linear bind group"),+ });++ let texture_nearest_bind_group = webgpu.device.create_bind_group(&wgpu::BindGroupDescriptor {+ layout: &webgpu.texture_bind_group_layout,+ entries: &[+ wgpu::BindGroupEntry {+ binding: 0,+ resource: wgpu::BindingResource::TextureView(&texture_view),+ },+ wgpu::BindGroupEntry {+ binding: 1,+ resource: wgpu::BindingResource::Sampler(&webgpu.texture_nearest_sampler),+ },+ ],+ label: Some("nearest bind group"),+ });++ let projection = euclid::Transform3D::<f32, f32, f32>::ortho(+ -(dimensions.pixel_width as f32) / 2.0,+ dimensions.pixel_width as f32 / 2.0,+ dimensions.pixel_height as f32 / 2.0,+ -(dimensions.pixel_height as f32) / 2.0,+ -1.0,+ 1.0,+ )+ .to_arrays_transposed();++ let mut cleared = false;+ let mut draw_calls = 0usize;+ let mut vertices_total = 0usize;+ let draw_start = crate::perf::now();+ for layer in render_state.layers.borrow().iter() {+ for idx in 0..3 {+ let vb = &layer.vb.borrow()[idx];+ let (vertex_count, index_count) = vb.vertex_index_count();+ let vertex_buffer;+ let uniforms;+ if vertex_count > 0 {+ let mut vertices = vb.current_vb_mut();+ let mut render_pass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor {+ label: Some("Render Pass"),+ color_attachments: &[Some(wgpu::RenderPassColorAttachment {+ view: &view,+ resolve_target: None,+ ops: wgpu::Operations {+ load: if cleared {+ wgpu::LoadOp::Load+ } else {+ wgpu::LoadOp::Clear(clear_color)+ },+ store: wgpu::StoreOp::Store,+ },+ })],+ depth_stencil_attachment: None,+ occlusion_query_set: None,+ timestamp_writes: None,+ });+ cleared = true;++ uniforms = webgpu.create_uniform(ShaderUniform {+ foreground_text_hsb,+ milliseconds,+ projection,+ });++ render_pass.set_pipeline(&webgpu.render_pipeline);+ render_pass.set_bind_group(0, &uniforms, &[]);+ render_pass.set_bind_group(1, &texture_linear_bind_group, &[]);+ render_pass.set_bind_group(2, &texture_nearest_bind_group, &[]);+ vertex_buffer = vertices.webgpu_mut().recreate();+ vertex_buffer.unmap();+ render_pass.set_vertex_buffer(0, vertex_buffer.slice(..));+ render_pass+ .set_index_buffer(vb.indices.webgpu().slice(..), wgpu::IndexFormat::Uint32);+ render_pass.draw_indexed(0..index_count as _, 0, 0..1);+ draw_calls += 1;+ vertices_total += vertex_count;+ }++ vb.next_index();+ }+ }++ crate::perf::log_duration("webgpu_encode", draw_start);+ crate::perf::log_counter("webgpu_draw_calls", draw_calls);+ crate::perf::log_counter("webgpu_vertices", vertices_total);+ let submit_start = crate::perf::now();+ webgpu.queue.submit(std::iter::once(encoder.finish()));+ output.present();+ crate::perf::log_duration("webgpu_submit_present", submit_start);++ Ok(())+}+impl crate::TermWindow {pub fn call_draw(&mut self, frame: &mut RenderFrame) -> anyhow::Result<()> {match frame {@@ -18,57 +150,8 @@ impl crate::TermWindow {}fn call_draw_webgpu(&mut self) -> anyhow::Result<()> {- use crate::termwindow::webgpu::WebGpuTexture;-let webgpu = self.webgpu.as_mut().unwrap();let render_state = self.render_state.as_ref().unwrap();-- let output = webgpu.surface.get_current_texture()?;- let view = output- .texture- .create_view(&wgpu::TextureViewDescriptor::default());- let mut encoder = webgpu- .device- .create_command_encoder(&wgpu::CommandEncoderDescriptor {- label: Some("Render Encoder"),- });- let tex = render_state.glyph_cache.borrow().atlas.texture();- let tex = tex.downcast_ref::<WebGpuTexture>().unwrap();- let texture_view = tex.create_view(&wgpu::TextureViewDescriptor::default());-- let texture_linear_bind_group =- webgpu.device.create_bind_group(&wgpu::BindGroupDescriptor {- layout: &webgpu.texture_bind_group_layout,- entries: &[- wgpu::BindGroupEntry {- binding: 0,- resource: wgpu::BindingResource::TextureView(&texture_view),- },- wgpu::BindGroupEntry {- binding: 1,- resource: wgpu::BindingResource::Sampler(&webgpu.texture_linear_sampler),- },- ],- label: Some("linear bind group"),- });-- let texture_nearest_bind_group =- webgpu.device.create_bind_group(&wgpu::BindGroupDescriptor {- layout: &webgpu.texture_bind_group_layout,- entries: &[- wgpu::BindGroupEntry {- binding: 0,- resource: wgpu::BindingResource::TextureView(&texture_view),- },- wgpu::BindGroupEntry {- binding: 1,- resource: wgpu::BindingResource::Sampler(&webgpu.texture_nearest_sampler),- },- ],- label: Some("nearest bind group"),- });-- let mut cleared = false;let foreground_text_hsb = self.config.foreground_text_hsb;let foreground_text_hsb = [foreground_text_hsb.hue,@@ -77,76 +160,19 @@ impl crate::TermWindow {];let milliseconds = self.created.elapsed().as_millis() as u32;- let projection = euclid::Transform3D::<f32, f32, f32>::ortho(- -(self.dimensions.pixel_width as f32) / 2.0,- self.dimensions.pixel_width as f32 / 2.0,- self.dimensions.pixel_height as f32 / 2.0,- -(self.dimensions.pixel_height as f32) / 2.0,- -1.0,- 1.0,+ draw_webgpu_layers(+ webgpu,+ render_state,+ self.dimensions,+ foreground_text_hsb,+ milliseconds,+ wgpu::Color {+ r: 0.,+ g: 0.,+ b: 0.,+ a: 0.,+ },)- .to_arrays_transposed();-- for layer in render_state.layers.borrow().iter() {- for idx in 0..3 {- let vb = &layer.vb.borrow()[idx];- let (vertex_count, index_count) = vb.vertex_index_count();- let vertex_buffer;- let uniforms;- if vertex_count > 0 {- let mut vertices = vb.current_vb_mut();- let mut render_pass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor {- label: Some("Render Pass"),- color_attachments: &[Some(wgpu::RenderPassColorAttachment {- view: &view,- resolve_target: None,- ops: wgpu::Operations {- load: if cleared {- wgpu::LoadOp::Load- } else {- wgpu::LoadOp::Clear(wgpu::Color {- r: 0.,- g: 0.,- b: 0.,- a: 0.,- })- },- store: wgpu::StoreOp::Store,- },- })],- depth_stencil_attachment: None,- occlusion_query_set: None,- timestamp_writes: None,- });- cleared = true;-- uniforms = webgpu.create_uniform(ShaderUniform {- foreground_text_hsb,- milliseconds,- projection,- });-- render_pass.set_pipeline(&webgpu.render_pipeline);- render_pass.set_bind_group(0, &uniforms, &[]);- render_pass.set_bind_group(1, &texture_linear_bind_group, &[]);- render_pass.set_bind_group(2, &texture_nearest_bind_group, &[]);- vertex_buffer = vertices.webgpu_mut().recreate();- vertex_buffer.unmap();- render_pass.set_vertex_buffer(0, vertex_buffer.slice(..));- render_pass- .set_index_buffer(vb.indices.webgpu().slice(..), wgpu::IndexFormat::Uint32);- render_pass.draw_indexed(0..index_count as _, 0, 0..1);- }-- vb.next_index();- }- }-- // submit will accept anything that implements IntoIter- webgpu.queue.submit(std::iter::once(encoder.finish()));- output.present();-- Ok(())}fn call_draw_glium(&mut self, frame: &mut glium::Frame) -> anyhow::Result<()> {diff --git a/wezterm-gui/src/termwindow/render/fancy_tab_bar.rs b/wezterm-gui/src/termwindow/render/fancy_tab_bar.rsindex 935e3c91..5eea5f37 100644--- a/wezterm-gui/src/termwindow/render/fancy_tab_bar.rs+++ b/wezterm-gui/src/termwindow/render/fancy_tab_bar.rs@@ -3,11 +3,15 @@ use crate::quad::{QuadTrait, TripleLayerQuadAllocator, TripleLayerQuadAllocatorTuse crate::tabbar::{TabBarItem, TabEntry};use crate::termwindow::ui::icons::SvgIcon;use crate::termwindow::ui::tokens::{- active_capsule_bg, capsule_border, CAPSULE_BORDER_WIDTH, TAB_CLOSE_HOVER_INSET,- TAB_CLOSE_HOVER_RADIUS, TAB_CLOSE_RIGHT_GAP, TAB_ROW_START_PADDING, TAB_VERTICAL_PADDING,- WINDOW_TAB_ACTION_RESERVED_WIDTH, WINDOW_TAB_GAP, WINDOW_TAB_RADIUS,+ CAPSULE_BORDER_WIDTH, SIDEBAR_INSET, TAB_CLOSE_HOVER_INSET, TAB_CLOSE_HOVER_RADIUS,+ TAB_CLOSE_RIGHT_GAP, TAB_ROW_START_PADDING, TAB_VERTICAL_PADDING,+ WINDOW_TAB_ACTION_RESERVED_WIDTH, WINDOW_TAB_FULLSCREEN_SIDEBAR_BUTTON_SIZE,+ WINDOW_TAB_FULLSCREEN_SIDEBAR_ICON_SIZE, WINDOW_TAB_GAP, WINDOW_TAB_LEADING_ACTION_BUTTON_SIZE,+ WINDOW_TAB_LEADING_ACTION_GAP, WINDOW_TAB_LEADING_ACTION_ICON_SIZE, WINDOW_TAB_RADIUS,+ WINDOW_TAB_TOP_SPACER,};use crate::termwindow::{TermWindowNotif, UIItem, UIItemType};+use crate::ui::UiPalette;use crate::utilsprites::RenderMetrics;use anyhow::Context;use finl_unicode::grapheme_clusters::Graphemes;@@ -15,7 +19,6 @@ use std::rc::Rc;use termwiz::cell::grapheme_column_width;use wezterm_bidi::Direction;use wezterm_font::LoadedFont;-use wezterm_term::color::{ColorAttribute, ColorPalette};use wezterm_term::Line;use window::color::LinearRgba;use window::WindowOps;@@ -33,26 +36,21 @@ impl crate::TermWindow {&mut self,layers: &mut TripleLayerQuadAllocator,) -> anyhow::Result<Vec<UIItem>> {- let palette = self.palette().clone();+ let chrome = UiPalette::for_appearance(crate::native_settings::effective_appearance());let row_height = self.tab_bar_pixel_height()?.ceil() as usize;if row_height == 0 {return Ok(vec![]);}- let font = self.fonts.title_font()?;+ let font = self+ .fonts+ .title_font_with_size(crate::native_settings::tab_font_size())?;let metrics = RenderMetrics::with_font_metrics(&font.metrics());- let icon_size = fancy_tab_icon_size(&metrics, row_height as f32) as usize;- let button_size = row_height- .saturating_sub(TAB_VERTICAL_PADDING * 2)- .max(icon_size);let tab_width = self.window_tab_width_pixels().ceil() as usize;- let background = palette- .resolve_bg(ColorAttribute::Default)- .to_linear()- .mul_alpha(self.config.window_background_opacity);- let foreground = palette.foreground.to_linear();- let muted_fg = foreground.mul_alpha(0.66);+ let background = chrome.sidebar_bg;+ let foreground = chrome.text;+ let muted_fg = chrome.secondary_text;let border = self.get_os_border();let row_x = self.tab_bar_left_edge();@@ -63,6 +61,17 @@ impl crate::TermWindow {} else {border.top.get() as usize};+ let content_top_spacer = if self.config.tab_bar_at_bottom {+ 0+ } else {+ 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 = fancy_tab_icon_size(&metrics, content_row_height as f32) as usize;+ let button_size = content_row_height+ .saturating_sub(TAB_VERTICAL_PADDING * 2)+ .max(icon_size);let row_width = self.dimensions.pixel_width@@ -86,6 +95,7 @@ impl crate::TermWindow {background,).context("fancy tab bar background")?;+let mut ui_items = vec![UIItem {x: row_x,y: row_y,@@ -94,6 +104,34 @@ impl crate::TermWindow {item_type: UIItemType::TabBar(TabBarItem::None),}];+ self.paint_window_tab_leading_actions(+ layers,+ &mut ui_items,+ row_x,+ content_row_y,+ content_row_height,+ foreground,+ muted_fg,+ )?;++ let show_pane_layer_divider = mux::Mux::get()+ .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+ };+ self.filled_rectangle(+ layers,+ 1,+ euclid::rect(row_x as f32, divider_y as f32, row_width as f32, 1.0),+ foreground.mul_alpha(0.14),+ )+ .context("fancy tab bar pane layer divider")?;+ }+if viewport_width == 0 || tab_width == 0 {return Ok(ui_items);}@@ -141,14 +179,14 @@ impl crate::TermWindow {visible_width,viewport_left,viewport_right,- row_y,- row_height,+ content_row_y,+ content_row_height,tab_width,button_size,icon_size,&font,metrics,- &palette,+ chrome,background,if active { foreground } else { muted_fg },)?;@@ -158,8 +196,8 @@ impl crate::TermWindow {layers,&mut ui_items,row_right,- row_y,- row_height,+ content_row_y,+ content_row_height,button_size,icon_size,foreground,@@ -169,6 +207,121 @@ impl crate::TermWindow {Ok(ui_items)}+ #[allow(clippy::too_many_arguments)]+ fn paint_window_tab_leading_actions(+ &self,+ layers: &mut TripleLayerQuadAllocator,+ ui_items: &mut Vec<UIItem>,+ row_x: usize,+ row_y: usize,+ row_height: usize,+ foreground: LinearRgba,+ muted_fg: LinearRgba,+ ) -> anyhow::Result<()> {+ let action_slot_count = self.window_tab_leading_action_slot_count();+ if action_slot_count == 0 {+ return Ok(());+ }++ let mut button_x = row_x + self.window_tab_leading_action_start_pixels().ceil() as usize;+ for action_idx in 0..action_slot_count {+ let is_sidebar_toggle =+ action_idx == 0 && self.window_tab_shows_sidebar_toggle_action();+ let action_button_size = if is_sidebar_toggle {+ WINDOW_TAB_FULLSCREEN_SIDEBAR_BUTTON_SIZE+ } else {+ WINDOW_TAB_LEADING_ACTION_BUTTON_SIZE+ };+ let action_icon_size = if is_sidebar_toggle {+ WINDOW_TAB_FULLSCREEN_SIDEBAR_ICON_SIZE+ } else {+ WINDOW_TAB_LEADING_ACTION_ICON_SIZE+ };+ let button_size = action_button_size.min(row_height.saturating_sub(4)).max(1);+ 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 {+ row_y.saturating_sub(WINDOW_TAB_TOP_SPACER) + SIDEBAR_INSET+ };+ self.paint_window_sidebar_toggle_button(+ layers,+ ui_items,+ button_x,+ button_y,+ button_size,+ icon_size,+ foreground,+ muted_fg,+ )?;+ }+ button_x += action_button_size + WINDOW_TAB_LEADING_ACTION_GAP;+ }++ Ok(())+ }++ #[allow(clippy::too_many_arguments)]+ fn paint_window_sidebar_toggle_button(+ &self,+ layers: &mut TripleLayerQuadAllocator,+ ui_items: &mut Vec<UIItem>,+ button_x: usize,+ button_y: usize,+ button_size: usize,+ icon_size: usize,+ foreground: LinearRgba,+ muted_fg: LinearRgba,+ ) -> anyhow::Result<()> {+ let hovered = self.is_pointer_over_ui_rect(button_x, button_y, button_size, button_size);+ if hovered {+ self.fill_rounded_rectangle(+ layers,+ 1,+ euclid::rect(+ button_x as f32,+ button_y as f32,+ button_size as f32,+ button_size as f32,+ ),+ foreground.mul_alpha(+ if self.is_pointer_pressing_ui_rect(+ button_x,+ button_y,+ button_size,+ button_size,+ ) {+ 0.20+ } else {+ 0.12+ },+ ),+ 6.0,+ )+ .context("window sidebar toggle hover")?;+ }++ ui_items.push(UIItem {+ x: button_x,+ y: button_y,+ width: button_size,+ height: button_size,+ item_type: UIItemType::WorkspaceSidebarToggle,+ });++ let icon_size = icon_size.min(button_size.saturating_sub(2)).max(1);+ self.paint_fancy_tab_icon(+ layers,+ self.workspace_sidebar_toggle_icon(),+ button_x + (button_size.saturating_sub(icon_size) / 2),+ button_y + (button_size.saturating_sub(icon_size) / 2),+ icon_size,+ if hovered { foreground } else { muted_fg },+ )+ }+#[allow(clippy::too_many_arguments)]fn paint_window_tab(&self,@@ -190,7 +343,7 @@ impl crate::TermWindow {icon_size: usize,font: &Rc<LoadedFont>,metrics: RenderMetrics,- palette: &ColorPalette,+ chrome: UiPalette,background: LinearRgba,foreground: LinearRgba,) -> anyhow::Result<()> {@@ -205,13 +358,12 @@ impl crate::TermWindow {let hover_x = visible_left.max(0.0) as usize;let hover_width = visible_width.max(0.0) as usize;let is_hovered = self.is_pointer_over_ui_rect(hover_x, row_y, hover_width, row_height);- let surface_foreground = palette.foreground.to_linear();let tab_surface_color = if active {- active_capsule_bg(background.3)+ chrome.control_bg} else if is_hovered && !is_renaming {- surface_foreground.mul_alpha(0.055)+ chrome.control_hover_bg} else {- surface_foreground.mul_alpha(0.025)+ background};let tab_surface_y = row_y + (row_height.saturating_sub(button_size) / 2);self.fill_rounded_rectangle_with_border(@@ -225,7 +377,7 @@ impl crate::TermWindow {),tab_surface_color,if active {- capsule_border(surface_foreground, true)+ chrome.control_border} else {LinearRgba::TRANSPARENT},@@ -336,10 +488,10 @@ impl crate::TermWindow {text_width.saturating_add(6) as f32,metrics.cell_size.height as f32,),- palette.selection_bg.to_linear(),+ chrome.selected_bg,).context("window tab rename selection")?;- palette.selection_fg.to_linear()+ chrome.selected_text} else {foreground};diff --git a/wezterm-gui/src/termwindow/render/paint.rs b/wezterm-gui/src/termwindow/render/paint.rsindex 7bd9516f..daaa1350 100644--- a/wezterm-gui/src/termwindow/render/paint.rs+++ b/wezterm-gui/src/termwindow/render/paint.rs@@ -1,4 +1,5 @@use crate::termwindow::{RenderFrame, TermWindowNotif};+use crate::ui::UiPalette;use ::window::bitmaps::atlas::OutOfTextureSpace;use ::window::WindowOps;use anyhow::Context;@@ -261,15 +262,28 @@ impl crate::TermWindow {if paint_terminal_background {// Regular window background color- let background = if panes.len() == 1 {+ let background = if matches!(+ crate::native_settings::effective_appearance(),+ window::Appearance::Dark | window::Appearance::DarkHighContrast+ ) {+ UiPalette::for_appearance(crate::native_settings::effective_appearance())+ .sidebar_bg+ .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- panes[0].pane.palette().background+ panes[0]+ .pane+ .palette()+ .background+ .to_linear()+ .mul_alpha(self.config.window_background_opacity)} else {- self.palette().background- }- .to_linear()- .mul_alpha(self.config.window_background_opacity);+ self.palette()+ .background+ .to_linear()+ .mul_alpha(self.config.window_background_opacity)+ };self.filled_rectangle(&mut layers,@@ -285,6 +299,19 @@ impl crate::TermWindow {.context("filled_rectangle for window background")?;}+ let border = self.get_os_border();+ let header_height = border.top.get() as f32;+ if header_height > 0.0 {+ let chrome = UiPalette::for_appearance(crate::native_settings::effective_appearance());+ self.filled_rectangle(+ &mut layers,+ 0,+ euclid::rect(0.0, 0.0, self.dimensions.pixel_width as f32, header_height),+ chrome.sidebar_bg,+ )+ .context("filled_rectangle for chrome header background")?;+ }+for pos in panes {if pos.is_active {self.update_text_cursor(&pos);diff --git a/wezterm-gui/src/termwindow/render/pane.rs b/wezterm-gui/src/termwindow/render/pane.rsindex 30012cc7..99ebf8e0 100644--- a/wezterm-gui/src/termwindow/render/pane.rs+++ b/wezterm-gui/src/termwindow/render/pane.rs@@ -10,11 +10,12 @@ use crate::termwindow::render::{use crate::termwindow::ui::icons::SvgIcon;use crate::termwindow::ui::pane_nav_bar_height_for_metrics;use crate::termwindow::ui::tokens::{- active_capsule_bg, capsule_border, CAPSULE_BORDER_WIDTH, PANE_NAV_BUTTON_GAP,- PANE_NAV_ICON_GAP, PANE_NAV_INSET, PANE_NAV_TAB_GAP, PANE_NAV_TAB_RADIUS,- TAB_CLOSE_HOVER_INSET, TAB_CLOSE_HOVER_RADIUS, TAB_CLOSE_RIGHT_GAP, TAB_VERTICAL_PADDING,+ CAPSULE_BORDER_WIDTH, PANE_NAV_BUTTON_GAP, PANE_NAV_ICON_GAP, PANE_NAV_INSET, PANE_NAV_TAB_GAP,+ PANE_NAV_TAB_RADIUS, PANE_NAV_TAB_TOP_OFFSET, TAB_CLOSE_HOVER_INSET, TAB_CLOSE_HOVER_RADIUS,+ TAB_CLOSE_RIGHT_GAP, TAB_VERTICAL_PADDING,};use crate::termwindow::{PaneNavAction, ScrollHit, UIItem, UIItemType};+use crate::ui::UiPalette;use crate::utilsprites::RenderMetrics;use ::window::bitmaps::TextureRect;use ::window::DeadKeyStatus;@@ -70,7 +71,7 @@ impl crate::TermWindow {&mut self,pos: &PositionedPane,layers: &mut TripleLayerQuadAllocator,- palette: &ColorPalette,+ _palette: &ColorPalette,) -> anyhow::Result<usize> {let nav_height = self.pane_nav_bar_height(pos);if nav_height == 0 {@@ -90,14 +91,20 @@ impl crate::TermWindow {};let pane_width = (content_pane_right - pane_x).max(1.0);- let background = palette- .resolve_bg(ColorAttribute::Default)- .to_linear()- .mul_alpha(self.config.window_background_opacity);- let foreground = palette.foreground.to_linear();- let muted_fg = foreground.mul_alpha(0.66);+ let chrome = UiPalette::for_appearance(crate::native_settings::effective_appearance());+ let background = chrome.sidebar_bg;+ let foreground = chrome.text;+ let muted_fg = chrome.secondary_text;let tab_fg = if pos.is_active { foreground } else { muted_fg };+ self.filled_rectangle(+ layers,+ 0,+ euclid::rect(pane_x, pane_y, pane_width, nav_height as f32),+ background,+ )+ .context("pane nav background")?;+self.ui_items.push(UIItem {x: pane_x.max(0.0) as usize,y: pane_y.max(0.0) as usize,@@ -114,7 +121,9 @@ impl crate::TermWindow {let button_size = nav_height.saturating_sub(TAB_VERTICAL_PADDING * 2).max(icon_size);- let button_y = pane_y as usize + (nav_height.saturating_sub(button_size) / 2);+ let button_y = pane_y as usize+ + (nav_height.saturating_sub(button_size) / 2 + PANE_NAV_TAB_TOP_OFFSET)+ .min(nav_height.saturating_sub(button_size));let mut button_x = (pane_x + pane_width) as usize;for (icon, action) in [(SvgIcon::SplitVertical, PaneNavAction::SplitDown),@@ -187,14 +196,14 @@ impl crate::TermWindow {let is_hovered = !suppress_hover&& self.is_pointer_over_ui_rect(hover_x, tab_y, hover_width, tab_height);let tab_surface_color = if selected_tab {- active_capsule_bg(background.3)+ chrome.control_bg} else if is_hovered && !is_renaming_tab {- foreground.mul_alpha(0.055)+ chrome.control_hover_bg} else {foreground.mul_alpha(0.025)};let tab_border_color = if selected_tab {- capsule_border(foreground, true)+ chrome.control_border} else {LinearRgba::TRANSPARENT};@@ -293,7 +302,10 @@ impl crate::TermWindow {}}- let ui_font = self.fonts.title_font().context("pane nav title font")?;+ let ui_font = self+ .fonts+ .title_font_with_size(crate::native_settings::pane_header_font_size())+ .context("pane nav title font")?;let ui_metrics = RenderMetrics::with_font_metrics(&ui_font.metrics());let text_x = title_icon_x + icon_size + PANE_NAV_ICON_GAP;let text_right = if close_slot_reserved {@@ -318,11 +330,11 @@ impl crate::TermWindow {text_width.saturating_add(6) as f32,ui_metrics.cell_size.height as f32,),- palette.selection_bg.to_linear(),+ chrome.selected_bg,4.0,).context("pane nav rename selection")?;- palette.selection_fg.to_linear()+ chrome.selected_text} else {this_tab_fg};@@ -529,9 +541,15 @@ impl crate::TermWindow {let window_is_transparent =!self.window_background.is_empty() || config.window_background_opacity != 1.0;- let default_bg = palette- .resolve_bg(ColorAttribute::Default)- .to_linear()+ let dark_chrome_background = matches!(+ crate::native_settings::effective_appearance(),+ window::Appearance::Dark | window::Appearance::DarkHighContrast+ )+ .then(|| {+ UiPalette::for_appearance(crate::native_settings::effective_appearance()).sidebar_bg+ });+ let default_bg = dark_chrome_background+ .unwrap_or_else(|| palette.resolve_bg(ColorAttribute::Default).to_linear()).mul_alpha(if window_is_transparent {0.} else {@@ -592,9 +610,8 @@ impl crate::TermWindow {layers,0,background_rect,- palette- .background- .to_linear()+ dark_chrome_background+ .unwrap_or_else(|| palette.background.to_linear()).mul_alpha(config.window_background_opacity),).context("filled_rectangle")?;diff --git a/wezterm-gui/src/termwindow/render/tab_bar.rs b/wezterm-gui/src/termwindow/render/tab_bar.rsindex f66a71da..1ba34fe3 100644--- a/wezterm-gui/src/termwindow/render/tab_bar.rs+++ b/wezterm-gui/src/termwindow/render/tab_bar.rs@@ -2,6 +2,7 @@ use crate::quad::TripleLayerQuadAllocator;use crate::termwindow::render::RenderScreenLineParams;use crate::termwindow::theme_aligned_tab_bar_colors_from_palette;use crate::termwindow::ui::pane_nav_bar_height_for_metrics;+use crate::termwindow::ui::tokens::WINDOW_TAB_TOP_SPACER;use crate::utilsprites::RenderMetrics;use config::ConfigHandle;use mux::renderable::RenderableDimensions;@@ -129,7 +130,7 @@ impl crate::TermWindow {render_metrics: &RenderMetrics,) -> anyhow::Result<f32> {if config.use_fancy_tab_bar {- Ok(pane_nav_bar_height_for_metrics(*render_metrics) as f32)+ Ok((pane_nav_bar_height_for_metrics(*render_metrics) + WINDOW_TAB_TOP_SPACER) as f32)} else {Ok(render_metrics.cell_size.height as f32)}diff --git a/wezterm-gui/src/termwindow/resize.rs b/wezterm-gui/src/termwindow/resize.rsindex 782a96ec..2a39c14c 100644--- a/wezterm-gui/src/termwindow/resize.rs+++ b/wezterm-gui/src/termwindow/resize.rs@@ -3,8 +3,10 @@ use crate::termwindow::ui::pane_nav_bar_height_for_metrics;use crate::utilsprites::RenderMetrics;use ::window::{Dimensions, ResizeIncrement, Window, WindowOps, WindowState};use config::{ConfigHandle, DimensionContext};+use mux::pane::PaneId;use mux::tab::PositionedPane;use mux::Mux;+use std::collections::HashMap;use std::rc::Rc;use wezterm_font::FontConfiguration;use wezterm_term::TerminalSize;@@ -22,6 +24,236 @@ pub enum ScaleChange {}impl super::TermWindow {+ fn normalized_font_scale_value(&self, font_scale: Option<f64>) -> Option<f64> {+ let global_scale = self.fonts.get_font_scale();+ font_scale+ .filter(|scale| scale.is_finite() && *scale > 0.0)+ .filter(|scale| scale.to_bits() != global_scale.to_bits())+ }++ fn persisted_font_scale_for_pane(&self, pane_id: PaneId) -> Option<f64> {+ let font_scale = self+ .pane_state+ .borrow()+ .get(&pane_id)+ .and_then(|state| state.font_scale);+ self.normalized_font_scale_value(font_scale)+ }++ pub(crate) fn snapshot_active_project_session_layout(&self) {+ crate::project_sessions::snapshot_active_session_layout_with_font_scales(+ self.mux_window_id,+ |pane_id| self.persisted_font_scale_for_pane(pane_id),+ );+ }++ fn persist_workspace_pane_font_scales(&self) {+ let mux = Mux::get();+ let Some(window) = mux.get_window(self.mux_window_id) else {+ return;+ };+ crate::project_sessions::snapshot_workspace_layout_with_font_scales(+ window.get_workspace(),+ self.mux_window_id,+ |pane_id| self.persisted_font_scale_for_pane(pane_id),+ );+ }++ fn apply_font_scales_to_mux_window_panes(&mut self, font_scales: HashMap<PaneId, Option<f64>>) {+ let mux = Mux::get();+ let Some(mux_window) = mux.get_window(self.mux_window_id) else {+ return;+ };++ for tab in mux_window.iter() {+ for pos in tab.iter_panes_ignoring_zoom() {+ let pane_id = pos.pane.pane_id();+ let font_scale = self.normalized_font_scale_value(+ font_scales.get(&pane_id).copied().unwrap_or(None),+ );+ let mut state = self.pane_state(pos.pane.pane_id());+ if state.font_scale != font_scale {+ state.font_scale = font_scale;+ }+ }+ }++ self.sync_pane_font_sizes();+ self.quad_generation += 1;+ self.shape_generation += 1;+ self.pane_font_cache.borrow_mut().clear();+ self.shape_cache.borrow_mut().clear();+ self.line_to_ele_shape_cache.borrow_mut().clear();+ self.invalidate_fancy_tab_bar();+ self.invalidate_modal();+ if let Some(window) = self.window.as_ref() {+ window.invalidate();+ }+ }++ pub(crate) fn apply_workspace_session_font_scales(&mut self) {+ let mux = Mux::get();+ let Some(window) = mux.get_window(self.mux_window_id) else {+ return;+ };+ let Some(font_scales) = crate::project_sessions::workspace_pane_font_scales(+ window.get_workspace(),+ self.mux_window_id,+ ) else {+ return;+ };+ self.apply_font_scales_to_mux_window_panes(font_scales);+ }++ pub(crate) fn apply_native_terminal_settings(&mut self) {+ let settings = crate::native_settings::load();+ let Some(font_size) = settings.terminal.font_size else {+ return;+ };+ if !font_size.is_finite() || font_size <= 0.0 || self.config.font_size <= 0.0 {+ return;+ }+ let font_scale = (font_size / self.config.font_size).clamp(0.25, 4.0);+ if let Some(window) = self.window.as_ref().cloned() {+ self.adjust_font_scale(font_scale, &window);+ }+ }++ pub(crate) fn resize_layout_for_dimensions(+ &self,+ dimensions: &Dimensions,+ scale_changed_cells: Option<RowsAndCols>,+ ) -> (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.+ };++ let border = self.get_os_border();++ if let Some(cell_dims) = scale_changed_cells {+ // Scaling preserves existing terminal dimensions, yielding a new+ // overall set of window dimensions+ let size = TerminalSize {+ rows: cell_dims.rows,+ cols: cell_dims.cols,+ pixel_height: cell_dims.rows * self.render_metrics.cell_size.height as usize,+ pixel_width: cell_dims.cols * self.render_metrics.cell_size.width as usize,+ dpi: dimensions.dpi as u32,+ };++ let rows = size.rows;+ let cols = size.cols;++ let h_context = DimensionContext {+ dpi: dimensions.dpi as f32,+ pixel_max: size.pixel_width as f32,+ pixel_cell: self.render_metrics.cell_size.width as f32,+ };+ let v_context = DimensionContext {+ dpi: dimensions.dpi as f32,+ pixel_max: size.pixel_height as f32,+ pixel_cell: self.render_metrics.cell_size.height as f32,+ };+ let padding_left = config.window_padding.left.evaluate_as_pixels(h_context) as usize+ + self.workspace_sidebar_width();+ let padding_top = config.window_padding.top.evaluate_as_pixels(v_context) as usize;+ let padding_bottom =+ config.window_padding.bottom.evaluate_as_pixels(v_context) as usize;+ let padding_right = effective_right_padding(&config, h_context);++ let pixel_height = (rows * self.render_metrics.cell_size.height as usize)+ + (padding_top + padding_bottom)+ + (border.top + border.bottom).get() as usize+ + tab_bar_height as usize;++ let pixel_width = (cols * self.render_metrics.cell_size.width as usize)+ + (padding_left + padding_right)+ + (border.left + border.right).get() as usize;++ let dims = Dimensions {+ pixel_width: pixel_width as usize,+ pixel_height: pixel_height as usize,+ dpi: dimensions.dpi,+ };++ let ri_calc = ResizeIncrementCalculator {+ x: self.render_metrics.cell_size.width as u16,+ y: self.render_metrics.cell_size.height as u16,+ padding_left: padding_left,+ padding_top: padding_top,+ padding_right: padding_right,+ padding_bottom: padding_bottom,+ border: border,+ tab_bar_height: tab_bar_height as usize,+ };++ (size, dims, ri_calc)+ } else {+ // Resize of the window dimensions may result in changed terminal dimensions++ let h_context = DimensionContext {+ dpi: dimensions.dpi as f32,+ pixel_max: self.terminal_size.pixel_width as f32,+ pixel_cell: self.render_metrics.cell_size.width as f32,+ };+ let v_context = DimensionContext {+ dpi: dimensions.dpi as f32,+ pixel_max: self.terminal_size.pixel_height as f32,+ pixel_cell: self.render_metrics.cell_size.height as f32,+ };+ let padding_left = config.window_padding.left.evaluate_as_pixels(h_context) as usize+ + self.workspace_sidebar_width();+ let padding_top = config.window_padding.top.evaluate_as_pixels(v_context) as usize;+ let padding_bottom =+ config.window_padding.bottom.evaluate_as_pixels(v_context) as usize;+ let padding_right = effective_right_padding(&config, h_context);++ let avail_width = dimensions.pixel_width.saturating_sub(+ (padding_left + padding_right) as usize+ + (border.left + border.right).get() as usize,+ );+ let avail_height = dimensions+ .pixel_height+ .saturating_sub(+ (padding_top + padding_bottom) as usize+ + (border.top + border.bottom).get() as usize,+ )+ .saturating_sub(tab_bar_height as usize);++ let rows = avail_height / self.render_metrics.cell_size.height as usize;+ let cols = avail_width / self.render_metrics.cell_size.width as usize;++ let size = TerminalSize {+ rows,+ cols,+ // Take care to use the exact pixel dimensions of the cells, rather+ // than the available space, so that apps that are sensitive to+ // the pixels-per-cell have consistent values at a given font size.+ // https://github.com/wezterm/wezterm/issues/535+ pixel_height: rows * self.render_metrics.cell_size.height as usize,+ pixel_width: cols * self.render_metrics.cell_size.width as usize,+ dpi: dimensions.dpi as u32,+ };++ let ri_calc = ResizeIncrementCalculator {+ x: self.render_metrics.cell_size.width as u16,+ y: self.render_metrics.cell_size.height as u16,+ padding_left: padding_left,+ padding_top: padding_top,+ padding_right: padding_right,+ padding_bottom: padding_bottom,+ border: border,+ tab_bar_height: tab_bar_height as usize,+ };++ (size, *dimensions, ri_calc)+ }+ }+pub(crate) fn terminal_size_for_positioned_pane(&self,pos: &PositionedPane,@@ -224,146 +456,25 @@ impl super::TermWindow {// final size, which in that case should result in a NOP// change to the tab size.- let config = &self.config;-- let tab_bar_height = if self.show_tab_bar {- self.tab_bar_pixel_height().unwrap_or(0.)- } else {- 0.- };-- let border = self.get_os_border();-- let (size, dims, ri_calc) = if let Some(cell_dims) = scale_changed_cells {- // Scaling preserves existing terminal dimensions, yielding a new- // overall set of window dimensions- let size = TerminalSize {- rows: cell_dims.rows,- cols: cell_dims.cols,- pixel_height: cell_dims.rows * self.render_metrics.cell_size.height as usize,- pixel_width: cell_dims.cols * self.render_metrics.cell_size.width as usize,- dpi: dimensions.dpi as u32,- };-- let rows = size.rows;- let cols = size.cols;-- let h_context = DimensionContext {- dpi: dimensions.dpi as f32,- pixel_max: size.pixel_width as f32,- pixel_cell: self.render_metrics.cell_size.width as f32,- };- let v_context = DimensionContext {- dpi: dimensions.dpi as f32,- pixel_max: size.pixel_height as f32,- pixel_cell: self.render_metrics.cell_size.height as f32,- };- let padding_left = config.window_padding.left.evaluate_as_pixels(h_context) as usize- + self.workspace_sidebar_width();- let padding_top = config.window_padding.top.evaluate_as_pixels(v_context) as usize;- let padding_bottom =- config.window_padding.bottom.evaluate_as_pixels(v_context) as usize;- let padding_right = effective_right_padding(&config, h_context);-- let pixel_height = (rows * self.render_metrics.cell_size.height as usize)- + (padding_top + padding_bottom)- + (border.top + border.bottom).get() as usize- + tab_bar_height as usize;-- let pixel_width = (cols * self.render_metrics.cell_size.width as usize)- + (padding_left + padding_right)- + (border.left + border.right).get() as usize;-- let dims = Dimensions {- pixel_width: pixel_width as usize,- pixel_height: pixel_height as usize,- dpi: dimensions.dpi,- };-- let ri_calc = ResizeIncrementCalculator {- x: self.render_metrics.cell_size.width as u16,- y: self.render_metrics.cell_size.height as u16,- padding_left: padding_left,- padding_top: padding_top,- padding_right: padding_right,- padding_bottom: padding_bottom,- border: border,- tab_bar_height: tab_bar_height as usize,- };-- (size, dims, ri_calc)- } else {- // Resize of the window dimensions may result in changed terminal dimensions-- let h_context = DimensionContext {- dpi: dimensions.dpi as f32,- pixel_max: self.terminal_size.pixel_width as f32,- pixel_cell: self.render_metrics.cell_size.width as f32,- };- let v_context = DimensionContext {- dpi: dimensions.dpi as f32,- pixel_max: self.terminal_size.pixel_height as f32,- pixel_cell: self.render_metrics.cell_size.height as f32,- };- let padding_left = config.window_padding.left.evaluate_as_pixels(h_context) as usize- + self.workspace_sidebar_width();- let padding_top = config.window_padding.top.evaluate_as_pixels(v_context) as usize;- let padding_bottom =- config.window_padding.bottom.evaluate_as_pixels(v_context) as usize;- let padding_right = effective_right_padding(&config, h_context);-- let avail_width = dimensions.pixel_width.saturating_sub(- (padding_left + padding_right) as usize- + (border.left + border.right).get() as usize,- );- let avail_height = dimensions- .pixel_height- .saturating_sub(- (padding_top + padding_bottom) as usize- + (border.top + border.bottom).get() as usize,- )- .saturating_sub(tab_bar_height as usize);-- let rows = avail_height / self.render_metrics.cell_size.height as usize;- let cols = avail_width / self.render_metrics.cell_size.width as usize;-- let size = TerminalSize {- rows,- cols,- // Take care to use the exact pixel dimensions of the cells, rather- // than the available space, so that apps that are sensitive to- // the pixels-per-cell have consistent values at a given font size.- // https://github.com/wezterm/wezterm/issues/535- pixel_height: rows * self.render_metrics.cell_size.height as usize,- pixel_width: cols * self.render_metrics.cell_size.width as usize,- dpi: dimensions.dpi as u32,- };-- let ri_calc = ResizeIncrementCalculator {- x: self.render_metrics.cell_size.width as u16,- y: self.render_metrics.cell_size.height as u16,- padding_left: padding_left,- padding_top: padding_top,- padding_right: padding_right,- padding_bottom: padding_bottom,- border: border,- tab_bar_height: tab_bar_height as usize,- };-- (size, *dimensions, ri_calc)- };+ let (size, dims, ri_calc) =+ self.resize_layout_for_dimensions(dimensions, scale_changed_cells);log::trace!("apply_dimensions computed size {:?}, dims {:?}", size, dims);+ let terminal_size_changed = self.terminal_size != size;self.terminal_size = size;-- let mux = Mux::get();- if let Some(window) = mux.get_window(self.mux_window_id) {- for tab in window.iter() {- tab.resize(size);+ if terminal_size_changed {+ let mux = Mux::get();+ if let Some(window) = mux.get_window(self.mux_window_id) {+ for tab in window.iter() {+ tab.resize(size);+ }}- };- self.sync_pane_font_sizes();+ self.sync_pane_font_sizes();+ } else {+ log::trace!("terminal size unchanged; skipping mux tab resize");+ }+self.resize_overlays();self.invalidate_fancy_tab_bar();self.update_title();@@ -554,6 +665,7 @@ impl super::TermWindow {Some(font_scale)};}+ self.persist_workspace_pane_font_scales();self.sync_pane_font_sizes();self.quad_generation += 1;diff --git a/wezterm-gui/src/termwindow/ui/icons.rs b/wezterm-gui/src/termwindow/ui/icons.rsindex b03b0ad8..68757b78 100644--- a/wezterm-gui/src/termwindow/ui/icons.rs+++ b/wezterm-gui/src/termwindow/ui/icons.rs@@ -7,13 +7,28 @@ pub enum SvgIcon {Archive,ChevronDown,ChevronRight,+ Cloud,ExternalLink,+ Folder,FolderOpen,FolderPlus,Globe,+ Info,+ Keyboard,+ Minus,+ Palette,+ PanelLeft,+ PanelLeftClose,+ PanelLeftOpen,PanelRightClose,PanelRightOpen,+ Pin,+ PinOff,Plus,+ RotateCcw,+ Search,+ Settings,+ SlidersHorizontal,SquareTerminal,SplitHorizontal,SplitVertical,@@ -32,9 +47,11 @@ impl SvgIcon {Self::ChevronRight => {include_bytes!("../../../../third_party/lucide/icons/chevron-right.svg")}+ Self::Cloud => include_bytes!("../../../../third_party/lucide/icons/cloud.svg"),Self::ExternalLink => {include_bytes!("../../../../third_party/lucide/icons/external-link.svg")}+ Self::Folder => include_bytes!("../../../../third_party/lucide/icons/folder.svg"),Self::FolderOpen => {include_bytes!("../../../../third_party/lucide/icons/folder-open.svg")}@@ -42,13 +59,36 @@ impl SvgIcon {include_bytes!("../../../../third_party/lucide/icons/folder-plus.svg")}Self::Globe => include_bytes!("../../../../third_party/lucide/icons/globe.svg"),+ Self::Info => include_bytes!("../../../../third_party/lucide/icons/info.svg"),+ Self::Keyboard => include_bytes!("../../../../third_party/lucide/icons/keyboard.svg"),+ Self::Minus => include_bytes!("../../../../third_party/lucide/icons/minus.svg"),+ Self::Palette => include_bytes!("../../../../third_party/lucide/icons/palette.svg"),+ Self::PanelLeft => {+ include_bytes!("../../../../third_party/lucide/icons/panel-left.svg")+ }+ Self::PanelLeftClose => {+ include_bytes!("../../../../third_party/lucide/icons/panel-left-close.svg")+ }+ Self::PanelLeftOpen => {+ include_bytes!("../../../../third_party/lucide/icons/panel-left-open.svg")+ }Self::PanelRightClose => {include_bytes!("../../../../third_party/lucide/icons/panel-right-close.svg")}Self::PanelRightOpen => {include_bytes!("../../../../third_party/lucide/icons/panel-right-open.svg")}+ Self::Pin => include_bytes!("../../../../third_party/lucide/icons/pin.svg"),+ Self::PinOff => include_bytes!("../../../../third_party/lucide/icons/pin-off.svg"),Self::Plus => include_bytes!("../../../../third_party/lucide/icons/plus.svg"),+ Self::RotateCcw => {+ include_bytes!("../../../../third_party/lucide/icons/rotate-ccw.svg")+ }+ Self::Search => include_bytes!("../../../../third_party/lucide/icons/search.svg"),+ Self::Settings => include_bytes!("../../../../third_party/lucide/icons/settings.svg"),+ Self::SlidersHorizontal => {+ include_bytes!("../../../../third_party/lucide/icons/sliders-horizontal.svg")+ }Self::SquareTerminal => {include_bytes!("../../../../third_party/lucide/icons/square-terminal.svg")}@@ -96,12 +136,27 @@ mod tests {SvgIcon::ExternalLink,SvgIcon::ChevronDown,SvgIcon::ChevronRight,+ SvgIcon::Cloud,+ SvgIcon::Folder,SvgIcon::FolderOpen,SvgIcon::FolderPlus,SvgIcon::Globe,+ SvgIcon::Info,+ SvgIcon::Keyboard,+ SvgIcon::Minus,+ SvgIcon::Palette,+ SvgIcon::PanelLeft,+ SvgIcon::PanelLeftClose,+ SvgIcon::PanelLeftOpen,SvgIcon::PanelRightClose,SvgIcon::PanelRightOpen,+ SvgIcon::Pin,+ SvgIcon::PinOff,SvgIcon::Plus,+ SvgIcon::RotateCcw,+ SvgIcon::Search,+ SvgIcon::Settings,+ SvgIcon::SlidersHorizontal,SvgIcon::SquareTerminal,SvgIcon::SplitHorizontal,SvgIcon::SplitVertical,diff --git a/wezterm-gui/src/termwindow/ui/sidebar.rs b/wezterm-gui/src/termwindow/ui/sidebar.rsindex d278910f..7d181282 100644--- a/wezterm-gui/src/termwindow/ui/sidebar.rs+++ b/wezterm-gui/src/termwindow/ui/sidebar.rs@@ -1,3 +1,4 @@+use crate::customglyph::BlockKey;use crate::project_sessions;use crate::quad::{QuadTrait, TripleLayerQuadAllocator, TripleLayerQuadAllocatorTrait};use crate::termwindow::render::corners::{@@ -6,21 +7,27 @@ use crate::termwindow::render::corners::{};use crate::termwindow::ui::icons::SvgIcon;use crate::termwindow::ui::tokens::{- active_capsule_bg, capsule_border, CAPSULE_BORDER_WIDTH, SIDEBAR_ICON_GAP, SIDEBAR_INSET,+ CAPSULE_BORDER_WIDTH, MACOS_TITLEBAR_CONTENT_TOP_INSET, SIDEBAR_ICON_GAP, SIDEBAR_INSET,SIDEBAR_MAX_WIDTH, SIDEBAR_MIN_WIDTH, SIDEBAR_RESIZE_HANDLE_WIDTH, SIDEBAR_ROW_GAP,- SIDEBAR_ROW_RADIUS, SIDEBAR_WIDTH_CELLS,+ SIDEBAR_ROW_RADIUS, SIDEBAR_WIDTH_CELLS, WINDOW_TAB_FULLSCREEN_SIDEBAR_BUTTON_SIZE,+ WINDOW_TAB_FULLSCREEN_SIDEBAR_BUTTON_X, WINDOW_TAB_FULLSCREEN_SIDEBAR_ICON_SIZE,};use crate::termwindow::{UIItem, UIItemType};+use crate::ui::UiPalette;use crate::utilsprites::RenderMetrics;use anyhow::Context;+use finl_unicode::grapheme_clusters::Graphemes;use mux::Mux;+use std::borrow::Cow;use std::rc::Rc;+use wezterm_bidi::Direction;use wezterm_font::LoadedFont;-use wezterm_term::color::ColorAttribute;use window::color::LinearRgba;-use window::{MouseEventKind as WMEK, RectF};+use window::{MouseEventKind as WMEK, RectF, WindowOps, WindowState};const SIDEBAR_SCROLLBAR_VISIBLE_MS: u64 = 900;+const SIDEBAR_SETTINGS_FOOTER_HEIGHT: usize = 72;+const SIDEBAR_SETTINGS_FADE_HEIGHT: usize = 52;#[derive(Debug, Clone, Copy)]pub struct WorkspaceSidebarRect {@@ -72,6 +79,14 @@ impl crate::TermWindow {self.workspace_sidebar_collapsed = false;}+ pub(crate) fn workspace_sidebar_toggle_icon(&self) -> SvgIcon {+ if self.workspace_sidebar_collapsed {+ SvgIcon::PanelLeftOpen+ } else {+ SvgIcon::PanelLeftClose+ }+ }+pub fn tab_bar_left_edge(&self) -> usize {let border = self.get_os_border();border.left.get() as usize + self.workspace_sidebar_width()@@ -115,6 +130,14 @@ impl crate::TermWindow {row_gap: usize,) -> usize {let mut height = 0usize;+ if !view.pinned_sessions.is_empty() {+ height = height.saturating_add(row_height + row_gap);+ height = height.saturating_add(+ view.pinned_sessions+ .len()+ .saturating_mul(row_height + row_gap),+ );+ }for project in &view.projects {height = height.saturating_add(row_height + row_gap);if !project.sessions_collapsed {@@ -125,6 +148,16 @@ impl crate::TermWindow {height.saturating_sub(row_gap)}+ fn workspace_sidebar_content_top(&self, panel_y: usize) -> usize {+ let base_top = panel_y + SIDEBAR_INSET;+ if cfg!(target_os = "macos") && !self.window_state.contains(WindowState::FULL_SCREEN) {+ let tab_row_height = self.tab_bar_pixel_height().unwrap_or(0.0).ceil() as usize;+ panel_y + MACOS_TITLEBAR_CONTENT_TOP_INSET.max(tab_row_height)+ } else {+ base_top+ }+ }+pub fn workspace_sidebar_scroll_max(&self) -> f32 {let Some(rect) = self.workspace_sidebar_rect() else {return 0.0;@@ -146,8 +179,12 @@ impl crate::TermWindow {let panel_margin = 0usize;let panel_y = rect.y + panel_margin;let panel_height = rect.height.saturating_sub(panel_margin * 2).max(1);- let content_bottom = panel_y + panel_height.saturating_sub(SIDEBAR_INSET);- let list_top = panel_y + SIDEBAR_INSET + ui_cell_height + SIDEBAR_INSET;+ let settings_footer_top = panel_y+ .saturating_add(panel_height)+ .saturating_sub(SIDEBAR_SETTINGS_FOOTER_HEIGHT);+ let content_bottom = (panel_y + panel_height.saturating_sub(SIDEBAR_INSET))+ .min(settings_footer_top.max(panel_y));+ let list_top = self.workspace_sidebar_content_top(panel_y) + ui_cell_height + SIDEBAR_INSET;let viewport_height = content_bottom.saturating_sub(list_top);if viewport_height == 0 {return 0.0;@@ -184,8 +221,12 @@ impl crate::TermWindow {let panel_y = rect.y + panel_margin;let panel_width = rect.width.saturating_sub(panel_margin * 2).max(1);let panel_height = rect.height.saturating_sub(panel_margin * 2).max(1);- let content_bottom = panel_y + panel_height.saturating_sub(SIDEBAR_INSET);- let list_top = panel_y + SIDEBAR_INSET + ui_cell_height + SIDEBAR_INSET;+ let settings_footer_top = panel_y+ .saturating_add(panel_height)+ .saturating_sub(SIDEBAR_SETTINGS_FOOTER_HEIGHT);+ let content_bottom = (panel_y + panel_height.saturating_sub(SIDEBAR_INSET))+ .min(settings_footer_top.max(panel_y));+ let list_top = self.workspace_sidebar_content_top(panel_y) + ui_cell_height + SIDEBAR_INSET;let viewport_height = content_bottom.saturating_sub(list_top);if viewport_height == 0 {return None;@@ -234,21 +275,18 @@ impl crate::TermWindow {None => return Ok(()),};- let palette = self.palette().clone();- let background = palette- .resolve_bg(ColorAttribute::Default)- .to_linear()- .mul_alpha(self.config.window_background_opacity);- let foreground = palette.foreground.to_linear();- let sidebar_bg = background;- let selected_bg = active_capsule_bg(background.3);- let selected_border = capsule_border(foreground, true);- let active_fg = palette- .selection_fg- .to_linear()- .when_fully_transparent(foreground);- let muted_fg = foreground.mul_alpha(0.62);- let ui_font = self.fonts.title_font().context("sidebar ui font")?;+ let chrome = UiPalette::for_appearance(crate::native_settings::effective_appearance());+ let foreground = chrome.text;+ let sidebar_bg = chrome.workspace_sidebar_bg;+ let sidebar_separator = chrome.separator;+ let selected_bg = chrome.control_bg;+ let selected_border = chrome.control_border;+ let active_fg = chrome.text;+ let muted_fg = chrome.secondary_text;+ let ui_font = self+ .fonts+ .title_font_with_size(crate::native_settings::sidebar_font_size())+ .context("sidebar ui font")?;let ui_metrics = RenderMetrics::with_font_metrics(&ui_font.metrics());let ui_cell_height = ui_metrics.cell_size.height as usize;let icon_size = (ui_cell_height + 12).clamp(30, 36);@@ -257,7 +295,7 @@ impl crate::TermWindow {let panel_y = rect.y + panel_margin;let panel_width = rect.width.saturating_sub(panel_margin * 2).max(1);let panel_height = rect.height.saturating_sub(panel_margin * 2).max(1);- let content_bottom = panel_y + panel_height.saturating_sub(SIDEBAR_INSET);+ let mut content_bottom = panel_y + panel_height.saturating_sub(SIDEBAR_INSET);if rect.y > 0 {self.filled_rectangle(@@ -313,8 +351,58 @@ impl crate::TermWindow {let header_icon_size = icon_size.min(32);let button_size = (header_icon_size + 8).clamp(32, 40);- let mut y = panel_y + SIDEBAR_INSET;+ let mut y = self.workspace_sidebar_content_top(panel_y);+ let show_sidebar_toolbar = self.window_state.contains(WindowState::FULL_SCREEN);+ let sidebar_toggle_size = WINDOW_TAB_FULLSCREEN_SIDEBAR_BUTTON_SIZE;+ let sidebar_toggle_x = panel_x + WINDOW_TAB_FULLSCREEN_SIDEBAR_BUTTON_X;+ let sidebar_toggle_y = y;+ let sidebar_toggle_icon_size =+ WINDOW_TAB_FULLSCREEN_SIDEBAR_ICON_SIZE.min(sidebar_toggle_size.saturating_sub(2));+ if show_sidebar_toolbar {+ let toggle_hovered = self.is_pointer_over_ui_rect(+ sidebar_toggle_x,+ sidebar_toggle_y,+ sidebar_toggle_size,+ sidebar_toggle_size,+ );+ self.fill_rounded_rectangle(+ layers,+ 1,+ euclid::rect(+ sidebar_toggle_x as f32,+ sidebar_toggle_y as f32,+ sidebar_toggle_size as f32,+ sidebar_toggle_size as f32,+ ),+ foreground.mul_alpha(if toggle_hovered { 0.14 } else { 0.08 }),+ SIDEBAR_ROW_RADIUS,+ )+ .context("sidebar toolbar toggle button")?;+ self.ui_items.push(UIItem {+ x: sidebar_toggle_x,+ y: sidebar_toggle_y,+ width: sidebar_toggle_size,+ height: sidebar_toggle_size,+ item_type: UIItemType::WorkspaceSidebarToggle,+ });+ self.paint_sidebar_icon(+ layers,+ self.workspace_sidebar_toggle_icon(),+ sidebar_toggle_x+ + ((sidebar_toggle_size.saturating_sub(sidebar_toggle_icon_size)) / 2),+ sidebar_toggle_y+ + ((sidebar_toggle_size.saturating_sub(sidebar_toggle_icon_size)) / 2),+ sidebar_toggle_icon_size,+ if toggle_hovered { foreground } else { muted_fg },+ )?;+ y += sidebar_toggle_size + SIDEBAR_INSET;+ }let section_button_size = button_size.min(34);+ let settings_footer_height = SIDEBAR_SETTINGS_FOOTER_HEIGHT.min(panel_height);+ let settings_footer_y = panel_y+ .saturating_add(panel_height)+ .saturating_sub(settings_footer_height);+ content_bottom = content_bottom.min(settings_footer_y.max(panel_y));let section_button_x = item_x.saturating_add(item_width).saturating_sub(section_button_size + SIDEBAR_INSET);@@ -378,6 +466,187 @@ impl crate::TermWindow {.is_some_and(|event| matches!(event.kind, WMEK::VertWheel(_) | WMEK::HorzWheel(_)));let mut virtual_y = 0usize;+ if !view.pinned_sessions.is_empty() {+ let label_top = list_top_f + virtual_y as f32 - scroll_offset;+ let label_bottom = label_top + session_row_height as f32;+ let label_is_visible = label_bottom > list_top_f && label_top < content_bottom_f;+ if label_is_visible {+ let label_y = label_top.floor().max(0.0) as usize;+ let label_icon_size = header_icon_size.min(ui_cell_height).max(16);+ let label_icon_x = item_x + SIDEBAR_INSET;+ let label_icon_y =+ label_y + ((session_row_height.saturating_sub(label_icon_size)) / 2);+ let label_text_x = label_icon_x + label_icon_size + SIDEBAR_ICON_GAP;+ self.paint_sidebar_icon(+ layers,+ SvgIcon::Pin,+ label_icon_x,+ label_icon_y,+ label_icon_size,+ muted_fg,+ )?;+ self.paint_sidebar_text(+ layers,+ &ui_font,+ ui_metrics,+ "Pinned",+ label_text_x,+ label_y + ((session_row_height.saturating_sub(ui_cell_height)) / 2),+ item_x+ .saturating_add(item_width)+ .saturating_sub(label_text_x + SIDEBAR_INSET),+ muted_fg,+ )?;+ }+ virtual_y += session_row_height + row_gap;++ let pinned_x = item_x + SIDEBAR_INSET;+ let pinned_width = item_width.saturating_sub(SIDEBAR_INSET * 2);+ let pinned_text_x = pinned_x + SIDEBAR_INSET;+ for session in &view.pinned_sessions {+ let row_top = list_top_f + virtual_y as f32 - scroll_offset;+ let row_bottom = row_top + session_row_height as f32;+ let row_is_visible = row_bottom > list_top_f && row_top < content_bottom_f;+ let y = row_top.floor().max(0.0) as usize;+ let hit_y = row_top.max(list_top_f).floor().max(0.0) as usize;+ let hit_bottom = row_bottom.min(content_bottom_f).ceil().max(hit_y as f32) as usize;+ let hit_height = hit_bottom.saturating_sub(hit_y).max(1);++ if row_is_visible {+ self.ui_items.push(UIItem {+ x: pinned_x,+ y: hit_y,+ width: pinned_width,+ height: hit_height,+ item_type: UIItemType::ProjectSession(session.id.clone()),+ });+ let is_hovered = !suppress_hover+ && self.is_pointer_over_ui_rect(+ pinned_x,+ y,+ pinned_width,+ session_row_height,+ );+ let is_renaming_session = self.is_renaming_sidebar_session(&session.id);+ if session.is_active {+ self.fill_rounded_rectangle_with_border(+ layers,+ 0,+ euclid::rect(+ pinned_x as f32,+ y as f32,+ pinned_width as f32,+ session_row_height as f32,+ ),+ selected_bg,+ selected_border,+ SIDEBAR_ROW_RADIUS + 2.0,+ CAPSULE_BORDER_WIDTH,+ )+ .context("sidebar selected pinned session")?;+ } else if is_hovered && !is_renaming_session {+ self.fill_rounded_rectangle(+ layers,+ 0,+ euclid::rect(+ pinned_x as f32,+ y as f32,+ pinned_width as f32,+ session_row_height as f32,+ ),+ foreground.mul_alpha(0.06),+ SIDEBAR_ROW_RADIUS + 2.0,+ )+ .context("sidebar hovered pinned session")?;+ }++ let text_y = y + ((session_row_height.saturating_sub(ui_cell_height)) / 2);+ let action_size = section_button_size+ .min(session_row_height.saturating_sub(12))+ .max(24);+ let delete_x = pinned_x+ .saturating_add(pinned_width)+ .saturating_sub(SIDEBAR_INSET + action_size);+ let pin_x = delete_x.saturating_sub(action_size + 4);+ let action_y = y + ((session_row_height.saturating_sub(action_size)) / 2);+ let text_right = if is_hovered && !is_renaming_session {+ pin_x+ } else {+ pinned_x+ .saturating_add(pinned_width)+ .saturating_sub(SIDEBAR_INSET)+ };+ let title = self.sidebar_session_title(&session.id, &session.name);+ self.paint_sidebar_text(+ layers,+ &ui_font,+ ui_metrics,+ &title,+ pinned_text_x,+ text_y,+ text_right.saturating_sub(pinned_text_x + SIDEBAR_INSET),+ if session.is_active {+ active_fg+ } else {+ foreground+ },+ )?;++ if is_hovered && !is_renaming_session {+ for (x, item_type, icon, context_name) in [+ (+ pin_x,+ UIItemType::ProjectSessionPin(session.id.clone()),+ SvgIcon::PinOff,+ "sidebar unpin pinned session button",+ ),+ (+ delete_x,+ UIItemType::ProjectSessionDelete(session.id.clone()),+ SvgIcon::Trash2,+ "sidebar delete pinned session button",+ ),+ ] {+ let hovered =+ self.is_pointer_over_ui_rect(x, action_y, action_size, action_size);+ self.fill_rounded_rectangle(+ layers,+ 1,+ euclid::rect(+ x as f32,+ action_y as f32,+ action_size as f32,+ action_size as f32,+ ),+ foreground.mul_alpha(if hovered { 0.14 } else { 0.08 }),+ SIDEBAR_ROW_RADIUS,+ )+ .context(context_name)?;+ self.ui_items.push(UIItem {+ x,+ y: action_y,+ width: action_size,+ height: action_size,+ item_type,+ });+ let action_icon_size =+ header_icon_size.min(action_size.saturating_sub(10));+ self.paint_sidebar_icon(+ layers,+ icon,+ x + ((action_size.saturating_sub(action_icon_size)) / 2),+ action_y + ((action_size.saturating_sub(action_icon_size)) / 2),+ action_icon_size,+ if hovered { foreground } else { muted_fg },+ )?;+ }+ }+ }++ virtual_y += session_row_height + row_gap;+ }+ }+for project in &view.projects {let row_top = list_top_f + virtual_y as f32 - scroll_offset;let row_bottom = row_top + session_row_height as f32;@@ -439,17 +708,22 @@ impl crate::TermWindow {)?;self.paint_sidebar_icon(layers,- SvgIcon::FolderOpen,+ if project.sessions_collapsed {+ SvgIcon::Folder+ } else {+ SvgIcon::FolderOpen+ },project_icon_x,icon_y,icon_size,muted_fg,)?;+ let project_title = self.sidebar_project_title(&project.id, &project.name);self.paint_sidebar_text(layers,&ui_font,ui_metrics,- &project.name,+ &project_title,project_text_x,text_y,project_text_right.saturating_sub(project_text_x + SIDEBAR_INSET),@@ -554,16 +828,22 @@ impl crate::TermWindow {session_width,session_row_height,);+ let is_renaming_session = self.is_renaming_sidebar_session(&session.id);let action_size = section_button_size.min(session_row_height.saturating_sub(12)).max(24);- let action_x = session_x+ let delete_x = session_x.saturating_add(session_width).saturating_sub(SIDEBAR_INSET + action_size);+ let pin_x = delete_x.saturating_sub(action_size + 4);let action_y = y + ((session_row_height.saturating_sub(action_size)) / 2);- let text_right = if is_hovered { action_x } else { status_x };+ let text_right = if is_hovered && !is_renaming_session {+ pin_x+ } else {+ status_x+ };let text_width = text_right.saturating_sub(session_text_x + SIDEBAR_INSET);- if is_hovered && !session.is_active {+ if is_hovered && !session.is_active && !is_renaming_session {self.fill_rounded_rectangle(layers,0,@@ -590,11 +870,12 @@ impl crate::TermWindow {muted_fg},)?;+ let session_title = self.sidebar_session_title(&session.id, &session.name);self.paint_sidebar_text(layers,&ui_font,ui_metrics,- &session.name,+ &session_title,session_text_x,text_y,text_width,@@ -604,43 +885,63 @@ impl crate::TermWindow {foreground},)?;- if is_hovered {- let delete_hovered = self.is_pointer_over_ui_rect(- action_x,- action_y,- action_size,- action_size,- );- self.fill_rounded_rectangle(- layers,- 1,- euclid::rect(- action_x as f32,- action_y as f32,- action_size as f32,- action_size as f32,+ if is_hovered && !is_renaming_session {+ let pin_icon = if session.is_pinned {+ SvgIcon::PinOff+ } else {+ SvgIcon::Pin+ };+ for (x, item_type, icon, context_name) in [+ (+ pin_x,+ UIItemType::ProjectSessionPin(session.id.clone()),+ pin_icon,+ "sidebar pin session button",),- foreground.mul_alpha(if delete_hovered { 0.14 } else { 0.08 }),- SIDEBAR_ROW_RADIUS,- )- .context("sidebar delete session button")?;- self.ui_items.push(UIItem {- x: action_x,- y: action_y,- width: action_size,- height: action_size,- item_type: UIItemType::ProjectSessionArchive(session.id.clone()),- });- let action_icon_size =- header_icon_size.min(action_size.saturating_sub(10));- self.paint_sidebar_icon(- layers,- SvgIcon::Archive,- action_x + ((action_size.saturating_sub(action_icon_size)) / 2),- action_y + ((action_size.saturating_sub(action_icon_size)) / 2),- action_icon_size,- if delete_hovered { foreground } else { muted_fg },- )?;+ (+ delete_x,+ UIItemType::ProjectSessionDelete(session.id.clone()),+ SvgIcon::Trash2,+ "sidebar delete session button",+ ),+ ] {+ let hovered = self.is_pointer_over_ui_rect(+ x,+ action_y,+ action_size,+ action_size,+ );+ self.fill_rounded_rectangle(+ layers,+ 1,+ euclid::rect(+ x as f32,+ action_y as f32,+ action_size as f32,+ action_size as f32,+ ),+ foreground.mul_alpha(if hovered { 0.14 } else { 0.08 }),+ SIDEBAR_ROW_RADIUS,+ )+ .context(context_name)?;+ self.ui_items.push(UIItem {+ x,+ y: action_y,+ width: action_size,+ height: action_size,+ item_type,+ });+ let action_icon_size =+ header_icon_size.min(action_size.saturating_sub(10));+ self.paint_sidebar_icon(+ layers,+ icon,+ x + ((action_size.saturating_sub(action_icon_size)) / 2),+ action_y + ((action_size.saturating_sub(action_icon_size)) / 2),+ action_icon_size,+ if hovered { foreground } else { muted_fg },+ )?;+ }} else {self.fill_rounded_rectangle(layers,@@ -651,11 +952,10 @@ impl crate::TermWindow {status_size as f32,status_size as f32,),- if session.is_unread {- palette- .selection_bg- .to_linear()- .when_fully_transparent(foreground)+ if session.is_active {+ LinearRgba::with_components(0.20, 0.78, 0.36, 1.0)+ } else if session.is_unread {+ chrome.selected_bg} else if session.is_pinned {foreground.mul_alpha(0.68)} else if session.is_materialized {@@ -712,10 +1012,41 @@ impl crate::TermWindow {ui_metrics,"Workspaces",item_x + SIDEBAR_INSET,- panel_y + SIDEBAR_INSET,+ y.saturating_sub(ui_cell_height + SIDEBAR_INSET),section_button_x.saturating_sub(item_x + SIDEBAR_INSET * 2),muted_fg,)?;+ if show_sidebar_toolbar {+ let toggle_hovered = self.is_pointer_over_ui_rect(+ sidebar_toggle_x,+ sidebar_toggle_y,+ sidebar_toggle_size,+ sidebar_toggle_size,+ );+ self.fill_rounded_rectangle(+ layers,+ 2,+ euclid::rect(+ sidebar_toggle_x as f32,+ sidebar_toggle_y as f32,+ sidebar_toggle_size as f32,+ sidebar_toggle_size as f32,+ ),+ foreground.mul_alpha(if toggle_hovered { 0.14 } else { 0.08 }),+ SIDEBAR_ROW_RADIUS,+ )+ .context("sidebar toolbar toggle button repaint")?;+ self.paint_sidebar_icon(+ layers,+ self.workspace_sidebar_toggle_icon(),+ sidebar_toggle_x+ + ((sidebar_toggle_size.saturating_sub(sidebar_toggle_icon_size)) / 2),+ sidebar_toggle_y+ + ((sidebar_toggle_size.saturating_sub(sidebar_toggle_icon_size)) / 2),+ sidebar_toggle_icon_size,+ if toggle_hovered { foreground } else { muted_fg },+ )?;+ }self.fill_rounded_rectangle(layers,2,@@ -757,6 +1088,104 @@ impl crate::TermWindow {.context("sidebar bottom scroll mask")?;}+ if settings_footer_height > 0 {+ let fade_height = SIDEBAR_SETTINGS_FADE_HEIGHT+ .min(settings_footer_y.saturating_sub(panel_y))+ .min(content_bottom.saturating_sub(panel_y));+ if max_scroll > 0.0 && fade_height > 0 {+ for step in 0..fade_height {+ let progress = (step + 1) as f32 / fade_height as f32;+ self.filled_rectangle(+ layers,+ 2,+ euclid::rect(+ panel_x as f32,+ (settings_footer_y.saturating_sub(fade_height) + step) as f32,+ panel_width as f32,+ 1.0,+ ),+ sidebar_bg.mul_alpha(progress * progress * (3.0 - 2.0 * progress)),+ )+ .context("sidebar settings fade")?;+ }+ }++ self.filled_rectangle(+ layers,+ 2,+ euclid::rect(+ panel_x as f32,+ settings_footer_y as f32,+ panel_width as f32,+ settings_footer_height as f32,+ ),+ sidebar_bg,+ )+ .context("sidebar settings footer background")?;++ let settings_row_x = item_x + SIDEBAR_INSET;+ let settings_row_y = settings_footer_y + 8;+ let settings_row_width = item_width.saturating_sub(SIDEBAR_INSET * 2);+ let settings_row_height = 48usize+ .min(settings_footer_height.saturating_sub(SIDEBAR_INSET))+ .max(1);+ let settings_hovered = self.is_pointer_over_ui_rect(+ settings_row_x,+ settings_row_y,+ settings_row_width,+ settings_row_height,+ );+ if settings_hovered {+ self.fill_rounded_rectangle(+ layers,+ 2,+ euclid::rect(+ settings_row_x as f32,+ settings_row_y as f32,+ settings_row_width as f32,+ settings_row_height as f32,+ ),+ foreground.mul_alpha(0.10),+ SIDEBAR_ROW_RADIUS + 4.0,+ )+ .context("sidebar settings button hover")?;+ }+ self.ui_items.push(UIItem {+ x: settings_row_x,+ y: settings_row_y,+ width: settings_row_width,+ height: settings_row_height,+ item_type: UIItemType::WorkspaceSidebarSettings,+ });+ let settings_icon_size = icon_size.min(settings_row_height.saturating_sub(8));+ let settings_icon_x = settings_row_x + SIDEBAR_INSET + 2;+ let settings_icon_y =+ settings_row_y + ((settings_row_height.saturating_sub(settings_icon_size)) / 2);+ let settings_text_x = settings_icon_x + settings_icon_size + SIDEBAR_ICON_GAP + 4;+ let settings_text_y =+ settings_row_y + ((settings_row_height.saturating_sub(ui_cell_height)) / 2);+ self.paint_sidebar_icon(+ layers,+ SvgIcon::Settings,+ settings_icon_x,+ settings_icon_y,+ settings_icon_size,+ foreground,+ )?;+ self.paint_sidebar_text(+ layers,+ &ui_font,+ ui_metrics,+ "Settings",+ settings_text_x,+ settings_text_y,+ settings_row_x+ .saturating_add(settings_row_width)+ .saturating_sub(settings_text_x + SIDEBAR_INSET),+ foreground,+ )?;+ }+if self.workspace_sidebar_scrollbar_visible() {self.update_next_frame_time(self.workspace_sidebar_scrollbar_visible_until);}@@ -812,6 +1241,19 @@ impl crate::TermWindow {});}+ self.filled_rectangle(+ layers,+ 2,+ euclid::rect(+ rect.x.saturating_add(rect.width).saturating_sub(1) as f32,+ 0.0,+ 1.0,+ rect.y.saturating_add(rect.height) as f32,+ ),+ sidebar_separator,+ )+ .context("sidebar right separator")?;+Ok(())}@@ -976,7 +1418,70 @@ impl crate::TermWindow {return Ok(());}- self.paint_ui_title_text(layers, font, &metrics, text, x, y, width, foreground)+ let text = self.ellipsize_sidebar_text(font, text, width)?;+ if text.is_empty() {+ return Ok(());+ }++ self.paint_ui_title_text(layers, font, &metrics, &text, x, y, width, foreground)+ }++ fn ellipsize_sidebar_text<'a>(+ &self,+ font: &Rc<LoadedFont>,+ text: &'a str,+ width: usize,+ ) -> anyhow::Result<Cow<'a, str>> {+ let max_width = width as f32;+ if max_width <= 0.0 {+ return Ok(Cow::Borrowed(""));+ }++ if self.sidebar_text_width(font, text)? <= max_width {+ return Ok(Cow::Borrowed(text));+ }++ const ELLIPSIS: &str = "...";+ if self.sidebar_text_width(font, ELLIPSIS)? > max_width {+ let mut fallback = String::new();+ for dot_count in 1..=ELLIPSIS.len() {+ let candidate = ".".repeat(dot_count);+ if self.sidebar_text_width(font, &candidate)? > max_width {+ break;+ }+ fallback = candidate;+ }+ return Ok(Cow::Owned(fallback));+ }++ let mut output = String::new();+ for grapheme in Graphemes::new(text) {+ let mut candidate = output.clone();+ candidate.push_str(grapheme);+ candidate.push_str(ELLIPSIS);+ if self.sidebar_text_width(font, &candidate)? > max_width {+ break;+ }+ output.push_str(grapheme);+ }+ output.push_str(ELLIPSIS);+ Ok(Cow::Owned(output))+ }++ fn sidebar_text_width(&self, font: &Rc<LoadedFont>, text: &str) -> anyhow::Result<f32> {+ let Some(window) = self.window.as_ref().cloned() else {+ return Ok(0.0);+ };+ let infos = font.shape(+ text,+ move || window.notify(crate::termwindow::TermWindowNotif::InvalidateShapeCache),+ BlockKey::filter_out_synthetic,+ None,+ Direction::LeftToRight,+ None,+ None,+ )?;+ Ok(infos.iter().map(|info| info.x_advance.get() as f32).sum())}fn paint_sidebar_icon(diff --git a/wezterm-gui/src/termwindow/ui/tokens.rs b/wezterm-gui/src/termwindow/ui/tokens.rsindex 5ee89dce..8e4af534 100644--- a/wezterm-gui/src/termwindow/ui/tokens.rs+++ b/wezterm-gui/src/termwindow/ui/tokens.rs@@ -1,5 +1,3 @@-use window::color::LinearRgba;-pub const SIDEBAR_WIDTH_CELLS: usize = 26;pub const SIDEBAR_MIN_WIDTH: usize = 224;pub const SIDEBAR_MAX_WIDTH: usize = 520;@@ -8,9 +6,19 @@ pub const SIDEBAR_ICON_GAP: usize = 10;pub const SIDEBAR_ROW_GAP: usize = 10;pub const SIDEBAR_ROW_RADIUS: f32 = 10.0;pub const SIDEBAR_RESIZE_HANDLE_WIDTH: usize = 8;+pub const MACOS_TITLEBAR_CONTENT_TOP_INSET: usize = 52;+pub const MACOS_TRAFFIC_LIGHT_CLEARANCE_WIDTH: usize = 164;+pub const MACOS_WINDOW_TAB_RESERVED_ACTION_SLOTS: usize = 1;pub const TAB_ROW_START_PADDING: usize = 16;+pub const WINDOW_TAB_TOP_SPACER: usize = 4;pub const WINDOW_TAB_ACTION_RESERVED_WIDTH: usize = 48;+pub const WINDOW_TAB_FULLSCREEN_SIDEBAR_BUTTON_X: usize = 16;+pub const WINDOW_TAB_FULLSCREEN_SIDEBAR_BUTTON_SIZE: usize = 42;+pub const WINDOW_TAB_FULLSCREEN_SIDEBAR_ICON_SIZE: usize = 36;+pub const WINDOW_TAB_LEADING_ACTION_BUTTON_SIZE: usize = 34;+pub const WINDOW_TAB_LEADING_ACTION_GAP: usize = 8;+pub const WINDOW_TAB_LEADING_ACTION_ICON_SIZE: usize = 26;pub const WINDOW_TAB_GAP: usize = 18;pub const WINDOW_TAB_RADIUS: f32 = 12.0;pub const TAB_CLOSE_HOVER_INSET: usize = 5;@@ -22,23 +30,10 @@ pub const PANE_NAV_INSET: usize = 10;pub const PANE_NAV_ICON_GAP: usize = 8;pub const PANE_NAV_BUTTON_GAP: usize = 4;pub const PANE_NAV_TAB_GAP: usize = 18;+pub const PANE_NAV_TAB_TOP_OFFSET: usize = 4;pub const PANE_NAV_EXTRA_HEIGHT: usize = 32;pub const PANE_NAV_MIN_HEIGHT: usize = 62;pub const PANE_NAV_MAX_HEIGHT: usize = 72;pub const PANE_NAV_TAB_RADIUS: f32 = 12.0;-pub const ACTIVE_CAPSULE_CHANNEL: f32 = 8.0 / 255.0;pub const CAPSULE_BORDER_WIDTH: f32 = 1.0;--pub fn active_capsule_bg(alpha: f32) -> LinearRgba {- LinearRgba::with_components(- ACTIVE_CAPSULE_CHANNEL,- ACTIVE_CAPSULE_CHANNEL,- ACTIVE_CAPSULE_CHANNEL,- alpha.clamp(0.0, 1.0),- )-}--pub fn capsule_border(foreground: LinearRgba, active: bool) -> LinearRgba {- foreground.mul_alpha(if active { 0.24 } else { 0.10 })-}diff --git a/wezterm-gui/src/ui/events.rs b/wezterm-gui/src/ui/events.rsnew file mode 100644index 00000000..afd1945f--- /dev/null+++ b/wezterm-gui/src/ui/events.rs@@ -0,0 +1,42 @@+use crate::ui::{contains, ScrollState};+use window::{MouseEvent, MouseEventKind};++pub(crate) fn wheel_delta_pixels(amount: i16) -> f32 {+ -(amount as f32) * 34.0+}++pub(crate) fn precise_wheel_delta_pixels(event: &MouseEvent) -> Option<f32> {+ let delta = event.precise_scroll_delta?;+ if delta.y.abs() >= delta.x.abs() && delta.y.abs() > f32::EPSILON {+ Some(-delta.y)+ } else {+ None+ }+}++pub(crate) fn apply_wheel_to_area(+ event: &MouseEvent,+ area: window::RectF,+ scroll: &mut ScrollState,+) -> bool {+ if !contains(area, event.coords.x as f32, event.coords.y as f32) {+ return false;+ }++ scroll.set_phase(event.momentum_phase.or(event.scroll_phase));++ if let Some(delta) = precise_wheel_delta_pixels(event) {+ let old = scroll.offset;+ scroll.scroll_by(delta);+ return (scroll.offset - old).abs() > 0.01;+ }++ match event.kind {+ MouseEventKind::VertWheel(amount) => {+ let old_velocity = scroll.velocity;+ scroll.scroll_by_smooth(wheel_delta_pixels(amount));+ (scroll.velocity - old_velocity).abs() > 0.5+ }+ _ => false,+ }+}diff --git a/wezterm-gui/src/ui/geometry.rs b/wezterm-gui/src/ui/geometry.rsnew file mode 100644index 00000000..becaa37b--- /dev/null+++ b/wezterm-gui/src/ui/geometry.rs@@ -0,0 +1,20 @@+pub(crate) fn rect(x: f32, y: f32, width: f32, height: f32) -> window::RectF {+ euclid::rect(x, y, width.max(0.0), height.max(0.0))+}++pub(crate) fn inset(rect: window::RectF, amount: f32) -> window::RectF {+ euclid::rect(+ rect.origin.x + amount,+ rect.origin.y + amount,+ (rect.size.width - amount * 2.0).max(0.0),+ (rect.size.height - amount * 2.0).max(0.0),+ )+}++pub(crate) fn contains(rect: window::RectF, x: f32, y: f32) -> bool {+ rect.contains(euclid::point2(x, y))+}++pub(crate) fn clamp(value: f32, min: f32, max: f32) -> f32 {+ value.max(min).min(max)+}diff --git a/wezterm-gui/src/ui/icons.rs b/wezterm-gui/src/ui/icons.rsnew file mode 100644index 00000000..e3486931--- /dev/null+++ b/wezterm-gui/src/ui/icons.rs@@ -0,0 +1,34 @@+pub(crate) use crate::termwindow::ui::icons::SvgIcon;++#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]+pub(crate) enum SettingsIcon {+ General,+ Appearance,+ Terminal,+ Workspaces,+ Keymap,+ Sync,+ Developer,+ About,+ Search,+ Clear,+ External,+}++impl SettingsIcon {+ pub(crate) fn svg(self) -> SvgIcon {+ match self {+ Self::General => SvgIcon::SlidersHorizontal,+ Self::Appearance => SvgIcon::Palette,+ Self::Terminal => SvgIcon::Terminal,+ Self::Workspaces => SvgIcon::FolderOpen,+ Self::Keymap => SvgIcon::Keyboard,+ Self::Sync => SvgIcon::Cloud,+ Self::Developer => SvgIcon::Settings,+ Self::About => SvgIcon::Info,+ Self::Search => SvgIcon::Search,+ Self::Clear => SvgIcon::X,+ Self::External => SvgIcon::ExternalLink,+ }+ }+}diff --git a/wezterm-gui/src/ui/mod.rs b/wezterm-gui/src/ui/mod.rsnew file mode 100644index 00000000..3f340168--- /dev/null+++ b/wezterm-gui/src/ui/mod.rs@@ -0,0 +1,15 @@+#![allow(dead_code)]++pub(crate) mod events;+pub(crate) mod geometry;+pub(crate) mod icons;+pub(crate) mod primitives;+pub(crate) mod state;+pub(crate) mod tokens;++pub(crate) use events::*;+pub(crate) use geometry::*;+pub(crate) use icons::*;+pub(crate) use primitives::*;+pub(crate) use state::*;+pub(crate) use tokens::*;diff --git a/wezterm-gui/src/ui/primitives.rs b/wezterm-gui/src/ui/primitives.rsnew file mode 100644index 00000000..f7eebfd5--- /dev/null+++ b/wezterm-gui/src/ui/primitives.rs@@ -0,0 +1,71 @@+use crate::ui::{UiPalette, UiTokens, WidgetKind};++#[derive(Debug, Clone, Copy, PartialEq, Eq)]+pub(crate) enum ControlState {+ Normal,+ Hovered,+ Pressed,+ Active,+ Disabled,+}++impl ControlState {+ pub(crate) fn colors(+ self,+ palette: UiPalette,+ ) -> (window::color::LinearRgba, window::color::LinearRgba) {+ match self {+ Self::Normal => (palette.control_bg, palette.control_border),+ Self::Hovered => (palette.control_hover_bg, palette.separator),+ Self::Pressed => (palette.control_pressed_bg, palette.selected_bg),+ Self::Active => (palette.selected_bg, palette.selected_bg),+ Self::Disabled => (palette.control_bg, palette.control_border),+ }+ }+}++#[derive(Debug, Clone, Copy)]+pub(crate) struct ButtonSpec<'a, A: Copy> {+ pub label: &'a str,+ pub action: A,+ pub rect: window::RectF,+ pub state: ControlState,+ pub kind: WidgetKind,+}++#[derive(Debug, Clone, Copy)]+pub(crate) struct TextInputSpec<'a, A: Copy> {+ pub placeholder: &'a str,+ pub text: &'a str,+ pub rect: window::RectF,+ pub focused: bool,+ pub selected_all: bool,+ pub action: A,+}++#[derive(Debug, Clone, Copy)]+pub(crate) struct SettingRowSpec<'a> {+ pub label: &'a str,+ pub description: &'a str,+ pub value: &'a str,+ pub y: f32,+}++#[derive(Debug, Clone, Copy)]+pub(crate) struct ScrollbarSpec {+ pub x: f32,+ pub y: f32,+ pub width: f32,+ pub height: f32,+}++impl ScrollbarSpec {+ pub(crate) fn from_area(area: window::RectF, tokens: UiTokens) -> Self {+ Self {+ x: area.origin.x + area.size.width - tokens.scrollbar_width - 4.0,+ y: area.origin.y + 8.0,+ width: tokens.scrollbar_width,+ height: (area.size.height - 16.0).max(0.0),+ }+ }+}diff --git a/wezterm-gui/src/ui/state.rs b/wezterm-gui/src/ui/state.rsnew file mode 100644index 00000000..8b11718d--- /dev/null+++ b/wezterm-gui/src/ui/state.rs@@ -0,0 +1,254 @@+use std::time::Instant;+use window::ScrollPhase;++#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]+pub(crate) struct WidgetId(pub u64);++#[derive(Debug, Clone, Copy, PartialEq, Eq)]+pub(crate) enum WidgetKind {+ Button,+ TextInput,+ SidebarRow,+ ResizeHandle,+ ScrollArea,+ PreviewControl,+}++#[derive(Debug, Clone, Copy)]+pub(crate) struct HitTarget<A: Copy> {+ pub rect: window::RectF,+ pub kind: WidgetKind,+ pub action: A,+}++#[derive(Debug, Clone)]+pub(crate) struct UiContext<A: Copy> {+ hits: Vec<HitTarget<A>>,+}++impl<A: Copy> Default for UiContext<A> {+ fn default() -> Self {+ Self { hits: Vec::new() }+ }+}++impl<A: Copy> UiContext<A> {+ pub(crate) fn clear(&mut self) {+ self.hits.clear();+ }++ pub(crate) fn push(&mut self, rect: window::RectF, kind: WidgetKind, action: A) {+ self.hits.push(HitTarget { rect, kind, action });+ }++ pub(crate) fn hit_test(&self, x: f32, y: f32) -> Option<HitTarget<A>> {+ self.hits+ .iter()+ .rev()+ .find(|target| target.rect.contains(euclid::point2(x, y)))+ .copied()+ }+}++#[derive(Debug, Clone)]+pub(crate) struct InteractionState<A: Copy + PartialEq> {+ pub hovered: Option<A>,+ pub pressed: Option<A>,+ pub focused: Option<A>,+}++impl<A: Copy + PartialEq> Default for InteractionState<A> {+ fn default() -> Self {+ Self {+ hovered: None,+ pressed: None,+ focused: None,+ }+ }+}++#[derive(Debug, Clone)]+pub(crate) struct TextInputState {+ pub text: String,+ pub selected_all: bool,+}++impl TextInputState {+ pub(crate) fn new() -> Self {+ Self {+ text: String::new(),+ selected_all: false,+ }+ }++ pub(crate) fn push_text(&mut self, text: &str) {+ if self.selected_all {+ self.text.clear();+ self.selected_all = false;+ }+ self.text.extend(text.chars().filter(|ch| !ch.is_control()));+ }++ pub(crate) fn backspace(&mut self) {+ if self.selected_all {+ self.text.clear();+ self.selected_all = false;+ } else {+ self.text.pop();+ }+ }++ pub(crate) fn clear(&mut self) {+ self.text.clear();+ self.selected_all = false;+ }++ pub(crate) fn is_empty(&self) -> bool {+ self.text.is_empty()+ }++ pub(crate) fn select_all(&mut self) {+ self.selected_all = !self.text.is_empty();+ }+}++#[derive(Debug, Clone, Copy)]+pub(crate) struct ScrollState {+ pub offset: f32,+ pub velocity: f32,+ pub target_offset: f32,+ pub viewport_extent: f32,+ pub content_extent: f32,+ pub active_phase: Option<ScrollPhase>,+ last_animation_time: Option<Instant>,+}++impl ScrollState {+ pub(crate) fn new() -> Self {+ Self {+ offset: 0.0,+ velocity: 0.0,+ target_offset: 0.0,+ viewport_extent: 0.0,+ content_extent: 0.0,+ active_phase: None,+ last_animation_time: None,+ }+ }++ pub(crate) fn set_extents(&mut self, viewport_extent: f32, content_extent: f32) {+ self.viewport_extent = viewport_extent.max(0.0);+ self.content_extent = content_extent.max(0.0);+ self.offset = self.offset.clamp(0.0, self.max_offset());+ self.target_offset = self.target_offset.clamp(0.0, self.max_offset());+ }++ pub(crate) fn scroll_by(&mut self, delta: f32) {+ let offset = (self.offset + delta).clamp(0.0, self.max_offset());+ self.offset = offset;+ self.target_offset = offset;+ self.velocity = 0.0;+ self.last_animation_time = None;+ }++ pub(crate) fn scroll_by_smooth(&mut self, delta: f32) {+ self.velocity += delta * 24.0;+ self.target_offset = self.offset;+ self.last_animation_time = None;+ }++ pub(crate) fn set_phase(&mut self, phase: Option<ScrollPhase>) {+ self.active_phase = phase;+ if matches!(phase, Some(ScrollPhase::Ended | ScrollPhase::Cancelled)) {+ self.active_phase = None;+ }+ }++ pub(crate) fn reset(&mut self) {+ self.offset = 0.0;+ self.target_offset = 0.0;+ self.velocity = 0.0;+ self.active_phase = None;+ self.last_animation_time = None;+ }++ pub(crate) fn advance_animation(&mut self, now: Instant) -> bool {+ let previous = self.last_animation_time.replace(now).unwrap_or(now);+ let dt = now+ .saturating_duration_since(previous)+ .as_secs_f32()+ .clamp(1.0 / 240.0, 1.0 / 30.0);++ if self.velocity.abs() > 0.5 {+ let old = self.offset;+ self.offset = (self.offset + self.velocity * dt).clamp(0.0, self.max_offset());+ if (self.offset - old).abs() <= f32::EPSILON+ && (self.offset <= 0.0 || self.offset >= self.max_offset())+ {+ self.velocity = 0.0;+ } else {+ self.velocity *= (-18.0 * dt).exp();+ }+ self.target_offset = self.offset;+ return true;+ }++ self.velocity = 0.0;++ let target_delta = self.target_offset - self.offset;+ if target_delta.abs() <= 0.45 {+ let was_animating = (self.offset - self.target_offset).abs() > f32::EPSILON;+ self.offset = self.target_offset;+ self.last_animation_time = None;+ return was_animating;+ }++ let alpha = 1.0 - (-42.0 * dt).exp();+ self.offset += target_delta * alpha;+ true+ }++ pub(crate) fn max_offset(&self) -> f32 {+ (self.content_extent - self.viewport_extent).max(0.0)+ }++ pub(crate) fn has_overflow(&self) -> bool {+ self.max_offset() > 0.5+ }++ pub(crate) fn thumb(&self, track_start: f32, track_extent: f32) -> Option<(f32, f32)> {+ if !self.has_overflow() || track_extent <= 0.0 || self.content_extent <= 0.0 {+ return None;+ }+ let ratio = (self.viewport_extent / self.content_extent).clamp(0.08, 1.0);+ let thumb_extent = (track_extent * ratio).max(32.0).min(track_extent);+ let travel = (track_extent - thumb_extent).max(0.0);+ let progress = if self.max_offset() <= 0.0 {+ 0.0+ } else {+ self.offset / self.max_offset()+ };+ Some((track_start + travel * progress, thumb_extent))+ }+}++#[derive(Debug, Clone, Copy)]+pub(crate) struct ResizablePaneState {+ pub width: f32,+ pub min_width: f32,+ pub max_width: f32,+}++impl ResizablePaneState {+ pub(crate) fn new(width: f32, min_width: f32, max_width: f32) -> Self {+ Self {+ width: width.clamp(min_width, max_width),+ min_width,+ max_width,+ }+ }++ pub(crate) fn set_width(&mut self, width: f32) {+ self.width = width.clamp(self.min_width, self.max_width);+ }+}diff --git a/wezterm-gui/src/ui/tokens.rs b/wezterm-gui/src/ui/tokens.rsnew file mode 100644index 00000000..184a74ca--- /dev/null+++ b/wezterm-gui/src/ui/tokens.rs@@ -0,0 +1,107 @@+use window::color::LinearRgba;+use window::Appearance;++#[derive(Debug, Clone, Copy)]+pub(crate) struct UiPalette {+ pub window_bg: LinearRgba,+ pub sidebar_bg: LinearRgba,+ pub workspace_sidebar_bg: LinearRgba,+ pub header_bg: LinearRgba,+ pub separator: LinearRgba,+ pub control_bg: LinearRgba,+ pub control_hover_bg: LinearRgba,+ pub control_pressed_bg: LinearRgba,+ pub control_border: LinearRgba,+ pub selected_bg: LinearRgba,+ pub text: LinearRgba,+ pub secondary_text: LinearRgba,+ pub muted_text: LinearRgba,+ pub selected_text: LinearRgba,+ pub scrollbar_thumb: LinearRgba,+}++impl UiPalette {+ pub(crate) fn for_appearance(appearance: Appearance) -> Self {+ match appearance {+ Appearance::Light | Appearance::LightHighContrast => Self {+ window_bg: rgb(238, 238, 242),+ sidebar_bg: rgb(238, 238, 242),+ workspace_sidebar_bg: rgb(226, 226, 232),+ header_bg: rgb(238, 238, 242),+ separator: rgba(60, 60, 67, 0.18),+ control_bg: rgba(255, 255, 255, 0.94),+ control_hover_bg: rgba(247, 247, 250, 0.98),+ control_pressed_bg: rgba(232, 242, 255, 0.98),+ control_border: rgba(60, 60, 67, 0.20),+ selected_bg: rgb(0, 122, 255),+ text: rgb(28, 28, 30),+ secondary_text: rgb(72, 72, 74),+ muted_text: rgb(142, 142, 147),+ selected_text: rgb(255, 255, 255),+ scrollbar_thumb: rgba(60, 60, 67, 0.32),+ },+ Appearance::Dark | Appearance::DarkHighContrast => Self {+ window_bg: rgb(25, 25, 26),+ sidebar_bg: rgb(25, 25, 26),+ workspace_sidebar_bg: rgb(18, 18, 20),+ header_bg: rgb(25, 25, 26),+ separator: rgba(84, 84, 88, 0.22),+ control_bg: rgba(45, 45, 47, 0.98),+ control_hover_bg: rgba(55, 55, 57, 0.98),+ control_pressed_bg: rgba(66, 66, 69, 0.98),+ control_border: rgba(118, 118, 128, 0.28),+ selected_bg: rgb(58, 58, 60),+ text: rgb(242, 242, 247),+ secondary_text: rgb(199, 199, 204),+ muted_text: rgb(142, 142, 147),+ selected_text: rgb(255, 255, 255),+ scrollbar_thumb: rgba(142, 142, 147, 0.42),+ },+ }+ }+}++#[derive(Debug, Clone, Copy)]+pub(crate) struct UiTokens {+ pub sidebar_min_width: f32,+ pub sidebar_max_width: f32,+ pub sidebar_default_width: f32,+ pub sidebar_padding: f32,+ pub row_height: f32,+ pub row_gap: f32,+ pub control_height: f32,+ pub control_radius: f32,+ pub row_radius: f32,+ pub icon_size: f32,+ pub resize_handle_width: f32,+ pub scrollbar_width: f32,+}++impl Default for UiTokens {+ fn default() -> Self {+ Self {+ sidebar_min_width: 340.0,+ sidebar_max_width: 580.0,+ sidebar_default_width: 380.0,+ sidebar_padding: 28.0,+ row_height: 48.0,+ row_gap: 8.0,+ control_height: 56.0,+ control_radius: 12.0,+ row_radius: 9.0,+ icon_size: 26.0,+ resize_handle_width: 24.0,+ scrollbar_width: 5.0,+ }+ }+}++fn rgb(red: u8, green: u8, blue: u8) -> LinearRgba {+ rgba(red, green, blue, 1.0)+}++fn rgba(red: u8, green: u8, blue: u8, alpha: f32) -> LinearRgba {+ let mut color = LinearRgba::with_srgba(red, green, blue, 255);+ color.3 = alpha;+ color+}diff --git a/wezterm-input-types/src/lib.rs b/wezterm-input-types/src/lib.rsindex 833aa22b..2253dec4 100644--- a/wezterm-input-types/src/lib.rs+++ b/wezterm-input-types/src/lib.rs@@ -1269,7 +1269,23 @@ pub enum MouseEventKind {HorzWheel(i16),}-#[derive(Debug, Clone, PartialEq, Eq)]+#[derive(Debug, Copy, Clone, PartialEq)]+pub struct PreciseScrollDelta {+ pub x: f32,+ pub y: f32,+}++#[derive(Debug, Copy, Clone, PartialEq, Eq)]+pub enum ScrollPhase {+ Began,+ Stationary,+ Changed,+ Ended,+ Cancelled,+ MayBegin,+}++#[derive(Debug, Clone, PartialEq)]pub struct MouseEvent {pub kind: MouseEventKind,/// Coordinates of the mouse relative to the top left of the window@@ -1278,6 +1294,15 @@ pub struct MouseEvent {pub screen_coords: crate::ScreenPoint,pub mouse_buttons: MouseButtons,pub modifiers: Modifiers,+ /// Pixel-precise wheel delta from native scroll devices when available.+ ///+ /// Traditional `VertWheel`/`HorzWheel` values are line/discrete oriented;+ /// this preserves high-resolution trackpad scrolling for UI chrome.+ pub precise_scroll_delta: Option<PreciseScrollDelta>,+ /// Native scroll gesture phase when available.+ pub scroll_phase: Option<ScrollPhase>,+ /// Native momentum scroll phase when available.+ pub momentum_phase: Option<ScrollPhase>,}#[derive(Debug, Clone)]diff --git a/window/src/connection.rs b/window/src/connection.rsindex 9564d499..e58a0e77 100644--- a/window/src/connection.rs+++ b/window/src/connection.rs@@ -68,6 +68,9 @@ pub trait ConnectionOps {Appearance::Light}+ /// Override the application appearance. Passing `None` follows the system.+ fn set_preferred_appearance(&self, _appearance: Option<Appearance>) {}+/// Hide the application./// This actions hides all of the windows of the application and switches/// focus away from it.diff --git a/window/src/os/macos/connection.rs b/window/src/os/macos/connection.rsindex b5a85d2e..dd51ae50 100644--- a/window/src/os/macos/connection.rs+++ b/window/src/os/macos/connection.rs@@ -1,8 +1,8 @@// let () = msg_send! is a common pattern for objc#![allow(clippy::let_unit_value)]-use super::nsstring_to_str;use super::window::WindowInner;+use super::{nsstring, nsstring_to_str};use crate::connection::ConnectionOps;use crate::os::macos::app::create_app_delegate;use crate::screen::{ScreenInfo, Screens};@@ -152,6 +152,23 @@ impl ConnectionOps for Connection {}}+ fn set_preferred_appearance(&self, appearance: Option<Appearance>) {+ unsafe {+ let ns_appearance: id = match appearance {+ Some(Appearance::Light | Appearance::LightHighContrast) => {+ let name = nsstring("NSAppearanceNameAqua");+ msg_send![class!(NSAppearance), appearanceNamed: *name]+ }+ Some(Appearance::Dark | Appearance::DarkHighContrast) => {+ let name = nsstring("NSAppearanceNameDarkAqua");+ msg_send![class!(NSAppearance), appearanceNamed: *name]+ }+ None => nil,+ };+ let () = msg_send![self.ns_app, setAppearance: ns_appearance];+ }+ }+fn run_message_loop(&self) -> anyhow::Result<()> {unsafe {self.ns_app.run();diff --git a/window/src/os/macos/window.rs b/window/src/os/macos/window.rsindex ab9485ee..bf5712d7 100644--- a/window/src/os/macos/window.rs+++ b/window/src/os/macos/window.rs@@ -11,8 +11,9 @@ use crate::parameters::{Border, Parameters, TitleBar};use crate::{Clipboard, Connection, ContextMenuItem, DeadKeyStatus, Dimensions, Handled, Image, KeyCode,KeyEvent, Modifiers, MouseButtons, MouseCursor, MouseEvent, MouseEventKind, MousePress, Point,- RawKeyEvent, Rect, RequestedWindowGeometry, ResizeIncrement, ResolvedGeometry, ScreenPoint,- Size, ULength, WindowDecorations, WindowEvent, WindowEventSender, WindowOps, WindowState,+ PreciseScrollDelta, RawKeyEvent, Rect, RequestedWindowGeometry, ResizeIncrement,+ ResolvedGeometry, ScreenPoint, ScrollPhase, Size, ULength, WindowDecorations, WindowEvent,+ WindowEventSender, WindowOps, WindowState,};use anyhow::{anyhow, bail, ensure};use async_trait::async_trait;@@ -20,9 +21,9 @@ use block2::RcBlock;use cocoa::appkit::{self, CGFloat, NSApplication, NSApplicationActivateIgnoringOtherApps,NSApplicationPresentationOptions, NSBackingStoreBuffered, NSEvent, NSEventModifierFlags,- NSImage, NSImageNameApplicationIcon, NSOpenGLContext, NSOpenGLPixelFormat, NSPasteboard,- NSRunningApplication, NSScreen, NSView, NSViewHeightSizable, NSViewWidthSizable, NSWindow,- NSWindowStyleMask,+ NSEventPhase, NSImage, NSImageNameApplicationIcon, NSOpenGLContext, NSOpenGLPixelFormat,+ NSPasteboard, NSRunningApplication, NSScreen, NSView, NSViewHeightSizable, NSViewWidthSizable,+ NSWindow, NSWindowStyleMask,};use cocoa::base::*;use cocoa::foundation::{@@ -53,7 +54,7 @@ use std::path::{Path, PathBuf};use std::ptr::NonNull;use std::rc::Rc;use std::str::FromStr;-use std::sync::{Arc, Mutex};+use std::sync::{Arc, Mutex, OnceLock};use std::time::Instant;use wezterm_font::FontConfiguration;use wezterm_input_types::{is_ascii_control, IntegratedTitleButtonStyle, KeyboardLedStatus};@@ -63,11 +64,96 @@ const NSViewLayerContentsPlacementTopLeft: NSInteger = 11;#[allow(non_upper_case_globals)]const NSViewLayerContentsRedrawDuringViewResize: NSInteger = 2;const THINKTERM_TITLEBAR_SIDEBAR_BUTTON_FALLBACK_X: f64 = 96.0;-const THINKTERM_TITLEBAR_SIDEBAR_BUTTON_FULLSCREEN_X: f64 = 22.0;const THINKTERM_TITLEBAR_SIDEBAR_BUTTON_GAP: f64 = 8.0;const THINKTERM_TITLEBAR_SIDEBAR_BUTTON_SIZE: f64 = 30.0;const THINKTERM_TITLEBAR_SIDEBAR_BUTTON_TAG: NSInteger = 0x7474_7362;+static THINKTERM_PERF_ENABLED: OnceLock<bool> = OnceLock::new();++fn thinkterm_perf_enabled() -> bool {+ *THINKTERM_PERF_ENABLED.get_or_init(|| {+ std::env::var_os("THINKTERM_PERF")+ .map(|value| value != "0" && !value.is_empty())+ .unwrap_or(false)+ })+}++fn macos_current_screen_max_fps() -> Option<usize> {+ unsafe {+ let screen = NSScreen::mainScreen(nil);+ if screen.is_null() {+ return None;+ }+ let has_max_fps: BOOL = msg_send!(screen, respondsToSelector: sel!(maximumFramesPerSecond));+ if has_max_fps == YES {+ let max_fps: NSInteger = msg_send!(screen, maximumFramesPerSecond);+ Some(max_fps.max(1) as usize)+ } else {+ None+ }+ }+}++fn target_frame_fps(configured_max_fps: u64) -> f64 {+ let configured = configured_max_fps.max(1) as f64;+ let screen = macos_current_screen_max_fps().unwrap_or(60).max(1) as f64;+ configured.min(screen).max(1.0)+}++fn ns_event_phase_to_scroll_phase(phase: NSEventPhase) -> Option<ScrollPhase> {+ if phase.contains(NSEventPhase::NSEventPhaseBegan) {+ Some(ScrollPhase::Began)+ } else if phase.contains(NSEventPhase::NSEventPhaseStationary) {+ Some(ScrollPhase::Stationary)+ } else if phase.contains(NSEventPhase::NSEventPhaseChanged) {+ Some(ScrollPhase::Changed)+ } else if phase.contains(NSEventPhase::NSEventPhaseEnded) {+ Some(ScrollPhase::Ended)+ } else if phase.contains(NSEventPhase::NSEventPhaseCancelled) {+ Some(ScrollPhase::Cancelled)+ } else if phase.contains(NSEventPhase::NSEventPhaseMayBegin) {+ Some(ScrollPhase::MayBegin)+ } else {+ None+ }+}++unsafe fn set_view_background_color(view: id, color: RgbaColor) {+ if view.is_null() {+ return;+ }++ let layer: id = msg_send![view, layer];+ if !layer.is_null() {+ let srgb_cgcolor = objc2_core_graphics::CGColor::new_srgb(+ color.0.into(),+ color.1.into(),+ color.2.into(),+ color.3.into(),+ );+ let _: () = msg_send![layer, setBackgroundColor: srgb_cgcolor];+ }+}++unsafe fn set_standard_window_buttons_visible(window: &StrongPtr, visible: bool) {+ let hidden = if visible { NO } else { YES };+ let alpha = if visible { 1.0 } else { 0.0 };+ let enabled = if visible { YES } else { NO };++ for titlebar_button in &[+ appkit::NSWindowButton::NSWindowMiniaturizeButton,+ appkit::NSWindowButton::NSWindowCloseButton,+ appkit::NSWindowButton::NSWindowZoomButton,+ ] {+ let button = window.standardWindowButton_(*titlebar_button);+ if !button.is_null() {+ let _: () = msg_send![button, setHidden: hidden];+ let _: () = msg_send![button, setAlphaValue: alpha];+ let _: () = msg_send![button, setEnabled: enabled];+ }+ }+}+pub fn set_application_icon_from_file(path: &Path) -> anyhow::Result<()> {let path_string = path.to_string_lossy();@@ -514,6 +600,7 @@ impl Window {view_id: None,window_id,window: None,+ titlebar_sidebar_button_visible: false,screen_changed: false,paint_throttled: false,invalidated: true,@@ -523,6 +610,7 @@ impl Window {hscroll_remainder: 0.,vscroll_remainder: 0.,last_wheel: Instant::now(),+ last_repaint_time: None,key_is_down: None,dead_pending: None,fullscreen: None,@@ -1109,11 +1197,17 @@ impl WindowInner {fn set_titlebar_sidebar_button_visible(&mut self, visible: bool) {self.titlebar_sidebar_button_visible = visible;+ if let Some(window_view) = WindowView::get_this(unsafe { &**self.view }) {+ window_view+ .inner+ .borrow_mut()+ .titlebar_sidebar_button_visible = visible;+ }self.update_titlebar_sidebar_button();}fn update_titlebar_sidebar_button(&mut self) {- if self.titlebar_sidebar_button_visible {+ if self.titlebar_sidebar_button_visible && !self.is_fullscreen() {install_thinkterm_titlebar_sidebar_button(&self.window, *self.view);} else {remove_thinkterm_titlebar_sidebar_button(&self.window);@@ -1238,39 +1332,14 @@ impl WindowInner {}fn update_titlebar_background(&self) {- if !self- .config- .window_decorations- .contains(WindowDecorations::MACOS_USE_BACKGROUND_COLOR_AS_TITLEBAR_COLOR)- {- return;- }-- // Set the titlebar background to the theme color falling back to black if there is no- // specified color scheme- let color = self- .config- .resolved_palette- .background- .unwrap_or(RgbaColor::from(SrgbaTuple(0., 0., 0., 255.)));-unsafe {if let Some(titlebar_view_container) = get_titlebar_view_container(&self.window) {- let layer: id = msg_send![*titlebar_view_container.load(), layer];-- if layer.is_null() {- return;- }-- // We need to make sure to convert the config color into an sRGB CGColor or the color will be slightly off- let srgb_cgcolor = objc2_core_graphics::CGColor::new_srgb(- color.0.into(),- color.1.into(),- color.2.into(),- color.3.into(),+ let titlebar_view_container_id = titlebar_view_container.load();+ set_view_background_color(+ *titlebar_view_container_id,+ RgbaColor::from(SrgbaTuple(0.0, 0.0, 0.0, 0.0)),);-- let _: () = msg_send![layer, setBackgroundColor: srgb_cgcolor];+ set_standard_window_buttons_visible(&self.window, true);} else {log::trace!("failed to get titlebar view container from window");}@@ -1310,7 +1379,8 @@ impl WindowInner {self.update_titlebar_background();self.update_titlebar_sidebar_button();- self.window.makeKeyAndOrderFront_(nil)+ self.window.makeKeyAndOrderFront_(nil);+ self.update_titlebar_background();}}@@ -1549,36 +1619,14 @@ fn apply_decorations_to_window(integrated_title_button_style: IntegratedTitleButtonStyle,) {let mask = decoration_to_mask(decorations, integrated_title_button_style);- let decorations = effective_decorations(decorations, integrated_title_button_style);unsafe {window.setStyleMask_(mask);- let hidden = if decorations.contains(WindowDecorations::TITLE)- || decorations.contains(WindowDecorations::INTEGRATED_BUTTONS)- {- NO- } else {- YES- };-- for titlebar_button in &[- appkit::NSWindowButton::NSWindowMiniaturizeButton,- appkit::NSWindowButton::NSWindowCloseButton,- appkit::NSWindowButton::NSWindowZoomButton,- ] {- let button = window.standardWindowButton_(*titlebar_button);- let _: () = msg_send![button, setHidden: hidden];- }+ set_standard_window_buttons_visible(window, true);window.setTitleVisibility_(appkit::NSWindowTitleVisibility::NSWindowTitleHidden);- if decorations.contains(WindowDecorations::INTEGRATED_BUTTONS)- || decorations.contains(WindowDecorations::MACOS_USE_BACKGROUND_COLOR_AS_TITLEBAR_COLOR)- {- window.setTitlebarAppearsTransparent_(YES);- } else {- window.setTitlebarAppearsTransparent_(hidden);- }+ window.setTitlebarAppearsTransparent_(YES);}}@@ -1645,8 +1693,6 @@ fn position_thinkterm_titlebar_sidebar_button(unsafe {let titlebar_frame = NSView::frame(titlebar_view_container_id);let zoom_button = window.standardWindowButton_(appkit::NSWindowButton::NSWindowZoomButton);- let is_fullscreen =- NSWindow::styleMask(**window).contains(NSWindowStyleMask::NSFullScreenWindowMask);let zoom_button_hidden = if zoom_button.is_null() {false} else {@@ -1654,15 +1700,11 @@ fn position_thinkterm_titlebar_sidebar_button(hidden == YES};let x = if zoom_button.is_null() {- if is_fullscreen {- THINKTERM_TITLEBAR_SIDEBAR_BUTTON_FULLSCREEN_X- } else {- THINKTERM_TITLEBAR_SIDEBAR_BUTTON_FALLBACK_X- }+ THINKTERM_TITLEBAR_SIDEBAR_BUTTON_FALLBACK_X} else {let zoom_frame = NSView::frame(zoom_button);if zoom_button_hidden && zoom_frame.size.width <= 0.0 {- THINKTERM_TITLEBAR_SIDEBAR_BUTTON_FULLSCREEN_X+ THINKTERM_TITLEBAR_SIDEBAR_BUTTON_FALLBACK_X} else {zoom_frame.origin.x + zoom_frame.size.width + THINKTERM_TITLEBAR_SIDEBAR_BUTTON_GAP}@@ -1680,22 +1722,6 @@ fn position_thinkterm_titlebar_sidebar_button(}}-fn reposition_thinkterm_titlebar_sidebar_button_if_present(window: &StrongPtr) {- let Some(titlebar_view_container) = get_titlebar_view_container(window) else {- return;- };- let titlebar_view_container = titlebar_view_container.load();- if titlebar_view_container.is_null() {- return;- }-- let Some(button) = thinkterm_titlebar_sidebar_button(&titlebar_view_container) else {- return;- };-- position_thinkterm_titlebar_sidebar_button(window, *titlebar_view_container, button);-}-fn remove_thinkterm_titlebar_sidebar_button(window: &StrongPtr) {unsafe {let Some(titlebar_view_container) = get_titlebar_view_container(window) else {@@ -1756,10 +1782,12 @@ fn decoration_to_mask(| NSWindowStyleMask::NSClosableWindowMask| NSWindowStyleMask::NSMiniaturizableWindowMask| NSWindowStyleMask::NSResizableWindowMask+ | NSWindowStyleMask::NSFullSizeContentViewWindowMask} else if decorations== WindowDecorations::MACOS_FORCE_SQUARE_CORNERS | WindowDecorations::RESIZE{- NSWindowStyleMask::NSClosableWindowMask+ NSWindowStyleMask::NSTitledWindowMask+ | NSWindowStyleMask::NSClosableWindowMask| NSWindowStyleMask::NSMiniaturizableWindowMask| NSWindowStyleMask::NSResizableWindowMask| NSWindowStyleMask::NSFullSizeContentViewWindowMask@@ -1782,7 +1810,8 @@ fn decoration_to_mask(| NSWindowStyleMask::NSClosableWindowMask| NSWindowStyleMask::NSMiniaturizableWindowMask} else if decorations == WindowDecorations::MACOS_FORCE_SQUARE_CORNERS {- NSWindowStyleMask::NSClosableWindowMask+ NSWindowStyleMask::NSTitledWindowMask+ | NSWindowStyleMask::NSClosableWindowMask| NSWindowStyleMask::NSMiniaturizableWindowMask| NSWindowStyleMask::NSFullSizeContentViewWindowMask} else {@@ -1871,6 +1900,7 @@ struct Inner {events: WindowEventSender,view_id: Option<WeakPtr>,window: Option<WeakPtr>,+ titlebar_sidebar_button_visible: bool,screen_changed: bool,paint_throttled: bool,window_id: usize,@@ -1881,6 +1911,7 @@ struct Inner {hscroll_remainder: f64,vscroll_remainder: f64,last_wheel: Instant,+ last_repaint_time: Option<Instant>,/// We use this to avoid double-emitting events when/// procesing key-up events.key_is_down: Option<bool>,@@ -2485,11 +2516,19 @@ impl WindowView {extern "C" fn view_did_change_effective_appearance(this: &mut Object, _sel: Sel) {if let Some(this) = Self::get_this(this) {- let appearance = Connection::get().unwrap().get_appearance();- this.inner- .borrow_mut()- .events- .dispatch(WindowEvent::AppearanceChanged(appearance));+ let Some(connection) = Connection::get() else {+ return;+ };+ let appearance = connection.get_appearance();+ if let Ok(mut inner) = this.inner.try_borrow_mut() {+ inner+ .events+ .dispatch(WindowEvent::AppearanceChanged(appearance));+ } else {+ log::trace!(+ "deferring appearance change because the macOS window is dispatching another event"+ );+ }}}@@ -2660,7 +2699,14 @@ impl WindowView {}}- fn mouse_common(this: &mut Object, nsevent: id, kind: MouseEventKind) {+ fn mouse_common(+ this: &mut Object,+ nsevent: id,+ kind: MouseEventKind,+ precise_scroll_delta: Option<PreciseScrollDelta>,+ scroll_phase: Option<ScrollPhase>,+ momentum_phase: Option<ScrollPhase>,+ ) {let view = this as id;let coords;let mouse_buttons;@@ -2686,6 +2732,9 @@ impl WindowView {screen_coords: cartesian_to_screen_point(screen_coords),mouse_buttons,modifiers,+ precise_scroll_delta,+ scroll_phase,+ momentum_phase,};if let Some(myself) = Self::get_this(this) {@@ -2695,14 +2744,35 @@ impl WindowView {}extern "C" fn mouse_up(this: &mut Object, _sel: Sel, nsevent: id) {- Self::mouse_common(this, nsevent, MouseEventKind::Release(MousePress::Left));+ Self::mouse_common(+ this,+ nsevent,+ MouseEventKind::Release(MousePress::Left),+ None,+ None,+ None,+ );}extern "C" fn mouse_down(this: &mut Object, _sel: Sel, nsevent: id) {- Self::mouse_common(this, nsevent, MouseEventKind::Press(MousePress::Left));+ Self::mouse_common(+ this,+ nsevent,+ MouseEventKind::Press(MousePress::Left),+ None,+ None,+ None,+ );}extern "C" fn right_mouse_up(this: &mut Object, _sel: Sel, nsevent: id) {- Self::mouse_common(this, nsevent, MouseEventKind::Release(MousePress::Right));+ Self::mouse_common(+ this,+ nsevent,+ MouseEventKind::Release(MousePress::Right),+ None,+ None,+ None,+ );}extern "C" fn other_mouse_up(this: &mut Object, _sel: Sel, nsevent: id) {@@ -2712,13 +2782,34 @@ impl WindowView {// Button 2 is the middle mouse button (scroll wheel)// but is the dedicated middle mouse button on 4 button mousesif button_number == 2 {- Self::mouse_common(this, nsevent, MouseEventKind::Release(MousePress::Middle));+ Self::mouse_common(+ this,+ nsevent,+ MouseEventKind::Release(MousePress::Middle),+ None,+ None,+ None,+ );}}}extern "C" fn scroll_wheel(this: &mut Object, _sel: Sel, nsevent: id) {let precise = unsafe { nsevent.hasPreciseScrollingDeltas() } == YES;+ let raw_vert_delta = unsafe { nsevent.scrollingDeltaY() };+ let raw_horz_delta = unsafe { nsevent.scrollingDeltaX() };+ let scroll_phase = unsafe { ns_event_phase_to_scroll_phase(nsevent.phase()) };+ let momentum_phase = unsafe { ns_event_phase_to_scroll_phase(nsevent.momentumPhase()) };+ let precise_scroll_delta = if precise+ && (raw_vert_delta.abs() > f64::EPSILON || raw_horz_delta.abs() > f64::EPSILON)+ {+ Some(PreciseScrollDelta {+ x: raw_horz_delta as f32,+ y: raw_vert_delta as f32,+ })+ } else {+ None+ };let scale = if precise {// Devices with precise deltas report number of pixels scrolled.// At this layer we don't know how many pixels comprise a cell@@ -2732,8 +2823,8 @@ impl WindowView {// so we want to report those lines here wholesale.1.0};- let mut vert_delta = unsafe { nsevent.scrollingDeltaY() } / scale;- let mut horz_delta = unsafe { nsevent.scrollingDeltaX() } / scale;+ let mut vert_delta = raw_vert_delta / scale;+ let mut horz_delta = raw_horz_delta / scale;if let Some(myself) = Self::get_this(this) {let mut inner = myself.inner.borrow_mut();@@ -2780,16 +2871,36 @@ impl WindowView {return;}- let kind = if vert_delta.abs() > horz_delta.abs() {+ let vertical_is_dominant = vert_delta.abs() > horz_delta.abs();+ let kind = if vertical_is_dominant {MouseEventKind::VertWheel(round_away_from_zero(vert_delta))} else {MouseEventKind::HorzWheel(round_away_from_zero(horz_delta))};- Self::mouse_common(this, nsevent, kind);+ if thinkterm_perf_enabled() {+ log::info!(+ "thinkterm_perf scroll precise={precise} raw=({raw_horz_delta:.2},{raw_vert_delta:.2}) phase={scroll_phase:?} momentum={momentum_phase:?}"+ );+ }+ Self::mouse_common(+ this,+ nsevent,+ kind,+ precise_scroll_delta,+ scroll_phase,+ momentum_phase,+ );}extern "C" fn right_mouse_down(this: &mut Object, _sel: Sel, nsevent: id) {- Self::mouse_common(this, nsevent, MouseEventKind::Press(MousePress::Right));+ Self::mouse_common(+ this,+ nsevent,+ MouseEventKind::Press(MousePress::Right),+ None,+ None,+ None,+ );}extern "C" fn other_mouse_down(this: &mut Object, _sel: Sel, nsevent: id) {@@ -2798,13 +2909,20 @@ impl WindowView {let button_number = NSEvent::buttonNumber(nsevent);// See `other_mouse_up`if button_number == 2 {- Self::mouse_common(this, nsevent, MouseEventKind::Press(MousePress::Middle));+ Self::mouse_common(+ this,+ nsevent,+ MouseEventKind::Press(MousePress::Middle),+ None,+ None,+ None,+ );}}}extern "C" fn mouse_moved_or_dragged(this: &mut Object, _sel: Sel, nsevent: id) {- Self::mouse_common(this, nsevent, MouseEventKind::Move);+ Self::mouse_common(this, nsevent, MouseEventKind::Move, None, None, None);}extern "C" fn mouse_exited(this: &mut Object, _sel: Sel, _nsevent: id) {@@ -3317,7 +3435,15 @@ impl WindowView {_ => WindowState::default(),};if let Some(window) = inner.window.as_ref() {- reposition_thinkterm_titlebar_sidebar_button_if_present(&window.load());+ let window = window.load();+ if let (true, Some(view)) = (+ inner.titlebar_sidebar_button_visible && !is_full_screen,+ inner.view_id.as_ref().map(|view| view.load()),+ ) {+ install_thinkterm_titlebar_sidebar_button(&window, *view);+ } else {+ remove_thinkterm_titlebar_sidebar_button(&window);+ }}let dpi = inner@@ -3417,15 +3543,26 @@ impl WindowView {if inner.paint_throttled {inner.invalidated = true;} else {+ let now = Instant::now();+ if let Some(last) = inner.last_repaint_time.replace(now) {+ if thinkterm_perf_enabled() {+ log::info!(+ "thinkterm_perf macos_frame_interval_ms={:.2}",+ now.saturating_duration_since(last).as_secs_f64() * 1000.0+ );+ }+ }inner.events.dispatch(WindowEvent::NeedRepaint);inner.invalidated = false;inner.paint_throttled = true;let window_id = inner.window_id;- let max_fps = inner.config.max_fps;+ let max_fps = target_frame_fps(inner.config.max_fps);+ if thinkterm_perf_enabled() {+ log::info!("thinkterm_perf macos_target_fps={max_fps:.0}");+ }promise::spawn::spawn(async move {- async_io::Timer::after(std::time::Duration::from_millis(1000 / max_fps as u64))- .await;+ async_io::Timer::after(std::time::Duration::from_secs_f64(1.0 / max_fps)).await;Connection::with_window_inner(window_id, move |inner| {if let Some(window_view) = WindowView::get_this(unsafe { &**inner.view }) {if let Ok(mut state) = window_view.inner.try_borrow_mut() {@@ -3558,7 +3695,6 @@ impl WindowView {sel!(thinktermToggleWorkspaceSidebar:),Self::thinkterm_toggle_workspace_sidebar as extern "C" fn(&mut Object, Sel, id),);-cls.add_method(sel!(windowWillClose:),Self::window_will_close as extern "C" fn(&mut Object, Sel, id),diff --git a/window/src/os/wayland/window.rs b/window/src/os/wayland/window.rsindex b76a7691..ff969660 100644--- a/window/src/os/wayland/window.rs+++ b/window/src/os/wayland/window.rs@@ -719,6 +719,9 @@ impl WaylandWindowInner {),mouse_buttons: self.mouse_buttons,modifiers: self.modifiers,+ precise_scroll_delta: None,+ scroll_phase: None,+ momentum_phase: None,};self.events.dispatch(WindowEvent::MouseEvent(event));self.refresh_frame();@@ -750,6 +753,9 @@ impl WaylandWindowInner {),mouse_buttons: self.mouse_buttons,modifiers: self.modifiers,+ precise_scroll_delta: None,+ scroll_phase: None,+ momentum_phase: None,};self.events.dispatch(WindowEvent::MouseEvent(event));}@@ -774,6 +780,9 @@ impl WaylandWindowInner {),mouse_buttons: self.mouse_buttons,modifiers: self.modifiers,+ precise_scroll_delta: None,+ scroll_phase: None,+ momentum_phase: None,};self.events.dispatch(WindowEvent::MouseEvent(event));}@@ -794,6 +803,9 @@ impl WaylandWindowInner {),mouse_buttons: self.mouse_buttons,modifiers: self.modifiers,+ precise_scroll_delta: None,+ scroll_phase: None,+ momentum_phase: None,};self.events.dispatch(WindowEvent::MouseEvent(event));}diff --git a/window/src/os/windows/window.rs b/window/src/os/windows/window.rsindex 69e516d1..179c0d17 100644--- a/window/src/os/windows/window.rs+++ b/window/src/os/windows/window.rs@@ -1757,6 +1757,9 @@ unsafe fn mouse_button(hwnd: HWND, msg: UINT, wparam: WPARAM, lparam: LPARAM) ->screen_coords: client_to_screen(hwnd, coords),mouse_buttons,modifiers,+ precise_scroll_delta: None,+ scroll_phase: None,+ momentum_phase: None,};inner.borrow_mut()@@ -1807,6 +1810,9 @@ unsafe fn nc_mouse_button(screen_coords: client_to_screen(hwnd, coords),mouse_buttons,modifiers,+ precise_scroll_delta: None,+ scroll_phase: None,+ momentum_phase: None,};inner.borrow_mut()@@ -1840,6 +1846,9 @@ unsafe fn mouse_move(hwnd: HWND, _msg: UINT, wparam: WPARAM, lparam: LPARAM) ->screen_coords: client_to_screen(hwnd, coords),mouse_buttons,modifiers,+ precise_scroll_delta: None,+ scroll_phase: None,+ momentum_phase: None,};inner.events.dispatch(WindowEvent::MouseEvent(event));@@ -1876,6 +1885,9 @@ unsafe fn nc_mouse_move(hwnd: HWND, _msg: UINT, wparam: WPARAM, lparam: LPARAM)screen_coords: client_to_screen(hwnd, coords),mouse_buttons,modifiers,+ precise_scroll_delta: None,+ scroll_phase: None,+ momentum_phase: None,};inner.events.dispatch(WindowEvent::MouseEvent(event));@@ -1968,6 +1980,9 @@ unsafe fn mouse_wheel(hwnd: HWND, msg: UINT, wparam: WPARAM, lparam: LPARAM) ->screen_coords,mouse_buttons,modifiers,+ precise_scroll_delta: None,+ scroll_phase: None,+ momentum_phase: None,};inner.borrow_mut()diff --git a/window/src/os/x11/window.rs b/window/src/os/x11/window.rsindex a1b40843..2f7cff01 100644--- a/window/src/os/x11/window.rs+++ b/window/src/os/x11/window.rs@@ -474,6 +474,9 @@ impl XWindowInner {screen_coords: ScreenPoint::new(root_x.try_into().unwrap(), root_y.try_into().unwrap()),modifiers: xkeysyms::modifiers_from_state(state.bits()),mouse_buttons: MouseButtons::default(),+ precise_scroll_delta: None,+ scroll_phase: None,+ momentum_phase: None,};self.do_mouse_event(event)}@@ -731,6 +734,9 @@ impl XWindowInner {),modifiers: xkeysyms::modifiers_from_state(motion.state().bits()),mouse_buttons: MouseButtons::default(),+ precise_scroll_delta: None,+ scroll_phase: None,+ momentum_phase: None,};self.do_mouse_event(event)?;}diff --git a/window/src/spawn.rs b/window/src/spawn.rsindex 5363ef4b..512e5807 100644--- a/window/src/spawn.rs+++ b/window/src/spawn.rs@@ -4,6 +4,7 @@ use crate::os::windows::event::EventHandle;use core_foundation::runloop::*;use promise::spawn::{Runnable, SpawnFunc};use std::collections::VecDeque;+use std::panic::{catch_unwind, AssertUnwindSafe};use std::sync::{Arc, Mutex};use std::time::Instant;#[cfg(all(unix, not(target_os = "macos")))]@@ -95,6 +96,18 @@ impl SpawnQueue {!self.spawned_funcs.lock().unwrap().is_empty()|| !self.spawned_funcs_low_pri.lock().unwrap().is_empty()}++ fn run_func(func: SpawnFunc) {+ if let Err(payload) = catch_unwind(AssertUnwindSafe(func)) {+ if let Some(message) = payload.downcast_ref::<&str>() {+ log::error!("spawn queue callback panicked: {message}");+ } else if let Some(message) = payload.downcast_ref::<String>() {+ log::error!("spawn queue callback panicked: {message}");+ } else {+ log::error!("spawn queue callback panicked");+ }+ }+ }}#[cfg(windows)]@@ -118,7 +131,7 @@ impl SpawnQueue {fn run_impl(&self) -> bool {self.event_handle.reset_event();while let Some(func) = self.pop_func() {- func();+ Self::run_func(func);}self.has_any_queued()}@@ -166,7 +179,7 @@ impl SpawnQueue {// we can return to the main loop and process messages// from the X serverif let Some(func) = self.pop_func() {- func();+ Self::run_func(func);}// try to drain the pipe.@@ -237,7 +250,7 @@ impl SpawnQueue {fn run_impl(&self) -> bool {if let Some(func) = self.pop_func() {- func();+ Self::run_func(func);}self.has_any_queued()}