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
feat(settings): choose hard or smooth cursor blink
Mirro Choued1c3d67380a
diff --git a/thinkterm-i18n/i18n/de-DE.ftl b/thinkterm-i18n/i18n/de-DE.ftlindex a2a3611e..e761d0b7 100644--- a/thinkterm-i18n/i18n/de-DE.ftl+++ b/thinkterm-i18n/i18n/de-DE.ftl@@ -258,6 +258,10 @@ settings-text-contrast-off = Aussettings-text-contrast-3 = 3:1settings-text-contrast-45 = 4.5:1settings-text-contrast-7 = 7:1+settings-cursor-blink = Cursor-Blinken+settings-cursor-blink-description = „Hart“ schaltet den Cursor direkt ein und aus; „Sanft“ blendet ihn mit der eingestellten Kurve ein und aus.+settings-cursor-blink-hard = Hart+settings-cursor-blink-smooth = Sanftsettings-overlay-scrollbar = Bildlaufleistesettings-overlay-scrollbar-description = Beim Scrollen erscheint am rechten Rand des Fensterbereichs eine schmale Bildlaufleiste, die danach ausblendet; sie lässt sich ziehen.settings-split-animation = Teilungsanimationdiff --git a/thinkterm-i18n/i18n/en-US.ftl b/thinkterm-i18n/i18n/en-US.ftlindex 41d68dba..bc791636 100644--- a/thinkterm-i18n/i18n/en-US.ftl+++ b/thinkterm-i18n/i18n/en-US.ftl@@ -258,6 +258,10 @@ settings-text-contrast-off = Offsettings-text-contrast-3 = 3:1settings-text-contrast-45 = 4.5:1settings-text-contrast-7 = 7:1+settings-cursor-blink = Cursor blink+settings-cursor-blink-description = Hard switches the cursor between fully on and fully off; Smooth eases it in and out with the configured curve.+settings-cursor-blink-hard = Hard+settings-cursor-blink-smooth = Smoothsettings-overlay-scrollbar = Scrollbarsettings-overlay-scrollbar-description = A thin scrollbar appears over the right edge of a pane while it scrolls and fades out afterwards; it can be dragged.settings-split-animation = Split animationdiff --git a/thinkterm-i18n/i18n/fr-FR.ftl b/thinkterm-i18n/i18n/fr-FR.ftlindex 90f582c4..26d2000f 100644--- a/thinkterm-i18n/i18n/fr-FR.ftl+++ b/thinkterm-i18n/i18n/fr-FR.ftl@@ -258,6 +258,10 @@ settings-text-contrast-off = Désactivésettings-text-contrast-3 = 3:1settings-text-contrast-45 = 4.5:1settings-text-contrast-7 = 7:1+settings-cursor-blink = Clignotement du curseur+settings-cursor-blink-description = « Net » allume et éteint le curseur d'un coup ; « Doux » le fait apparaître et disparaître avec la courbe configurée.+settings-cursor-blink-hard = Net+settings-cursor-blink-smooth = Douxsettings-overlay-scrollbar = Barre de défilementsettings-overlay-scrollbar-description = Une fine barre de défilement apparaît sur le bord droit du volet pendant le défilement puis disparaît en fondu ; elle peut être glissée.settings-split-animation = Animation de divisiondiff --git a/thinkterm-i18n/i18n/ja-JP.ftl b/thinkterm-i18n/i18n/ja-JP.ftlindex 7e6416e8..5447091a 100644--- a/thinkterm-i18n/i18n/ja-JP.ftl+++ b/thinkterm-i18n/i18n/ja-JP.ftl@@ -255,6 +255,10 @@ settings-text-contrast-off = オフsettings-text-contrast-3 = 3:1settings-text-contrast-45 = 4.5:1settings-text-contrast-7 = 7:1+settings-cursor-blink = カーソルの点滅+settings-cursor-blink-description = 「ハード」はカーソルをそのまま点けたり消したりします。「スムーズ」は設定された曲線で徐々に表示・非表示にします。+settings-cursor-blink-hard = ハード+settings-cursor-blink-smooth = スムーズsettings-overlay-scrollbar = スクロールバーsettings-overlay-scrollbar-description = スクロール中はペインの右端に細いスクロールバーが表示され、その後フェードアウトします。ドラッグもできます。settings-split-animation = 分割アニメーションdiff --git a/thinkterm-i18n/i18n/zh-CN.ftl b/thinkterm-i18n/i18n/zh-CN.ftlindex a228f3e4..724f506d 100644--- a/thinkterm-i18n/i18n/zh-CN.ftl+++ b/thinkterm-i18n/i18n/zh-CN.ftl@@ -255,6 +255,10 @@ settings-text-contrast-off = 关settings-text-contrast-3 = 3:1settings-text-contrast-45 = 4.5:1settings-text-contrast-7 = 7:1+settings-cursor-blink = 光标闪烁+settings-cursor-blink-description = “硬闪”让光标直接亮灭;“平滑”按配置的曲线渐入渐出。+settings-cursor-blink-hard = 硬闪+settings-cursor-blink-smooth = 平滑settings-overlay-scrollbar = 滚动条settings-overlay-scrollbar-description = 滚动时在面板右侧显示一条细滚动条,停止后自动淡出;可以拖动。settings-split-animation = 分屏动画diff --git a/wezterm-gui/src/native_settings.rs b/wezterm-gui/src/native_settings.rsindex 103760f5..114ca2a0 100644--- a/wezterm-gui/src/native_settings.rs+++ b/wezterm-gui/src/native_settings.rs@@ -360,6 +360,31 @@ impl NativeTextContrast {}}+/// How the cursor blinks.+///+/// `Hard` switches it between fully on and fully off, as Apple's Terminal+/// does; `Smooth` eases it in and out, as the Lua+/// `cursor_blink_ease_in`/`cursor_blink_ease_out` settings describe. Smooth+/// stays the default so the configuration keeps deciding; Hard is there for+/// the classic on/off cursor.+#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Deserialize, Serialize)]+#[serde(rename_all = "snake_case")]+pub(crate) enum NativeCursorBlink {+ Hard,+ Smooth,+}++impl Default for NativeCursorBlink {+ fn default() -> Self {+ Self::Smooth+ }+}++impl NativeCursorBlink {+ /// Every choice, in the order the settings window offers them.+ pub(crate) const ALL: [Self; 2] = [Self::Smooth, Self::Hard];+}+/// A value this build does not know about must not cost the user the rest of/// their settings, so an unreadable choice reads as the default rather than/// failing the whole file. Same reasoning as `theme_mode_or_default`.@@ -874,6 +899,10 @@ pub(crate) struct NativeTerminalSettings {/// `text_min_contrast_ratio`, which is itself off unless set.#[serde(deserialize_with = "text_contrast_or_default")]pub(crate) text_contrast: NativeTextContrast,+ /// See [`NativeCursorBlink`]. Smooth is the default, preserving the+ /// eased cursor the Lua settings describe.+ #[serde(deserialize_with = "choice_or_default")]+ pub(crate) cursor_blink: NativeCursorBlink,pub(crate) bottom_quote_enabled: bool,pub(crate) bottom_quote_mode: NativeBottomQuoteMode,pub(crate) bottom_quote_interval_minutes: Option<u32>,@@ -898,6 +927,7 @@ impl Default for NativeTerminalSettings {copy_effect: NativeCopyEffect::default(),focus_follows_mouse: false,text_contrast: NativeTextContrast::default(),+ cursor_blink: NativeCursorBlink::default(),bottom_quote_enabled: false,bottom_quote_mode: NativeBottomQuoteMode::default(),bottom_quote_interval_minutes: None,@@ -961,6 +991,24 @@ pub(crate) fn text_min_contrast_ratio(config: &ConfigHandle) -> Option<f32> {.or(config.text_min_contrast_ratio)}+/// The easing pair the cursor's `ColorEase` should use.+///+/// `Hard` overrides the Lua easing entirely; `Smooth` leaves it in charge,+/// so a configuration that named `EaseIn`, `EaseInOut` or `Linear` keeps the+/// function it asked for. Read when the state is built and when the setting+/// changes, not per frame.+pub(crate) fn cursor_blink_eases(+ config: &ConfigHandle,+) -> (config::EasingFunction, config::EasingFunction) {+ match load_shared().terminal.cursor_blink {+ NativeCursorBlink::Hard => (+ config::EasingFunction::Constant,+ config::EasingFunction::Constant,+ ),+ NativeCursorBlink::Smooth => (config.cursor_blink_ease_in, config.cursor_blink_ease_out),+ }+}+/// Read once per painted pane, through the shared handle.pub(crate) fn overlay_scrollbar() -> bool {load_shared().terminal.overlay_scrollbar@@ -2220,6 +2268,7 @@ fn apply_external_change(before: &ThinkTermNativeSettings, after: &ThinkTermNatilet font_size = (before.terminal.font_size != after.terminal.font_size).then_some(after.terminal.font_size);let contrast = before.terminal.text_contrast != after.terminal.text_contrast;+ let cursor_blink = before.terminal.cursor_blink != after.terminal.cursor_blink;let before_chrome = &before.chrome;let after_chrome = &after.chrome;let panels = before_chrome.right_sidebar_files_enabled != after_chrome.right_sidebar_files_enabled@@ -2253,6 +2302,9 @@ fn apply_external_change(before: &ThinkTermNativeSettings, after: &ThinkTermNatiif contrast {term_window.refresh_text_min_contrast();}+ if cursor_blink {+ term_window.refresh_cursor_blink();+ }if panels {term_window.right_sidebar_panels_changed();}@@ -3393,6 +3445,38 @@ mod tests {}}+ /// A file written before this setting existed keeps the eased cursor the+ /// Lua defaults describe rather than silently changing its blink.+ #[test]+ fn a_settings_file_without_a_blink_choice_reads_as_smooth() {+ let json = r#"{+ "version": 1,+ "terminal": { "scroll_mode": "smooth" }+ }"#;+ let settings: ThinkTermNativeSettings =+ serde_json::from_str(json).expect("the file has to survive");+ assert_eq!(settings.terminal.cursor_blink, NativeCursorBlink::Smooth);+ }++ #[test]+ fn a_blink_choice_round_trips_through_the_file() {+ for (written, expected) in [+ ("hard", NativeCursorBlink::Hard),+ ("smooth", NativeCursorBlink::Smooth),+ ] {+ let json = format!(r#"{{"terminal": {{"cursor_blink": "{written}"}}}}"#);+ let settings: ThinkTermNativeSettings =+ serde_json::from_str(&json).expect("the file has to survive");+ assert_eq!(settings.terminal.cursor_blink, expected, "{written}");++ let out = serde_json::to_string(&settings).expect("serialises");+ assert!(+ out.contains(&format!("\"cursor_blink\":\"{written}\"")),+ "{written} has to survive a save: {out}"+ );+ }+ }+/// Same reasoning as the theme mode below: a ratio a newer build offers/// must not cost this one the rest of the file.#[test]diff --git a/wezterm-gui/src/settings_window.rs b/wezterm-gui/src/settings_window.rsindex d7ab357c..a364f1b6 100644--- a/wezterm-gui/src/settings_window.rs+++ b/wezterm-gui/src/settings_window.rs@@ -1780,6 +1780,14 @@ fn localized_text_contrast_label(mode: crate::native_settings::NativeTextContras})}+fn localized_cursor_blink_label(mode: crate::native_settings::NativeCursorBlink) -> String {+ use crate::native_settings::NativeCursorBlink;+ crate::i18n::tr(match mode {+ NativeCursorBlink::Hard => "settings-cursor-blink-hard",+ NativeCursorBlink::Smooth => "settings-cursor-blink-smooth",+ })+}+/// The groove and the selected segment of a segmented control, which have to/// be told apart.///@@ -2084,6 +2092,7 @@ enum SettingsAction {/// has the search and the live preview a thousand entries need.OpenColorSchemePicker,SetTextContrast(crate::native_settings::NativeTextContrast),+ SetCursorBlink(crate::native_settings::NativeCursorBlink),ToggleOverlayScrollbar,ToggleSplitAnimation,SetBottomQuoteMode(NativeBottomQuoteMode),@@ -5598,6 +5607,44 @@ impl SettingsWindow {}}+ fn apply_cursor_blink(&mut self, mode: crate::native_settings::NativeCursorBlink) {+ self.ui.open_dropdown = None;+ // Merge into the freshest settings for the reason `apply_text_contrast`+ // gives: another row may have written the file while this window was+ // open.+ let mut merged = crate::native_settings::load();+ merged.terminal.cursor_blink = mode;+ self.set_native_settings(merged);+ match crate::native_settings::save(&self.native_settings) {+ Ok(()) => {+ // The blink state carries the easing pair, so each window has+ // to rebuild it rather than just repaint.+ if let Some(front_end) = crate::frontend::try_front_end() {+ for gui_window in front_end.gui_windows() {+ gui_window.window.notify(+ crate::termwindow::TermWindowNotif::Apply(Box::new(|term_window| {+ term_window.refresh_cursor_blink();+ })),+ );+ }+ }+ self.status = settings_tr(+ "settings-status-value-now",+ &[+ ("setting", crate::i18n::tr("settings-cursor-blink")),+ ("value", localized_cursor_blink_label(mode)),+ ],+ );+ }+ Err(err) => {+ self.status = settings_tr(+ "settings-status-terminal-error",+ &[("error", format!("{err:#}"))],+ );+ }+ }+ }+fn apply_remote_pane_resize_mode(&mut self, mode: NativeRemotePaneResizeMode) {self.ui.open_dropdown = None;self.native_settings.terminal.remote_pane_resize_mode = mode;@@ -6666,6 +6713,7 @@ impl SettingsWindow {// Handled as a drag, on press and release.SettingsAction::WindowOpacitySlider => {}SettingsAction::SetTextContrast(mode) => self.apply_text_contrast(mode),+ SettingsAction::SetCursorBlink(mode) => self.apply_cursor_blink(mode),SettingsAction::SetRemotePaneResizeMode(mode) => {self.apply_remote_pane_resize_mode(mode)}@@ -13588,7 +13636,9 @@ impl SettingsWindow {&crate::i18n::tr("settings-terminal-display-heading"),)?;let bottom = self.paint_card(layers, x, card_y, max_width, |this, layers, top| {- use crate::native_settings::{NativeScrollMode, NativeTextContrast};+ use crate::native_settings::{+ NativeCursorBlink, NativeScrollMode, NativeTextContrast,+ };let mut rows = RowCursor::new(top, this);let options: Vec<(String, SettingsAction)> = NativeScrollMode::ALL@@ -13697,6 +13747,39 @@ impl SettingsWindow {rows.rule(),)?);+ let options: Vec<(String, SettingsAction)> = NativeCursorBlink::ALL+ .iter()+ .map(|mode| {+ (+ localized_cursor_blink_label(*mode),+ SettingsAction::SetCursorBlink(*mode),+ )+ })+ .collect();+ let selected = NativeCursorBlink::ALL+ .iter()+ .position(|mode| *mode == this.native_settings.terminal.cursor_blink)+ .unwrap_or(0);+ let (tx, tw) = this.paint_row_tile(+ layers,+ row_x,+ rows.y,+ row_width,+ SvgIcon::Eye,+ TileColor::Purple,+ )?;+ rows.add(this.paint_segmented_setting_row(+ layers,+ tx,+ rows.y,+ tw,+ &crate::i18n::tr("settings-cursor-blink"),+ &crate::i18n::tr("settings-cursor-blink-description"),+ &options,+ selected,+ rows.rule(),+ )?);+let options: Vec<(String, SettingsAction)> = NativeRemotePaneResizeMode::ALL.iter().map(|mode| {diff --git a/wezterm-gui/src/termwindow/mod.rs b/wezterm-gui/src/termwindow/mod.rsindex d764832a..a7020fd9 100644--- a/wezterm-gui/src/termwindow/mod.rs+++ b/wezterm-gui/src/termwindow/mod.rs@@ -4703,6 +4703,8 @@ impl TermWindow {&config,None,);+ let (cursor_blink_ease_in, cursor_blink_ease_out) =+ crate::native_settings::cursor_blink_eases(&config);let myself = Self {frontend_geometry_phases: HashMap::new(),remote_open_intent: remote_open_domain@@ -4853,9 +4855,9 @@ impl TermWindow {last_gpu_allocator_log: Cell::new(None),cursor_blink_state: RefCell::new(ColorEase::new(config.cursor_blink_rate,- config.cursor_blink_ease_in,+ cursor_blink_ease_in,config.cursor_blink_rate,- config.cursor_blink_ease_out,+ cursor_blink_ease_out,None,)),blink_state: RefCell::new(ColorEase::new(@@ -7573,6 +7575,22 @@ impl TermWindow {self.invalidate_window();}+ /// Rebuild the cursor's blink state from the style chosen in Settings.+ /// `config_was_reloaded` does this too; this is the direct route, for the+ /// settings window, which writes the choice to its own file and never+ /// touches the configuration.+ pub(crate) fn refresh_cursor_blink(&mut self) {+ let (ease_in, ease_out) = crate::native_settings::cursor_blink_eases(&self.config);+ *self.cursor_blink_state.borrow_mut() = ColorEase::new(+ self.config.cursor_blink_rate,+ ease_in,+ self.config.cursor_blink_rate,+ ease_out,+ None,+ );+ self.invalidate_window();+ }+/// Re-resolve the cached chrome colours. `config_was_reloaded` does this/// too; this is the direct route, for when the appearance moved without a/// configuration reload behind it.@@ -7842,11 +7860,13 @@ impl TermWindow {_ => return,};self.terminal_bar_kind = self.wanted_terminal_bar_kind(&config, window.len());+ let (cursor_blink_ease_in, cursor_blink_ease_out) =+ crate::native_settings::cursor_blink_eases(&config);*self.cursor_blink_state.borrow_mut() = ColorEase::new(config.cursor_blink_rate,- config.cursor_blink_ease_in,+ cursor_blink_ease_in,config.cursor_blink_rate,- config.cursor_blink_ease_out,+ cursor_blink_ease_out,None,);*self.blink_state.borrow_mut() = ColorEase::new(