key: Add super modifier

Fixes #11217
This commit is contained in:
Fabian Boehm
2025-03-04 16:57:59 +01:00
parent b3ff27b089
commit 9f5e1736a8
3 changed files with 8 additions and 1 deletions

View File

@@ -24,7 +24,7 @@ If only ``KEYS`` is given, any existing binding for those keys in the given ``MO
If no ``KEYS`` argument is provided, all bindings (in the given ``MODE``) are 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

@@ -578,6 +578,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

@@ -59,6 +59,7 @@ pub struct Modifiers {
pub ctrl: bool,
pub alt: bool,
pub shift: bool,
pub sup: bool,
}
impl Modifiers {
@@ -67,6 +68,7 @@ const fn new() -> Self {
ctrl: false,
alt: false,
shift: false,
sup: false,
}
}
pub(crate) const ALT: Self = {
@@ -284,6 +286,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'",
@@ -420,6 +423,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
}