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
Ctrl+arrows walk the focus without changing the selection
Marcos Gramelich28972975e0dd
diff --git a/crates/rf-app/src/folder_view.rs b/crates/rf-app/src/folder_view.rsindex ace6d76d..f4c52cd6 100644--- a/crates/rf-app/src/folder_view.rs+++ b/crates/rf-app/src/folder_view.rs@@ -3505,15 +3505,17 @@ impl FolderView {self.anchor.or(self.cursor).unwrap_or(if delta >= 0 { 0 } else { last })}- fn move_cursor(&mut self, delta: isize, extend: bool, cx: &mut Context<Self>) {- // (the arrow keys are the rename box's while it is open: they moved the selection behind it, issue 464)- if self.visible.is_empty() || self.renaming.is_some() {- return;- }- let last = self.visible.len() as isize - 1;- let next = match self.cursor {+ /// The visible index a move of `delta` lands on (the grouped Grid's vertical step included).+ fn next_index(&mut self, delta: isize) -> Option<usize> {+ let last = self.visible.len().checked_sub(1)? as isize;+ Some(match self.cursor {None => {- if delta >= 0 {+ // (Home / End come as extreme deltas: with nothing focused yet they still go to the first / last item)+ if delta == isize::MIN / 2 {+ 0+ } else if delta == isize::MAX / 2 {+ last+ } else if delta >= 0 {0} else {last@@ -3522,9 +3524,18 @@ impl FolderView {// (in the grouped Grid a step of a row's width is a step to the row below or above, across group headers)Some(c) if self.grid_grouped() && self.grid_cols > 1 && delta.unsigned_abs() == self.grid_cols => self.grid_vertical(c, delta > 0) as isize,Some(c) => (c as isize + delta).clamp(0, last),- } as usize;+ } as usize)+ }++ fn move_cursor(&mut self, delta: isize, extend: bool, cx: &mut Context<Self>) {+ // (the arrow keys are the rename box's while it is open: they moved the selection behind it, issue 464)+ if self.visible.is_empty() || self.renaming.is_some() {+ return;+ }+ let Some(next) = self.next_index(delta) else { return };+ let last = self.visible.len() - 1;if extend {- let anchor = self.extend_anchor(delta, last as usize);+ let anchor = self.extend_anchor(delta, last);self.anchor = Some(anchor);self.select_range(anchor, next);} else {@@ -3534,6 +3545,18 @@ impl FolderView {cx.notify();}+ /// Moves the keyboard focus (the outline) without touching the selection: the Explorer walk with Ctrl+arrows, whose+ /// items are then marked or unmarked with Ctrl+Space.+ fn move_focus(&mut self, delta: isize, cx: &mut Context<Self>) {+ if self.visible.is_empty() || self.renaming.is_some() {+ return;+ }+ let Some(next) = self.next_index(delta) else { return };+ self.cursor = Some(next);+ self.reveal_item(next);+ cx.notify();+ }+fn grid_tile_w(&self) -> Pixels {match self.grid_style {GridStyle::Tiles => px(GRID_SIZES[self.grid_size as usize].0),@@ -3969,6 +3992,7 @@ impl FolderView {});let e = &self.entries[ei as usize];let selected = self.selected.contains(&ei);+ let is_cursor = self.cursor == Some(vi);let cat = icons::category(e);// (hidden, a cloud file not on this PC, or cut: issue 201)let dim = e.is_hidden() || e.is_cloud_placeholder() || (crate::cut_marks::any() && self.path_of(ei).is_some_and(|p| crate::cut_marks::is_cut(&p)));@@ -4211,6 +4235,8 @@ impl FolderView {.when(selected && !renaming_here, |d| d.bg(p.selection).border_1().border_color(p.selection_border)).when(selected && renaming_here, |d| d.bg(p.selection).border_1().border_color(transparent_black())).when(!selected, |d| d.border_1().border_color(transparent_black()))+ // the keyboard focus on an item that is not selected (Ctrl+arrows): the outline alone+ .when(is_cursor && !selected, |d| d.border_1().border_color(p.selection_border)).when(!selected && part.is_none(), |d| d.hover(|s| s.bg(hover))).when(!selected && part.is_some() && self.grid_hover.is_some_and(|(h, _)| h == vi), |d| d.bg(hover)).on_mouse_down(@@ -4903,6 +4929,25 @@ impl FolderView {let m = &ev.keystroke.modifiers;// Ctrl+Alt together is AltGr on Windows (Turkish Q: AltGr+ı = i, AltGr+Q = @): that is textlet altgr = m.control && m.alt;+ // Ctrl+arrows walk the focus without touching the selection (the Explorer way); Ctrl+Space is ToggleSelection's.+ if self.view_mode != ViewMode::Columns && m.control && !m.alt && !m.platform && self.renaming.is_none() {+ let delta = match ev.keystroke.key.as_str() {+ "down" => Some(self.row_step()),+ "up" => Some(-self.row_step()),+ "left" if self.view_mode == ViewMode::Grid => Some(-self.side_step()),+ "right" if self.view_mode == ViewMode::Grid => Some(self.side_step()),+ "home" => Some(isize::MIN / 2),+ "end" => Some(isize::MAX / 2),+ "pagedown" => Some(PAGE_STEP),+ "pageup" => Some(-PAGE_STEP),+ _ => None,+ };+ if let Some(delta) = delta {+ self.move_focus(delta, cx);+ cx.stop_propagation();+ return;+ }+ }if ((m.control || m.alt) && !altgr) || m.platform || self.renaming.is_some() {return;}@@ -5285,11 +5330,12 @@ impl FolderView {&self.entries[ei as usize]}- /// Entry under the keyboard cursor, or the single selected entry.+ /// Entry under the keyboard cursor, else the single selected entry.pub(crate) fn cursor_entry(&self) -> Option<u32> {+ // the cursor can rest on an item that is not selected (Ctrl+arrows move the focus alone): keyboard commands+ // (Quick Look on Space, for one) still act on itself.cursor.and_then(|c| self.visible.get(c).copied())- .filter(|ei| self.selected.contains(ei)).or_else(|| (self.selected.len() == 1).then(|| *self.selected.iter().next().unwrap()))}@@ -6462,7 +6508,7 @@ impl FolderView {.when(!selected, |d| d.hover(|s| s.bg(if alternating { p.stripe_hover() } else { p.hover })))// the focused one of several: an outline laid over the row, not a border of it, which moved the row's content and its// pill a pixel (issue 276)- .when(is_cursor && selected && self.selected.len() > 1, |d| {+ .when(is_cursor && (!selected || self.selected.len() > 1), |d| {d.child(div().absolute().inset_0().rounded(theme::RADIUS_SM).border_1().border_color(p.selection_border))}).on_mouse_down(