key: Add super modifier

Fixes #11217

(cherry picked from commit 9f5e1736a8)
This commit is contained in:
Fabian Boehm
2025-03-04 16:57:59 +01:00
parent 67b6afffd4
commit 5cd2ef903a
3 changed files with 8 additions and 1 deletions

View File

@@ -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.
``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-``, ``alt-``, ``shift-`` and ``super-`` (i.e. the "windows" or "command" key).
For example, pressing :kbd:`w` while holding the Alt modifier is written as ``alt-w``.
Key names are case-sensitive; for example ``alt-W`` is the same as ``alt-shift-w``.
``ctrl-x,ctrl-e`` would mean pressing :kbd:`ctrl-x` followed by :kbd:`ctrl-e`.

View File

@@ -560,6 +560,7 @@ pub(crate) fn terminal_protocols_disable_ifn() {
fn parse_mask(mask: u32) -> Modifiers {
Modifiers {
sup: (mask & 8) != 0,
ctrl: (mask & 4) != 0,
alt: (mask & 2) != 0,
shift: (mask & 1) != 0,

View File

@@ -54,6 +54,7 @@ pub struct Modifiers {
pub ctrl: bool,
pub alt: bool,
pub shift: bool,
pub sup: bool,
}
impl Modifiers {
@@ -62,6 +63,7 @@ const fn new() -> Self {
ctrl: false,
alt: false,
shift: false,
sup: false,
}
}
pub(crate) const ALT: Self = {
@@ -271,6 +273,7 @@ pub(crate) fn parse_keys(value: &wstr) -> Result<Vec<Key>, WString> {
_ if modifier == "ctrl" => modifiers.ctrl = true,
_ if modifier == "alt" => modifiers.alt = true,
_ if modifier == "shift" => modifiers.shift = true,
_ if modifier == "super" => modifiers.sup = true,
_ => {
return Err(wgettext_fmt!(
"unknown modifier '%s' in '%s'",
@@ -407,6 +410,9 @@ fn from(key: Key) -> Self {
if key.modifiers.ctrl {
res.insert_utfstr(0, L!("ctrl-"));
}
if key.modifiers.sup {
res.insert_utfstr(0, L!("super-"));
}
res
}