pub struct FileTree { /* private fields */ }Expand description
Stateful file tree over a diff document, usable as a standalone Widget.
A host builds it from a DiffDocument, drives selection through the
navigation methods, and renders it anywhere via its Widget
implementation. The diff viewer embeds one and renders it directly.
Implementations§
Source§impl FileTree
impl FileTree
Sourcepub fn new(document: &DiffDocument, root: String) -> Self
pub fn new(document: &DiffDocument, root: String) -> Self
Creates a file tree from document, rooted at the folder named root.
Sourcepub fn active_file(self, file: Option<FileId>) -> Self
pub fn active_file(self, file: Option<FileId>) -> Self
Sets the file highlighted as active when rendered through Widget.
Sourcepub fn palette(self, palette: DiffPalette) -> Self
pub fn palette(self, palette: DiffPalette) -> Self
Sets the palette used for badges and stats when rendered through Widget.
Sourcepub fn state(&self) -> &TreeState<usize>
pub fn state(&self) -> &TreeState<usize>
Returns the file tree’s expansion and cursor state.
The model is immutable after construction, so this is the only part
that changes between actions.
Sourcepub fn target(&self) -> Option<FileTreeTarget>
pub fn target(&self) -> Option<FileTreeTarget>
Returns the file-tree target under the cursor.
Sourcepub fn select(&mut self, delta: isize) -> Option<FileId>
pub fn select(&mut self, delta: isize) -> Option<FileId>
Moves the file-tree cursor by delta visible rows.
Sourcepub fn select_file(&mut self, file: FileId) -> bool
pub fn select_file(&mut self, file: FileId) -> bool
Selects the visible file-tree row for file.
Sourcepub fn activate_target(&mut self) -> Option<FileId>
pub fn activate_target(&mut self) -> Option<FileId>
Activates the current file-tree cursor.
Sourcepub fn selected_file(&self) -> Option<FileId>
pub fn selected_file(&self) -> Option<FileId>
Returns the file represented by the selected file-tree row.
Sourcepub fn collapse_folder(&mut self)
pub fn collapse_folder(&mut self)
Collapses the focused file-tree folder.
Sourcepub fn expand_folder(&mut self)
pub fn expand_folder(&mut self)
Expands the focused file-tree folder.