mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
macos: detect error during surface initialization and render
This commit is contained in:
@ -147,7 +147,10 @@ extension Ghostty {
|
|||||||
// If our surface is not healthy, then we render an error view over it.
|
// If our surface is not healthy, then we render an error view over it.
|
||||||
if (!surfaceView.healthy) {
|
if (!surfaceView.healthy) {
|
||||||
Rectangle().fill(ghostty.config.backgroundColor)
|
Rectangle().fill(ghostty.config.backgroundColor)
|
||||||
SurfaceUnhealthyView()
|
SurfaceRendererUnhealthyView()
|
||||||
|
} else if (surfaceView.error != nil) {
|
||||||
|
Rectangle().fill(ghostty.config.backgroundColor)
|
||||||
|
SurfaceErrorView()
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we're part of a split view and don't have focus, we put a semi-transparent
|
// If we're part of a split view and don't have focus, we put a semi-transparent
|
||||||
@ -167,7 +170,7 @@ extension Ghostty {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct SurfaceUnhealthyView: View {
|
struct SurfaceRendererUnhealthyView: View {
|
||||||
var body: some View {
|
var body: some View {
|
||||||
HStack {
|
HStack {
|
||||||
Image("AppIconImage")
|
Image("AppIconImage")
|
||||||
@ -189,6 +192,27 @@ extension Ghostty {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct SurfaceErrorView: View {
|
||||||
|
var body: some View {
|
||||||
|
HStack {
|
||||||
|
Image("AppIconImage")
|
||||||
|
.resizable()
|
||||||
|
.scaledToFit()
|
||||||
|
.frame(width: 128, height: 128)
|
||||||
|
|
||||||
|
VStack(alignment: .leading) {
|
||||||
|
Text("Oh, no. 😭").font(.title)
|
||||||
|
Text("""
|
||||||
|
The terminal failed to initialize. Please check the logs for
|
||||||
|
more information. This is usually a bug.
|
||||||
|
""".replacingOccurrences(of: "\n", with: " ")
|
||||||
|
)
|
||||||
|
.frame(maxWidth: 350)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.padding()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// A surface is terminology in Ghostty for a terminal surface, or a place where a terminal is actually drawn
|
/// A surface is terminology in Ghostty for a terminal surface, or a place where a terminal is actually drawn
|
||||||
/// and interacted with. The word "surface" is used because a surface may represent a window, a tab,
|
/// and interacted with. The word "surface" is used because a surface may represent a window, a tab,
|
||||||
@ -284,6 +308,9 @@ extension Ghostty {
|
|||||||
// renderer health. In the future we may want to make this an enum.
|
// renderer health. In the future we may want to make this an enum.
|
||||||
@Published var healthy: Bool = true
|
@Published var healthy: Bool = true
|
||||||
|
|
||||||
|
// Any error while initializing the surface.
|
||||||
|
@Published var error: Error? = nil
|
||||||
|
|
||||||
// An initial size to request for a window. This will only affect
|
// An initial size to request for a window. This will only affect
|
||||||
// then the view is moved to a new window.
|
// then the view is moved to a new window.
|
||||||
var initialSize: NSSize? = nil
|
var initialSize: NSSize? = nil
|
||||||
@ -327,8 +354,6 @@ extension Ghostty {
|
|||||||
var notificationIdentifiers: Set<String> = []
|
var notificationIdentifiers: Set<String> = []
|
||||||
|
|
||||||
private(set) var surface: ghostty_surface_t?
|
private(set) var surface: ghostty_surface_t?
|
||||||
var error: Error? = nil
|
|
||||||
|
|
||||||
private var markedText: NSMutableAttributedString
|
private var markedText: NSMutableAttributedString
|
||||||
private var mouseEntered: Bool = false
|
private var mouseEntered: Bool = false
|
||||||
private(set) var focused: Bool = true
|
private(set) var focused: Bool = true
|
||||||
|
Reference in New Issue
Block a user