blob: b1844743b2bb6b111725924bb5d7c262e1b45b34 (
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
|
use crate::context::JoshutoContext;
use crate::error::JoshutoResult;
use super::cursor_move;
pub fn select_files(context: &mut JoshutoContext, toggle: bool, all: bool) -> JoshutoResult<()> {
if toggle {
if !all {
if let Some(s) = context
.tab_context_mut()
.curr_tab_mut()
.curr_list_mut()
.and_then(|s| s.curr_entry_mut())
{
s.set_selected(!s.is_selected());
cursor_move::down(context, 1)?;
}
} else if let Some(curr_list) = context.tab_context_mut().curr_tab_mut().curr_list_mut() {
for curr in &mut curr_list.contents {
curr.set_selected(!curr.is_selected());
}
}
} else if !all {
if let Some(s) = context
.tab_context_mut()
.curr_tab_mut()
.curr_list_mut()
.and_then(|s| s.curr_entry_mut())
{
s.set_selected(!s.is_selected());
cursor_move::down(context, 1)?;
}
} else if let Some(curr_list) = context.tab_context_mut().curr_tab_mut().curr_list_mut() {
curr_list
.contents
.iter_mut()
.for_each(|c| c.set_selected(true));
}
Ok(())
}
|