Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions GhosttyTabs.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
8C4BBF2DEF6DF93F395A9EE7 /* TerminalControllerSocketSecurityTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 491751CE2321474474F27DCF /* TerminalControllerSocketSecurityTests.swift */; };
9C1BEA3D2E6F49709A71C020 /* TerminalControllerSocketWriteTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9C1BEA3D2E6F49709A71C021 /* TerminalControllerSocketWriteTests.swift */; };
A5001001 /* cmuxApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5001011 /* cmuxApp.swift */; };
A50033840000000000000003 /* SettingsDebugSocketCommands.swift in Sources */ = {isa = PBXBuildFile; fileRef = A50033840000000000000004 /* SettingsDebugSocketCommands.swift */; };
A50033840000000000000001 /* SettingsPickerRows.swift in Sources */ = {isa = PBXBuildFile; fileRef = A50033840000000000000002 /* SettingsPickerRows.swift */; };
A50019A0 /* SettingsNavigation.swift in Sources */ = {isa = PBXBuildFile; fileRef = A50019A1 /* SettingsNavigation.swift */; };
A50019B0 /* SettingsSearchAliases.swift in Sources */ = {isa = PBXBuildFile; fileRef = A50019B1 /* SettingsSearchAliases.swift */; };
A50019B2 /* SettingsSearchIndexTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A50019B3 /* SettingsSearchIndexTests.swift */; };
Expand Down Expand Up @@ -365,6 +367,8 @@
B7F9A605B7F9A605B7F9A605 /* RightSidebarChromeStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RightSidebarChromeStyle.swift; sourceTree = "<group>"; };
A5001000 /* cmux.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = cmux.app; sourceTree = BUILT_PRODUCTS_DIR; };
A5001011 /* cmuxApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = cmuxApp.swift; sourceTree = "<group>"; };
A50033840000000000000004 /* SettingsDebugSocketCommands.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Settings/SettingsDebugSocketCommands.swift; sourceTree = "<group>"; };
A50033840000000000000002 /* SettingsPickerRows.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Settings/SettingsPickerRows.swift; sourceTree = "<group>"; };
A50019A1 /* SettingsNavigation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsNavigation.swift; sourceTree = "<group>"; };
A50019B1 /* SettingsSearchAliases.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsSearchAliases.swift; sourceTree = "<group>"; };
A50019B3 /* SettingsSearchIndexTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsSearchIndexTests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -720,6 +724,8 @@
3023B1003023B1003023B100 /* ConfigSource.swift */,
3023B1013023B1013023B101 /* ConfigSettingsView.swift */,
A5001011 /* cmuxApp.swift */,
A50033840000000000000004 /* SettingsDebugSocketCommands.swift */,
A50033840000000000000002 /* SettingsPickerRows.swift */,
A50019A1 /* SettingsNavigation.swift */,
A50019B1 /* SettingsSearchAliases.swift */,
A5001012 /* ContentView.swift */,
Expand Down Expand Up @@ -1176,6 +1182,8 @@
3023A1003023A1003023A100 /* ConfigSource.swift in Sources */,
3023A1013023A1013023A101 /* ConfigSettingsView.swift in Sources */,
A5001001 /* cmuxApp.swift in Sources */,
A50033840000000000000003 /* SettingsDebugSocketCommands.swift in Sources */,
A50033840000000000000001 /* SettingsPickerRows.swift in Sources */,
A50019A0 /* SettingsNavigation.swift in Sources */,
A50019B0 /* SettingsSearchAliases.swift in Sources */,
A5001002 /* ContentView.swift in Sources */,
Expand Down
23 changes: 23 additions & 0 deletions Sources/Settings/SettingsDebugSocketCommands.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import AppKit

