From 9ac230876c48855db2b2d317445d132703f37358 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Tue, 2 Mar 2021 20:44:08 -0800 Subject: [PATCH] Add status_update_interval option for status updates The status event is triggered at window creation, and then every `status_update_interval` milliseconds. refs: https://github.com/wez/wezterm/issues/500 --- config/src/lib.rs | 7 +++++++ wezterm-gui/src/termwindow/mod.rs | 21 ++++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/config/src/lib.rs b/config/src/lib.rs index 606854a41..3da982d59 100644 --- a/config/src/lib.rs +++ b/config/src/lib.rs @@ -1039,9 +1039,16 @@ pub struct Config { #[serde(default = "default_alternate_buffer_wheel_scroll_speed")] pub alternate_buffer_wheel_scroll_speed: u8, + + #[serde(default = "default_status_update_interval")] + pub status_update_interval: u64, } impl_lua_conversion!(Config); +fn default_status_update_interval() -> u64 { + 1_000 +} + fn default_alternate_buffer_wheel_scroll_speed() -> u8 { 3 } diff --git a/wezterm-gui/src/termwindow/mod.rs b/wezterm-gui/src/termwindow/mod.rs index 0330b84ed..345589b13 100644 --- a/wezterm-gui/src/termwindow/mod.rs +++ b/wezterm-gui/src/termwindow/mod.rs @@ -519,9 +519,28 @@ impl TermWindow { }); } }); + + // Trigger an initial status update + { + let window = window.clone(); + promise::spawn::spawn(async move { + window + .apply(move |tw, ops| { + if let Some(term_window) = tw.downcast_mut::() { + term_window.emit_status_event(ops)?; + } + Ok(()) + }) + .await + }) + .detach(); + } + + let interval = configuration().status_update_interval; + let interval = std::time::Duration::from_millis(interval); Connection::get() .unwrap() - .schedule_timer(std::time::Duration::from_secs(1), move || { + .schedule_timer(interval, move || { window.apply(move |myself, window| { if let Some(myself) = myself.downcast_mut::() { myself.emit_status_event(window)?;