forked from gitui-org/gitui
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommand.rs
More file actions
85 lines (78 loc) · 1.55 KB
/
command.rs
File metadata and controls
85 lines (78 loc) · 1.55 KB
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
///
#[derive(Clone, PartialEq, PartialOrd, Ord, Eq)]
pub struct CommandText {
///
pub name: String,
///
pub desc: &'static str,
///
pub group: &'static str,
///
pub hide_help: bool,
}
impl CommandText {
///
pub const fn new(
name: String,
desc: &'static str,
group: &'static str,
) -> Self {
Self {
name,
desc,
group,
hide_help: false,
}
}
///
pub const fn hide_help(self) -> Self {
let mut tmp = self;
tmp.hide_help = true;
tmp
}
}
///
pub struct CommandInfo {
///
pub text: CommandText,
/// available but not active in the context
pub enabled: bool,
/// will show up in the quick bar
pub quick_bar: bool,
/// available in current app state
pub available: bool,
/// used to order commands in quickbar
pub order: i8,
}
impl CommandInfo {
///
pub const fn new(
text: CommandText,
enabled: bool,
available: bool,
) -> Self {
Self {
text,
enabled,
quick_bar: true,
available,
order: 0,
}
}
///
pub const fn order(self, order: i8) -> Self {
let mut res = self;
res.order = order;
res
}
///
pub const fn hidden(self) -> Self {
let mut res = self;
res.quick_bar = false;
res
}
///
pub const fn show_in_quickbar(&self) -> bool {
self.quick_bar && self.available
}
}