feat: persist notes window size and use monospaced text

This commit is contained in:
2026-10-19 18:45:00 +02:00
parent fea0041302
commit afa27b941f
5 changed files with 82 additions and 13 deletions
+17 -4
View File
@@ -28,6 +28,7 @@ final class LauncherWindowController: NSWindowController, NSWindowDelegate, NSSe
private var previousApplication: NSRunningApplication?
private var alignmentGuides: LauncherAlignmentGuides?
private static let positionKey = "launcherPosition"
private static let notesSizeKey = "notesWindowSize"
private let uninstaller: ApplicationUninstaller
private let actionsButton = NSButton(title: "Actions ⌘K", target: nil, action: nil)
private let actions = ApplicationActionsController()
@@ -240,6 +241,11 @@ final class LauncherWindowController: NSWindowController, NSWindowDelegate, NSSe
alignmentGuides?.update(for: window)
}
func windowDidResize(_ notification: Notification) {
guard notes != nil, let window, window.styleMask.contains(.resizable) else { return }
defaults.set(NSStringFromSize(window.frame.size), forKey: Self.notesSizeKey)
}
func windowShouldClose(_ sender: NSWindow) -> Bool {
dismiss()
return false
@@ -915,6 +921,7 @@ final class LauncherWindowController: NSWindowController, NSWindowDelegate, NSSe
self.launcherViews.first?.setAccessibilityHidden(false)
if command == .notes, let previousFrame {
self.window?.styleMask = [.borderless]
self.window?.minSize = .zero
self.window?.appearance = NSAppearance(named: .darkAqua)
self.window?.setFrame(previousFrame, display: true)
if let material = content as? NSVisualEffectView { roundMaterialCorners(material, radius: 24) }
@@ -954,16 +961,22 @@ final class LauncherWindowController: NSWindowController, NSWindowDelegate, NSSe
)
searchField.setAccessibilityLabel(accessibilityLabel)
if command == .notes {
let savedSize = defaults.string(forKey: Self.notesSizeKey).map(NSSizeFromString)
?? NSSize(width: 570, height: 404)
window?.appearance = nil
window?.styleMask = [.titled, .closable, .fullSizeContentView]
window?.styleMask = [.titled, .closable, .resizable, .fullSizeContentView]
window?.minSize = NSSize(width: 570, height: 260)
window?.standardWindowButton(.miniaturizeButton)?.isHidden = true
window?.standardWindowButton(.zoomButton)?.isHidden = true
launcherViews.first?.isHidden = true
launcherViews.first?.setAccessibilityHidden(true)
if var frame = window?.frame {
frame.origin.x += (frame.width - 570) / 2
frame.origin.y = frame.maxY - 404
frame.size = NSSize(width: 570, height: 404)
let available = window?.screen?.visibleFrame.size ?? savedSize
let size = NSSize(width: min(max(savedSize.width, 570), available.width),
height: min(max(savedSize.height, 260), available.height))
frame.origin.x += (frame.width - size.width) / 2
frame.origin.y = frame.maxY - size.height
frame.size = size
window?.setFrame(frame, display: true)
}
if let material = content as? NSVisualEffectView { roundMaterialCorners(material, radius: 14) }
+3 -3
View File
@@ -4,7 +4,7 @@ import Highlighter
@MainActor
enum NotesAppearance {
static let font = NSFont.systemFont(ofSize: 17)
static let font = NSFont.monospacedSystemFont(ofSize: 17, weight: .regular)
static let paragraph: NSParagraphStyle = {
let style = NSMutableParagraphStyle()
style.lineSpacing = 5
@@ -499,8 +499,8 @@ private final class NotesView: NSView {
enum MarkdownHighlighting {
// ponytail: whole-note highlighting; incremental parsing if large notes make typing slow.
private static let rules: [(NSRegularExpression, [NSAttributedString.Key: Any])] = [
(try! NSRegularExpression(pattern: "(?m)^#{1,6} .+$"), [.font: NSFont.systemFont(ofSize: 23, weight: .semibold)]),
(try! NSRegularExpression(pattern: "\\*\\*[^\\n]+?\\*\\*|__[^\\n]+?__"), [.font: NSFont.boldSystemFont(ofSize: 17)]),
(try! NSRegularExpression(pattern: "(?m)^#{1,6} .+$"), [.font: NSFont.monospacedSystemFont(ofSize: 23, weight: .semibold)]),
(try! NSRegularExpression(pattern: "\\*\\*[^\\n]+?\\*\\*|__[^\\n]+?__"), [.font: NSFont.monospacedSystemFont(ofSize: 17, weight: .bold)]),
(try! NSRegularExpression(pattern: "(?<!\\*)\\*(?!\\*)[^*\\n]+\\*(?!\\*)|(?<!_)_(?!_)[^_\\n]+_(?!_)"), [.font: NSFontManager.shared.convert(NotesAppearance.font, toHaveTrait: .italicFontMask)]),
(try! NSRegularExpression(pattern: "!?\\[[^\\]\\n]+\\]\\([^\\n)]+\\)|(?m)^\\s*(?:[-+*]|[0-9]+\\.)\\s"), [.foregroundColor: SunsetPalette.accent]),
(try! NSRegularExpression(pattern: "~~[^\\n]+?~~"), [.strikethroughStyle: NSUnderlineStyle.single.rawValue]),