mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-09-15 15:58:20 +00:00
macos: assign unique UUID per surface, store in app state
This commit is contained in:
@@ -25,7 +25,7 @@ extension Ghostty {
|
||||
@StateObject private var surfaceView: SurfaceView
|
||||
|
||||
init(_ app: ghostty_app_t, @ViewBuilder content: @escaping ((SurfaceView) -> Content)) {
|
||||
_surfaceView = StateObject(wrappedValue: SurfaceView(app, nil))
|
||||
_surfaceView = StateObject(wrappedValue: SurfaceView(app))
|
||||
self.content = content
|
||||
}
|
||||
|
||||
@@ -259,8 +259,13 @@ extension Ghostty {
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Surface View
|
||||
|
||||
/// The NSView implementation for a terminal surface.
|
||||
class SurfaceView: NSView, NSTextInputClient, ObservableObject {
|
||||
/// Unique ID per surface
|
||||
let uuid: NSUUID
|
||||
|
||||
// The current title of the surface as defined by the pty. This can be
|
||||
// changed with escape codes. This is public because the callbacks go
|
||||
// to the app level and it is set from there.
|
||||
@@ -342,8 +347,9 @@ extension Ghostty {
|
||||
case pendingHidden
|
||||
}
|
||||
|
||||
init(_ app: ghostty_app_t, _ baseConfig: SurfaceConfiguration?) {
|
||||
init(_ app: ghostty_app_t, baseConfig: SurfaceConfiguration? = nil, uuid: NSUUID? = nil) {
|
||||
self.markedText = NSMutableAttributedString()
|
||||
self.uuid = uuid ?? .init()
|
||||
|
||||
// Initialize with some default frame size. The important thing is that this
|
||||
// is non-zero so that our layer bounds are non-zero so that our renderer
|
||||
|
Reference in New Issue
Block a user