summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorManos Pitsidianakis <el13635@mail.ntua.gr>2020-11-15 21:02:06 +0200
committerManos Pitsidianakis <el13635@mail.ntua.gr>2020-11-15 21:30:54 +0200
commit76f8bdc558d3df10ff575aa710160f9e52fdcadf (patch)
tree46c490203c58f9ac84a6b4dcf4d572042680bd93 /src
parentd404910a0ff619361f1095b64692ad25d1fc613d (diff)
Add configurable shortcut for 'quit'
Quit ('q' button) was hardcoded, switch to configurable shortcut setting instead.
Diffstat (limited to 'src')
-rw-r--r--src/bin.rs3
-rw-r--r--src/conf/shortcuts.rs1
-rw-r--r--src/state.rs5
3 files changed, 7 insertions, 2 deletions
diff --git a/src/bin.rs b/src/bin.rs
index 586e94b8..73c2f246 100644
--- a/src/bin.rs
+++ b/src/bin.rs
@@ -375,6 +375,7 @@ fn run_app(opt: Opt) -> Result<()> {
.general
.enter_command_mode
.clone();
+ let quit_key: Key = state.context.settings.shortcuts.general.quit.clone();
/* Keep track of the input mode. See UIMode for details */
'main: loop {
@@ -421,7 +422,7 @@ fn run_app(opt: Opt) -> Result<()> {
match state.mode {
UIMode::Normal => {
match k {
- Key::Char('q') | Key::Char('Q') => {
+ _ if k == quit_key => {
if state.can_quit_cleanly() {
drop(state);
break 'main;
diff --git a/src/conf/shortcuts.rs b/src/conf/shortcuts.rs
index bfdfc9b9..e40b58ca 100644
--- a/src/conf/shortcuts.rs
+++ b/src/conf/shortcuts.rs
@@ -216,6 +216,7 @@ shortcut_key_values! { "general",
pub struct GeneralShortcuts {
toggle_help |> "Toggle help and shortcuts view." |> Key::Char('?'),
enter_command_mode |> "Enter COMMAND mode." |> Key::Char(':'),
+ quit |> "Quit meli." |> Key::Char('q'),
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,
diff --git a/src/state.rs b/src/state.rs
index 2cd18b0a..009d5328 100644
--- a/src/state.rs
+++ b/src/state.rs
@@ -1034,7 +1034,10 @@ impl State {
Quit => {
self.context
.sender
- .send(ThreadEvent::Input((Key::Char('q'), vec![b'q'])))
+ .send(ThreadEvent::Input((
+ self.context.settings.shortcuts.general.quit.clone(),
+ vec![],
+ )))
.unwrap();
}
v => {