Skip to content

Commit

Permalink
Add theme based indicator
Browse files Browse the repository at this point in the history
  • Loading branch information
jeevithakannan2 committed Sep 11, 2024
1 parent ea92fba commit b291a8d
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/hint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
9 changes: 7 additions & 2 deletions src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!(
"{} {} {}",
Expand All @@ -177,6 +181,7 @@ impl AppState {
indicator
))
.style(self.theme.cmd_color())
.patch_style(style)
}
},
));
Expand Down
7 changes: 7 additions & 0 deletions src/theme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit b291a8d

Please sign in to comment.