diff --git a/macos/Sources/Features/Terminal/TerminalController.swift b/macos/Sources/Features/Terminal/TerminalController.swift index 95bb035cb..482946f69 100644 --- a/macos/Sources/Features/Terminal/TerminalController.swift +++ b/macos/Sources/Features/Terminal/TerminalController.swift @@ -9,14 +9,18 @@ class TerminalController: NSWindowController, NSWindowDelegate, TerminalViewDele /// The app instance that this terminal view will represent. let ghostty: Ghostty.AppState + /// The base configuration for the new window + let baseConfig: Ghostty.SurfaceConfiguration? + /// The currently focused surface. var focusedSurface: Ghostty.SurfaceView? = nil /// Fullscreen state management. private let fullscreenHandler = FullScreenHandler() - init(_ ghostty: Ghostty.AppState) { + init(_ ghostty: Ghostty.AppState, withBaseConfig base: Ghostty.SurfaceConfiguration? = nil) { self.ghostty = ghostty + self.baseConfig = base super.init(window: nil) let center = NotificationCenter.default @@ -64,7 +68,8 @@ class TerminalController: NSWindowController, NSWindowDelegate, TerminalViewDele // Initialize our content view to the SwiftUI root window.contentView = NSHostingView(rootView: TerminalView( ghostty: self.ghostty, - delegate: self + delegate: self, + baseConfig: baseConfig )) } diff --git a/macos/Sources/Features/Terminal/TerminalManager.swift b/macos/Sources/Features/Terminal/TerminalManager.swift index 77b7677eb..0613abcb9 100644 --- a/macos/Sources/Features/Terminal/TerminalManager.swift +++ b/macos/Sources/Features/Terminal/TerminalManager.swift @@ -89,9 +89,9 @@ class TerminalManager { } /// Creates a window controller, adds it to our managed list, and returns it. - private func createWindow(withBaseConfig: Ghostty.SurfaceConfiguration?) -> TerminalController { + private func createWindow(withBaseConfig base: Ghostty.SurfaceConfiguration?) -> TerminalController { // Initialize our controller to load the window - let c = TerminalController(ghostty) + let c = TerminalController(ghostty, withBaseConfig: base) // Create a listener for when the window is closed so we can remove it. let pubClose = NotificationCenter.default.publisher( diff --git a/macos/Sources/Features/Terminal/TerminalView.swift b/macos/Sources/Features/Terminal/TerminalView.swift index 727a99a83..576e394af 100644 --- a/macos/Sources/Features/Terminal/TerminalView.swift +++ b/macos/Sources/Features/Terminal/TerminalView.swift @@ -28,6 +28,9 @@ struct TerminalView: View { // An optional delegate to receive information about terminal changes. weak var delegate: TerminalViewDelegate? = nil + // If this is set, this is the base configuration that we build our surface out of. + let baseConfig: Ghostty.SurfaceConfiguration? + // This seems like a crutch after switching from SwiftUI to AppKit lifecycle. @FocusState private var focused: Bool @@ -70,7 +73,7 @@ struct TerminalView: View { DebugBuildWarningView() } - Ghostty.TerminalSplit(onClose: onClose, baseConfig: nil) + Ghostty.TerminalSplit(onClose: onClose, baseConfig: baseConfig) .ghosttyApp(ghostty.app!) .ghosttyConfig(ghostty.config!) .focused($focused)