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>,
pub focused: bool,
/* 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).
focused: boolWhether this picker currently owns keyboard focus.
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_focused(self, focused: bool) -> Self
pub fn with_focused(self, focused: bool) -> Self
Mark whether this picker currently owns keyboard focus.
Sourcepub fn set_focused(&mut self, focused: bool)
pub fn set_focused(&mut self, focused: bool)
Update keyboard focus ownership.
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.