feat: ALT+A to deselect all files (#263)
Some checks are pending
Coverage / build (push) Waiting to run
Linux / build (push) Waiting to run
MacOS / build (push) Waiting to run
Windows / build (push) Waiting to run

This commit is contained in:
Christian Visintin
2024-07-08 15:56:20 +02:00
committed by GitHub
parent b5b3aeb645
commit f3b84c97e1
11 changed files with 44 additions and 2 deletions

View File

@@ -796,6 +796,9 @@ impl KeybindingsPopup {
.add_col(TextSpan::new("<CTRL+A>").bold().fg(key_color))
.add_col(TextSpan::from(" Select all files"))
.add_row()
.add_col(TextSpan::new("<ALT+A>").bold().fg(key_color))
.add_col(TextSpan::from(" Deselect all files"))
.add_row()
.add_col(TextSpan::new("<CTRL+C>").bold().fg(key_color))
.add_col(TextSpan::from(" Interrupt file transfer"))
.add_row()

View File

@@ -12,6 +12,7 @@ use tuirealm::tui::widgets::{List as TuiList, ListItem, ListState};
use tuirealm::{MockComponent, Props, State, StateValue};
pub const FILE_LIST_CMD_SELECT_ALL: &str = "A";
pub const FILE_LIST_CMD_DESELECT_ALL: &str = "D";
/// OwnStates contains states for this component
#[derive(Clone, Default)]
@@ -113,6 +114,11 @@ impl OwnStates {
}
}
/// Select all files
pub fn deselect_all(&mut self) {
self.selected.clear();
}
/// Select provided index if not selected yet
fn select(&mut self, entry: usize) {
if !self.is_selected(entry) {
@@ -332,6 +338,10 @@ impl MockComponent for FileList {
self.states.select_all();
CmdResult::None
}
Cmd::Custom(FILE_LIST_CMD_DESELECT_ALL) => {
self.states.deselect_all();
CmdResult::None
}
Cmd::Toggle => {
self.states.toggle_file(self.states.list_index());
CmdResult::None

View File

@@ -73,6 +73,13 @@ impl Component<Msg, NoUserEvent> for ExplorerFind {
let _ = self.perform(Cmd::Custom(file_list::FILE_LIST_CMD_SELECT_ALL));
Some(Msg::None)
}
Event::Keyboard(KeyEvent {
code: Key::Char('a'),
modifiers: KeyModifiers::ALT,
}) => {
let _ = self.perform(Cmd::Custom(file_list::FILE_LIST_CMD_DESELECT_ALL));
Some(Msg::None)
}
Event::Keyboard(KeyEvent {
code: Key::Char('m'),
modifiers: KeyModifiers::NONE,
@@ -198,6 +205,13 @@ impl Component<Msg, NoUserEvent> for ExplorerLocal {
let _ = self.perform(Cmd::Custom(file_list::FILE_LIST_CMD_SELECT_ALL));
Some(Msg::None)
}
Event::Keyboard(KeyEvent {
code: Key::Char('a'),
modifiers: KeyModifiers::ALT,
}) => {
let _ = self.perform(Cmd::Custom(file_list::FILE_LIST_CMD_DESELECT_ALL));
Some(Msg::None)
}
Event::Keyboard(KeyEvent {
code: Key::Char('m'),
modifiers: KeyModifiers::NONE,
@@ -383,6 +397,13 @@ impl Component<Msg, NoUserEvent> for ExplorerRemote {
let _ = self.perform(Cmd::Custom(file_list::FILE_LIST_CMD_SELECT_ALL));
Some(Msg::None)
}
Event::Keyboard(KeyEvent {
code: Key::Char('a'),
modifiers: KeyModifiers::ALT,
}) => {
let _ = self.perform(Cmd::Custom(file_list::FILE_LIST_CMD_DESELECT_ALL));
Some(Msg::None)
}
Event::Keyboard(KeyEvent {
code: Key::Char('m'),
modifiers: KeyModifiers::NONE,