mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-01 04:41:14 -03:00
Allow abbreviating ctrl-/alt- as c-/a-
This makes them more convenient to use interactively, similar to the existing \c and \a versions. The resulting bind output keeps using the canonical ctrl/alt version. Not sure about s- because that's somewhat ambiguous, it could be "super".
This commit is contained in:
@@ -23,7 +23,7 @@ If both ``KEYS`` and ``COMMAND`` are given, ``bind`` adds (or replaces) a bindin
|
|||||||
If only ``KEYS`` is given, any existing binding in the given ``MODE`` will be printed.
|
If only ``KEYS`` is given, any existing binding in the given ``MODE`` will be printed.
|
||||||
|
|
||||||
``KEYS`` is a comma-separated list of key names.
|
``KEYS`` is a comma-separated list of key names.
|
||||||
Modifier keys can be specified by prefixing a key name with a combination of ``ctrl-``, ``alt-`` and ``shift-``.
|
Modifier keys can be specified by prefixing a key name with a combination of ``ctrl-``/``c-``, ``alt-``/``a-`` and ``shift-``.
|
||||||
For example, :kbd:`Alt`\ +\ :kbd:`w` is written as ``alt-w``.
|
For example, :kbd:`Alt`\ +\ :kbd:`w` is written as ``alt-w``.
|
||||||
Key names are case-sensitive; for example ``alt-W`` is the same as ``alt-shift-w``.
|
Key names are case-sensitive; for example ``alt-W`` is the same as ``alt-shift-w``.
|
||||||
|
|
||||||
|
|||||||
@@ -259,8 +259,8 @@ pub(crate) fn parse_keys(value: &wstr) -> Result<Vec<Key>, WString> {
|
|||||||
for _i in 0..num_keys.checked_sub(1).unwrap() {
|
for _i in 0..num_keys.checked_sub(1).unwrap() {
|
||||||
let modifier = components.next().unwrap();
|
let modifier = components.next().unwrap();
|
||||||
match modifier {
|
match modifier {
|
||||||
_ if modifier == "ctrl" => modifiers.ctrl = true,
|
_ if modifier == "ctrl" || modifier == "c" => modifiers.ctrl = true,
|
||||||
_ if modifier == "alt" => modifiers.alt = true,
|
_ if modifier == "alt" || modifier == "a" => modifiers.alt = true,
|
||||||
_ if modifier == "shift" => modifiers.shift = true,
|
_ if modifier == "shift" => modifiers.shift = true,
|
||||||
_ => {
|
_ => {
|
||||||
return Err(wgettext_fmt!(
|
return Err(wgettext_fmt!(
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ fn test_parse_key() {
|
|||||||
);
|
);
|
||||||
assert_eq!(parse_keys(L!("\x1b")), Ok(vec![Key::from_raw(key::Escape)]));
|
assert_eq!(parse_keys(L!("\x1b")), Ok(vec![Key::from_raw(key::Escape)]));
|
||||||
assert_eq!(parse_keys(L!("ctrl-a")), Ok(vec![ctrl('a')]));
|
assert_eq!(parse_keys(L!("ctrl-a")), Ok(vec![ctrl('a')]));
|
||||||
|
assert_eq!(parse_keys(L!("c-a")), Ok(vec![ctrl('a')]));
|
||||||
assert_eq!(parse_keys(L!("\x01")), Ok(vec![ctrl('a')]));
|
assert_eq!(parse_keys(L!("\x01")), Ok(vec![ctrl('a')]));
|
||||||
assert!(parse_keys(L!("F0")).is_err());
|
assert!(parse_keys(L!("F0")).is_err());
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
|||||||
Reference in New Issue
Block a user