macos: stylistic changes

This commit is contained in:
Mitchell Hashimoto
2023-09-28 08:34:27 -07:00
parent 137d24db9c
commit 0e4b91de88
2 changed files with 10 additions and 17 deletions

View File

@ -189,7 +189,7 @@ class PrimaryWindowManager {
for (index, window) in windows.enumerated().prefix(9) { for (index, window) in windows.enumerated().prefix(9) {
let action = "goto_tab:\(index + 1)" let action = "goto_tab:\(index + 1)"
let trigger = ghostty_config_trigger(cfg, action, UInt(action.count)) let trigger = ghostty_config_trigger(cfg, action, UInt(action.count))
guard let equiv = Ghostty.keyEquivalent(key: trigger.key, mods: trigger.mods) else { guard let equiv = Ghostty.keyEquivalentLabel(key: trigger.key, mods: trigger.mods) else {
continue continue
} }

View File

@ -7,24 +7,17 @@ extension Ghostty {
return Self.keyToEquivalent[key] return Self.keyToEquivalent[key]
} }
static func keyEquivalent(key: ghostty_input_key_e, mods: ghostty_input_mods_e) -> String? { /// Returns the keyEquivalent label that includes the mods.
static func keyEquivalentLabel(key: ghostty_input_key_e, mods: ghostty_input_mods_e) -> String? {
guard var key = Self.keyEquivalent(key: key) else { return nil } guard var key = Self.keyEquivalent(key: key) else { return nil }
let flags = Self.eventModifierFlags(mods: mods) let flags = Self.eventModifierFlags(mods: mods)
if flags.contains(.command) {
key = "\(key)"
}
if flags.contains(.shift) { // Note: the order below matters; it matches the ordering modifiers show for
key = "\(key)" // macOS menu shortcut labels.
} if flags.contains(.command) { key = "\(key)" }
if flags.contains(.shift) { key = "\(key)" }
if flags.contains(.option) { if flags.contains(.option) { key = "\(key)" }
key = "\(key)" if flags.contains(.control) { key = "\(key)" }
}
if flags.contains(.control) {
key = "\(key)"
}
return key return key
} }