#if DEBUG
extension TerminalController {
func v2DebugSettingsWindowState(params: [String: Any]) -> TerminalController.V2CallResult {
let window = NSApp.windows.first { $0.identifier?.rawValue == SettingsWindowPresenter.windowIdentifier }
let frame = window?.frame ?? .zero
if params["close"] as? Bool == true {
window?.close()
}
return .ok([
"exists": window != nil,
"identifier": window?.identifier?.rawValue ?? NSNull(),
"visible": window?.isVisible ?? false,
"miniaturized": window?.isMiniaturized ?? false,
"main": NSApp.mainWindow === window,
"key": NSApp.keyWindow === window,
"width": Int(frame.width.rounded()),
"height": Int(frame.height.rounded())
])
}
}
#endif
323 changes: 323 additions & 0 deletions Sources/Settings/SettingsPickerRows.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,323 @@
import SwiftUI

enum SettingsConfigurationReview: Equatable {
case settingsFile([String])
case settingsOnly
case action
case debugOnly

static func json(_ paths: String...) -> Self {
.settingsFile(paths)
}

var searchAnchorIDs: [String] {
guard case .settingsFile(let paths) = self else { return [] }
return paths.compactMap(SettingsSearchIndex.anchorID(forSettingsPath:))
}

func validate(file: StaticString = #fileID, line: UInt = #line) {
guard case .settingsFile(let paths) = self else { return }
let unknownPaths = paths.filter { !CmuxSettingsFileStore.supportedSettingsJSONPaths.contains($0) }
precondition(
unknownPaths.isEmpty,
"Unknown settings.json path(s): \(unknownPaths.joined(separator: ", "))",
file: file,
line: line
)
}
}

private struct ThemeWindowThumbnail: View {
let isDark: Bool

var body: some View {
GeometryReader { geo in
let width = geo.size.width
let height = geo.size.height

ZStack {
// Wallpaper background
if isDark {
LinearGradient(
colors: [Color(red: 0.1, green: 0.1, blue: 0.3), Color(red: 0.05, green: 0.05, blue: 0.1)],
startPoint: .topLeading,
endPoint: .bottomTrailing
)
Path { path in
path.move(to: CGPoint(x: 0, y: height * 0.5))
path.addQuadCurve(to: CGPoint(x: width, y: height), control: CGPoint(x: width * 0.5, y: height * 0.2))
path.addLine(to: CGPoint(x: width, y: 0))
path.addLine(to: CGPoint(x: 0, y: 0))
}
.fill(LinearGradient(colors: [Color(red: 0.2, green: 0.2, blue: 0.6).opacity(0.5), .clear], startPoint: .topLeading, endPoint: .bottomTrailing))
} else {
LinearGradient(
colors: [Color(red: 0.6, green: 0.8, blue: 0.95), Color(red: 0.2, green: 0.4, blue: 0.8)],
startPoint: .topLeading,
endPoint: .bottomTrailing
)
Path { path in
path.move(to: CGPoint(x: 0, y: height * 0.5))
path.addQuadCurve(to: CGPoint(x: width, y: height), control: CGPoint(x: width * 0.5, y: height * 0.2))
path.addLine(to: CGPoint(x: width, y: 0))
path.addLine(to: CGPoint(x: 0, y: 0))
}
.fill(LinearGradient(colors: [Color(red: 0.8, green: 0.9, blue: 1.0).opacity(0.6), .clear], startPoint: .topLeading, endPoint: .bottomTrailing))
}

// Menu bar
VStack(spacing: 0) {
HStack {
Image(systemName: "applelogo")
.font(.system(size: max(height * 0.08, 6)))
.foregroundColor(isDark ? .white : .black)
.opacity(0.8)
Spacer()
}
.padding(.horizontal, max(width * 0.04, 4))
.frame(height: max(height * 0.12, 8))
.background(.ultraThinMaterial)
Spacer()
}

// Back window
VStack(spacing: 0) {
Rectangle()
.fill(isDark ? Color(white: 0.2) : Color(white: 0.9))
.frame(height: max(height * 0.15, 8))
ZStack(alignment: .top) {
Rectangle()
.fill(isDark ? Color(white: 0.15) : Color(white: 0.98))
RoundedRectangle(cornerRadius: max(width * 0.02, 2), style: .continuous)
.fill(Color.accentColor)
.frame(height: max(height * 0.12, 6))
.padding(max(width * 0.04, 4))
}
}
.clipShape(RoundedRectangle(cornerRadius: max(width * 0.04, 4), style: .continuous))
.frame(width: width * 0.65, height: height * 0.45)
.shadow(color: .black.opacity(isDark ? 0.4 : 0.15), radius: 4, x: 0, y: 2)
.offset(x: -width * 0.08, y: -height * 0.1)

// Front window with traffic lights
VStack(spacing: 0) {
ZStack {
Rectangle()
.fill(isDark ? Color(white: 0.18) : Color(white: 0.92))
HStack(spacing: max(width * 0.025, 2)) {
Circle().fill(Color(red: 1.0, green: 0.37, blue: 0.34)).frame(width: max(width * 0.04, 3))
Circle().fill(Color(red: 1.0, green: 0.74, blue: 0.18)).frame(width: max(width * 0.04, 3))
Circle().fill(Color(red: 0.15, green: 0.79, blue: 0.25)).frame(width: max(width * 0.04, 3))
Spacer()
}
.padding(.horizontal, max(width * 0.04, 4))
}
.frame(height: max(height * 0.18, 10))
Rectangle()
.fill(isDark ? Color(white: 0.1) : .white)
}
.clipShape(RoundedRectangle(cornerRadius: max(width * 0.05, 5), style: .continuous))
.shadow(color: .black.opacity(isDark ? 0.5 : 0.2), radius: 6, x: 0, y: 3)
.frame(width: width * 0.75, height: height * 0.55)
.offset(x: width * 0.12, y: height * 0.2)
}
}
.clipShape(RoundedRectangle(cornerRadius: 14, style: .continuous))
.overlay(
RoundedRectangle(cornerRadius: 14, style: .continuous)
.stroke(Color.primary.opacity(0.1), lineWidth: 1)
)
}
}

