mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
macos: create modifier flags as OptionSet instead of from array
Nit picky change, but the OptionSet class (which NSEvent.ModifierFlags is an instance of) has an API for incrementally setting values without needing to create an array.
This commit is contained in:

committed by
Mitchell Hashimoto

parent
8f75e83958
commit
4837d840f6
@ -9,12 +9,12 @@ extension Ghostty {
|
|||||||
|
|
||||||
/// Returns the event modifier flags set for the Ghostty mods enum.
|
/// Returns the event modifier flags set for the Ghostty mods enum.
|
||||||
static func eventModifierFlags(mods: ghostty_input_mods_e) -> NSEvent.ModifierFlags {
|
static func eventModifierFlags(mods: ghostty_input_mods_e) -> NSEvent.ModifierFlags {
|
||||||
var flags: [NSEvent.ModifierFlags] = [];
|
var flags = NSEvent.ModifierFlags(rawValue: 0);
|
||||||
if (mods.rawValue & GHOSTTY_MODS_SHIFT.rawValue != 0) { flags.append(.shift) }
|
if (mods.rawValue & GHOSTTY_MODS_SHIFT.rawValue != 0) { flags.insert(.shift) }
|
||||||
if (mods.rawValue & GHOSTTY_MODS_CTRL.rawValue != 0) { flags.append(.control) }
|
if (mods.rawValue & GHOSTTY_MODS_CTRL.rawValue != 0) { flags.insert(.control) }
|
||||||
if (mods.rawValue & GHOSTTY_MODS_ALT.rawValue != 0) { flags.append(.option) }
|
if (mods.rawValue & GHOSTTY_MODS_ALT.rawValue != 0) { flags.insert(.option) }
|
||||||
if (mods.rawValue & GHOSTTY_MODS_SUPER.rawValue != 0) { flags.append(.command) }
|
if (mods.rawValue & GHOSTTY_MODS_SUPER.rawValue != 0) { flags.insert(.command) }
|
||||||
return NSEvent.ModifierFlags(flags)
|
return flags
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A map from the Ghostty key enum to the keyEquivalent string for shortcuts.
|
/// A map from the Ghostty key enum to the keyEquivalent string for shortcuts.
|
||||||
|
Reference in New Issue
Block a user