Add move to first/last item with home/end keys
This commit is contained in:
parent
59ea01fc0c
commit
85929c44ce
3 changed files with 40 additions and 0 deletions
|
|
@ -125,6 +125,8 @@ pub enum Action {
|
||||||
Rename,
|
Rename,
|
||||||
RestoreFromTrash,
|
RestoreFromTrash,
|
||||||
SearchActivate,
|
SearchActivate,
|
||||||
|
SelectFirst,
|
||||||
|
SelectLast,
|
||||||
SelectAll,
|
SelectAll,
|
||||||
SetSort(HeadingOptions, bool),
|
SetSort(HeadingOptions, bool),
|
||||||
Settings,
|
Settings,
|
||||||
|
|
@ -190,6 +192,8 @@ impl Action {
|
||||||
Action::RestoreFromTrash => Message::RestoreFromTrash(entity_opt),
|
Action::RestoreFromTrash => Message::RestoreFromTrash(entity_opt),
|
||||||
Action::SearchActivate => Message::SearchActivate,
|
Action::SearchActivate => Message::SearchActivate,
|
||||||
Action::SelectAll => Message::TabMessage(entity_opt, tab::Message::SelectAll),
|
Action::SelectAll => Message::TabMessage(entity_opt, tab::Message::SelectAll),
|
||||||
|
Action::SelectFirst => Message::TabMessage(entity_opt, tab::Message::SelectFirst),
|
||||||
|
Action::SelectLast => Message::TabMessage(entity_opt, tab::Message::SelectLast),
|
||||||
Action::SetSort(sort, dir) => {
|
Action::SetSort(sort, dir) => {
|
||||||
Message::TabMessage(entity_opt, tab::Message::SetSort(*sort, *dir))
|
Message::TabMessage(entity_opt, tab::Message::SetSort(*sort, *dir))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,10 +29,14 @@ pub fn key_binds(mode: &tab::Mode) -> HashMap<KeyBind, Action> {
|
||||||
bind!([], Key::Named(Named::ArrowLeft), ItemLeft);
|
bind!([], Key::Named(Named::ArrowLeft), ItemLeft);
|
||||||
bind!([], Key::Named(Named::ArrowRight), ItemRight);
|
bind!([], Key::Named(Named::ArrowRight), ItemRight);
|
||||||
bind!([], Key::Named(Named::ArrowUp), ItemUp);
|
bind!([], Key::Named(Named::ArrowUp), ItemUp);
|
||||||
|
bind!([], Key::Named(Named::Home), SelectFirst);
|
||||||
|
bind!([], Key::Named(Named::End), SelectLast);
|
||||||
bind!([Shift], Key::Named(Named::ArrowDown), ItemDown);
|
bind!([Shift], Key::Named(Named::ArrowDown), ItemDown);
|
||||||
bind!([Shift], Key::Named(Named::ArrowLeft), ItemLeft);
|
bind!([Shift], Key::Named(Named::ArrowLeft), ItemLeft);
|
||||||
bind!([Shift], Key::Named(Named::ArrowRight), ItemRight);
|
bind!([Shift], Key::Named(Named::ArrowRight), ItemRight);
|
||||||
bind!([Shift], Key::Named(Named::ArrowUp), ItemUp);
|
bind!([Shift], Key::Named(Named::ArrowUp), ItemUp);
|
||||||
|
bind!([Shift], Key::Named(Named::Home), SelectFirst);
|
||||||
|
bind!([Shift], Key::Named(Named::End), SelectLast);
|
||||||
bind!([Ctrl, Shift], Key::Character("n".into()), NewFolder);
|
bind!([Ctrl, Shift], Key::Character("n".into()), NewFolder);
|
||||||
bind!([], Key::Named(Named::Enter), Open);
|
bind!([], Key::Named(Named::Enter), Open);
|
||||||
bind!([Ctrl], Key::Named(Named::Space), Preview);
|
bind!([Ctrl], Key::Named(Named::Space), Preview);
|
||||||
|
|
|
||||||
32
src/tab.rs
32
src/tab.rs
|
|
@ -1071,6 +1071,8 @@ pub enum Message {
|
||||||
SearchContext(Location, SearchContextWrapper),
|
SearchContext(Location, SearchContextWrapper),
|
||||||
SearchReady(bool),
|
SearchReady(bool),
|
||||||
SelectAll,
|
SelectAll,
|
||||||
|
SelectFirst,
|
||||||
|
SelectLast,
|
||||||
SetSort(HeadingOptions, bool),
|
SetSort(HeadingOptions, bool),
|
||||||
Thumbnail(PathBuf, ItemThumbnail),
|
Thumbnail(PathBuf, ItemThumbnail),
|
||||||
ToggleShowHidden,
|
ToggleShowHidden,
|
||||||
|
|
@ -2801,6 +2803,36 @@ impl Tab {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Message::SelectFirst => {
|
||||||
|
if self.select_position(0, 0, mod_shift) {
|
||||||
|
if let Some(offset) = self.select_focus_scroll() {
|
||||||
|
commands.push(Command::Iced(
|
||||||
|
scrollable::scroll_to(self.scrollable_id.clone(), offset).into(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
if let Some(id) = self.select_focus_id() {
|
||||||
|
commands.push(Command::Iced(widget::button::focus(id).into()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Message::SelectLast => {
|
||||||
|
if let Some(ref items) = self.items_opt {
|
||||||
|
if let Some(last_pos) = items.iter().filter_map(|item| item.pos_opt.get()).max()
|
||||||
|
{
|
||||||
|
if self.select_position(last_pos.0, last_pos.1, mod_shift) {
|
||||||
|
if let Some(offset) = self.select_focus_scroll() {
|
||||||
|
commands.push(Command::Iced(
|
||||||
|
scrollable::scroll_to(self.scrollable_id.clone(), offset)
|
||||||
|
.into(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
if let Some(id) = self.select_focus_id() {
|
||||||
|
commands.push(Command::Iced(widget::button::focus(id).into()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Message::SetSort(heading_option, dir) => {
|
Message::SetSort(heading_option, dir) => {
|
||||||
if !matches!(self.location, Location::Search(..)) {
|
if !matches!(self.location, Location::Search(..)) {
|
||||||
self.sort_name = heading_option;
|
self.sort_name = heading_option;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue