From b291a8de0f84c4d7538a809f7a3d77abb3c7346e Mon Sep 17 00:00:00 2001 From: JEEVITHA KANNAN K S Date: Wed, 11 Sep 2024 20:59:19 +0530 Subject: [PATCH] Add theme based indicator --- Cargo.lock | 4 ++-- src/hint.rs | 4 ++-- src/state.rs | 9 +++++++-- src/theme.rs | 7 +++++++ 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 095c4b85e..bc6b5eebb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1004,9 +1004,9 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.13" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "unicode-segmentation" diff --git a/src/hint.rs b/src/hint.rs index 76e2e9eab..189bbf60f 100644 --- a/src/hint.rs +++ b/src/hint.rs @@ -140,8 +140,8 @@ pub fn draw_shortcuts(state: &AppState, frame: &mut Frame, area: Rect) { hints.push(Shortcut::new(vec!["t"], "Next theme")); hints.push(Shortcut::new(vec!["T"], "Previous theme")); if state.is_current_tab_multi_selectable() { - hints.push(Shortcut::new(vec!["v"], "Toggle Multi selection")); - hints.push(Shortcut::new(vec!["Space"], "Multi select commands")); + hints.push(Shortcut::new(vec!["v"], "Toggle multi-selection mode")); + hints.push(Shortcut::new(vec!["Space"], "Select multiple commands")); } ShortcutList { scope_name: "Item list", diff --git a/src/state.rs b/src/state.rs index f18c3878b..b744f660b 100644 --- a/src/state.rs +++ b/src/state.rs @@ -159,8 +159,12 @@ impl AppState { |ListEntry { node, has_children, .. }| { - let is_selected = self.selected_commands.contains(&node.command); // Add * if command is selected - let indicator = if is_selected { "*" } else { "" }; + let is_selected = self.selected_commands.contains(&node.command); + let (indicator, style) = if is_selected { + (self.theme.multi_select_icon(), Style::default().bold()) + } else { + ("", Style::new()) + }; if *has_children { Line::from(format!( "{} {} {}", @@ -177,6 +181,7 @@ impl AppState { indicator )) .style(self.theme.cmd_color()) + .patch_style(style) } }, )); diff --git a/src/theme.rs b/src/theme.rs index 84fa15b4d..8337645a2 100644 --- a/src/theme.rs +++ b/src/theme.rs @@ -56,6 +56,13 @@ impl Theme { } } + pub fn multi_select_icon(&self) -> &'static str { + match self { + Theme::Default => "", + Theme::Compatible => "*", + } + } + pub fn success_color(&self) -> Color { match self { Theme::Default => Color::Rgb(199, 55, 44),