pub struct FilePickerState {
pub current_dir: PathBuf,
pub root: Option<PathBuf>,
pub entries: Vec<DirEntry>,
pub cursor: usize,
pub offset: usize,
pub selected: Option<PathBuf>,
/* private fields */
}Expand description
Mutable state for the file picker.
Fields§
§current_dir: PathBufCurrent directory being displayed.
root: Option<PathBuf>Root directory for confinement (if set, cannot navigate above this).
entries: Vec<DirEntry>Directory entries (sorted: dirs first, then files).
cursor: usizeCurrently highlighted index.
offset: usizeScroll offset (first visible row).
selected: Option<PathBuf>The selected/confirmed path (set when user presses enter on a file).
Implementations§
Source§impl FilePickerState
impl FilePickerState
Sourcepub fn new(current_dir: PathBuf, entries: Vec<DirEntry>) -> Self
pub fn new(current_dir: PathBuf, entries: Vec<DirEntry>) -> Self
Create a new state with the given directory and entries.
Sourcepub fn with_root(self, root: impl Into<PathBuf>) -> Self
pub fn with_root(self, root: impl Into<PathBuf>) -> Self
Set a root directory to confine navigation.
When set, the user cannot navigate to a parent directory above this root.
Sourcepub fn from_path(path: impl AsRef<Path>) -> Result<Self>
pub fn from_path(path: impl AsRef<Path>) -> Result<Self>
Create state from a directory path by reading the filesystem.
Sorts entries: directories first (alphabetical), then files (alphabetical). Returns an error if the directory cannot be read.
Sourcepub fn cursor_down(&mut self)
pub fn cursor_down(&mut self)
Move cursor down.
Sourcepub fn cursor_home(&mut self)
pub fn cursor_home(&mut self)
Move cursor to the first entry.
Sourcepub fn cursor_end(&mut self)
pub fn cursor_end(&mut self)
Move cursor to the last entry.
Trait Implementations§
Source§impl Clone for FilePickerState
impl Clone for FilePickerState
Source§fn clone(&self) -> FilePickerState
fn clone(&self) -> FilePickerState
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more