Add 'a' key to select/deselect all lines in custom mode

This commit is contained in:
SW 2026-06-15 21:55:44 +02:00
parent 9d66553443
commit e0a4290743
3 changed files with 16 additions and 1 deletions

View file

@ -99,6 +99,16 @@ impl CustomState {
pub fn focus_lines(&mut self) { pub fn focus_lines(&mut self) {
self.focus = CustomFocus::Lines; 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)] #[derive(Debug, Clone, Copy, PartialEq, Eq)]

View file

@ -134,6 +134,11 @@ fn handle_custom_event(app: &mut App, key: event::KeyEvent) -> bool {
state.command.push(' '); state.command.push(' ');
} }
} }
KeyCode::Char('a') => {
if state.focus == CustomFocus::Lines {
state.toggle_all();
}
}
KeyCode::Backspace => { KeyCode::Backspace => {
state.command.pop(); state.command.pop();
} }

View file

@ -109,7 +109,7 @@ fn draw_custom(f: &mut Frame, app: &App) {
.wrap(Wrap { trim: true }); .wrap(Wrap { trim: true });
f.render_widget(input, chunks[1]); 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 { let text = match &app.message {
Some(msg) => Text::from(msg.as_str()), Some(msg) => Text::from(msg.as_str()),
None => Text::from(help), None => Text::from(help),