diff options
Diffstat (limited to 'atuin-client')
| -rw-r--r-- | atuin-client/config.toml | 5 | ||||
| -rw-r--r-- | atuin-client/src/settings.rs | 48 |
2 files changed, 53 insertions, 0 deletions
diff --git a/atuin-client/config.toml b/atuin-client/config.toml index 9e097a41..d18d9783 100644 --- a/atuin-client/config.toml +++ b/atuin-client/config.toml @@ -134,6 +134,11 @@ enter_accept = true ## the specified one. # keymap_mode = "auto" +## Cursor style in each keymap mode. If specified, the cursor style is changed +## in entering the cursor shape. Available values are "default" and +## "{blink,steady}-{block,underilne,bar}". +# keymap_cursor = { emacs = "blink-block", vim_insert = "blink-block", vim_normal = "steady-block" } + # network_connect_timeout = 5 # network_timeout = 5 diff --git a/atuin-client/src/settings.rs b/atuin-client/src/settings.rs index e57b61e3..c95c8ba5 100644 --- a/atuin-client/src/settings.rs +++ b/atuin-client/src/settings.rs @@ -1,4 +1,5 @@ use std::{ + collections::HashMap, convert::TryFrom, io::prelude::*, path::{Path, PathBuf}, @@ -169,6 +170,49 @@ impl KeymapMode { } } +// We want to translate the config to crossterm::cursor::SetCursorStyle, but +// the original type does not implement trait serde::Deserialize unfortunately. +// It seems impossible to implement Deserialize for external types when it is +// used in HashMap (https://stackoverflow.com/questions/67142663). We instead +// define an adapter type. +#[derive(Clone, Debug, Deserialize, Copy, PartialEq, Eq, ValueEnum)] +pub enum CursorStyle { + #[serde(rename = "default")] + DefaultUserShape, + + #[serde(rename = "blink-block")] + BlinkingBlock, + + #[serde(rename = "steady-block")] + SteadyBlock, + + #[serde(rename = "blink-underline")] + BlinkingUnderScore, + + #[serde(rename = "steady-underline")] + SteadyUnderScore, + + #[serde(rename = "blink-bar")] + BlinkingBar, + + #[serde(rename = "steady-bar")] + SteadyBar, +} + +impl CursorStyle { + pub fn as_str(&self) -> &'static str { + match self { + CursorStyle::DefaultUserShape => "DEFAULT", + CursorStyle::BlinkingBlock => "BLINKBLOCK", + CursorStyle::SteadyBlock => "STEADYBLOCK", + CursorStyle::BlinkingUnderScore => "BLINKUNDERLINE", + CursorStyle::SteadyUnderScore => "STEADYUNDERLINE", + CursorStyle::BlinkingBar => "BLINKBAR", + CursorStyle::SteadyBar => "STEADYBAR", + } + } +} + #[derive(Clone, Debug, Deserialize)] pub struct Stats { #[serde(default = "Stats::common_prefix_default")] @@ -228,6 +272,8 @@ pub struct Settings { pub show_help: bool, pub exit_mode: ExitMode, pub keymap_mode: KeymapMode, + pub keymap_mode_shell: KeymapMode, + pub keymap_cursor: HashMap<String, CursorStyle>, pub word_jump_mode: WordJumpMode, pub word_chars: String, pub scroll_context_lines: usize, @@ -466,6 +512,8 @@ impl Settings { .set_default("enter_accept", false)? .set_default("sync.records", false)? .set_default("keymap_mode", "emacs")? + .set_default("keymap_mode_shell", "auto")? + .set_default("keymap_cursor", HashMap::<String, String>::new())? .add_source( Environment::with_prefix("atuin") .prefix_separator("_") |
