Something went wrong. Try again.
An auto tiler for macOS
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139import Foundationimport ParcelConfig
extension KeyChord { package var displayString: String { modifiers.displayString + key.shortcutDisplayString }
package var accessibilityLabel: String { shortcutAccessibilityList(modifiers.shortcutAccessibilityNames + [key.shortcutAccessibilityName]) }}
extension KeyModifiers { var displayString: String { orderedShortcutModifiers.map(\.shortcutGlyph).joined() }
var accessibilityLabel: String { shortcutAccessibilityList(shortcutAccessibilityNames) }
fileprivate var shortcutAccessibilityNames: [String] { orderedShortcutModifiers.map(\.shortcutAccessibilityName) }
private var orderedShortcutModifiers: [KeyModifiers] { [KeyModifiers.ctrl, .alt, .shift, .cmd, .fn].filter { contains($0) } }
private var shortcutGlyph: String { switch self { case .ctrl: "⌃" case .alt: "⌥" case .shift: "⇧" case .cmd: "⌘" case .fn: "🌐" default: preconditionFailure("Expected a single shortcut modifier") } }
private var shortcutAccessibilityName: String { switch self { case .ctrl: String(localized: "Control", table: "UI", bundle: .module) case .alt: String(localized: "Option", table: "UI", bundle: .module) case .shift: String(localized: "Shift", table: "UI", bundle: .module) case .cmd: String(localized: "Command", table: "UI", bundle: .module) case .fn: String(localized: "Function", table: "UI", bundle: .module) default: preconditionFailure("Expected a single shortcut modifier") } }}
extension MouseModifiers { var displayString: String { KeyModifiers(rawValue: rawValue).displayString } var accessibilityLabel: String { KeyModifiers(rawValue: rawValue).accessibilityLabel }}
private func shortcutAccessibilityList(_ names: [String]) -> String { guard let first = names.first else { return "" } return names.dropFirst().reduce(first) { previous, next in String(localized: "\(previous) \(next)", table: "UI", bundle: .module) }}
private extension ANSIKey { var shortcutDisplayString: String { switch self { case .left: "←" case .right: "→" case .up: "↑" case .down: "↓" case .return: "↩" case .tab: "⇥" case .delete: "⌫" case .forwardDelete: "⌦" case .escape: "⎋" case .capsLock: "⇪" case .home: "↖" case .end: "↘" case .pageUp: "⇞" case .pageDown: "⇟" case .minus: "-" case .equal, .leftBracket, .rightBracket, .backslash, .semicolon, .quote, .comma, .period, .slash, .grave: rawValue default: shortcutAccessibilityName } }
var shortcutAccessibilityName: String { switch self { case .a, .b, .c, .d, .e, .f, .g, .h, .i, .j, .k, .l, .m, .n, .o, .p, .q, .r, .s, .t, .u, .v, .w, .x, .y, .z, .zero, .one, .two, .three, .four, .five, .six, .seven, .eight, .nine, .f1, .f2, .f3, .f4, .f5, .f6, .f7, .f8, .f9, .f10, .f11, .f12, .f13, .f14, .f15, .f16, .f17, .f18, .f19, .f20: rawValue.uppercased() case .minus: String(localized: "Minus", table: "UI", bundle: .module) case .equal: String(localized: "Equal", table: "UI", bundle: .module) case .leftBracket: String(localized: "Left Bracket", table: "UI", bundle: .module) case .rightBracket: String(localized: "Right Bracket", table: "UI", bundle: .module) case .backslash: String(localized: "Backslash", table: "UI", bundle: .module) case .semicolon: String(localized: "Semicolon", table: "UI", bundle: .module) case .quote: String(localized: "Quote", table: "UI", bundle: .module) case .comma: String(localized: "Comma", table: "UI", bundle: .module) case .period: String(localized: "Period", table: "UI", bundle: .module) case .slash: String(localized: "Slash", table: "UI", bundle: .module) case .grave: String(localized: "Grave Accent", table: "UI", bundle: .module) case .return: String(localized: "Return", table: "UI", bundle: .module) case .space: String(localized: "Space", table: "UI", bundle: .module) case .tab: String(localized: "Tab", table: "UI", bundle: .module) case .escape: String(localized: "Escape", table: "UI", bundle: .module) case .delete: String(localized: "Delete", table: "UI", bundle: .module) case .forwardDelete: String(localized: "Forward Delete", table: "UI", bundle: .module) case .capsLock: String(localized: "Caps Lock", table: "UI", bundle: .module) case .home: String(localized: "Home", table: "UI", bundle: .module) case .end: String(localized: "End", table: "UI", bundle: .module) case .help: String(localized: "Help", table: "UI", bundle: .module) case .pageUp: String(localized: "Page Up", table: "UI", bundle: .module) case .pageDown: String(localized: "Page Down", table: "UI", bundle: .module) case .left: String(localized: "Left Arrow", table: "UI", bundle: .module) case .right: String(localized: "Right Arrow", table: "UI", bundle: .module) case .up: String(localized: "Up Arrow", table: "UI", bundle: .module) case .down: String(localized: "Down Arrow", table: "UI", bundle: .module) case .keypad0: String(localized: "Keypad 0", table: "UI", bundle: .module) case .keypad1: String(localized: "Keypad 1", table: "UI", bundle: .module) case .keypad2: String(localized: "Keypad 2", table: "UI", bundle: .module) case .keypad3: String(localized: "Keypad 3", table: "UI", bundle: .module) case .keypad4: String(localized: "Keypad 4", table: "UI", bundle: .module) case .keypad5: String(localized: "Keypad 5", table: "UI", bundle: .module) case .keypad6: String(localized: "Keypad 6", table: "UI", bundle: .module) case .keypad7: String(localized: "Keypad 7", table: "UI", bundle: .module) case .keypad8: String(localized: "Keypad 8", table: "UI", bundle: .module) case .keypad9: String(localized: "Keypad 9", table: "UI", bundle: .module) case .keypadDecimal: String(localized: "Keypad Decimal", table: "UI", bundle: .module) case .keypadMultiply: String(localized: "Keypad Multiply", table: "UI", bundle: .module) case .keypadPlus: String(localized: "Keypad Plus", table: "UI", bundle: .module) case .keypadClear: String(localized: "Keypad Clear", table: "UI", bundle: .module) case .keypadDivide: String(localized: "Keypad Divide", table: "UI", bundle: .module) case .keypadEnter: String(localized: "Keypad Enter", table: "UI", bundle: .module) case .keypadMinus: String(localized: "Keypad Minus", table: "UI", bundle: .module) case .keypadEqual: String(localized: "Keypad Equal", table: "UI", bundle: .module) } }}