From 831f71bf433748ebbfb323eeed4ee9785c24dc0c Mon Sep 17 00:00:00 2001 From: JEEVITHA KANNAN K S Date: Thu, 19 Sep 2024 22:54:56 +0530 Subject: [PATCH] Fix description and preview hints (#495) --- tui/src/hint.rs | 22 ++++++++++++---------- tui/src/state.rs | 4 ++-- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/tui/src/hint.rs b/tui/src/hint.rs index 9d10e4da..93ec8312 100644 --- a/tui/src/hint.rs +++ b/tui/src/hint.rs @@ -100,11 +100,18 @@ impl Shortcut { } } -fn get_list_item_shortcut(state: &AppState) -> Shortcut { +fn get_list_item_shortcut(state: &AppState) -> Vec { if state.selected_item_is_dir() { - Shortcut::new(vec!["l", "Right", "Enter"], "Go to selected dir") + vec![Shortcut::new( + vec!["l", "Right", "Enter"], + "Go to selected dir", + )] } else { - Shortcut::new(vec!["l", "Right", "Enter"], "Run selected command") + vec![ + Shortcut::new(vec!["l", "Right", "Enter"], "Run selected command"), + Shortcut::new(vec!["p"], "Enable preview"), + Shortcut::new(vec!["d"], "Command Description"), + ] } } @@ -121,7 +128,7 @@ pub fn draw_shortcuts(state: &AppState, frame: &mut Frame, area: Rect) { if state.at_root() { hints.push(Shortcut::new(vec!["h", "Left"], "Focus tab list")); - hints.push(get_list_item_shortcut(state)); + hints.extend(get_list_item_shortcut(state)); } else { if state.selected_item_is_up_dir() { hints.push(Shortcut::new( @@ -130,14 +137,9 @@ pub fn draw_shortcuts(state: &AppState, frame: &mut Frame, area: Rect) { )); } else { hints.push(Shortcut::new(vec!["h", "Left"], "Go to parent directory")); - hints.push(get_list_item_shortcut(state)); - if state.selected_item_is_cmd() { - hints.push(Shortcut::new(vec!["p"], "Enable preview")); - hints.push(Shortcut::new(vec!["d"], "Command Description")); - } + hints.extend(get_list_item_shortcut(state)); } }; - hints.push(Shortcut::new(vec!["k", "Up"], "Select item above")); hints.push(Shortcut::new(vec!["j", "Down"], "Select item below")); hints.push(Shortcut::new(vec!["t"], "Next theme")); diff --git a/tui/src/state.rs b/tui/src/state.rs index d5d943a7..5b7c9849 100644 --- a/tui/src/state.rs +++ b/tui/src/state.rs @@ -316,8 +316,8 @@ impl AppState { Focus::List if key.kind != KeyEventKind::Release => match key.code { KeyCode::Char('j') | KeyCode::Down => self.selection.select_next(), KeyCode::Char('k') | KeyCode::Up => self.selection.select_previous(), - KeyCode::Char('p') => self.enable_preview(), - KeyCode::Char('d') => self.enable_description(), + KeyCode::Char('p') | KeyCode::Char('P') => self.enable_preview(), + KeyCode::Char('d') | KeyCode::Char('D') => self.enable_description(), KeyCode::Enter | KeyCode::Char('l') | KeyCode::Right => self.handle_enter(), KeyCode::Char('h') | KeyCode::Left => { if self.at_root() {