diff options
author | qkzk <qu3nt1n@gmail.com> | 2024-01-08 15:05:51 +0100 |
---|---|---|
committer | qkzk <qu3nt1n@gmail.com> | 2024-01-08 15:05:51 +0100 |
commit | 4381264a2aef7e5ec19f348f257e43f777586975 (patch) | |
tree | 966b6c57d1e913790a4ccf0cbab0c44a521b8650 | |
parent | e20c9f0e9d24b7618ac5eeeb148cf4b39aae983b (diff) |
better footer for flagged files
-rw-r--r-- | src/app/header_footer.rs | 29 | ||||
-rw-r--r-- | src/app/mod.rs | 2 | ||||
-rw-r--r-- | src/app/status.rs | 5 | ||||
-rw-r--r-- | src/io/display.rs | 6 |
4 files changed, 21 insertions, 21 deletions
diff --git a/src/app/header_footer.rs b/src/app/header_footer.rs index 7bfbfd7..a78fe2c 100644 --- a/src/app/header_footer.rs +++ b/src/app/header_footer.rs @@ -290,13 +290,13 @@ mod inner { } } - pub struct FuzzyHeader { + pub struct FlaggedHeader { strings: Vec<String>, sizes: Vec<usize>, width: usize, } - impl FuzzyHeader { + impl FlaggedHeader { const ACTIONS: [ActionMap; 2] = [ActionMap::ResetMode, ActionMap::OpenFile]; pub fn new(status: &Status) -> Result<Self> { @@ -336,14 +336,14 @@ mod inner { } } - impl ClickableLine for FuzzyHeader { + impl ClickableLine for FlaggedHeader { /// Vector of displayed strings. fn strings(&self) -> &Vec<String> { self.strings.as_ref() } } - impl ClickableLineInner for FuzzyHeader { + impl ClickableLineInner for FlaggedHeader { fn sizes(&self) -> &Vec<usize> { self.sizes.as_ref() } @@ -356,20 +356,20 @@ mod inner { self.width } } - pub struct FuzzyFooter { + pub struct FlaggedFooter { strings: Vec<String>, sizes: Vec<usize>, width: usize, } - impl ClickableLine for FuzzyFooter { + impl ClickableLine for FlaggedFooter { /// Vector of displayed strings. fn strings(&self) -> &Vec<String> { self.strings.as_ref() } } - impl ClickableLineInner for FuzzyFooter { + impl ClickableLineInner for FlaggedFooter { fn sizes(&self) -> &Vec<usize> { self.sizes.as_ref() } @@ -383,7 +383,7 @@ mod inner { } } - impl FuzzyFooter { + impl FlaggedFooter { const ACTIONS: [ActionMap; 2] = [ActionMap::Nothing, ActionMap::Jump]; pub fn new(status: &Status) -> Result<Self> { @@ -405,12 +405,13 @@ mod inner { } fn make_strings(status: &Status) -> Vec<String> { + let index = if status.menu.flagged.is_empty() { + 0 + } else { + status.menu.flagged.index + 1 + }; vec![ - format!( - " {index} / {len}", - index = status.menu.flagged.index + 1, - len = status.menu.flagged.len() - ), + format!(" {index} / {len}", len = status.menu.flagged.len()), format!(" {nb} flags", nb = status.menu.flagged.len()), ] } @@ -424,4 +425,4 @@ mod inner { } } -pub use inner::{ClickableLine, Footer, FuzzyFooter, FuzzyHeader, Header}; +pub use inner::{ClickableLine, FlaggedFooter, FlaggedHeader, Footer, Header}; diff --git a/src/app/mod.rs b/src/app/mod.rs index 4437451..e75913d 100644 --- a/src/app/mod.rs +++ b/src/app/mod.rs @@ -9,7 +9,7 @@ mod tab; pub use application::FM; pub use displayer::Displayer; -pub use header_footer::{ClickableLine, Footer, FuzzyFooter, FuzzyHeader, Header}; +pub use header_footer::{ClickableLine, FlaggedFooter, FlaggedHeader, Footer, Header}; pub use internal_settings::InternalSettings; pub use refresher::Refresher; pub use session::Session; diff --git a/src/app/status.rs b/src/app/status.rs index 72f1f0e..ea05a84 100644 --- a/src/app/status.rs +++ b/src/app/status.rs @@ -10,8 +10,8 @@ use tuikit::prelude::{from_keyname, Event}; use tuikit::term::Term; use crate::app::ClickableLine; +use crate::app::FlaggedHeader; use crate::app::Footer; -use crate::app::FuzzyHeader; use crate::app::Header; use crate::app::InternalSettings; use crate::app::Session; @@ -492,7 +492,6 @@ impl Status { } Display::Preview => (), } - {}; } } @@ -1014,7 +1013,7 @@ impl Status { let is_right = self.index == 1; match self.current_tab().display_mode { Display::Preview => return Ok(()), - Display::Flagged => FuzzyHeader::new(self)? + Display::Flagged => FlaggedHeader::new(self)? .action(col as usize, is_right) .matcher(self, binds), _ => Header::new(self, self.current_tab())? diff --git a/src/io/display.rs b/src/io/display.rs index b704bd3..c47b34d 100644 --- a/src/io/display.rs +++ b/src/io/display.rs @@ -11,7 +11,7 @@ use crate::app::Footer; use crate::app::Header; use crate::app::Status; use crate::app::Tab; -use crate::app::{ClickableLine, FuzzyFooter, FuzzyHeader}; +use crate::app::{ClickableLine, FlaggedFooter, FlaggedHeader}; use crate::common::path_to_string; use crate::common::{ ENCRYPTED_DEVICE_BINDS, HELP_FIRST_SENTENCE, HELP_SECOND_SENTENCE, LOG_FIRST_SENTENCE, @@ -610,7 +610,7 @@ impl<'a> Draw for WinMainHeader<'a> { fn draw(&self, canvas: &mut dyn Canvas) -> DrawResult<()> { let content = match self.tab.display_mode { DisplayMode::Preview => PreviewHeader::strings(self.status, self.tab), - DisplayMode::Flagged => FuzzyHeader::new(self.status)?.strings().to_owned(), + DisplayMode::Flagged => FlaggedHeader::new(self.status)?.strings().to_owned(), _ => Header::new(self.status, self.tab)?.strings().to_owned(), }; draw_colored_strings(0, 0, &content, canvas, self.is_selected)?; @@ -760,7 +760,7 @@ impl<'a> Draw for WinMainFooter<'a> { let height = canvas.height()?; let content = match self.tab.display_mode { DisplayMode::Preview => vec![], - DisplayMode::Flagged => FuzzyFooter::new(self.status)?.strings().to_owned(), + DisplayMode::Flagged => FlaggedFooter::new(self.status)?.strings().to_owned(), _ => Footer::new(self.status, self.tab)?.strings().to_owned(), }; let mut attr = ATTR_COB_BOLD; |