struct ThemePickerRow: View {
let configurationReview: SettingsConfigurationReview
let selectedMode: String
let onSelect: (AppearanceMode) -> Void

private let thumbWidth: CGFloat = 76
private let thumbHeight: CGFloat = 50

init(
configurationReview: SettingsConfigurationReview,
selectedMode: String,
onSelect: @escaping (AppearanceMode) -> Void
) {
configurationReview.validate()
self.configurationReview = configurationReview
self.selectedMode = selectedMode
self.onSelect = onSelect
}

var body: some View {
HStack(alignment: .top, spacing: 12) {
Text(String(localized: "settings.app.theme", defaultValue: "Theme"))
.font(.system(size: 13, weight: .medium))
.frame(maxWidth: .infinity, alignment: .leading)

HStack(spacing: 8) {
ForEach(AppearanceMode.visibleCases) { mode in
let isSelected = selectedMode == mode.rawValue
Button {
onSelect(mode)
} label: {
VStack(spacing: 4) {
Group {
if mode == .system {
ZStack {
ThemeWindowThumbnail(isDark: false)
.mask(
GeometryReader { geo in
Rectangle()
.frame(width: geo.size.width / 2, height: geo.size.height)
.position(x: geo.size.width / 4, y: geo.size.height / 2)
}
)
ThemeWindowThumbnail(isDark: true)
.mask(
GeometryReader { geo in
Rectangle()
.frame(width: geo.size.width / 2, height: geo.size.height)
.position(x: geo.size.width * 0.75, y: geo.size.height / 2)
}
)
GeometryReader { geo in
Rectangle()
.fill(Color.primary.opacity(0.15))
.frame(width: 1, height: geo.size.height)
.position(x: geo.size.width / 2, y: geo.size.height / 2)
}
}
} else {
ThemeWindowThumbnail(isDark: mode == .dark)
}
}
.frame(width: thumbWidth, height: thumbHeight)

Text(mode.displayName)
.font(.system(size: 10))
.fontWeight(isSelected ? .semibold : .regular)
.foregroundColor(isSelected ? .primary : .secondary)
}
.padding(.vertical, 8)
.padding(.horizontal, 10)
.contentShape(Rectangle())
.background(
RoundedRectangle(cornerRadius: 8, style: .continuous)
.fill(isSelected
? Color.accentColor.opacity(0.12)
: Color.clear)
)
.overlay(
RoundedRectangle(cornerRadius: 8, style: .continuous)
.stroke(isSelected ? Color.accentColor : Color.clear, lineWidth: 2)
)
}
.buttonStyle(.plain)
.focusable(false)
.accessibilityAddTraits(isSelected ? .isSelected : [])
}
}
.layoutPriority(1)
}
.padding(.horizontal, 14)
.padding(.vertical, 9)
.frame(maxWidth: .infinity, alignment: .leading)
.settingsSearchAnchors(configurationReview.searchAnchorIDs)
}
}

