diff options
author | rabite <rabite@posteo.de> | 2019-02-07 16:32:27 +0100 |
---|---|---|
committer | rabite <rabite@posteo.de> | 2019-02-07 16:32:27 +0100 |
commit | ea9d6d4d92a620a52efec96cd3310ecd690e7c40 (patch) | |
tree | 122f28c0beec203b54ccb58721f46ba6cf36f360 /src/files.rs | |
parent | 626ba13239108d926a0b256f711f7981f93ac3c3 (diff) |
multi-file selection
Diffstat (limited to 'src/files.rs')
-rw-r--r-- | src/files.rs | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/files.rs b/src/files.rs index 728fb71..6cb3611 100644 --- a/src/files.rs +++ b/src/files.rs @@ -170,6 +170,10 @@ impl Files { pub fn len(&self) -> usize { self.files.len() } + + pub fn get_selected(&self) -> Vec<&File> { + self.files.iter().filter(|f| f.is_selected()).collect() + } } #[derive(Debug, Copy, Clone, PartialEq, Eq)] @@ -210,6 +214,7 @@ pub struct File { pub mode: u32, pub user: u32, pub group: u32, + pub selected: bool // flags: Option<String>, } @@ -234,10 +239,8 @@ impl File { color: color, mode: mode, user: user, - group: group - // owner: None, - // group: None, - // flags: None, + group: group, + selected: false } } @@ -320,6 +323,14 @@ impl File { self.path.clone() } + pub fn toggle_selection(&mut self) { + self.selected = !self.selected + } + + pub fn is_selected(&self) -> bool { + self.selected + } + pub fn pretty_print_permissions(&self) -> String { let perms: usize = format!("{:o}", self.mode).parse().unwrap(); let perms: usize = perms % 800; |