Skip to main content

App

Struct App 

Source
pub struct App {
Show 22 fields pub left: FileExplorer, pub right: FileExplorer, pub active: Pane, pub clipboard: Option<ClipboardItem>, pub themes: Vec<(&'static str, &'static str, Theme)>, pub theme_idx: usize, pub show_theme_panel: bool, pub show_options_panel: bool, pub single_pane: bool, pub modal: Option<Modal>, pub selected: Option<PathBuf>, pub status_msg: String, pub snackbar: Option<Snackbar>, pub copy_progress: Option<CopyProgress>, pub cd_on_exit: bool, pub editor: Editor, pub open_with_editor: Option<PathBuf>, pub show_editor_panel: bool, pub editor_panel_idx: usize, pub verbose: bool, pub debug_log: Vec<String>, pub debug_scroll: usize,
}

Fields§

§left: FileExplorer

The left-hand explorer pane.

§right: FileExplorer

The right-hand explorer pane.

§active: Pane

Which pane currently has keyboard focus.

§clipboard: Option<ClipboardItem>

The most recently yanked entry, if any.

§themes: Vec<(&'static str, &'static str, Theme)>

All available themes as (name, description, Theme) triples.

§theme_idx: usize

Index into themes for the currently active theme.

§show_theme_panel: bool

Whether the theme-picker side-panel is visible.

§show_options_panel: bool

Whether the options side-panel is visible.

§single_pane: bool

Whether only the active pane is shown (single-pane mode).

§modal: Option<Modal>

The currently displayed confirmation modal, if any.

§selected: Option<PathBuf>

The path chosen by the user (set on Enter / confirm).

§status_msg: String

One-line status text shown in the action bar.

§snackbar: Option<Snackbar>

Optional floating notification that auto-expires.

§copy_progress: Option<CopyProgress>

Progress of an ongoing copy/move operation, if any.

§cd_on_exit: bool

Whether cd-on-exit is enabled (dismiss prints cwd to stdout).

§editor: Editor

Which editor to open when the user presses e on a file.

§open_with_editor: Option<PathBuf>

When Some, the run-loop should suspend the TUI, open this path in self.editor, then restore the TUI. Set by the e key handler; cleared by run_loop after the editor exits.

§show_editor_panel: bool

Whether the editor-picker side-panel is visible.

§editor_panel_idx: usize

Highlighted row index in the editor-picker panel (cursor position).

§verbose: bool

Whether the debug log panel is visible (--verbose / -v).

§debug_log: Vec<String>

Accumulated debug log lines shown in the log panel.

§debug_scroll: usize

Scroll offset for the debug log panel (0 = pinned to bottom).

Implementations§

Source§

impl App

Source

pub fn new(opts: AppOptions) -> Self

Construct a new App from an AppOptions config struct.

Source

pub fn log(&mut self, msg: impl Into<String>)

Append a line to the debug log (visible in the log panel when --verbose is active).

Source

pub fn first_ide_idx() -> usize

Index of the first IDE/GUI editor in the [all_editors] list.

Everything before this index is a terminal editor; everything from this index onward is a GUI editor or IDE. Used by the editor panel to render the two section headers.

Source

pub fn all_editors() -> Vec<Editor>

Return every Editor variant in display order.

Used by the editor-picker panel to populate the list and navigate it. Terminal editors come first, then GUI editors/IDEs.

Source

pub fn sync_editor_panel_idx(&mut self)

Sync editor_panel_idx to point at the currently active editor.

Called when the panel is opened so the cursor lands on the current selection. Defaults to index 0 (Editor::None) if not found.

Source

pub fn notify(&mut self, msg: impl Into<String>)

Show an info snackbar with the given message (auto-expires after 3 s).

Source

pub fn notify_error(&mut self, msg: impl Into<String>)

Show an error snackbar with the given message (auto-expires after 4 s).

Source

pub fn active_pane(&self) -> &FileExplorer

Source

pub fn active_pane_mut(&mut self) -> &mut FileExplorer

Return a mutable reference to the currently active pane.

Source

pub fn theme(&self) -> &Theme

Return a reference to the currently selected Theme.

Source

pub fn theme_name(&self) -> &str

Return the name of the currently selected theme.

Source

pub fn theme_desc(&self) -> &str

Return the description of the currently selected theme.

Source

pub fn next_theme(&mut self)

Advance to the next theme, wrapping around at the end of the list.

Source

pub fn prev_theme(&mut self)

Retreat to the previous theme, wrapping around at the beginning.

Source

pub fn yank(&mut self, op: ClipOp)

Yank (copy or cut) into the clipboard.

Marks are checked in priority order:

  1. Active pane marks — the normal single-pane workflow.
  2. Inactive pane marks — handles the common dual-pane workflow where the user marks files in the source pane, tabs to the destination pane, and then presses y.
  3. Active pane cursor entry — fallback when nothing is marked.

Marks on whichever pane was used are cleared after the yank.

Source

pub fn paste(&mut self)

Paste the clipboard item into the active pane’s current directory.

If the destination already exists, a Modal::Overwrite is raised instead of overwriting silently.

Source

pub fn do_paste(&mut self, src: &Path, dst: &Path, is_cut: bool)

Perform the actual copy/move for a single src→dst pair.

Used by the overwrite-confirmation modal path (single file only). For multi-file paste use App::do_paste_all.

Source

pub fn do_paste_all(&mut self, srcs: &[PathBuf], dst_dir: &Path, is_cut: bool)

Paste all srcs into dst_dir, performing copy or move for each.

Errors are collected and reported in the status message alongside the success count. On a fully successful cut the clipboard is cleared.

Source

pub fn prompt_delete(&mut self)

Raise a Modal::Delete for the currently highlighted entry, or a Modal::MultiDelete when there are space-marked entries in the active pane.

Source

pub fn confirm_delete_many(&mut self, paths: &[PathBuf])

Execute a confirmed multi-deletion and reload both panes.

Source

pub fn confirm_delete(&mut self, path: &Path)

Execute a confirmed deletion and reload both panes.

Source

pub fn handle_key(&mut self, key: KeyEvent) -> Result<bool>

Process a single [KeyEvent] and update application state.

This is the core key-dispatch method. Library consumers that read their own events (e.g. via a shared event loop) should call this directly instead of App::handle_event.

Returns true when the event loop should exit (user confirmed a selection or dismissed the explorer).

§Example
use crossterm::event::{self, Event, KeyCode, KeyEvent, KeyModifiers};
use tui_file_explorer::{App, AppOptions};

let mut app = App::new(AppOptions::default());

// Read the event yourself and forward only key events.
if let Event::Key(key) = event::read().unwrap() {
    let should_exit = app.handle_key(key).unwrap();
}
Source

pub fn handle_event(&mut self) -> Result<bool>

Read one terminal event and update application state.

Calls event::read internally. If your application already owns the event loop and reads events itself, call App::handle_key instead.

Returns true when the event loop should exit (user confirmed a selection or dismissed the explorer).

Auto Trait Implementations§

§

impl Freeze for App

§

impl RefUnwindSafe for App

§

impl Send for App

§

impl Sync for App

§

impl Unpin for App

§

impl UnsafeUnpin for App

§

impl UnwindSafe for App

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> 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, 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.