From 8b90c7fcb6f63fe12ae1f43f2bb664375e1e061c Mon Sep 17 00:00:00 2001 From: Manos Pitsidianakis Date: Sat, 25 Jul 2020 13:24:42 +0300 Subject: [PATCH] conf/shortcuts: add shortcut for COMMAND mode Replace hardcoded Key value with customisable shortcut "general.enter_command_mode" --- meli.conf.5 | 6 ++++++ src/bin.rs | 9 ++++++++- src/conf/shortcuts.rs | 3 ++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/meli.conf.5 b/meli.conf.5 index 31a212d1..4ec93c49 100644 --- a/meli.conf.5 +++ b/meli.conf.5 @@ -441,6 +441,12 @@ exit_thread = 'i' .Pp .Em general .Bl -tag -width 36n +.It Ic enter_command_mode +Enter +.Em COMMAND +mode. +.\" default value +.Pq Ql Em \ .It Ic next_tab Go to next tab. .\" default value diff --git a/src/bin.rs b/src/bin.rs index 810f1734..aa0878ff 100644 --- a/src/bin.rs +++ b/src/bin.rs @@ -343,6 +343,13 @@ fn run_app(opt: Opt) -> Result<()> { state.register_component(xdg_notifications); state.register_component(Box::new(components::notifications::NotificationFilter {})); } + let enter_command_mode: Key = state + .context + .settings + .shortcuts + .general + .enter_command_mode + .clone(); /* Keep track of the input mode. See UIMode for details */ 'main: loop { @@ -397,7 +404,7 @@ fn run_app(opt: Opt) -> Result<()> { state.redraw(); } }, - Key::Char(' ') => { + _ if k == enter_command_mode => { state.mode = UIMode::Command; state.rcv_event(UIEvent::ChangeMode(UIMode::Command)); state.redraw(); diff --git a/src/conf/shortcuts.rs b/src/conf/shortcuts.rs index 1ad69bac..f6b40abb 100644 --- a/src/conf/shortcuts.rs +++ b/src/conf/shortcuts.rs @@ -79,7 +79,7 @@ macro_rules! shortcut_key_values { #[serde(default)] #[serde(rename = $cname)] pub struct $name { - $($fname : Key),* + $(pub $fname : Key),* } impl $name { @@ -163,6 +163,7 @@ shortcut_key_values! { "pager", shortcut_key_values! { "general", pub struct GeneralShortcuts { + enter_command_mode |> "Enter COMMAND mode." |> Key::Char(' '), go_to_tab |> "Go to the nth tab" |> Key::Alt('n'), next_tab |> "Next tab." |> Key::Char('T'), scroll_right |> "Generic scroll right (catch-all setting)" |> Key::Right,