mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-06-04 02:44:50 +00:00
macos: swiftlint 'implicit_optional_initialization' rule
This commit is contained in:
@@ -17,7 +17,6 @@ disabled_rules:
|
||||
- for_where
|
||||
- force_cast
|
||||
- implicit_getter
|
||||
- implicit_optional_initialization
|
||||
- legacy_constant
|
||||
- legacy_constructor
|
||||
- line_length
|
||||
|
||||
@@ -144,16 +144,16 @@ class AppDelegate: NSObject,
|
||||
}
|
||||
|
||||
/// Tracks the windows that we hid for toggleVisibility.
|
||||
private(set) var hiddenState: ToggleVisibilityState? = nil
|
||||
private(set) var hiddenState: ToggleVisibilityState?
|
||||
|
||||
/// The observer for the app appearance.
|
||||
private var appearanceObserver: NSKeyValueObservation? = nil
|
||||
private var appearanceObserver: NSKeyValueObservation?
|
||||
|
||||
/// Signals
|
||||
private var signals: [DispatchSourceSignal] = []
|
||||
|
||||
/// The custom app icon image that is currently in use.
|
||||
@Published private(set) var appIcon: NSImage? = nil
|
||||
@Published private(set) var appIcon: NSImage?
|
||||
|
||||
override init() {
|
||||
#if DEBUG
|
||||
|
||||
@@ -13,7 +13,7 @@ class ClipboardConfirmationController: NSWindowController {
|
||||
let contents: String
|
||||
let request: Ghostty.ClipboardRequest
|
||||
let state: UnsafeMutableRawPointer?
|
||||
weak private var delegate: ClipboardConfirmationViewDelegate? = nil
|
||||
weak private var delegate: ClipboardConfirmationViewDelegate?
|
||||
|
||||
init(surface: ghostty_surface_t, contents: String, request: Ghostty.ClipboardRequest, state: UnsafeMutableRawPointer?, delegate: ClipboardConfirmationViewDelegate) {
|
||||
self.surface = surface
|
||||
|
||||
@@ -32,7 +32,7 @@ struct ClipboardConfirmationView: View {
|
||||
let request: Ghostty.ClipboardRequest
|
||||
|
||||
/// Optional delegate to get results. If this is nil, then this view will never close on its own.
|
||||
weak var delegate: ClipboardConfirmationViewDelegate? = nil
|
||||
weak var delegate: ClipboardConfirmationViewDelegate?
|
||||
|
||||
/// Used to track if we should rehide on disappear
|
||||
@State private var cursorHiddenCount: UInt = 0
|
||||
|
||||
@@ -231,7 +231,7 @@ struct CommandPaletteView: View {
|
||||
/// The text field for building the query for the command palette.
|
||||
fileprivate struct CommandPaletteQuery: View {
|
||||
@Binding var query: String
|
||||
var onEvent: ((KeyboardEvent) -> Void)? = nil
|
||||
var onEvent: ((KeyboardEvent) -> Void)?
|
||||
@FocusState private var isTextFieldFocused: Bool
|
||||
|
||||
init(query: Binding<String>, isTextFieldFocused: FocusState<Bool>, onEvent: ((KeyboardEvent) -> Void)? = nil) {
|
||||
|
||||
@@ -16,11 +16,11 @@ class GlobalEventTap {
|
||||
|
||||
// The event tap used for global event listening. This is non-nil if it is
|
||||
// created.
|
||||
private var eventTap: CFMachPort? = nil
|
||||
private var eventTap: CFMachPort?
|
||||
|
||||
// This is the timer used to retry enabling the global event tap if we
|
||||
// don't have permissions.
|
||||
private var enableTimer: Timer? = nil
|
||||
private var enableTimer: Timer?
|
||||
|
||||
// Private init so it can't be constructed outside of our singleton
|
||||
private init() {}
|
||||
|
||||
@@ -16,16 +16,16 @@ class QuickTerminalController: BaseTerminalController {
|
||||
/// The previously running application when the terminal is shown. This is NEVER Ghostty.
|
||||
/// If this is set then when the quick terminal is animated out then we will restore this
|
||||
/// application to the front.
|
||||
private var previousApp: NSRunningApplication? = nil
|
||||
private var previousApp: NSRunningApplication?
|
||||
|
||||
// The active space when the quick terminal was last shown.
|
||||
private var previousActiveSpace: CGSSpace? = nil
|
||||
private var previousActiveSpace: CGSSpace?
|
||||
|
||||
/// Cache for per-screen window state.
|
||||
let screenStateCache: QuickTerminalScreenStateCache
|
||||
|
||||
/// Non-nil if we have hidden dock state.
|
||||
private var hiddenDock: HiddenDock? = nil
|
||||
private var hiddenDock: HiddenDock?
|
||||
|
||||
/// The configuration derived from the Ghostty config so we don't need to rely on references.
|
||||
private var derivedConfig: DerivedConfig
|
||||
|
||||
@@ -32,7 +32,7 @@ class QuickTerminalWindow: NSPanel {
|
||||
|
||||
/// This is set to the frame prior to setting `contentView`. This is purely a hack to workaround
|
||||
/// bugs in older macOS versions (Ventura): https://github.com/ghostty-org/ghostty/pull/8026
|
||||
var initialFrame: NSRect? = nil
|
||||
var initialFrame: NSRect?
|
||||
|
||||
override func setFrame(_ frameRect: NSRect, display flag: Bool) {
|
||||
// Upon first adding this Window to its host view, older SwiftUI
|
||||
|
||||
@@ -37,7 +37,7 @@ class BaseTerminalController: NSWindowController,
|
||||
let ghostty: Ghostty.App
|
||||
|
||||
/// The currently focused surface.
|
||||
var focusedSurface: Ghostty.SurfaceView? = nil {
|
||||
var focusedSurface: Ghostty.SurfaceView? {
|
||||
didSet { syncFocusToSurfaceTree() }
|
||||
}
|
||||
|
||||
@@ -58,19 +58,19 @@ class BaseTerminalController: NSWindowController,
|
||||
}
|
||||
|
||||
/// Non-nil when an alert is active so we don't overlap multiple.
|
||||
private var alert: NSAlert? = nil
|
||||
private var alert: NSAlert?
|
||||
|
||||
/// The clipboard confirmation window, if shown.
|
||||
private var clipboardConfirmation: ClipboardConfirmationController? = nil
|
||||
private var clipboardConfirmation: ClipboardConfirmationController?
|
||||
|
||||
/// Fullscreen state management.
|
||||
private(set) var fullscreenStyle: FullscreenStyle?
|
||||
|
||||
/// Event monitor (see individual events for why)
|
||||
private var eventMonitor: Any? = nil
|
||||
private var eventMonitor: Any?
|
||||
|
||||
/// The previous frame information from the window
|
||||
private var savedFrame: SavedFrame? = nil
|
||||
private var savedFrame: SavedFrame?
|
||||
|
||||
/// Cache previously applied appearance to avoid unnecessary updates
|
||||
private var appliedColorScheme: ghostty_color_scheme_e?
|
||||
@@ -86,7 +86,7 @@ class BaseTerminalController: NSWindowController,
|
||||
|
||||
/// An override title for the tab/window set by the user via prompt_tab_title.
|
||||
/// When set, this takes precedence over the computed title from the terminal.
|
||||
var titleOverride: String? = nil {
|
||||
var titleOverride: String? {
|
||||
didSet { applyTitleToWindow() }
|
||||
}
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ class TerminalController: BaseTerminalController, TabGroupCloseCoordinator.Contr
|
||||
private var surfaceAppearanceCancellables: Set<AnyCancellable> = []
|
||||
|
||||
/// This will be set to the initial frame of the window from the xib on load.
|
||||
private var initialFrame: NSRect? = nil
|
||||
private var initialFrame: NSRect?
|
||||
|
||||
init(_ ghostty: Ghostty.App,
|
||||
withBaseConfig base: Ghostty.SurfaceConfiguration? = nil,
|
||||
@@ -210,7 +210,7 @@ class TerminalController: BaseTerminalController, TabGroupCloseCoordinator.Contr
|
||||
// to find the preferred window to attach new tabs, perform actions, etc. We
|
||||
// always prefer the main window but if there isn't any (because we're triggered
|
||||
// by something like an App Intent) then we prefer the most previous main.
|
||||
static private(set) weak var lastMain: TerminalController? = nil
|
||||
static private(set) weak var lastMain: TerminalController?
|
||||
|
||||
/// The "new window" action.
|
||||
static func newWindow(
|
||||
|
||||
@@ -45,7 +45,7 @@ struct TerminalView<ViewModel: TerminalViewModel>: View {
|
||||
@ObservedObject var viewModel: ViewModel
|
||||
|
||||
// An optional delegate to receive information about terminal changes.
|
||||
weak var delegate: (any TerminalViewDelegate)? = nil
|
||||
weak var delegate: (any TerminalViewDelegate)?
|
||||
|
||||
// The most recently focused surface, equal to focusedSurface when
|
||||
// it is non-nil.
|
||||
|
||||
@@ -35,7 +35,7 @@ class TerminalWindow: NSWindow {
|
||||
private(set) var derivedConfig: DerivedConfig = .init()
|
||||
|
||||
/// Sets up our tab context menu
|
||||
private var tabMenuObserver: NSObjectProtocol? = nil
|
||||
private var tabMenuObserver: NSObjectProtocol?
|
||||
|
||||
/// Whether this window supports the update accessory. If this is false, then views within this
|
||||
/// window should determine how to show update notifications.
|
||||
@@ -295,7 +295,7 @@ class TerminalWindow: NSWindow {
|
||||
|
||||
// MARK: Tab Key Equivalents
|
||||
|
||||
var keyEquivalent: String? = nil {
|
||||
var keyEquivalent: String? {
|
||||
didSet {
|
||||
// When our key equivalent is set, we must update the tab label.
|
||||
guard let keyEquivalent else {
|
||||
|
||||
@@ -172,7 +172,7 @@ class TitlebarTabsVenturaTerminalWindow: TerminalWindow {
|
||||
backgroundColor.luminance < 0.05
|
||||
}
|
||||
|
||||
private var newTabButtonImageLayer: VibrantLayer? = nil
|
||||
private var newTabButtonImageLayer: VibrantLayer?
|
||||
|
||||
func updateTabBar() {
|
||||
newTabButtonImageLayer = nil
|
||||
@@ -286,9 +286,9 @@ class TitlebarTabsVenturaTerminalWindow: TerminalWindow {
|
||||
|
||||
// MARK: - Titlebar Tabs
|
||||
|
||||
private var windowButtonsBackdrop: WindowButtonsBackdropView? = nil
|
||||
private var windowButtonsBackdrop: WindowButtonsBackdropView?
|
||||
|
||||
private var windowDragHandle: WindowDragView? = nil
|
||||
private var windowDragHandle: WindowDragView?
|
||||
|
||||
// Used by the window controller to enable/disable titlebar tabs.
|
||||
var titlebarTabs = false {
|
||||
|
||||
@@ -33,7 +33,7 @@ extension Ghostty {
|
||||
private var configPath: String?
|
||||
/// The ghostty app instance. We only have one of these for the entire app, although I guess
|
||||
/// in theory you can have multiple... I don't know why you would...
|
||||
@Published var app: ghostty_app_t? = nil {
|
||||
@Published var app: ghostty_app_t? {
|
||||
didSet {
|
||||
guard let old = oldValue else { return }
|
||||
ghostty_app_free(old)
|
||||
|
||||
@@ -7,7 +7,7 @@ extension Ghostty {
|
||||
// The underlying C pointer to the Ghostty config structure. This
|
||||
// should never be accessed directly. Any operations on this should
|
||||
// be called from the functions on this or another class.
|
||||
private(set) var config: ghostty_config_t? = nil {
|
||||
private(set) var config: ghostty_config_t? {
|
||||
didSet {
|
||||
// Free the old value whenever we change
|
||||
guard let old = oldValue else { return }
|
||||
@@ -160,7 +160,7 @@ extension Ghostty {
|
||||
|
||||
var title: String? {
|
||||
guard let config = self.config else { return nil }
|
||||
var v: UnsafePointer<Int8>? = nil
|
||||
var v: UnsafePointer<Int8>?
|
||||
let key = "title"
|
||||
guard ghostty_config_get(config, &v, key, UInt(key.lengthOfBytes(using: .utf8))) else { return nil }
|
||||
guard let ptr = v else { return nil }
|
||||
@@ -169,7 +169,7 @@ extension Ghostty {
|
||||
|
||||
var windowSaveState: String {
|
||||
guard let config = self.config else { return "" }
|
||||
var v: UnsafePointer<Int8>? = nil
|
||||
var v: UnsafePointer<Int8>?
|
||||
let key = "window-save-state"
|
||||
guard ghostty_config_get(config, &v, key, UInt(key.lengthOfBytes(using: .utf8))) else { return "" }
|
||||
guard let ptr = v else { return "" }
|
||||
@@ -192,7 +192,7 @@ extension Ghostty {
|
||||
|
||||
var windowNewTabPosition: String {
|
||||
guard let config = self.config else { return "" }
|
||||
var v: UnsafePointer<Int8>? = nil
|
||||
var v: UnsafePointer<Int8>?
|
||||
let key = "window-new-tab-position"
|
||||
guard ghostty_config_get(config, &v, key, UInt(key.lengthOfBytes(using: .utf8))) else { return "" }
|
||||
guard let ptr = v else { return "" }
|
||||
@@ -202,7 +202,7 @@ extension Ghostty {
|
||||
var windowDecorations: Bool {
|
||||
let defaultValue = true
|
||||
guard let config = self.config else { return defaultValue }
|
||||
var v: UnsafePointer<Int8>? = nil
|
||||
var v: UnsafePointer<Int8>?
|
||||
let key = "window-decoration"
|
||||
guard ghostty_config_get(config, &v, key, UInt(key.lengthOfBytes(using: .utf8))) else { return defaultValue }
|
||||
guard let ptr = v else { return defaultValue }
|
||||
@@ -212,7 +212,7 @@ extension Ghostty {
|
||||
|
||||
var windowTheme: String? {
|
||||
guard let config = self.config else { return nil }
|
||||
var v: UnsafePointer<Int8>? = nil
|
||||
var v: UnsafePointer<Int8>?
|
||||
let key = "window-theme"
|
||||
guard ghostty_config_get(config, &v, key, UInt(key.lengthOfBytes(using: .utf8))) else { return nil }
|
||||
guard let ptr = v else { return nil }
|
||||
@@ -233,7 +233,7 @@ extension Ghostty {
|
||||
#if canImport(AppKit)
|
||||
var windowFullscreen: FullscreenMode? {
|
||||
guard let config = self.config else { return nil }
|
||||
var v: UnsafePointer<Int8>? = nil
|
||||
var v: UnsafePointer<Int8>?
|
||||
let key = "fullscreen"
|
||||
guard ghostty_config_get(config, &v, key, UInt(key.lengthOfBytes(using: .utf8))) else { return nil }
|
||||
guard let ptr = v else { return nil }
|
||||
@@ -256,7 +256,7 @@ extension Ghostty {
|
||||
#else
|
||||
var windowFullscreen: Bool {
|
||||
guard let config = self.config else { return false }
|
||||
var v: UnsafePointer<Int8>? = nil
|
||||
var v: UnsafePointer<Int8>?
|
||||
let key = "fullscreen"
|
||||
guard ghostty_config_get(config, &v, key, UInt(key.lengthOfBytes(using: .utf8))) else { return false }
|
||||
guard let ptr = v else { return false }
|
||||
@@ -271,7 +271,7 @@ extension Ghostty {
|
||||
var windowFullscreenMode: FullscreenMode {
|
||||
let defaultValue: FullscreenMode = .native
|
||||
guard let config = self.config else { return defaultValue }
|
||||
var v: UnsafePointer<Int8>? = nil
|
||||
var v: UnsafePointer<Int8>?
|
||||
let key = "macos-non-native-fullscreen"
|
||||
guard ghostty_config_get(config, &v, key, UInt(key.lengthOfBytes(using: .utf8))) else { return defaultValue }
|
||||
guard let ptr = v else { return defaultValue }
|
||||
@@ -293,7 +293,7 @@ extension Ghostty {
|
||||
|
||||
var windowTitleFontFamily: String? {
|
||||
guard let config = self.config else { return nil }
|
||||
var v: UnsafePointer<Int8>? = nil
|
||||
var v: UnsafePointer<Int8>?
|
||||
let key = "window-title-font-family"
|
||||
guard ghostty_config_get(config, &v, key, UInt(key.lengthOfBytes(using: .utf8))) else { return nil }
|
||||
guard let ptr = v else { return nil }
|
||||
@@ -303,7 +303,7 @@ extension Ghostty {
|
||||
var macosWindowButtons: MacOSWindowButtons {
|
||||
let defaultValue = MacOSWindowButtons.visible
|
||||
guard let config = self.config else { return defaultValue }
|
||||
var v: UnsafePointer<Int8>? = nil
|
||||
var v: UnsafePointer<Int8>?
|
||||
let key = "macos-window-buttons"
|
||||
guard ghostty_config_get(config, &v, key, UInt(key.lengthOfBytes(using: .utf8))) else { return defaultValue }
|
||||
guard let ptr = v else { return defaultValue }
|
||||
@@ -314,7 +314,7 @@ extension Ghostty {
|
||||
var macosTitlebarStyle: String {
|
||||
let defaultValue = "transparent"
|
||||
guard let config = self.config else { return defaultValue }
|
||||
var v: UnsafePointer<Int8>? = nil
|
||||
var v: UnsafePointer<Int8>?
|
||||
let key = "macos-titlebar-style"
|
||||
guard ghostty_config_get(config, &v, key, UInt(key.lengthOfBytes(using: .utf8))) else { return defaultValue }
|
||||
guard let ptr = v else { return defaultValue }
|
||||
@@ -324,7 +324,7 @@ extension Ghostty {
|
||||
var macosTitlebarProxyIcon: MacOSTitlebarProxyIcon {
|
||||
let defaultValue = MacOSTitlebarProxyIcon.visible
|
||||
guard let config = self.config else { return defaultValue }
|
||||
var v: UnsafePointer<Int8>? = nil
|
||||
var v: UnsafePointer<Int8>?
|
||||
let key = "macos-titlebar-proxy-icon"
|
||||
guard ghostty_config_get(config, &v, key, UInt(key.lengthOfBytes(using: .utf8))) else { return defaultValue }
|
||||
guard let ptr = v else { return defaultValue }
|
||||
@@ -335,7 +335,7 @@ extension Ghostty {
|
||||
var macosDockDropBehavior: MacDockDropBehavior {
|
||||
let defaultValue = MacDockDropBehavior.new_tab
|
||||
guard let config = self.config else { return defaultValue }
|
||||
var v: UnsafePointer<Int8>? = nil
|
||||
var v: UnsafePointer<Int8>?
|
||||
let key = "macos-dock-drop-behavior"
|
||||
guard ghostty_config_get(config, &v, key, UInt(key.lengthOfBytes(using: .utf8))) else { return defaultValue }
|
||||
guard let ptr = v else { return defaultValue }
|
||||
@@ -354,7 +354,7 @@ extension Ghostty {
|
||||
var macosIcon: MacOSIcon {
|
||||
let defaultValue = MacOSIcon.official
|
||||
guard let config = self.config else { return defaultValue }
|
||||
var v: UnsafePointer<Int8>? = nil
|
||||
var v: UnsafePointer<Int8>?
|
||||
let key = "macos-icon"
|
||||
guard ghostty_config_get(config, &v, key, UInt(key.lengthOfBytes(using: .utf8))) else { return defaultValue }
|
||||
guard let ptr = v else { return defaultValue }
|
||||
@@ -366,7 +366,7 @@ extension Ghostty {
|
||||
#if os(macOS)
|
||||
let defaultValue = NSString("~/.config/ghostty/Ghostty.icns").expandingTildeInPath
|
||||
guard let config = self.config else { return defaultValue }
|
||||
var v: UnsafePointer<Int8>? = nil
|
||||
var v: UnsafePointer<Int8>?
|
||||
let key = "macos-custom-icon"
|
||||
guard ghostty_config_get(config, &v, key, UInt(key.lengthOfBytes(using: .utf8))) else { return defaultValue }
|
||||
guard let ptr = v else { return defaultValue }
|
||||
@@ -380,7 +380,7 @@ extension Ghostty {
|
||||
var macosIconFrame: MacOSIconFrame {
|
||||
let defaultValue = MacOSIconFrame.aluminum
|
||||
guard let config = self.config else { return defaultValue }
|
||||
var v: UnsafePointer<Int8>? = nil
|
||||
var v: UnsafePointer<Int8>?
|
||||
let key = "macos-icon-frame"
|
||||
guard ghostty_config_get(config, &v, key, UInt(key.lengthOfBytes(using: .utf8))) else { return defaultValue }
|
||||
guard let ptr = v else { return defaultValue }
|
||||
@@ -408,7 +408,7 @@ extension Ghostty {
|
||||
|
||||
var macosHidden: MacHidden {
|
||||
guard let config = self.config else { return .never }
|
||||
var v: UnsafePointer<Int8>? = nil
|
||||
var v: UnsafePointer<Int8>?
|
||||
let key = "macos-hidden"
|
||||
guard ghostty_config_get(config, &v, key, UInt(key.lengthOfBytes(using: .utf8))) else { return .never }
|
||||
guard let ptr = v else { return .never }
|
||||
@@ -508,7 +508,7 @@ extension Ghostty {
|
||||
#if canImport(AppKit)
|
||||
var quickTerminalPosition: QuickTerminalPosition {
|
||||
guard let config = self.config else { return .top }
|
||||
var v: UnsafePointer<Int8>? = nil
|
||||
var v: UnsafePointer<Int8>?
|
||||
let key = "quick-terminal-position"
|
||||
guard ghostty_config_get(config, &v, key, UInt(key.lengthOfBytes(using: .utf8))) else { return .top }
|
||||
guard let ptr = v else { return .top }
|
||||
@@ -518,7 +518,7 @@ extension Ghostty {
|
||||
|
||||
var quickTerminalScreen: QuickTerminalScreen {
|
||||
guard let config = self.config else { return .main }
|
||||
var v: UnsafePointer<Int8>? = nil
|
||||
var v: UnsafePointer<Int8>?
|
||||
let key = "quick-terminal-screen"
|
||||
guard ghostty_config_get(config, &v, key, UInt(key.lengthOfBytes(using: .utf8))) else { return .main }
|
||||
guard let ptr = v else { return .main }
|
||||
@@ -544,7 +544,7 @@ extension Ghostty {
|
||||
|
||||
var quickTerminalSpaceBehavior: QuickTerminalSpaceBehavior {
|
||||
guard let config = self.config else { return .move }
|
||||
var v: UnsafePointer<Int8>? = nil
|
||||
var v: UnsafePointer<Int8>?
|
||||
let key = "quick-terminal-space-behavior"
|
||||
guard ghostty_config_get(config, &v, key, UInt(key.lengthOfBytes(using: .utf8))) else { return .move }
|
||||
guard let ptr = v else { return .move }
|
||||
@@ -563,7 +563,7 @@ extension Ghostty {
|
||||
|
||||
var resizeOverlay: ResizeOverlay {
|
||||
guard let config = self.config else { return .after_first }
|
||||
var v: UnsafePointer<Int8>? = nil
|
||||
var v: UnsafePointer<Int8>?
|
||||
let key = "resize-overlay"
|
||||
guard ghostty_config_get(config, &v, key, UInt(key.lengthOfBytes(using: .utf8))) else { return .after_first }
|
||||
guard let ptr = v else { return .after_first }
|
||||
@@ -574,7 +574,7 @@ extension Ghostty {
|
||||
var resizeOverlayPosition: ResizeOverlayPosition {
|
||||
let defaultValue = ResizeOverlayPosition.center
|
||||
guard let config = self.config else { return defaultValue }
|
||||
var v: UnsafePointer<Int8>? = nil
|
||||
var v: UnsafePointer<Int8>?
|
||||
let key = "resize-overlay-position"
|
||||
guard ghostty_config_get(config, &v, key, UInt(key.lengthOfBytes(using: .utf8))) else { return defaultValue }
|
||||
guard let ptr = v else { return defaultValue }
|
||||
@@ -600,7 +600,7 @@ extension Ghostty {
|
||||
|
||||
var autoUpdate: AutoUpdate? {
|
||||
guard let config = self.config else { return nil }
|
||||
var v: UnsafePointer<Int8>? = nil
|
||||
var v: UnsafePointer<Int8>?
|
||||
let key = "auto-update"
|
||||
guard ghostty_config_get(config, &v, key, UInt(key.lengthOfBytes(using: .utf8))) else { return nil }
|
||||
guard let ptr = v else { return nil }
|
||||
@@ -611,7 +611,7 @@ extension Ghostty {
|
||||
var autoUpdateChannel: AutoUpdateChannel {
|
||||
let defaultValue = AutoUpdateChannel.stable
|
||||
guard let config = self.config else { return defaultValue }
|
||||
var v: UnsafePointer<Int8>? = nil
|
||||
var v: UnsafePointer<Int8>?
|
||||
let key = "auto-update-channel"
|
||||
guard ghostty_config_get(config, &v, key, UInt(key.lengthOfBytes(using: .utf8))) else { return defaultValue }
|
||||
guard let ptr = v else { return defaultValue }
|
||||
@@ -646,7 +646,7 @@ extension Ghostty {
|
||||
var macosShortcuts: MacShortcuts {
|
||||
let defaultValue = MacShortcuts.ask
|
||||
guard let config = self.config else { return defaultValue }
|
||||
var v: UnsafePointer<Int8>? = nil
|
||||
var v: UnsafePointer<Int8>?
|
||||
let key = "macos-shortcuts"
|
||||
guard ghostty_config_get(config, &v, key, UInt(key.lengthOfBytes(using: .utf8))) else { return defaultValue }
|
||||
guard let ptr = v else { return defaultValue }
|
||||
@@ -657,7 +657,7 @@ extension Ghostty {
|
||||
var scrollbar: Scrollbar {
|
||||
let defaultValue = Scrollbar.system
|
||||
guard let config = self.config else { return defaultValue }
|
||||
var v: UnsafePointer<Int8>? = nil
|
||||
var v: UnsafePointer<Int8>?
|
||||
let key = "scrollbar"
|
||||
guard ghostty_config_get(config, &v, key, UInt(key.lengthOfBytes(using: .utf8))) else { return defaultValue }
|
||||
guard let ptr = v else { return defaultValue }
|
||||
|
||||
@@ -94,7 +94,7 @@ extension Ghostty {
|
||||
class InspectorView: MTKView, NSTextInputClient {
|
||||
let commandQueue: MTLCommandQueue
|
||||
|
||||
var surfaceView: SurfaceView? = nil {
|
||||
var surfaceView: SurfaceView? {
|
||||
didSet { surfaceViewDidChange() }
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ extension Ghostty {
|
||||
/// A preference key that propagates the ID of the SurfaceView currently being dragged,
|
||||
/// or nil if no surface is being dragged.
|
||||
struct DraggingSurfaceKey: PreferenceKey {
|
||||
static var defaultValue: SurfaceView.ID? = nil
|
||||
static var defaultValue: SurfaceView.ID?
|
||||
|
||||
static func reduce(value: inout SurfaceView.ID?, nextValue: () -> SurfaceView.ID?) {
|
||||
value = nextValue() ?? value
|
||||
|
||||
@@ -300,7 +300,7 @@ extension Ghostty {
|
||||
|
||||
// This is the last size that we processed. This is how we handle our
|
||||
// timer state.
|
||||
@State var lastSize: CGSize? = nil
|
||||
@State var lastSize: CGSize?
|
||||
|
||||
// Ready is set to true after a short delay. This avoids some of the
|
||||
// challenges of initial view sizing from SwiftUI.
|
||||
@@ -640,19 +640,19 @@ extension Ghostty {
|
||||
/// libghostty, usually from the Ghostty configuration.
|
||||
struct SurfaceConfiguration {
|
||||
/// Explicit font size to use in points
|
||||
var fontSize: Float32? = nil
|
||||
var fontSize: Float32?
|
||||
|
||||
/// Explicit working directory to set
|
||||
var workingDirectory: String? = nil
|
||||
var workingDirectory: String?
|
||||
|
||||
/// Explicit command to set
|
||||
var command: String? = nil
|
||||
var command: String?
|
||||
|
||||
/// Environment variables to set for the terminal
|
||||
var environmentVariables: [String: String] = [:]
|
||||
|
||||
/// Extra input to send as stdin
|
||||
var initialInput: String? = nil
|
||||
var initialInput: String?
|
||||
|
||||
/// Wait after the command
|
||||
var waitAfterCommand: Bool = false
|
||||
@@ -1252,8 +1252,8 @@ extension FocusedValues {
|
||||
extension Ghostty.SurfaceView {
|
||||
class SearchState: ObservableObject {
|
||||
@Published var needle: String = ""
|
||||
@Published var selected: UInt? = nil
|
||||
@Published var total: UInt? = nil
|
||||
@Published var selected: UInt?
|
||||
@Published var total: UInt?
|
||||
|
||||
init(from startSearch: Ghostty.Action.StartSearch) {
|
||||
self.needle = startSearch.needle ?? ""
|
||||
|
||||
@@ -27,7 +27,7 @@ extension Ghostty {
|
||||
|
||||
// The current pwd of the surface as defined by the pty. This can be
|
||||
// changed with escape codes.
|
||||
@Published var pwd: String? = nil
|
||||
@Published var pwd: String?
|
||||
|
||||
// The cell size of this surface. This is set by the core when the
|
||||
// surface is first created and any time the cell size changes (i.e.
|
||||
@@ -40,13 +40,13 @@ extension Ghostty {
|
||||
@Published var healthy: Bool = true
|
||||
|
||||
// Any error while initializing the surface.
|
||||
@Published var error: Error? = nil
|
||||
@Published var error: Error?
|
||||
|
||||
// The hovered URL string
|
||||
@Published var hoverUrl: String? = nil
|
||||
@Published var hoverUrl: String?
|
||||
|
||||
// The progress report (if any)
|
||||
@Published var progressReport: Action.ProgressReport? = nil {
|
||||
@Published var progressReport: Action.ProgressReport? {
|
||||
didSet {
|
||||
// Cancel any existing timer
|
||||
progressReportTimer?.invalidate()
|
||||
@@ -69,7 +69,7 @@ extension Ghostty {
|
||||
@Published var keyTables: [String] = []
|
||||
|
||||
// The current search state. When non-nil, the search overlay should be shown.
|
||||
@Published var searchState: SearchState? = nil {
|
||||
@Published var searchState: SearchState? {
|
||||
didSet {
|
||||
if let searchState {
|
||||
// I'm not a Combine expert so if there is a better way to do this I'm
|
||||
@@ -107,11 +107,11 @@ extension Ghostty {
|
||||
|
||||
// The time this surface last became focused. This is a ContinuousClock.Instant
|
||||
// on supported platforms.
|
||||
@Published var focusInstant: ContinuousClock.Instant? = nil
|
||||
@Published var focusInstant: ContinuousClock.Instant?
|
||||
|
||||
// Returns sizing information for the surface. This is the raw C
|
||||
// structure because I'm lazy.
|
||||
@Published var surfaceSize: ghostty_surface_size_s? = nil
|
||||
@Published var surfaceSize: ghostty_surface_size_s?
|
||||
|
||||
// Whether the pointer should be visible or not
|
||||
@Published private(set) var pointerStyle: CursorStyle = .horizontalText
|
||||
@@ -121,7 +121,7 @@ extension Ghostty {
|
||||
|
||||
/// The background color within the color palette of the surface. This is only set if it is
|
||||
/// dynamically updated. Otherwise, the background color is the default background color.
|
||||
@Published private(set) var backgroundColor: Color? = nil
|
||||
@Published private(set) var backgroundColor: Color?
|
||||
|
||||
/// True when the bell is active. This is set inactive on focus or event.
|
||||
@Published private(set) var bell: Bool = false
|
||||
@@ -134,7 +134,7 @@ extension Ghostty {
|
||||
|
||||
// An initial size to request for a window. This will only affect
|
||||
// then the view is moved to a new window.
|
||||
var initialSize: NSSize? = nil
|
||||
var initialSize: NSSize?
|
||||
|
||||
// A content size received through sizeDidChange that may in some cases
|
||||
// be different from the frame size.
|
||||
@@ -210,10 +210,10 @@ extension Ghostty {
|
||||
private var markedText: NSMutableAttributedString
|
||||
private(set) var focused: Bool = true
|
||||
private var prevPressureStage: Int = 0
|
||||
private var appearanceObserver: NSKeyValueObservation? = nil
|
||||
private var appearanceObserver: NSKeyValueObservation?
|
||||
|
||||
// This is set to non-null during keyDown to accumulate insertText contents
|
||||
private var keyTextAccumulator: [String]? = nil
|
||||
private var keyTextAccumulator: [String]?
|
||||
|
||||
// A small delay that is introduced before a title change to avoid flickers
|
||||
private var titleChangeTimer: Timer?
|
||||
@@ -234,7 +234,7 @@ extension Ghostty {
|
||||
private(set) var cachedVisibleContents: CachedValue<String>
|
||||
|
||||
/// Event monitor (see individual events for why)
|
||||
private var eventMonitor: Any? = nil
|
||||
private var eventMonitor: Any?
|
||||
|
||||
// We need to support being a first responder so that we can get input events
|
||||
override var acceptsFirstResponder: Bool { return true }
|
||||
|
||||
@@ -15,7 +15,7 @@ extension Ghostty {
|
||||
@Published var title: String = "👻"
|
||||
|
||||
// The current pwd of the surface.
|
||||
@Published var pwd: String? = nil
|
||||
@Published var pwd: String?
|
||||
|
||||
// The cell size of this surface. This is set by the core when the
|
||||
// surface is first created and any time the cell size changes (i.e.
|
||||
@@ -28,23 +28,23 @@ extension Ghostty {
|
||||
@Published var healthy: Bool = true
|
||||
|
||||
// Any error while initializing the surface.
|
||||
@Published var error: Error? = nil
|
||||
@Published var error: Error?
|
||||
|
||||
// The hovered URL
|
||||
@Published var hoverUrl: String? = nil
|
||||
@Published var hoverUrl: String?
|
||||
|
||||
// The progress report (if any)
|
||||
@Published var progressReport: Action.ProgressReport? = nil
|
||||
@Published var progressReport: Action.ProgressReport?
|
||||
|
||||
// The time this surface last became focused. This is a ContinuousClock.Instant
|
||||
// on supported platforms.
|
||||
@Published var focusInstant: ContinuousClock.Instant? = nil
|
||||
@Published var focusInstant: ContinuousClock.Instant?
|
||||
|
||||
/// True when the bell is active. This is set inactive on focus or event.
|
||||
@Published var bell: Bool = false
|
||||
|
||||
// The current search state. When non-nil, the search overlay should be shown.
|
||||
@Published var searchState: SearchState? = nil
|
||||
@Published var searchState: SearchState?
|
||||
|
||||
// The currently active key tables. Empty if no tables are active.
|
||||
@Published var keyTables: [String] = []
|
||||
|
||||
Reference in New Issue
Block a user