Added settings window.

This commit is contained in:
2025-01-03 16:05:03 -08:00
parent d6e097506a
commit 83bb184fe3
13 changed files with 1162 additions and 129 deletions

View File

@@ -3,28 +3,48 @@ import os
final class EditableNSTextField: NSTextField {
private let commandKey = NSEvent.ModifierFlags.command.rawValue
private let commandShiftKey = NSEvent.ModifierFlags.command.rawValue | NSEvent.ModifierFlags.shift.rawValue
private let commandShiftKey = NSEvent.ModifierFlags.command.rawValue |
NSEvent.ModifierFlags.shift.rawValue
override func performKeyEquivalent(with event: NSEvent) -> Bool {
if event.type == NSEvent.EventType.keyDown {
if (event.modifierFlags.rawValue & NSEvent.ModifierFlags.deviceIndependentFlagsMask.rawValue) == commandKey {
if (event.modifierFlags.rawValue &
NSEvent.ModifierFlags.deviceIndependentFlagsMask.rawValue)
== commandKey
{
switch event.charactersIgnoringModifiers! {
case "x":
if NSApp.sendAction(#selector(NSText.cut(_:)), to: nil, from: self) { return true }
if NSApp.sendAction(#selector(NSText.cut(_:)),
to: nil, from: self)
{ return true }
case "c":
if NSApp.sendAction(#selector(NSText.copy(_:)), to: nil, from: self) { return true }
if NSApp.sendAction(#selector(NSText.copy(_:)),
to: nil, from: self)
{ return true }
case "v":
if NSApp.sendAction(#selector(NSText.paste(_:)), to: nil, from: self) { return true }
if NSApp.sendAction(#selector(NSText.paste(_:)),
to: nil, from: self)
{ return true }
case "z":
if NSApp.sendAction(Selector(("undo:")), to: nil, from: self) { return true }
if NSApp.sendAction(Selector(("undo:")),
to: nil, from: self)
{ return true }
case "a":
if NSApp.sendAction(#selector(NSResponder.selectAll(_:)), to: nil, from: self) { return true }
if NSApp.sendAction(
#selector(NSResponder.selectAll(_:)), to: nil,
from: self)
{ return true }
default:
break
}
} else if (event.modifierFlags.rawValue & NSEvent.ModifierFlags.deviceIndependentFlagsMask.rawValue) == commandShiftKey {
} else if (event.modifierFlags.rawValue &
NSEvent.ModifierFlags.deviceIndependentFlagsMask.rawValue)
== commandShiftKey
{
if event.charactersIgnoringModifiers == "Z" {
if NSApp.sendAction(Selector(("redo:")), to: nil, from: self) { return true }
if NSApp.sendAction(Selector(("redo:")), to: nil,
from: self)
{ return true }
}
}
}