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

View File

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