macos: move OSC8 URL view to right if mouse is over it

This commit is contained in:
Mitchell Hashimoto
2024-07-06 21:33:42 -07:00
parent ecdb0a74b0
commit 571182fb60

View File

@ -48,9 +48,12 @@ extension Ghostty {
// Maintain whether our window has focus (is key) or not // Maintain whether our window has focus (is key) or not
@State private var windowFocus: Bool = true @State private var windowFocus: Bool = true
// True if we're hovering over the left URL view, so we can show it on the right.
@State private var isHoveringURLLeft: Bool = false
@EnvironmentObject private var ghostty: Ghostty.App @EnvironmentObject private var ghostty: Ghostty.App
var body: some View { var body: some View {
let center = NotificationCenter.default let center = NotificationCenter.default
@ -146,19 +149,35 @@ extension Ghostty {
.ghosttySurfaceView(surfaceView) .ghosttySurfaceView(surfaceView)
// If we have a URL from hovering a link, we show that. // If we have a URL from hovering a link, we show that.
// TODO
if let url = surfaceView.hoverUrl { if let url = surfaceView.hoverUrl {
let padding: CGFloat = 3 let padding: CGFloat = 3
HStack { ZStack {
VStack(alignment: .leading) { HStack {
VStack(alignment: .leading) {
Spacer()
Text(verbatim: url)
.padding(.init(top: padding, leading: padding, bottom: padding, trailing: padding))
.background(.background)
.opacity(isHoveringURLLeft ? 0 : 1)
.onHover(perform: { hovering in
isHoveringURLLeft = hovering
})
}
Spacer() Spacer()
Text(verbatim: url)
.padding(.init(top: padding, leading: padding, bottom: padding, trailing: padding))
.background(.background)
} }
Spacer() HStack {
Spacer()
VStack(alignment: .leading) {
Spacer()
Text(verbatim: url)
.padding(.init(top: padding, leading: padding, bottom: padding, trailing: padding))
.background(.background)
.opacity(isHoveringURLLeft ? 1 : 0)
}
}
} }
} }