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
use std::fmt;
use crate::completion::InputCompleted;
#[derive(Clone)]
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)]
pub enum InputSimple {
Rename,
Chmod,
Newfile,
Newdir,
RegexMatch,
Sort,
Marks(MarkAction),
Filter,
}
#[derive(Clone)]
pub enum Navigate {
Jump,
History,
Shortcut,
Trash,
}
#[derive(Clone)]
pub enum Mode {
Normal,
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::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::Sort) => {
write!(f, "Sort: Kind Name Modif Size Ext Rev :")
}
Mode::InputSimple(InputSimple::Marks(_)) => write!(f, "Marks jump:"),
Mode::InputSimple(InputSimple::Filter) => write!(f, "Filter: "),
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::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::NeedConfirmation(_) => write!(f, "Y/N :"),
Mode::Preview => write!(f, "Preview : "),
}
}
}