Skip to main content

AppState

Struct AppState 

Source
pub struct AppState {
    pub theme: Option<String>,
    pub last_dir: Option<PathBuf>,
    pub last_dir_right: Option<PathBuf>,
    pub sort_mode: Option<SortMode>,
    pub show_hidden: Option<bool>,
    pub single_pane: Option<bool>,
    pub cd_on_exit: Option<bool>,
    pub editor: Option<String>,
}
Expand description

All application state that is persisted between sessions.

Every field is an Option so that absent keys are handled gracefully — the caller provides a sensible default for any field that is None.

§Example

use crate::persistence::{AppState, load_state, save_state};
use tui_file_explorer::SortMode;

let mut state = load_state();
state.theme      = Some("nord".into());
state.sort_mode  = Some(SortMode::SizeDesc);
state.show_hidden = Some(true);
save_state(&state);

Fields§

§theme: Option<String>

Colour theme name (e.g. "grape", "nord", "catppuccin-mocha").

§last_dir: Option<PathBuf>

Directory that was open in the left pane when the app last exited.

Only restored when the path still exists as a directory; stale entries (deleted directories) are silently ignored.

§last_dir_right: Option<PathBuf>

Directory that was open in the right pane when the app last exited.

Only restored when the path still exists as a directory; stale entries (deleted directories) are silently ignored.

§sort_mode: Option<SortMode>

Active sort mode: Name, SizeDesc, or Extension.

§show_hidden: Option<bool>

Whether hidden (dot-prefixed) files were visible.

§single_pane: Option<bool>

Whether single-pane mode was active.

§cd_on_exit: Option<bool>

Whether the cd-on-exit feature is enabled.

When true, tfe prints the active pane’s current directory to stdout on dismiss so the shell wrapper can cd to it. When false (default), dismissing without a selection prints nothing and exits with code 1.

§editor: Option<String>

The editor to use when the user presses e on a file.

Serialised as a short key string (e.g. "helix", "nvim", "custom:code"). None means “use the compiled-in default” (Helix).

Trait Implementations§

Source§

impl Clone for AppState

Source§

fn clone(&self) -> AppState

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for AppState

Source§

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

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

impl Default for AppState

Source§

fn default() -> AppState

Returns the “default value” for a type. Read more
Source§

impl PartialEq for AppState

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for AppState

Source§

impl StructuralPartialEq for AppState

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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 = Infallible

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

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

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.