mirror of
https://github.com/veeso/termscp.git
synced 2025-12-07 09:36:00 -08:00
feat: ALT+A to deselect all files (#263)
This commit is contained in:
committed by
GitHub
parent
b5b3aeb645
commit
f3b84c97e1
@@ -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()
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user