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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
use std::fmt;
use crate::completion::InputCompleted;
use crate::cryptsetup::{EncryptedAction, PasswordKind};
#[derive(Clone, Copy)]
pub enum MarkAction {
Jump,
New,
}
#[derive(Clone, Copy, Debug)]
pub enum NeedConfirmation {
Copy,
Delete,
Move,
EmptyTrash,
}
impl NeedConfirmation {
pub fn cursor_offset(&self) -> usize {
match *self {
Self::Copy => 25,
Self::Delete => 21,
Self::Move => 25,
Self::EmptyTrash => 35,
}
}
}
impl std::fmt::Display for NeedConfirmation {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
Self::Delete => write!(f, "Delete files :"),
Self::Move => write!(f, "Move files here :"),
Self::Copy => write!(f, "Copy files here :"),
Self::EmptyTrash => write!(f, "Empty the trash ?"),
}
}
}
#[derive(Clone, Copy)]
pub enum InputSimple {
Rename,
Chmod,
Newfile,
Newdir,
RegexMatch,
Sort,
Filter,
SetNvimAddress,
Password(PasswordKind, EncryptedAction),
}
#[derive(Clone, Copy)]
pub enum Navigate {
Jump,
History,
Shortcut,
Trash,
EncryptedDrive,
Marks(MarkAction),
Compress,
Bulk,
ShellMenu,
}
#[derive(Clone, Copy)]
pub enum Mode {
Normal,
Tree,
InputCompleted(InputCompleted),
Navigate(Navigate),
NeedConfirmation(NeedConfirmation),
Preview,
InputSimple(InputSimple),
}
impl fmt::Display for Mode {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
Mode::Normal => write!(f, "Normal: "),
Mode::Tree => write!(f, "Tree: "),
Mode::InputSimple(InputSimple::Rename) => write!(f, "Rename: "),
Mode::InputSimple(InputSimple::Chmod) => write!(f, "Chmod: "),
Mode::InputSimple(InputSimple::Newfile) => write!(f, "Newfile: "),
Mode::InputSimple(InputSimple::Newdir) => write!(f, "Newdir: "),
Mode::InputSimple(InputSimple::RegexMatch) => write!(f, "Regex: "),
Mode::InputSimple(InputSimple::SetNvimAddress) => write!(f, "Neovim: "),
Mode::InputSimple(InputSimple::Sort) => {
write!(f, "Sort: Kind Name Modif Size Ext Rev :")
}
Mode::InputSimple(InputSimple::Filter) => write!(f, "Filter: "),
Mode::InputSimple(InputSimple::Password(password_kind, _)) => {
write!(f, "{password_kind}")
}
Mode::InputCompleted(InputCompleted::Exec) => write!(f, "Exec: "),
Mode::InputCompleted(InputCompleted::Goto) => write!(f, "Goto : "),
Mode::InputCompleted(InputCompleted::Search) => write!(f, "Search: "),
Mode::InputCompleted(InputCompleted::Nothing) => write!(f, "Nothing: "),
Mode::InputCompleted(InputCompleted::Command) => write!(f, "Command: "),
Mode::Navigate(Navigate::Marks(_)) => write!(f, "Marks jump:"),
Mode::Navigate(Navigate::Jump) => write!(f, "Jump : "),
Mode::Navigate(Navigate::History) => write!(f, "History :"),
Mode::Navigate(Navigate::Shortcut) => write!(f, "Shortcut :"),
Mode::Navigate(Navigate::Trash) => write!(f, "Trash :"),
Mode::Navigate(Navigate::ShellMenu) => {
write!(f, "Start a new shell running a command:")
}
Mode::Navigate(Navigate::Bulk) => {
write!(f, "Bulk: rename flagged files or create new files")
}
Mode::Navigate(Navigate::Compress) => write!(f, "Compress :"),
Mode::Navigate(Navigate::EncryptedDrive) => {
write!(f, "Encrypted devices :")
}
Mode::NeedConfirmation(_) => write!(f, "Y/N :"),
Mode::Preview => write!(f, "Preview : "),
}
}
}