From 37b2dda7297a83f58d35d71de5cb971a355ff3f7 Mon Sep 17 00:00:00 2001 From: Alexandre Pasmantier <47638216+alexpasmantier@users.noreply.github.com> Date: Sun, 15 Dec 2024 00:54:14 +0100 Subject: [PATCH] refactor(help): enable help bar by default and add help keybinding (#122) --- .config/config.toml | 2 +- crates/television-screen/src/keybindings.rs | 18 +++++++++++------- crates/television/config/themes/builtin.rs | 9 ++++++--- crates/television/television.rs | 4 ++-- .../{catppuccin.toml => catppuccin-mocha.toml} | 4 ++-- themes/{nord.toml => nord-dark.toml} | 2 +- 6 files changed, 23 insertions(+), 16 deletions(-) rename themes/{catppuccin.toml => catppuccin-mocha.toml} (87%) rename themes/{nord.toml => nord-dark.toml} (95%) diff --git a/.config/config.toml b/.config/config.toml index ce48e17..b89171b 100644 --- a/.config/config.toml +++ b/.config/config.toml @@ -37,7 +37,7 @@ use_nerd_font_icons = false ui_scale = 100 # Whether to show the top help bar in the UI by default # This option can be toggled with the (default) `ctrl-g` keybinding -show_help_bar = false +show_help_bar = true # Where to place the input bar in the UI (top or bottom) input_bar_position = "bottom" # The theme to use for the UI diff --git a/crates/television-screen/src/keybindings.rs b/crates/television-screen/src/keybindings.rs index c0ba782..ddee2b8 100644 --- a/crates/television-screen/src/keybindings.rs +++ b/crates/television-screen/src/keybindings.rs @@ -29,6 +29,7 @@ pub enum DisplayableAction { ToggleRemoteControl, Cancel, Quit, + ToggleHelpBar, } impl Display for DisplayableAction { @@ -44,6 +45,7 @@ impl Display for DisplayableAction { DisplayableAction::ToggleRemoteControl => "Toggle Remote control", DisplayableAction::Cancel => "Cancel", DisplayableAction::Quit => "Quit", + DisplayableAction::ToggleHelpBar => "Toggle help bar", }; write!(f, "{action}") } @@ -149,12 +151,14 @@ fn build_keybindings_table_for_channel<'a>( )); // MISC line (quit, help, etc.) - // Quit ⏼ - let quit_keys = - keybindings.bindings.get(&DisplayableAction::Quit).unwrap(); - let quit_row = Row::new(build_cells_for_group( - "Quit", - quit_keys, + // Toggle help bar + let toggle_help_bar_keys = keybindings + .bindings + .get(&DisplayableAction::ToggleHelpBar) + .unwrap(); + let toggle_help_bar_row = Row::new(build_cells_for_group( + "Toggle help bar", + toggle_help_bar_keys, colorscheme.help.metadata_field_name_fg, colorscheme.mode.channel, )); @@ -169,7 +173,7 @@ fn build_keybindings_table_for_channel<'a>( copy_entry_row, send_to_channel_row, switch_channels_row, - quit_row, + toggle_help_bar_row, ], widths, ) diff --git a/crates/television/config/themes/builtin.rs b/crates/television/config/themes/builtin.rs index 4baab40..7010bbc 100644 --- a/crates/television/config/themes/builtin.rs +++ b/crates/television/config/themes/builtin.rs @@ -10,10 +10,13 @@ lazy_static! { include_str!("../../../../themes/gruvbox-dark.toml"), ); m.insert( - "catppuccin", - include_str!("../../../../themes/catppuccin.toml"), + "catppuccin-mocha", + include_str!("../../../../themes/catppuccin-mocha.toml"), + ); + m.insert( + "nord-dark", + include_str!("../../../../themes/nord-dark.toml"), ); - m.insert("nord", include_str!("../../../../themes/nord.toml")); m.insert( "solarized-dark", include_str!("../../../../themes/solarized-dark.toml"), diff --git a/crates/television/television.rs b/crates/television/television.rs index dd21471..33638e6 100644 --- a/crates/television/television.rs +++ b/crates/television/television.rs @@ -587,8 +587,8 @@ impl KeyBindings { ), ), ( - DisplayableAction::Quit, - serialized_keys_for_actions(self, &[Action::Quit]), + DisplayableAction::ToggleHelpBar, + serialized_keys_for_actions(self, &[Action::ToggleHelp]), ), ]); diff --git a/themes/catppuccin.toml b/themes/catppuccin-mocha.toml similarity index 87% rename from themes/catppuccin.toml rename to themes/catppuccin-mocha.toml index 355c8f4..da86dca 100644 --- a/themes/catppuccin.toml +++ b/themes/catppuccin-mocha.toml @@ -7,9 +7,9 @@ dimmed_text_fg = '#6c7086' input_text_fg = '#f38ba8' result_count_fg = '#f38ba8' # results -result_name_fg = '#b4befe' +result_name_fg = '#89b4fa' result_line_number_fg = '#f9e2af' -result_value_fg = '#a6adc8' +result_value_fg = '#b4befe' selection_bg = '#313244' match_fg = '#f38ba8' # preview diff --git a/themes/nord.toml b/themes/nord-dark.toml similarity index 95% rename from themes/nord.toml rename to themes/nord-dark.toml index b4854db..5dc5764 100644 --- a/themes/nord.toml +++ b/themes/nord-dark.toml @@ -1,6 +1,6 @@ # general background = '#2e3440' -border_fg = '#434c5e' +border_fg = '#81a1c1' text_fg = '#d8dee9' dimmed_text_fg = '#4c566a' # input