mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
macos: set proper window title for focused split
This commit is contained in:
@ -7,10 +7,12 @@ extension Ghostty {
|
|||||||
/// split direction by splitting the terminal.
|
/// split direction by splitting the terminal.
|
||||||
struct TerminalSplit: View {
|
struct TerminalSplit: View {
|
||||||
@Environment(\.ghosttyApp) private var app
|
@Environment(\.ghosttyApp) private var app
|
||||||
|
@FocusedValue(\.ghosttySurfaceTitle) private var surfaceTitle: String?
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
if let app = app {
|
if let app = app {
|
||||||
TerminalSplitChild(app)
|
TerminalSplitChild(app)
|
||||||
|
.navigationTitle(surfaceTitle ?? "Ghostty")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -22,11 +24,6 @@ extension Ghostty {
|
|||||||
case horizontal
|
case horizontal
|
||||||
}
|
}
|
||||||
|
|
||||||
enum Side: Hashable {
|
|
||||||
case TopLeft
|
|
||||||
case BottomRight
|
|
||||||
}
|
|
||||||
|
|
||||||
/// The stored state between invocations.
|
/// The stored state between invocations.
|
||||||
class ViewState: ObservableObject {
|
class ViewState: ObservableObject {
|
||||||
/// The direction of the split currently
|
/// The direction of the split currently
|
||||||
|
@ -5,10 +5,12 @@ extension Ghostty {
|
|||||||
/// Render a terminal for the active app in the environment.
|
/// Render a terminal for the active app in the environment.
|
||||||
struct Terminal: View {
|
struct Terminal: View {
|
||||||
@Environment(\.ghosttyApp) private var app
|
@Environment(\.ghosttyApp) private var app
|
||||||
|
@FocusedValue(\.ghosttySurfaceTitle) private var surfaceTitle: String?
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
if let app = self.app {
|
if let app = self.app {
|
||||||
TerminalForApp(app)
|
TerminalForApp(app)
|
||||||
|
.navigationTitle(surfaceTitle ?? "Ghostty")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -46,8 +48,7 @@ extension Ghostty {
|
|||||||
GeometryReader { geo in
|
GeometryReader { geo in
|
||||||
Surface(view: surfaceView, hasFocus: hasFocus, size: geo.size)
|
Surface(view: surfaceView, hasFocus: hasFocus, size: geo.size)
|
||||||
.focused($surfaceFocus)
|
.focused($surfaceFocus)
|
||||||
.focusedValue(\.ghosttySurfaceView, surfaceView)
|
.focusedValue(\.ghosttySurfaceTitle, surfaceView.title)
|
||||||
.navigationTitle(surfaceView.title)
|
|
||||||
}
|
}
|
||||||
.ghosttySurfaceView(surfaceView)
|
.ghosttySurfaceView(surfaceView)
|
||||||
}
|
}
|
||||||
@ -547,3 +548,14 @@ extension FocusedValues {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extension FocusedValues {
|
||||||
|
var ghosttySurfaceTitle: String? {
|
||||||
|
get { self[FocusedGhosttySurfaceTitle.self] }
|
||||||
|
set { self[FocusedGhosttySurfaceTitle.self] = newValue }
|
||||||
|
}
|
||||||
|
|
||||||
|
struct FocusedGhosttySurfaceTitle: FocusedValueKey {
|
||||||
|
typealias Value = String
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user