mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
macos: add keyEquivalent overload to also return modifier string
This commit is contained in:

committed by
Mitchell Hashimoto

parent
4837d840f6
commit
1fbd5e5590
@ -7,6 +7,28 @@ extension Ghostty {
|
||||
return Self.keyToEquivalent[key]
|
||||
}
|
||||
|
||||
static func keyEquivalent(key: ghostty_input_key_e, mods: ghostty_input_mods_e) -> String? {
|
||||
guard var key = Self.keyEquivalent(key: key) else { return nil }
|
||||
let flags = Self.eventModifierFlags(mods: mods)
|
||||
if flags.contains(.command) {
|
||||
key = "⌘\(key)"
|
||||
}
|
||||
|
||||
if flags.contains(.shift) {
|
||||
key = "⇧\(key)"
|
||||
}
|
||||
|
||||
if flags.contains(.option) {
|
||||
key = "⌥\(key)"
|
||||
}
|
||||
|
||||
if flags.contains(.control) {
|
||||
key = "⌃\(key)"
|
||||
}
|
||||
|
||||
return key
|
||||
}
|
||||
|
||||
/// Returns the event modifier flags set for the Ghostty mods enum.
|
||||
static func eventModifierFlags(mods: ghostty_input_mods_e) -> NSEvent.ModifierFlags {
|
||||
var flags = NSEvent.ModifierFlags(rawValue: 0);
|
||||
|
Reference in New Issue
Block a user