diff --git a/macos/Sources/Ghostty/Ghostty.Config.swift b/macos/Sources/Ghostty/Ghostty.Config.swift index 641cca917..df9df686c 100644 --- a/macos/Sources/Ghostty/Ghostty.Config.swift +++ b/macos/Sources/Ghostty/Ghostty.Config.swift @@ -258,5 +258,14 @@ extension Ghostty { blue: blue / 255 ) } + + // This isn't actually a configurable value currently but it could be done day. + // We put it here because it is a color that changes depending on the configuration. + var splitDividerColor: Color { + let backgroundColor = NSColor(backgroundColor) + let isLightBackground = backgroundColor.isLightColor + let newColor = isLightBackground ? backgroundColor.shadow(withLevel: 0.1) : backgroundColor.shadow(withLevel: 0.4) + return Color(nsColor: newColor ?? .gray.withAlphaComponent(0.5)) + } } } diff --git a/macos/Sources/Ghostty/Ghostty.TerminalSplit.swift b/macos/Sources/Ghostty/Ghostty.TerminalSplit.swift index e7edb041c..88b352748 100644 --- a/macos/Sources/Ghostty/Ghostty.TerminalSplit.swift +++ b/macos/Sources/Ghostty/Ghostty.TerminalSplit.swift @@ -280,6 +280,8 @@ extension Ghostty { /// This represents a split view that is in the horizontal or vertical split state. private struct TerminalSplitContainer: View { + @EnvironmentObject var ghostty: Ghostty.App + let neighbors: SplitNode.Neighbors @Binding var node: SplitNode? @StateObject var container: SplitNode.Container @@ -288,6 +290,7 @@ extension Ghostty { SplitView( container.direction, $container.split, + dividerColor: ghostty.config.splitDividerColor, resizeIncrements: .init(width: 1, height: 1), resizePublisher: container.resizeEvent, left: { diff --git a/macos/Sources/Ghostty/InspectorView.swift b/macos/Sources/Ghostty/InspectorView.swift index 074431274..cfc65bca0 100644 --- a/macos/Sources/Ghostty/InspectorView.swift +++ b/macos/Sources/Ghostty/InspectorView.swift @@ -6,6 +6,8 @@ import GhosttyKit extension Ghostty { /// InspectableSurface is a type of Surface view that allows an inspector to be attached. struct InspectableSurface: View { + @EnvironmentObject var ghostty: Ghostty.App + /// Same as SurfaceWrapper, see the doc comments there. @ObservedObject var surfaceView: SurfaceView var isSplit: Bool = false @@ -24,7 +26,7 @@ extension Ghostty { if (!surfaceView.inspectorVisible) { SurfaceWrapper(surfaceView: surfaceView, isSplit: isSplit) } else { - SplitView(.vertical, $split, left: { + SplitView(.vertical, $split, dividerColor: ghostty.config.splitDividerColor, left: { SurfaceWrapper(surfaceView: surfaceView, isSplit: isSplit) }, right: { InspectorViewRepresentable(surfaceView: surfaceView) diff --git a/macos/Sources/Helpers/SplitView/SplitView.Divider.swift b/macos/Sources/Helpers/SplitView/SplitView.Divider.swift index 4d7a11a0e..67aecb79d 100644 --- a/macos/Sources/Helpers/SplitView/SplitView.Divider.swift +++ b/macos/Sources/Helpers/SplitView/SplitView.Divider.swift @@ -3,11 +3,10 @@ import SwiftUI extension SplitView { /// The split divider that is rendered and can be used to resize a split view. struct Divider: View { - @EnvironmentObject var ghostty: Ghostty.App - let direction: SplitViewDirection let visibleSize: CGFloat let invisibleSize: CGFloat + let color: Color private var visibleWidth: CGFloat? { switch (direction) { @@ -45,14 +44,6 @@ extension SplitView { } } - private var color: Color { - let backgroundColor = NSColor(ghostty.config.backgroundColor) - let isLightBackground = backgroundColor.isLightColor - let newColor = isLightBackground ? backgroundColor.shadow(withLevel: 0.1) : backgroundColor.shadow(withLevel: 0.4) - - return Color(nsColor: newColor ?? .gray.withAlphaComponent(0.5)) - } - var body: some View { ZStack { Color.clear diff --git a/macos/Sources/Helpers/SplitView/SplitView.swift b/macos/Sources/Helpers/SplitView/SplitView.swift index ecfb68d03..3fad805e1 100644 --- a/macos/Sources/Helpers/SplitView/SplitView.swift +++ b/macos/Sources/Helpers/SplitView/SplitView.swift @@ -10,6 +10,9 @@ struct SplitView: View { /// Direction of the split let direction: SplitViewDirection + /// Divider color + let dividerColor: Color + /// If set, the split view supports programmatic resizing via events sent via the publisher. /// Minimum increment (in points) that this split can be resized by, in /// each direction. Both `height` and `width` should be whole numbers @@ -45,7 +48,10 @@ struct SplitView: View { right .frame(width: rightRect.size.width, height: rightRect.size.height) .offset(x: rightRect.origin.x, y: rightRect.origin.y) - Divider(direction: direction, visibleSize: splitterVisibleSize, invisibleSize: splitterInvisibleSize) + Divider(direction: direction, + visibleSize: splitterVisibleSize, + invisibleSize: splitterInvisibleSize, + color: dividerColor) .position(splitterPoint) .gesture(dragGesture(geo.size, splitterPoint: splitterPoint)) } @@ -57,10 +63,15 @@ struct SplitView: View { /// Initialize a split view. This view isn't programmatically resizable; it can only be resized /// by manually dragging the divider. - init(_ direction: SplitViewDirection, _ split: Binding, @ViewBuilder left: (() -> L), @ViewBuilder right: (() -> R)) { + init(_ direction: SplitViewDirection, + _ split: Binding, + dividerColor: Color, + @ViewBuilder left: (() -> L), + @ViewBuilder right: (() -> R)) { self.init( direction, split, + dividerColor: dividerColor, resizeIncrements: .init(width: 1, height: 1), resizePublisher: .init(), left: left, @@ -72,6 +83,7 @@ struct SplitView: View { init( _ direction: SplitViewDirection, _ split: Binding, + dividerColor: Color, resizeIncrements: NSSize, resizePublisher: PassthroughSubject, @ViewBuilder left: (() -> L), @@ -79,6 +91,7 @@ struct SplitView: View { ) { self.direction = direction self._split = split + self.dividerColor = dividerColor self.resizeIncrements = resizeIncrements self.resizePublisher = resizePublisher self.left = left()