Add 'a' key to select/deselect all lines in custom mode
This commit is contained in:
parent
9d66553443
commit
e0a4290743
3 changed files with 16 additions and 1 deletions
10
src/app.rs
10
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)]
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue