summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHelmut K. C. Tessarek <tessarek@evermeet.cx>2024-02-21 03:25:55 -0500
committerGitHub <noreply@github.com>2024-02-21 08:25:55 +0000
commit56b971ae1990f8b03603260801161caf0dfb84d7 (patch)
treebb6a260859556f2b3ea4dbf0a8f62d74d98f84b1
parent3d82adad369c47ab99b6fa87dba8797150065b73 (diff)
feat(client): add config option keys.scroll_exits (#1744)
* feat(client): add config option keys.scroll_exits If the config option is set the `false`, using the up/down key won't exit the TUI when scrolled past the first/last entry. Example: ``` [keys] scroll_exits = false ``` The default is `true`, which is the current behavior. * Update atuin/src/command/client/search/interactive.rs Co-authored-by: Koichi Murase <myoga.murase@gmail.com> * refactor: add option to config.toml --------- Co-authored-by: Koichi Murase <myoga.murase@gmail.com>
-rw-r--r--atuin-client/config.toml4
-rw-r--r--atuin-client/src/settings.rs9
-rw-r--r--atuin/src/command/client/search/interactive.rs2
3 files changed, 14 insertions, 1 deletions
diff --git a/atuin-client/config.toml b/atuin-client/config.toml
index 97c62881..1475b359 100644
--- a/atuin-client/config.toml
+++ b/atuin-client/config.toml
@@ -174,3 +174,7 @@ enter_accept = true
## Set commands that will be completely ignored from stats
#ignored_commands = ["cd", "ls", "vi"]
+
+[keys]
+# Defaults to true. If disabled, using the up/down key won't exit the TUI when scrolled past the first/last entry.
+# scroll_exits = false
diff --git a/atuin-client/src/settings.rs b/atuin-client/src/settings.rs
index 763fde1b..ad2e45ec 100644
--- a/atuin-client/src/settings.rs
+++ b/atuin-client/src/settings.rs
@@ -306,6 +306,11 @@ pub struct Sync {
pub records: bool,
}
+#[derive(Clone, Debug, Deserialize, Default)]
+pub struct Keys {
+ pub scroll_exits: bool,
+}
+
#[derive(Clone, Debug, Deserialize)]
pub struct Settings {
pub dialect: Dialect,
@@ -360,6 +365,9 @@ pub struct Settings {
#[serde(default)]
pub sync: Sync,
+ #[serde(default)]
+ pub keys: Keys,
+
// This is automatically loaded when settings is created. Do not set in
// config! Keep secrets and settings apart.
#[serde(skip)]
@@ -588,6 +596,7 @@ impl Settings {
// New users will get the new default, that is more similar to what they are used to.
.set_default("enter_accept", false)?
.set_default("sync.records", false)?
+ .set_default("keys.scroll_exits", true)?
.set_default("keymap_mode", "emacs")?
.set_default("keymap_mode_shell", "auto")?
.set_default("keymap_cursor", HashMap::<String, String>::new())?
diff --git a/atuin/src/command/client/search/interactive.rs b/atuin/src/command/client/search/interactive.rs
index 1c71a5b6..1f3a2cff 100644
--- a/atuin/src/command/client/search/interactive.rs
+++ b/atuin/src/command/client/search/interactive.rs
@@ -225,7 +225,7 @@ impl State {
is_down: bool,
) -> InputAction {
if is_down {
- if enable_exit && self.results_state.selected() == 0 {
+ if settings.keys.scroll_exits && enable_exit && self.results_state.selected() == 0 {
return Self::handle_key_exit(settings);
}
self.scroll_down(1);