Struct broot::browser::BrowserState

source ·
pub struct BrowserState {
    pub tree: Tree,
    pub filtered_tree: Option<Tree>,
    /* private fields */
}
Expand description

An application state dedicated to displaying a tree. It’s the first and main screen of broot.

Fields§

§tree: Tree§filtered_tree: Option<Tree>

Implementations§

source§

impl BrowserState

source

pub fn new( path: PathBuf, options: TreeOptions, screen: Screen, con: &AppContext, dam: &Dam ) -> Result<BrowserState, TreeBuildError>

build a new tree state if there’s no error and there’s no cancellation.

source

pub fn root(&self) -> &Path

source

pub fn page_height(screen: Screen) -> usize

source

pub fn displayed_tree(&self) -> &Tree

return a reference to the currently displayed tree, which is the filtered tree if there’s one, the base tree if not.

source

pub fn displayed_tree_mut(&mut self) -> &mut Tree

return a mutable reference to the currently displayed tree, which is the filtered tree if there’s one, the base tree if not.

source

pub fn open_selection_stay_in_broot( &mut self, screen: Screen, con: &AppContext, in_new_panel: bool, keep_pattern: bool ) -> Result<CmdResult, ProgramError>

source

pub fn go_to_parent( &mut self, screen: Screen, con: &AppContext, in_new_panel: bool ) -> CmdResult

Trait Implementations§

source§

impl PanelState for BrowserState

source§

fn with_new_options( &mut self, screen: Screen, change_options: &dyn Fn(&mut TreeOptions) -> &'static str, in_new_panel: bool, con: &AppContext ) -> CmdResult

build a cmdResult asking for the addition of a new state being a browser state similar to the current one but with different options

source§

fn do_pending_task( &mut self, app_state: &mut AppState, screen: Screen, con: &AppContext, dam: &mut Dam ) -> Result<(), ProgramError>

do some work, totally or partially, if there’s some to do. Stop as soon as the dam asks for interruption

source§

fn tree_root(&self) -> Option<&Path>

must return None if the state doesn’t display a file tree
source§

fn get_type(&self) -> PanelStateType

source§

fn set_mode(&mut self, mode: Mode)

source§

fn get_mode(&self) -> Mode

source§

fn get_pending_task(&self) -> Option<&'static str>

source§

fn selected_path(&self) -> Option<&Path>

source§

fn selection(&self) -> Option<Selection<'_>>

source§

fn tree_options(&self) -> TreeOptions

source§

fn clear_pending(&mut self)

called on start of on_command
source§

fn on_click( &mut self, _x: u16, y: u16, _screen: Screen, _con: &AppContext ) -> Result<CmdResult, ProgramError>

source§

fn on_double_click( &mut self, _x: u16, y: u16, screen: Screen, con: &AppContext ) -> Result<CmdResult, ProgramError>

source§

fn on_pattern( &mut self, pat: InputPattern, _app_state: &AppState, _con: &AppContext ) -> Result<CmdResult, ProgramError>

source§

fn on_internal( &mut self, w: &mut W, internal_exec: &InternalExecution, input_invocation: Option<&VerbInvocation>, trigger_type: TriggerType<'_>, app_state: &mut AppState, cc: &CmdContext<'_> ) -> Result<CmdResult, ProgramError>

execute the internal with the optional given invocation. Read more
source§

fn no_verb_status(&self, has_previous_state: bool, con: &AppContext) -> Status

return the status which should be used when there’s no verb edited
source§

fn display( &mut self, w: &mut W, disc: &DisplayContext<'_> ) -> Result<(), ProgramError>

source§

fn refresh(&mut self, screen: Screen, con: &AppContext) -> Command

source§

fn get_flags(&self) -> Vec<Flag>

return the flags to display
source§

fn get_starting_input(&self) -> String

source§

fn on_mode_verb(&mut self, mode: Mode, con: &AppContext) -> CmdResult

source§

fn on_internal_generic( &mut self, _w: &mut W, internal_exec: &InternalExecution, input_invocation: Option<&VerbInvocation>, _trigger_type: TriggerType<'_>, app_state: &mut AppState, cc: &CmdContext<'_> ) -> Result<CmdResult, ProgramError>

a generic implementation of on_internal which may be called by states when they don’t have a specific behavior to execute
source§

fn stage( &self, app_state: &mut AppState, cc: &CmdContext<'_>, con: &AppContext ) -> CmdResult

source§

fn unstage( &self, app_state: &mut AppState, cc: &CmdContext<'_>, _con: &AppContext ) -> CmdResult

source§

fn toggle_stage( &self, app_state: &mut AppState, cc: &CmdContext<'_>, con: &AppContext ) -> CmdResult

source§

fn execute_verb( &mut self, w: &mut W, verb: &Verb, invocation: Option<&VerbInvocation>, trigger_type: TriggerType<'_>, app_state: &mut AppState, cc: &CmdContext<'_> ) -> Result<CmdResult, ProgramError>

source§

fn execute_external( &mut self, w: &mut W, verb: &Verb, external_execution: &ExternalExecution, invocation: Option<&VerbInvocation>, app_state: &mut AppState, cc: &CmdContext<'_> ) -> Result<CmdResult, ProgramError>

source§

fn execute_sequence( &mut self, _w: &mut W, verb: &Verb, seq_ex: &SequenceExecution, invocation: Option<&VerbInvocation>, app_state: &mut AppState, _cc: &CmdContext<'_> ) -> Result<CmdResult, ProgramError>

source§

fn on_command( &mut self, w: &mut W, app_state: &mut AppState, cc: &CmdContext<'_> ) -> Result<CmdResult, ProgramError>

change the state, does no rendering
source§

fn open_preview( &mut self, prefered_mode: Option<PreviewMode>, close_if_open: bool, cc: &CmdContext<'_> ) -> CmdResult

return a cmdresult asking for the opening of a preview
source§

fn sel_info<'c>(&'c self, _app_state: &'c AppState) -> SelInfo<'c>

source§

fn has_at_least_one_selection(&self, _app_state: &AppState) -> bool

source§

fn set_selected_path(&mut self, _path: PathBuf, _con: &AppContext)

source§

fn get_status( &self, app_state: &AppState, cc: &CmdContext<'_>, has_previous_state: bool ) -> Status

source§

fn get_verb_status( &self, verb: &Verb, invocation: &VerbInvocation, sel_info: SelInfo<'_>, _cc: &CmdContext<'_>, app_state: &AppState ) -> Status

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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.

§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

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

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.