summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorqkzk <qu3nt1n@gmail.com>2024-01-21 22:13:34 +0100
committerqkzk <qu3nt1n@gmail.com>2024-01-21 22:13:34 +0100
commitb899c7eec46b41fd351aaabafbc1f084b8d94860 (patch)
tree88ac977b95564ff6506f224b6cd2b1afe31c4644
parentde24e10998c66e3bdedb29a18cca04f9410267ea (diff)
allow palette to change size in future. YAGNI ?
-rw-r--r--src/config/configuration.rs5
-rw-r--r--src/io/display.rs9
2 files changed, 12 insertions, 2 deletions
diff --git a/src/config/configuration.rs b/src/config/configuration.rs
index 93699ff..b654036 100644
--- a/src/config/configuration.rs
+++ b/src/config/configuration.rs
@@ -312,6 +312,11 @@ impl MenuColors {
color_to_attr(self.palette_4),
]
}
+
+ #[inline]
+ pub const fn palette_size(&self) -> usize {
+ self.palette().len()
+ }
}
lazy_static::lazy_static! {
diff --git a/src/io/display.rs b/src/io/display.rs
index eb8ee95..50897fd 100644
--- a/src/io/display.rs
+++ b/src/io/display.rs
@@ -674,7 +674,7 @@ impl<'a> Draw for WinMainFooter<'a> {
_ => Footer::new(self.status, self.tab)?.elems().to_owned(),
};
let mut attr = color_to_attr(MENU_COLORS.first);
- let last_index = (content.len() + 3) % 4;
+ let last_index = (content.len().saturating_sub(1)) % MENU_COLORS.palette_size();
let mut background = MENU_COLORS.palette()[last_index];
if self.is_selected {
attr.effect |= Effect::REVERSE;
@@ -949,7 +949,12 @@ impl<'a> WinSecondary<'a> {
}
fn draw_cli_applications(&self, canvas: &mut dyn Canvas) -> Result<()> {
- canvas.print_with_attr(1, 2, "pick a command", color_to_attr(MENU_COLORS.second))?;
+ canvas.print_with_attr(
+ 1,
+ 2,
+ self.tab.edit_mode.second_line(),
+ color_to_attr(MENU_COLORS.second),
+ )?;
let content = &self.status.menu.cli_applications.content;
let desc_size = self.status.menu.cli_applications.desc_size;