Add kitty protocol config to nushell (#10540)

# Description

Support keyboard enhancement protocol as implemented by Kitty console,
hence Kitty protocol.

This PR enables Nushell to use keybinding that is not available before,
such as Ctrl+i (that alias to Tab) or Ctrl+e (that alias to Esc, likely
I mistaken). After this PR merged and you set `use_kitty_protocol`
enabled, if your console app support Kitty protocol (WezTerm, Kitty,
etc.) you will be able to set more fine-grained keybinding.

For Colemak users, this feature is a blessing, because some Ctrl+[hjkl]
that previously unmap-able to Ctlr+[hnei] now it is.

# User-Facing Changes

This adds `use_kitty_protocol` config which defaults to false. When set
to `true`, it enables kitty protocol on the line editor when supported,
or else it warns.


---------

Co-authored-by: Stefan Holderbach <sholderbach@users.noreply.github.com>
This commit is contained in:
Faïz Hernawan
2023-09-29 20:52:34 +07:00
committed by GitHub
parent 9a0c6f2e02
commit 7ad4c679b3
4 changed files with 50 additions and 0 deletions

View File

@ -115,6 +115,7 @@ pub struct Config {
pub datetime_normal_format: Option<String>,
pub datetime_table_format: Option<String>,
pub error_style: String,
pub use_kitty_protocol: bool,
}
impl Default for Config {
@ -180,6 +181,8 @@ impl Default for Config {
keybindings: Vec::new(),
error_style: "fancy".into(),
use_kitty_protocol: false,
}
}
}
@ -1200,6 +1203,9 @@ impl Value {
"bracketed_paste" => {
try_bool!(cols, vals, index, span, bracketed_paste);
}
"use_kitty_protocol" => {
try_bool!(cols, vals, index, span, use_kitty_protocol);
}
// Menus
"menus" => match create_menus(value) {
Ok(map) => config.menus = map,