blob: 37009ac0b8798f525ca989baa6b24f060d2d9cd6 (
plain)
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
|
use crate::commands::{CursorMove, JoshutoCommand, JoshutoRunnable};
use crate::context::JoshutoContext;
#[derive(Debug, Clone)]
pub struct SelectFiles {
toggle: bool,
all: bool,
}
impl SelectFiles {
pub fn new(toggle: bool, all: bool) -> Self {
SelectFiles { toggle, all }
}
pub const fn command() -> &'static str {
"select_files"
}
}
impl JoshutoCommand for SelectFiles {}
impl std::fmt::Display for SelectFiles {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(
f,
"{} toggle={} all={}",
Self::command(),
self.toggle,
self.all
)
}
}
impl JoshutoRunnable for SelectFiles {
fn execute(&self, context: &mut JoshutoContext) {
if self.toggle && !self.all {
let mut selected = false;
if let Some(s) = context.tabs[context.curr_tab_index].curr_list.as_mut() {
s.curr_toggle_select();
selected = true;
}
if selected {
let subcommand = CursorMove::new(1);
subcommand.execute(context);
}
}
}
}
|