From e0a42907439a7359e42dfbe31ae6ae697adbb68f Mon Sep 17 00:00:00 2001 From: SW Date: Mon, 15 Jun 2026 21:55:44 +0200 Subject: [PATCH] Add 'a' key to select/deselect all lines in custom mode --- src/app.rs | 10 ++++++++++ src/events.rs | 5 +++++ src/ui.rs | 2 +- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/app.rs b/src/app.rs index 975580f..67d8fdb 100644 --- a/src/app.rs +++ b/src/app.rs @@ -99,6 +99,16 @@ impl CustomState { pub fn focus_lines(&mut self) { self.focus = CustomFocus::Lines; } + + pub fn toggle_all(&mut self) { + if self.lines.is_empty() { + return; + } + let all_selected = self.selected.iter().all(|s| *s); + for s in &mut self.selected { + *s = !all_selected; + } + } } #[derive(Debug, Clone, Copy, PartialEq, Eq)] diff --git a/src/events.rs b/src/events.rs index 42f482b..d83670d 100644 --- a/src/events.rs +++ b/src/events.rs @@ -134,6 +134,11 @@ fn handle_custom_event(app: &mut App, key: event::KeyEvent) -> bool { state.command.push(' '); } } + KeyCode::Char('a') => { + if state.focus == CustomFocus::Lines { + state.toggle_all(); + } + } KeyCode::Backspace => { state.command.pop(); } diff --git a/src/ui.rs b/src/ui.rs index fd95e56..1ce5fae 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -109,7 +109,7 @@ fn draw_custom(f: &mut Frame, app: &App) { .wrap(Wrap { trim: true }); f.render_widget(input, chunks[1]); - let help = "↑/↓: move | Tab: focus | Space: toggle / space | Enter: run | Esc: back"; + let help = "↑/↓: move | Space: toggle | a: select all | Tab: focus | Enter: run | Esc: back"; let text = match &app.message { Some(msg) => Text::from(msg.as_str()), None => Text::from(help),