mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
macos: base config plumbed through
This commit is contained in:
@ -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
|
||||
))
|
||||
}
|
||||
|
||||
|
@ -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(
|
||||
|
@ -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)
|
||||
|
Reference in New Issue
Block a user