From f30871afe4498e5c078eab93c27226cf825bf9fe Mon Sep 17 00:00:00 2001 From: nkxxll Date: Fri, 25 Apr 2025 00:16:25 +0200 Subject: [PATCH] fix(results): remove keymap hint if help is disabled --- television/config/ui.rs | 3 +++ television/draw.rs | 1 + television/screen/results.rs | 6 +++++- television/television.rs | 1 + 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/television/config/ui.rs b/television/config/ui.rs index 72c82ad..e6f853e 100644 --- a/television/config/ui.rs +++ b/television/config/ui.rs @@ -6,11 +6,13 @@ use super::themes::DEFAULT_THEME; const DEFAULT_UI_SCALE: u16 = 100; +#[allow(clippy::struct_excessive_bools)] #[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Hash)] #[serde(default)] pub struct UiConfig { pub use_nerd_font_icons: bool, pub ui_scale: u16, + pub no_help: bool, pub show_help_bar: bool, pub show_preview_panel: bool, #[serde(default)] @@ -25,6 +27,7 @@ impl Default for UiConfig { Self { use_nerd_font_icons: false, ui_scale: DEFAULT_UI_SCALE, + no_help: false, show_help_bar: false, show_preview_panel: true, input_bar_position: InputPosition::Top, diff --git a/television/draw.rs b/television/draw.rs index 91a8ed9..08ac662 100644 --- a/television/draw.rs +++ b/television/draw.rs @@ -225,6 +225,7 @@ pub fn draw(ctx: &Ctx, f: &mut Frame<'_>, area: Rect) -> Result { .to_string(), // only show the preview keybinding hint if there's actually something to preview ctx.tv_state.preview_state.enabled, + ctx.config.ui.no_help, )?; // input box diff --git a/television/screen/results.rs b/television/screen/results.rs index 1d69f9b..4ab92a1 100644 --- a/television/screen/results.rs +++ b/television/screen/results.rs @@ -253,8 +253,12 @@ pub fn draw_results_list( help_keybinding: &str, preview_keybinding: &str, preview_togglable: bool, + no_help: bool, ) -> Result<()> { - let mut toggle_hints = format!(" help: <{help_keybinding}> ",); + let mut toggle_hints = String::new(); + if !no_help { + toggle_hints.push_str(&format!(" help: <{help_keybinding}> ",)); + } if preview_togglable { toggle_hints.push_str(&format!(" preview: <{preview_keybinding}> ",)); } diff --git a/television/television.rs b/television/television.rs index a58b768..40f16a4 100644 --- a/television/television.rs +++ b/television/television.rs @@ -109,6 +109,7 @@ impl Television { if no_help { config.ui.show_help_bar = false; + config.ui.no_help = true; } let matching_mode = if exact {