adds nice git interface
This commit is contained in:
@@ -7,14 +7,12 @@ public enum FocusZone: String, Sendable, Equatable {
|
||||
case terminal
|
||||
}
|
||||
|
||||
/// Pixel widths of the three fixed columns; the editor takes the remainder.
|
||||
/// Pixel widths of the two fixed columns; the editor takes the remainder.
|
||||
public struct ColumnWidths: Sendable, Equatable {
|
||||
public var sourceControl: Double
|
||||
public var explorer: Double
|
||||
public var agent: Double
|
||||
|
||||
public init(sourceControl: Double, explorer: Double, agent: Double) {
|
||||
self.sourceControl = sourceControl
|
||||
public init(explorer: Double, agent: Double) {
|
||||
self.explorer = explorer
|
||||
self.agent = agent
|
||||
}
|
||||
@@ -25,18 +23,17 @@ public enum ColumnLayout {
|
||||
public static let roomyWidth = 1600.0
|
||||
public static let minEditorWidth = 280.0
|
||||
public static let splitterWidth = 1.0
|
||||
public static let sourceControlRange = 160.0...460.0
|
||||
public static let explorerRange = 160.0...520.0
|
||||
|
||||
/// Fluid widths for a window. Roomy: 13.4% · 16.4% · flex · 27.3% (the design's
|
||||
/// 236 · 288 · flex · 480 on a 1760 frame). Tight: 15% · 15%, and the agent column
|
||||
/// takes 30%, or 20% with the editor focused, or 50% with a terminal focused.
|
||||
/// Fluid widths for a window. Roomy: 16.4% · flex · 27.3% (the design's 288 · flex · 480
|
||||
/// on a 1760 frame). Tight: 15%, and the agent column takes 30%, or 20% with the editor
|
||||
/// focused, or 50% with a terminal focused.
|
||||
public static func fluid(windowWidth w: Double, focus: FocusZone) -> ColumnWidths {
|
||||
if w >= roomyWidth {
|
||||
return ColumnWidths(sourceControl: (w * 0.134).rounded(), explorer: (w * 0.164).rounded(), agent: (w * 0.273).rounded())
|
||||
return ColumnWidths(explorer: (w * 0.164).rounded(), agent: (w * 0.273).rounded())
|
||||
}
|
||||
let agentShare = focus == .terminal ? 0.5 : focus == .editor ? 0.2 : 0.3
|
||||
return ColumnWidths(sourceControl: (w * 0.15).rounded(), explorer: (w * 0.15).rounded(), agent: (w * agentShare).rounded())
|
||||
return ColumnWidths(explorer: (w * 0.15).rounded(), agent: (w * agentShare).rounded())
|
||||
}
|
||||
|
||||
/// Scales the fixed columns down so the flex column keeps `minEditorWidth`; unchanged when they fit.
|
||||
@@ -45,12 +42,10 @@ public enum ColumnLayout {
|
||||
let agentIsFixed = visible.agent && visible.editor
|
||||
let flexMinimum = visible.editor || visible.agent ? minEditorWidth : 0
|
||||
let budget = windowWidth - Double(visible.splitterCount) * splitterWidth - flexMinimum
|
||||
let total = (visible.sourceControl ? widths.sourceControl : 0) + (visible.explorer ? widths.explorer : 0)
|
||||
+ (agentIsFixed ? widths.agent : 0)
|
||||
let total = (visible.explorer ? widths.explorer : 0) + (agentIsFixed ? widths.agent : 0)
|
||||
guard total > budget, total > 0 else { return widths }
|
||||
let k = max(0, budget) / total
|
||||
return ColumnWidths(
|
||||
sourceControl: visible.sourceControl ? (widths.sourceControl * k).rounded(.down) : widths.sourceControl,
|
||||
explorer: visible.explorer ? (widths.explorer * k).rounded(.down) : widths.explorer,
|
||||
agent: agentIsFixed ? (widths.agent * k).rounded(.down) : widths.agent
|
||||
)
|
||||
@@ -58,20 +53,18 @@ public enum ColumnLayout {
|
||||
|
||||
/// The widest the agent column may be dragged: until the editor would drop below its minimum.
|
||||
public static func maxAgentWidth(windowWidth: Double, widths: ColumnWidths, visible: ColumnVisibility) -> Double {
|
||||
let others = (visible.sourceControl ? widths.sourceControl : 0) + (visible.explorer ? widths.explorer : 0)
|
||||
let others = visible.explorer ? widths.explorer : 0
|
||||
return max(minEditorWidth, windowWidth - Double(visible.splitterCount) * splitterWidth - others - minEditorWidth)
|
||||
}
|
||||
}
|
||||
|
||||
/// Which of the four columns are shown. A hidden column keeps its width and its contents.
|
||||
/// Which of the three columns are shown. A hidden column keeps its width and its contents.
|
||||
public struct ColumnVisibility: Sendable, Equatable {
|
||||
public var sourceControl: Bool
|
||||
public var explorer: Bool
|
||||
public var editor: Bool
|
||||
public var agent: Bool
|
||||
|
||||
public init(sourceControl: Bool = true, explorer: Bool = true, editor: Bool = true, agent: Bool = true) {
|
||||
self.sourceControl = sourceControl
|
||||
public init(explorer: Bool = true, editor: Bool = true, agent: Bool = true) {
|
||||
self.explorer = explorer
|
||||
self.editor = editor
|
||||
self.agent = agent
|
||||
@@ -81,6 +74,6 @@ public struct ColumnVisibility: Sendable, Equatable {
|
||||
|
||||
/// One splitter between each pair of neighbouring visible columns.
|
||||
public var splitterCount: Int {
|
||||
max(0, [sourceControl, explorer, editor, agent].filter { $0 }.count - 1)
|
||||
max(0, [explorer, editor, agent].filter { $0 }.count - 1)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user