pub struct Pane {
pub cwd: PathBuf,
pub entries: Vec<Entry>,
pub cursor: usize,
pub scroll_offset: usize,
pub show_hidden: bool,
pub selected: HashSet<usize>,
pub sort_key: SortKey,
pub sort_reversed: bool,
pub filter: Option<String>,
/* private fields */
}Fields§
§cwd: PathBuf§entries: Vec<Entry>§cursor: usize§scroll_offset: usize§selected: HashSet<usize>§sort_key: SortKey§sort_reversed: bool§filter: Option<String>Name filter narrowing the listing; None lists everything.
Implementations§
Source§impl Pane
impl Pane
pub fn new(cwd: PathBuf) -> Self
Move to path, recording it in history.
Navigating somewhere new after going back discards the forward tail: the branch not taken is no longer reachable, which is how every back/forward stack behaves.
Sourcepub fn go_back(&mut self) -> bool
pub fn go_back(&mut self) -> bool
Step back to the previously visited directory. Returns whether there was anywhere to go.
Sourcepub fn go_forward(&mut self) -> bool
pub fn go_forward(&mut self) -> bool
Step forward again after going back.
pub fn can_go_back(&self) -> bool
pub fn can_go_forward(&self) -> bool
Sourcepub fn set_sort_key(&mut self, key: SortKey)
pub fn set_sort_key(&mut self, key: SortKey)
Sets the sort key directly. If the requested key is already active, toggles the sort direction instead (the “press again to reverse” convention used by clickable column headers).
Sourcepub fn set_filter(&mut self, pattern: &str)
pub fn set_filter(&mut self, pattern: &str)
Sets the name filter, or clears it when pattern is blank — so
submitting an empty prompt is the same as clearing.
pub fn clear_filter(&mut self)
pub fn move_cursor_up(&mut self)
pub fn move_cursor_down(&mut self)
Sourcepub fn ensure_cursor_visible(&mut self, visible_items: usize)
pub fn ensure_cursor_visible(&mut self, visible_items: usize)
Keep the cursor in the visible viewport (for when viewport size changes or entries are reloaded)
pub fn selected(&self) -> Option<&Entry>
pub fn toggle_selection(&mut self)
pub fn extend_selection_down(&mut self)
pub fn extend_selection_up(&mut self)
pub fn clear_selection(&mut self)
Sourcepub fn jump_to_prefix(&mut self, query: &str) -> bool
pub fn jump_to_prefix(&mut self, query: &str) -> bool
Move the cursor to the first entry (other than “..”) whose name starts with
query, case-insensitively. Leaves the cursor untouched if nothing matches.
Returns whether a match was found.
Sourcepub fn effective_selection(&self) -> Vec<usize>
pub fn effective_selection(&self) -> Vec<usize>
Returns the tagged indices (sorted), or [cursor] if nothing is tagged.
Sourcepub fn load_entries(&mut self)
pub fn load_entries(&mut self)
Load entries from the current working directory.
Read cwd from disk into the entry cache, then derive the listing.
The read is the expensive half, so anything that only changes how
entries are presented — sort, hidden files, the filter — goes through
apply_view instead of coming back here.
Sourcepub fn reload_preserving_view(&mut self)
pub fn reload_preserving_view(&mut self)
Re-read cwd and rebuild the listing while keeping the user’s place.
This is the entry point for a reload nobody asked for — one driven by
another process writing to the directory. load_entries resets the
view through apply_view, which is right when the user changed what
they are looking at (navigation, sort, filter) and wrong here: the
cursor would snap to .. whenever some background process touched the
directory.
The reconciliation is by entry name, never by row index. selected
holds indices into the derived entries vec, whose length and order
shift as files appear and vanish, so keeping the indices would silently
re-tag whichever files landed on those rows — and the delete
confirmation acts on that set. Anchoring on names means the tagged set
can only ever shrink across a refresh, which is what makes refreshing
under an open modal safe.
Sourcepub fn enter_directory(&mut self)
pub fn enter_directory(&mut self)
Enter the selected directory. If selection is not a directory, does nothing.
Sourcepub fn goto_parent(&mut self)
pub fn goto_parent(&mut self)
Navigate to the parent directory. Does nothing if already at root.