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,
|
||||
RestoreFromTrash,
|
||||
SearchActivate,
|
||||
SelectFirst,
|
||||
SelectLast,
|
||||
SelectAll,
|
||||
SetSort(HeadingOptions, bool),
|
||||
Settings,
|
||||
|
|
@ -190,6 +192,8 @@ impl Action {
|
|||
Action::RestoreFromTrash => Message::RestoreFromTrash(entity_opt),
|
||||
Action::SearchActivate => Message::SearchActivate,
|
||||
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) => {
|
||||
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::ArrowRight), ItemRight);
|
||||
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::ArrowLeft), ItemLeft);
|
||||
bind!([Shift], Key::Named(Named::ArrowRight), ItemRight);
|
||||
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!([], Key::Named(Named::Enter), Open);
|
||||
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),
|
||||
SearchReady(bool),
|
||||
SelectAll,
|
||||
SelectFirst,
|
||||
SelectLast,
|
||||
SetSort(HeadingOptions, bool),
|
||||
Thumbnail(PathBuf, ItemThumbnail),
|
||||
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) => {
|
||||
if !matches!(self.location, Location::Search(..)) {
|
||||
self.sort_name = heading_option;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue