From 9f5e1736a860ac5e42b00bd6ebee37f6559495be Mon Sep 17 00:00:00 2001 From: Fabian Boehm Date: Tue, 4 Mar 2025 16:57:59 +0100 Subject: [PATCH] key: Add super modifier Fixes #11217 --- doc_src/cmds/bind.rst | 2 +- src/input_common.rs | 1 + src/key.rs | 6 ++++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/doc_src/cmds/bind.rst b/doc_src/cmds/bind.rst index 81dd76fd0..adc0c7322 100644 --- a/doc_src/cmds/bind.rst +++ b/doc_src/cmds/bind.rst @@ -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`. diff --git a/src/input_common.rs b/src/input_common.rs index 73533d717..3cdf5b6ed 100644 --- a/src/input_common.rs +++ b/src/input_common.rs @@ -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, diff --git a/src/key.rs b/src/key.rs index abddab9b6..eb3fd734e 100644 --- a/src/key.rs +++ b/src/key.rs @@ -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, 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 }