diff --git a/macos/Sources/Features/Splits/TerminalSplitTreeView.swift b/macos/Sources/Features/Splits/TerminalSplitTreeView.swift index 4a41afc42..b219e0b31 100644 --- a/macos/Sources/Features/Splits/TerminalSplitTreeView.swift +++ b/macos/Sources/Features/Splits/TerminalSplitTreeView.swift @@ -43,7 +43,6 @@ struct TerminalSplitSubtreeView: View { }), dividerColor: ghostty.config.splitDividerColor, resizeIncrements: .init(width: 1, height: 1), - resizePublisher: .init(), left: { TerminalSplitSubtreeView(node: split.left, onResize: onResize) }, diff --git a/macos/Sources/Helpers/SplitView/SplitView.swift b/macos/Sources/Helpers/SplitView/SplitView.swift index 8ac2bc33f..9747ac99f 100644 --- a/macos/Sources/Helpers/SplitView/SplitView.swift +++ b/macos/Sources/Helpers/SplitView/SplitView.swift @@ -1,5 +1,4 @@ import SwiftUI -import Combine /// A split view shows a left and right (or top and bottom) view with a divider in the middle to do resizing. /// The terminlogy "left" and "right" is always used but for vertical splits "left" is "top" and "right" is "bottom". @@ -13,12 +12,10 @@ struct SplitView: View { /// 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 /// greater than or equal to 1.0 let resizeIncrements: NSSize - let resizePublisher: PassthroughSubject /// The left and right views to render. let left: L @@ -55,37 +52,15 @@ struct SplitView: View { .position(splitterPoint) .gesture(dragGesture(geo.size, splitterPoint: splitterPoint)) } - .onReceive(resizePublisher) { value in - resize(for: geo.size, amount: value) - } } } - /// 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, - dividerColor: Color, - @ViewBuilder left: (() -> L), - @ViewBuilder right: (() -> R)) { - self.init( - direction, - split, - dividerColor: dividerColor, - resizeIncrements: .init(width: 1, height: 1), - resizePublisher: .init(), - left: left, - right: right - ) - } - - /// Initialize a split view that supports programmatic resizing. + /// Initialize a split view that can be resized by manually dragging the divider. init( _ direction: SplitViewDirection, _ split: Binding, dividerColor: Color, - resizeIncrements: NSSize, - resizePublisher: PassthroughSubject, + resizeIncrements: NSSize = .init(width: 1, height: 1), @ViewBuilder left: (() -> L), @ViewBuilder right: (() -> R) ) { @@ -93,25 +68,10 @@ struct SplitView: View { self._split = split self.dividerColor = dividerColor self.resizeIncrements = resizeIncrements - self.resizePublisher = resizePublisher self.left = left() self.right = right() } - private func resize(for size: CGSize, amount: Double) { - let dim: CGFloat - switch (direction) { - case .horizontal: - dim = size.width - case .vertical: - dim = size.height - } - - let pos = split * dim - let new = min(max(minSize, pos + amount), dim - minSize) - split = new / dim - } - private func dragGesture(_ size: CGSize, splitterPoint: CGPoint) -> some Gesture { return DragGesture() .onChanged { gesture in