aboutsummaryrefslogtreecommitdiffstats
path: root/sl0pstatus/src/widgets/command.rs
diff options
context:
space:
mode:
authoruser <user@clank>2026-08-08 23:54:38 +0200
committeruser <user@clank>2026-08-12 20:41:52 +0200
commitf075ce0bd2ac29168e27596ab32abdfb6b2813ec (patch)
tree3ad79eb3565fa685a70c5ce4d455f67ed473cef9 /sl0pstatus/src/widgets/command.rs
parentvendor(sl0pstatus): import zjstatus v0.24.0 tree (diff)
downloadsl0ppi-f075ce0bd2ac29168e27596ab32abdfb6b2813ec.tar.gz
sl0ppi-f075ce0bd2ac29168e27596ab32abdfb6b2813ec.tar.xz
sl0ppi-f075ce0bd2ac29168e27596ab32abdfb6b2813ec.zip
sl0p: double-click a tab to rename it
Double-clicking a tab in the bar switches to it and drops into RenameTab mode, matching the double-click-to-rename we added for panes in the sl0ppij zellij fork. Enter commits, Esc cancels, exactly as the rename keybind does. Widgets are held behind &self and cannot keep click state, so double-click detection lives centrally in ModuleConfig::handle_mouse_action and is passed to Widget::process_click as a flag. THE TRAP, and the reason this is not a two-line change: handle_mouse_action also runs for Mouse::Release. A single click therefore arrives as LeftClick followed by Release at the SAME position. Counting releases would make every single click register as a double click, and resetting on release would mean a real double click never registers at all, since the release falls between the two clicks. Only LeftClick participates; Release neither counts nor resets. A completed pair is consumed, so a triple click does not fire a second rename. switch_tab_to() is called before switch_to_input_mode(), because RenameTab acts on the ACTIVE tab - renaming without switching first would rename the wrong one. Threshold is 400ms, the same one zellij uses for text-selection double clicks, so the bar feels consistent with the panes. Detection is extracted as register_click_for_double_click() so it can be tested without constructing a ModuleConfig. Tests cover: a real double click, the release-in-between regression, too-slow clicks, clicks at different positions, and the triple-click case. Upstream tests still pass: 25 total (20 upstream + 5 new). Note: this repo's .cargo/config.toml targets wasm32-wasip1 and runs tests under wasmtime, which is not installed here. Tests are run with `cargo test --target x86_64-unknown-linux-gnu` instead.
Diffstat (limited to 'sl0pstatus/src/widgets/command.rs')
-rw-r--r--sl0pstatus/src/widgets/command.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/sl0pstatus/src/widgets/command.rs b/sl0pstatus/src/widgets/command.rs
index 245c5fc..55498c5 100644
--- a/sl0pstatus/src/widgets/command.rs
+++ b/sl0pstatus/src/widgets/command.rs
@@ -142,7 +142,7 @@ impl Widget for CommandWidget {
}
}
- fn process_click(&self, name: &str, _state: &ZellijState, _pos: usize) {
+ fn process_click(&self, name: &str, _state: &ZellijState, _pos: usize, _is_double_click: bool) {
let command_config = match self.config.get(name) {
Some(cc) => cc,
None => {