Add reload folder key binding, fixes #146
This commit is contained in:
parent
2a9b4ad068
commit
3b34ba8907
5 changed files with 26 additions and 3 deletions
|
|
@ -312,6 +312,7 @@ display-settings = Display settings...
|
|||
file = File
|
||||
new-tab = New tab
|
||||
new-window = New window
|
||||
reload-folder = Reload folder
|
||||
rename = Rename...
|
||||
close-tab = Close tab
|
||||
quit = Quit
|
||||
|
|
|
|||
|
|
@ -140,6 +140,7 @@ pub enum Action {
|
|||
Paste,
|
||||
PermanentlyDelete,
|
||||
Preview,
|
||||
Reload,
|
||||
Rename,
|
||||
RestoreFromTrash,
|
||||
SearchActivate,
|
||||
|
|
@ -208,6 +209,7 @@ impl Action {
|
|||
Action::Paste => Message::Paste(entity_opt),
|
||||
Action::PermanentlyDelete => Message::PermanentlyDelete(entity_opt),
|
||||
Action::Preview => Message::Preview(entity_opt),
|
||||
Action::Reload => Message::TabMessage(entity_opt, tab::Message::Reload),
|
||||
Action::Rename => Message::Rename(entity_opt),
|
||||
Action::RestoreFromTrash => Message::RestoreFromTrash(entity_opt),
|
||||
Action::SearchActivate => Message::SearchActivate,
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ 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::F5), Reload);
|
||||
bind!([], Key::Named(Named::Home), SelectFirst);
|
||||
bind!([], Key::Named(Named::End), SelectLast);
|
||||
bind!([Shift], Key::Named(Named::ArrowDown), ItemDown);
|
||||
|
|
|
|||
|
|
@ -573,6 +573,8 @@ pub fn menu_bar<'a>(
|
|||
menu::Item::Divider,
|
||||
menu_button_optional(fl!("rename"), Action::Rename, selected > 0),
|
||||
menu::Item::Divider,
|
||||
menu::Item::Button(fl!("reload-folder"), None, Action::Reload),
|
||||
menu::Item::Divider,
|
||||
menu_button_optional(
|
||||
fl!("add-to-sidebar"),
|
||||
Action::AddToSidebar,
|
||||
|
|
|
|||
23
src/tab.rs
23
src/tab.rs
|
|
@ -1403,6 +1403,7 @@ pub enum Message {
|
|||
LocationUp,
|
||||
ModifiersChanged(Modifiers),
|
||||
Open(Option<PathBuf>),
|
||||
Reload,
|
||||
RightClick(Option<usize>),
|
||||
MiddleClick(usize),
|
||||
Scroll(Viewport),
|
||||
|
|
@ -2483,12 +2484,12 @@ impl Tab {
|
|||
// Truncate history to remove next entries
|
||||
self.history.truncate(self.history_i + 1);
|
||||
|
||||
// Compact consecutive search locations
|
||||
// Compact consecutive matching paths
|
||||
{
|
||||
let mut remove = false;
|
||||
if let Some(last_location) = self.history.last() {
|
||||
if let Location::Search(last_path, ..) = last_location {
|
||||
if let Location::Search(path, ..) = location {
|
||||
if let Some(last_path) = last_location.path_opt() {
|
||||
if let Some(path) = location.path_opt() {
|
||||
remove = last_path == path;
|
||||
}
|
||||
}
|
||||
|
|
@ -3215,6 +3216,22 @@ impl Tab {
|
|||
}
|
||||
}
|
||||
}
|
||||
Message::Reload => {
|
||||
let mut selected_paths = Vec::new();
|
||||
//TODO: support keeping selected locations without paths
|
||||
for location in self.selected_locations() {
|
||||
if let Some(path) = location.path_opt() {
|
||||
selected_paths.push(path.to_path_buf());
|
||||
}
|
||||
}
|
||||
let location = self.location.clone();
|
||||
self.change_location(&location, None);
|
||||
commands.push(Command::ChangeLocation(
|
||||
self.title(),
|
||||
location,
|
||||
Some(selected_paths),
|
||||
));
|
||||
}
|
||||
Message::RightClick(click_i_opt) => {
|
||||
if mod_ctrl || mod_shift {
|
||||
self.update(Message::Click(click_i_opt), modifiers);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue