Something went wrong. Try again.
An auto tiler for macOS
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930import ParcelConfig
struct ShortcutKeyToken: Equatable, Sendable { let glyph: String let accessibilityLabel: String
static func modifiers(_ modifiers: KeyModifiers) -> [Self] { [KeyModifiers.ctrl, .alt, .shift, .cmd, .fn].filter { modifiers.contains($0) }.map { Self(glyph: $0.displayString, accessibilityLabel: $0.accessibilityLabel) } }
static func key(_ key: ANSIKey) -> Self { let chord = KeyChord(modifiers: [], key: key) return Self(glyph: chord.displayString, accessibilityLabel: chord.accessibilityLabel) }
static func chord(_ chord: KeyChord) -> [Self] { modifiers(chord.modifiers) + [key(chord.key)] }
static func groups(_ chords: [KeyChord]) -> [[Self]] { guard let first = chords.first else { return [] } guard chords.count > 1, !first.modifiers.isEmpty, chords.allSatisfy({ $0.modifiers == first.modifiers }) else { return chords.map(Self.chord) } return [modifiers(first.modifiers) + chords.map { key($0.key) }] }}