Skip to main content

FileTree

Struct FileTree 

Source
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

Source

pub fn new(document: &DiffDocument, root: String) -> Self

Creates a file tree from document, rooted at the folder named root.

Source

pub fn active_file(self, file: Option<FileId>) -> Self

Sets the file highlighted as active when rendered through Widget.

Source

pub fn palette(self, palette: DiffPalette) -> Self

Sets the palette used for badges and stats when rendered through Widget.

Source

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.

Source

pub fn target(&self) -> Option<FileTreeTarget>

Returns the file-tree target under the cursor.

Source

pub fn cols(&self, view_cols: usize) -> usize

Returns the file tree width for a viewport.

Source

pub fn select(&mut self, delta: isize) -> Option<FileId>

Moves the file-tree cursor by delta visible rows.

Source

pub fn select_file(&mut self, file: FileId) -> bool

Selects the visible file-tree row for file.

Source

pub fn activate_target(&mut self) -> Option<FileId>

Activates the current file-tree cursor.

Source

pub fn selected_file(&self) -> Option<FileId>

Returns the file represented by the selected file-tree row.

Source

pub fn collapse_folder(&mut self)

Collapses the focused file-tree folder.

Source

pub fn expand_folder(&mut self)

Expands the focused file-tree folder.

Trait Implementations§

Source§

impl Clone for FileTree

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for FileTree

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for FileTree

Source§

impl PartialEq for FileTree

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for FileTree

Source§

impl Widget for FileTree

Source§

fn size(&self, parent: Constraint) -> Size

Returns the widget size under a parent constraint.
Source§

fn render(&mut self, area: Rect, buf: &mut Buffer)

Renders the widget into an area.
Source§

fn columns(&self, parent: Constraint) -> usize

Returns the number of columns occupied by this widget.
Source§

fn rows(&self, parent: Constraint) -> usize

Returns the number of rows occupied by this widget.
Source§

fn to_buffer(&mut self, constraints: Constraint) -> Buffer

Renders this widget into a fresh buffer sized from the given constraints.
Source§

fn lines(&mut self, constraints: Constraint) -> Vec<Line>

Returns this widget rendered as styled lines, one per row. Read more
Source§

fn to_line(&mut self, constraints: Constraint) -> Line

Returns the first rendered row of this widget, or a blank line. Read more
Source§

fn display(&mut self, constraints: Constraint) -> String

Returns a plain string representation of this widget.
Source§

fn display_styled(&mut self, constraints: Constraint) -> String

Returns a string representation with terminal styling escapes.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.