Skip to main content

tui_lipan/widgets/file_tree/
events.rs

1use super::fs::FileKind;
2use std::sync::Arc;
3
4/// How the `FileTree` explorer input received focus.
5#[derive(Clone, Copy, Debug, PartialEq, Eq)]
6pub enum FileTreeExplorerFocusOrigin {
7    /// The focused tree handled its `/` shortcut.
8    Tree,
9    /// The explorer input was clicked directly.
10    Pointer,
11}
12
13/// Request emitted when an application-provided entry source needs a directory listing.
14#[derive(Clone, Debug, PartialEq, Eq)]
15pub struct FileTreeEntryRequest {
16    /// Full path of the directory to list.
17    pub path: Arc<str>,
18}
19
20/// File selection event emitted by `FileTree`.
21#[derive(Clone, Debug, PartialEq, Eq)]
22pub struct FileTreeEvent {
23    /// Full path of selected entry.
24    pub path: Arc<str>,
25    /// Kind of selected entry.
26    pub kind: FileKind,
27}
28
29/// File expand/collapse event emitted by `FileTree`.
30#[derive(Clone, Debug, PartialEq, Eq)]
31pub struct FileTreeToggleEvent {
32    /// Full path of toggled entry.
33    pub path: Arc<str>,
34    /// Kind of toggled entry.
35    pub kind: FileKind,
36    /// New expand state.
37    pub expanded: bool,
38}