struct AppIconPickerRow: View {
let configurationReview: SettingsConfigurationReview
let selectedMode: String
let onSelect: (AppIconMode) -> Void

private let iconSize: CGFloat = 48
private let autoIconSize: CGFloat = 36

init(
configurationReview: SettingsConfigurationReview,
selectedMode: String,
onSelect: @escaping (AppIconMode) -> Void
) {
configurationReview.validate()
self.configurationReview = configurationReview
self.selectedMode = selectedMode
self.onSelect = onSelect
}

var body: some View {
HStack(alignment: .top, spacing: 12) {
VStack(alignment: .leading, spacing: 3) {
Text(String(localized: "settings.app.appIcon", defaultValue: "App Icon"))
.font(.system(size: 13, weight: .medium))
Text(String(localized: "settings.app.appIcon.subtitle", defaultValue: "Dock and app switcher"))
.font(.caption)
.foregroundColor(.secondary)
}
.frame(maxWidth: .infinity, alignment: .leading)

HStack(spacing: 8) {
ForEach(AppIconMode.allCases) { mode in
let isSelected = selectedMode == mode.rawValue
Button {
onSelect(mode)
} label: {
VStack(spacing: 4) {
Group {
if mode == .automatic {
ZStack {
Image("AppIconLight")
.resizable()
.interpolation(.high)
.frame(width: autoIconSize, height: autoIconSize)
.clipShape(RoundedRectangle(cornerRadius: autoIconSize * 0.22, style: .continuous))
.offset(x: -10)
Image("AppIconDark")
.resizable()
.interpolation(.high)
.frame(width: autoIconSize, height: autoIconSize)
.clipShape(RoundedRectangle(cornerRadius: autoIconSize * 0.22, style: .continuous))
.offset(x: 10)
}
.frame(width: iconSize, height: iconSize)
} else {
Image(mode.imageName ?? "AppIconLight")
.resizable()
.interpolation(.high)
.frame(width: iconSize, height: iconSize)
.clipShape(RoundedRectangle(cornerRadius: iconSize * 0.22, style: .continuous))
}
}

Text(mode.displayName)
.font(.system(size: 10))
.foregroundColor(isSelected ? .primary : .secondary)
}
.padding(.vertical, 8)
.padding(.horizontal, 10)
.contentShape(Rectangle())
.background(
RoundedRectangle(cornerRadius: 8, style: .continuous)
.fill(isSelected
? Color.accentColor.opacity(0.12)
: Color.clear)
)
.overlay(
RoundedRectangle(cornerRadius: 8, style: .continuous)
.stroke(isSelected ? Color.accentColor : Color.clear, lineWidth: 2)
)
}
.buttonStyle(.plain)
.focusable(false)
.accessibilityAddTraits(isSelected ? .isSelected : [])
}
}
.layoutPriority(1)
}
.padding(.horizontal, 14)
.padding(.vertical, 9)
.frame(maxWidth: .infinity, alignment: .leading)
.settingsSearchAnchors(configurationReview.searchAnchorIDs)
}
}
Loading