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>
This commit is contained in:
Helmut K. C. Tessarek 2024-02-21 03:25:55 -05:00 committed by GitHub
parent 3d82adad36
commit 56b971ae19
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 14 additions and 1 deletions

View File

@ -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

View File

@ -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())?

View File

@ -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);