A fast file manager for Windows and macOS that never freezes: tabs, dual panes, archives as folders, Quick Look-style previews. A File Explorer and Finder alternative written in Rust.
Rust archive-managerdesktop-appdual-paneexplorer-alternativefile-browserfile-explorerfile-managerfluent-designgpu-acceleratedgpuimacosmicaproductivityquick-lookrustrust-guitabswindowswindows-11windows-explorer
Right-click menu: Explorer's access keys on our own rows and buttons
gelenmedyade12dc13eff2
diff --git a/crates/rf-app/src/ctx_menu.rs b/crates/rf-app/src/ctx_menu.rsindex 97e54901..df406630 100644--- a/crates/rf-app/src/ctx_menu.rs+++ b/crates/rf-app/src/ctx_menu.rs@@ -181,23 +181,24 @@ impl FolderView {let paste_ok = rf_win::clipboard::can_paste();if !with_items {return vec![- Quick::new(L::ClipboardPaste, t!("Yapıştır (Ctrl+V)"), paste_ok, act(me, |v, w, cx| v.paste(w, cx))),- Quick::new(L::Wrench, t!("Özellikler (Alt+Enter)"), true, act(me, |v, _, cx| v.folder_properties(cx))),+ Quick::new(L::ClipboardPaste, t!("Yapıştır (Ctrl+V)"), paste_ok, act(me, |v, w, cx| v.paste(w, cx))).key('p'),+ Quick::new(L::Wrench, t!("Özellikler (Alt+Enter)"), true, act(me, |v, _, cx| v.folder_properties(cx))).key('r'),];}vec![- Quick::new(L::Scissors, t!("Kes (Ctrl+X)"), true, act(me, |v, w, cx| v.copy_to_clipboard(Transfer::Move, w, cx))),- Quick::new(L::Copy, t!("Kopyala (Ctrl+C)"), true, act(me, |v, w, cx| v.copy_to_clipboard(Transfer::Copy, w, cx))),+ Quick::new(L::Scissors, t!("Kes (Ctrl+X)"), true, act(me, |v, w, cx| v.copy_to_clipboard(Transfer::Move, w, cx))).key('t'),+ Quick::new(L::Copy, t!("Kopyala (Ctrl+C)"), true, act(me, |v, w, cx| v.copy_to_clipboard(Transfer::Copy, w, cx))).key('c'),Quick::new(L::ClipboardPaste,t!("Yapıştır (Ctrl+V)"),paste_ok,act(me, |v, w, cx| if v.selected_is_single_dir() { v.paste_into_selected(w, cx) } else { v.paste(w, cx) }),- ),- Quick::new(L::TextCursorInput, t!("Yeniden adlandır (F2)"), true, act(me, |v, w, cx| v.rename_selection(w, cx))),+ )+ .key('p'),+ Quick::new(L::TextCursorInput, t!("Yeniden adlandır (F2)"), true, act(me, |v, w, cx| v.rename_selection(w, cx))).key('m'),Quick::new(L::Share2, t!("Paylaş"), true, act(me, |v, w, cx| v.share(w, cx))),- Quick::new(L::Trash, t!("Sil (Del)"), true, act(me, |v, w, cx| v.delete_selected(false, w, cx))),- Quick::new(L::Wrench, t!("Özellikler (Alt+Enter)"), true, act(me, |v, _, cx| v.properties(cx))),+ Quick::new(L::Trash, t!("Sil (Del)"), true, act(me, |v, w, cx| v.delete_selected(false, w, cx))).key('d'),+ Quick::new(L::Wrench, t!("Özellikler (Alt+Enter)"), true, act(me, |v, _, cx| v.properties(cx))).key('r'),]}@@ -589,6 +590,7 @@ impl FolderView {// (Windows' share sheet needs real files)quick.retain(|q| q.icon != L::Share2);}+ own_access_keys(&mut v);Menu { quick, items: v }}@@ -671,6 +673,7 @@ impl FolderView {}v.push(Item::Separator);v.push(Item::Sub { hint: None, mnemonic: None, label: t!("Diğer seçenekleri göster").into(), icon: icon(L::Ellipsis), items: Sub::Pending { key: "more", fallback: None }, click: None });+ own_access_keys(&mut v);Menu { quick: self.quick_clipboard(me, false), items: v }}@@ -1446,6 +1449,37 @@ fn with_packaged(packaged: Vec<Packaged>, rest: Pending, prefer_classic: bool) -Pending::Ready(Rc::new(items))}+/// Explorer's access keys on our own rows (Discussion 721: "delete with D, new with W"), the letters of Windows' English menu, which+/// Chinese, Japanese and Korean Windows show in brackets too; a row that already has one (from Windows' own menu) keeps it.+fn own_access_keys(items: &mut [Item]) {+ let table: [(&str, char); 13] = [+ (t!("Aç"), 'o'),+ (t!("Yeni"), 'w'),+ (t!("Gönder"), 'n'),+ (t!("Kısayol oluştur"), 's'),+ (t!("Kısayol yapıştır"), 's'),+ (t!("Yenile"), 'e'),+ (t!("Sırala"), 'o'),+ (t!("Gruplandır"), 'p'),+ (t!("Sayfa düzeni"), 'v'),+ (t!("Yönetici olarak çalıştır"), 'a'),+ (t!("Tümünü seç"), 'a'),+ (t!("Özellikler"), 'r'),+ (t!("Yeni sekmede aç"), 'b'),+ ];+ let undo = t!("Geri al");+ for it in items.iter_mut() {+ if it.mnemonic_char().is_some() {+ continue;+ }+ let Some(title) = item_title(it) else { continue };+ let key = table.iter().find(|(t, _)| title == *t).map(|&(_, k)| k).or_else(|| title.starts_with(undo).then_some('u'));+ if let Some(k) = key {+ *it = it.clone().mnemonic(Some(k));+ }+ }+}+/// Keeps a dropped twin's access key when the surviving entry carries none (issue 659: packaged/// Windows 11 verbs often omit `&` while the classic handler for the same app supplies one).fn inherit_twin_mnemonics(kept: &mut [Item], dropped: &[Item]) {@@ -1951,3 +1985,23 @@ mod more_tests {assert_eq!(packaged[1].mnemonic_char(), Some('n'), "existing mnemonic is kept");}}++#[cfg(test)]+mod access_key_tests {+ use super::own_access_keys;+ use crate::fluent_menu::{Item, MenuIcon};++ #[test]+ fn our_rows_get_explorers_letters_and_windows_ones_stay() {+ let mut items = vec![+ Item::action(crate::t!("Aç"), MenuIcon::None, |_, _| {}),+ Item::sub(crate::t!("Yeni"), MenuIcon::None, vec![]),+ Item::action(format!("{}: Silme", crate::t!("Geri al")), MenuIcon::None, |_, _| {}),+ Item::action(crate::t!("Özellikler"), MenuIcon::None, |_, _| {}).mnemonic(Some('x')),+ Item::action("Edit with Notepad++", MenuIcon::None, |_, _| {}),+ ];+ own_access_keys(&mut items);+ let keys: Vec<Option<char>> = items.iter().map(|i| i.mnemonic_char()).collect();+ assert_eq!(keys, [Some('o'), Some('w'), Some('u'), Some('x'), None]);+ }+}diff --git a/crates/rf-app/src/fluent_menu.rs b/crates/rf-app/src/fluent_menu.rsindex 3ce745ba..23d50d6e 100644--- a/crates/rf-app/src/fluent_menu.rs+++ b/crates/rf-app/src/fluent_menu.rs@@ -176,11 +176,18 @@ pub struct Quick {pub tip: SharedString,pub enabled: bool,pub run: Run,+ /// Its access key (lower case): pressed while the menu is open it runs the button, as the letter of Explorer's row does.+ pub key: Option<char>,}impl Quick {pub fn new(icon: L, tip: impl Into<SharedString>, enabled: bool, run: impl Fn(&mut Window, &mut App) + 'static) -> Self {- Self { icon, tip: tip.into(), enabled, run: Rc::new(run) }+ Self { icon, tip: tip.into(), enabled, run: Rc::new(run), key: None }+ }++ pub fn key(mut self, key: char) -> Self {+ self.key = Some(key);+ self}}@@ -1091,6 +1098,15 @@ impl MenuView {.map(|ch| mnemonic_match(items, cur, ch)).find(|r| *r != MnemonicMatch::None).unwrap_or(MnemonicMatch::None);+ // nothing in the list has that letter: the row of buttons at the top (Cut, Copy, Delete…) may (Discussion 721)+ if hit == MnemonicMatch::None && lv == 0 {+ let quick = candidates.into_iter().flatten().find_map(|ch| self.quick.iter().find(|q| q.enabled && q.key == Some(ch)).map(|q| q.run.clone()));+ if let Some(run) = quick {+ run_in_main(run, window, cx);+ cx.stop_propagation();+ return;+ }+ }match hit {MnemonicMatch::None => return,MnemonicMatch::Activate(ix) => self.activate_as(lv, ix, true, window, cx),