1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
use std::collections::HashSet;
use std::path::PathBuf;
use dua::traverse::{BackgroundTraversal, TraversalStats};
use dua::WalkOptions;
use crate::interactive::widgets::Column;
use super::{navigation::Navigation, EntryDataBundle, SortMode};
#[derive(Default, Copy, Clone, PartialEq)]
pub enum FocussedPane {
#[default]
Main,
Help,
Mark,
Glob,
}
#[derive(Default)]
pub struct Cursor {
pub show: bool,
pub x: u16,
pub y: u16,
}
pub struct FilesystemScan {
pub active_traversal: BackgroundTraversal,
/// The selected item prior to starting the traversal, if available, based on its name or index into [`AppState::entries`].
pub previous_selection: Option<(PathBuf, usize)>,
}
pub struct AppState {
pub navigation: Navigation,
pub glob_navigation: Option<Navigation>,
pub entries: Vec<EntryDataBundle>,
pub sorting: SortMode,
pub show_columns: HashSet<Column>,
pub message: Option<String>,
pub focussed: FocussedPane,
pub received_events: bool,
pub scan: Option<FilesystemScan>,
pub stats: TraversalStats,
pub walk_options: WalkOptions,
/// The paths used in the initial traversal, at least 1.
pub root_paths: Vec<PathBuf>,
/// If true, listed entries will be validated for presence when switching directories.
pub allow_entry_check: bool,
}
impl AppState {
pub fn new(walk_options: WalkOptions, input: Vec<PathBuf>) -> Self {
AppState {
navigation: Default::default(),
glob_navigation: None,
entries: vec![],
sorting: Default::default(),
show_columns: Default::default(),
message: None,
focussed: Default::default(),
received_events: false,
scan: None,
stats: TraversalStats::default(),
walk_options,
root_paths: input,
allow_entry_check: true,
}
}
}
|