From 320a6391f22d847c9ec294023a2ae790ed2f2bc6 Mon Sep 17 00:00:00 2001 From: Ellie Huxtable Date: Tue, 18 Jun 2024 10:13:53 +0100 Subject: [PATCH 1/2] feat(tui): configurable prefix character --- crates/atuin-client/src/settings.rs | 2 ++ crates/atuin/src/command/client/search/interactive.rs | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/atuin-client/src/settings.rs b/crates/atuin-client/src/settings.rs index c0ead292fac..b7342cbd3cd 100644 --- a/crates/atuin-client/src/settings.rs +++ b/crates/atuin-client/src/settings.rs @@ -330,6 +330,7 @@ pub struct Sync { #[derive(Clone, Debug, Deserialize, Default, Serialize)] pub struct Keys { pub scroll_exits: bool, + pub prefix: char, } #[derive(Clone, Debug, Deserialize, Serialize)] @@ -715,6 +716,7 @@ impl Settings { .set_default("enter_accept", false)? .set_default("sync.records", false)? .set_default("keys.scroll_exits", true)? + .set_default("keys.prefix", 'a')? .set_default("keymap_mode", "emacs")? .set_default("keymap_mode_shell", "auto")? .set_default("keymap_cursor", HashMap::::new())? diff --git a/crates/atuin/src/command/client/search/interactive.rs b/crates/atuin/src/command/client/search/interactive.rs index 9185bc0f2a9..4cc22b86b2f 100644 --- a/crates/atuin/src/command/client/search/interactive.rs +++ b/crates/atuin/src/command/client/search/interactive.rs @@ -204,7 +204,7 @@ impl State { let esc_allow_exit = !(self.tab_index == 0 && self.keymap_mode == KeymapMode::VimInsert); // support ctrl-a prefix, like screen or tmux - if ctrl && input.code == KeyCode::Char('a') { + if ctrl && input.code == KeyCode::Char(settings.keys.prefix) { self.prefix = true; return InputAction::Continue; } From 62b6e4f2ee967d42fe124813cd387499062a028c Mon Sep 17 00:00:00 2001 From: Ellie Huxtable Date: Tue, 18 Jun 2024 10:18:32 +0100 Subject: [PATCH 2/2] string not char because toml/json lol --- crates/atuin-client/src/settings.rs | 4 ++-- crates/atuin/src/command/client/search/interactive.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/atuin-client/src/settings.rs b/crates/atuin-client/src/settings.rs index b7342cbd3cd..a34758db317 100644 --- a/crates/atuin-client/src/settings.rs +++ b/crates/atuin-client/src/settings.rs @@ -330,7 +330,7 @@ pub struct Sync { #[derive(Clone, Debug, Deserialize, Default, Serialize)] pub struct Keys { pub scroll_exits: bool, - pub prefix: char, + pub prefix: String, } #[derive(Clone, Debug, Deserialize, Serialize)] @@ -716,7 +716,7 @@ impl Settings { .set_default("enter_accept", false)? .set_default("sync.records", false)? .set_default("keys.scroll_exits", true)? - .set_default("keys.prefix", 'a')? + .set_default("keys.prefix", "a")? .set_default("keymap_mode", "emacs")? .set_default("keymap_mode_shell", "auto")? .set_default("keymap_cursor", HashMap::::new())? diff --git a/crates/atuin/src/command/client/search/interactive.rs b/crates/atuin/src/command/client/search/interactive.rs index 4cc22b86b2f..de0f4ea12e8 100644 --- a/crates/atuin/src/command/client/search/interactive.rs +++ b/crates/atuin/src/command/client/search/interactive.rs @@ -204,7 +204,7 @@ impl State { let esc_allow_exit = !(self.tab_index == 0 && self.keymap_mode == KeymapMode::VimInsert); // support ctrl-a prefix, like screen or tmux - if ctrl && input.code == KeyCode::Char(settings.keys.prefix) { + if ctrl && input.code == KeyCode::Char(settings.keys.prefix.chars().next().unwrap_or('a')) { self.prefix = true; return InputAction::Continue; }