macos: whitespace

This commit is contained in:
Mitchell Hashimoto
2024-01-31 15:44:34 -08:00
parent 4a93181b79
commit 50125c0319
2 changed files with 51 additions and 51 deletions

View File

@ -3,8 +3,8 @@ import Cocoa
// Custom NSToolbar subclass that displays a centered window title,
// in order to accommodate the titlebar tabs feature.
class TerminalToolbar: NSToolbar, NSToolbarDelegate {
static private let identifier = NSToolbarItem.Identifier("TitleText")
private let titleTextField = NSTextField(labelWithString: "👻 Ghostty")
static private let identifier = NSToolbarItem.Identifier("TitleText")
private let titleTextField = NSTextField(labelWithString: "👻 Ghostty")
var titleText: String {
get {
@ -16,34 +16,34 @@ class TerminalToolbar: NSToolbar, NSToolbarDelegate {
}
}
override init(identifier: NSToolbar.Identifier) {
super.init(identifier: identifier)
override init(identifier: NSToolbar.Identifier) {
super.init(identifier: identifier)
delegate = self
delegate = self
if #available(macOS 13.0, *) {
centeredItemIdentifiers.insert(Self.identifier)
} else {
centeredItemIdentifier = Self.identifier
}
}
if #available(macOS 13.0, *) {
centeredItemIdentifiers.insert(Self.identifier)
} else {
centeredItemIdentifier = Self.identifier
}
}
func toolbar(_ toolbar: NSToolbar,
func toolbar(_ toolbar: NSToolbar,
itemForItemIdentifier itemIdentifier: NSToolbarItem.Identifier,
willBeInsertedIntoToolbar flag: Bool) -> NSToolbarItem? {
guard itemIdentifier == Self.identifier else { return nil }
guard itemIdentifier == Self.identifier else { return nil }
let toolbarItem = NSToolbarItem(itemIdentifier: itemIdentifier)
toolbarItem.isEnabled = true
toolbarItem.view = self.titleTextField
return toolbarItem
}
let toolbarItem = NSToolbarItem(itemIdentifier: itemIdentifier)
toolbarItem.isEnabled = true
toolbarItem.view = self.titleTextField
return toolbarItem
}
func toolbarAllowedItemIdentifiers(_ toolbar: NSToolbar) -> [NSToolbarItem.Identifier] {
return [Self.identifier]
}
func toolbarAllowedItemIdentifiers(_ toolbar: NSToolbar) -> [NSToolbarItem.Identifier] {
return [Self.identifier]
}
func toolbarDefaultItemIdentifiers(_ toolbar: NSToolbar) -> [NSToolbarItem.Identifier] {
return [Self.identifier]
}
func toolbarDefaultItemIdentifiers(_ toolbar: NSToolbar) -> [NSToolbarItem.Identifier] {
return [Self.identifier]
}
}

View File

@ -198,25 +198,25 @@ extension Ghostty {
return v
}
var macosTitlebarTabs: Bool {
guard let config = self.config else { return false }
var v = false;
let key = "macos-titlebar-tabs"
_ = ghostty_config_get(config, &v, key, UInt(key.count))
return v
}
var macosTitlebarTabs: Bool {
guard let config = self.config else { return false }
var v = false;
let key = "macos-titlebar-tabs"
_ = ghostty_config_get(config, &v, key, UInt(key.count))
return v
}
var backgroundColor: Color {
var rgb: UInt32 = 0
let bg_key = "background"
if (!ghostty_config_get(config, &rgb, bg_key, UInt(bg_key.count))) {
#if os(macOS)
#if os(macOS)
return Color(NSColor.windowBackgroundColor)
#elseif os(iOS)
#elseif os(iOS)
return Color(UIColor.systemBackground)
#else
#error("unsupported")
#endif
#else
#error("unsupported")
#endif
}
let red = Double(rgb & 0xff)