Skip to content

Commit 6447b3c

Browse files
committed
Add preference keys for theme
1 parent d5caace commit 6447b3c

3 files changed

Lines changed: 72 additions & 1 deletion

File tree

Pro

Submodule Pro updated from 7c3e41f to 2507d50

Tool/Sources/Preferences/Keys.swift

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,38 @@ public extension UserDefaultPreferenceKeys {
463463
}
464464
}
465465

466+
// MARK: - Theme
467+
468+
public extension UserDefaultPreferenceKeys {
469+
var syncSuggestionHighlightTheme: PreferenceKey<Bool> {
470+
.init(defaultValue: false, key: "SyncSuggestionHighlightTheme")
471+
}
472+
473+
var syncPromptToCodeHighlightTheme: PreferenceKey<Bool> {
474+
.init(defaultValue: false, key: "SyncPromptToCodeHighlightTheme")
475+
}
476+
477+
var syncChatCodeHighlightTheme: PreferenceKey<Bool> {
478+
.init(defaultValue: false, key: "SyncChatCodeHighlightTheme")
479+
}
480+
481+
var codeForegroundColorLight: PreferenceKey<UserDefaultsStorageBox<StorableColor?>> {
482+
.init(defaultValue: .init(nil), key: "CodeForegroundColorLight")
483+
}
484+
485+
var codeForegroundColorDark: PreferenceKey<UserDefaultsStorageBox<StorableColor?>> {
486+
.init(defaultValue: .init(nil), key: "CodeForegroundColorDark")
487+
}
488+
489+
var codeBackgroundColorLight: PreferenceKey<UserDefaultsStorageBox<StorableColor?>> {
490+
.init(defaultValue: .init(nil), key: "CodeBackgroundColorLight")
491+
}
492+
493+
var codeBackgroundColorDark: PreferenceKey<UserDefaultsStorageBox<StorableColor?>> {
494+
.init(defaultValue: .init(nil), key: "CodeBackgroundColorDark")
495+
}
496+
}
497+
466498
// MARK: - Bing Search
467499

468500
public extension UserDefaultPreferenceKeys {
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import Foundation
2+
3+
public struct StorableColor: Codable {
4+
public var red: Double
5+
public var green: Double
6+
public var blue: Double
7+
public var alpha: Double
8+
9+
public init(red: Double, green: Double, blue: Double, alpha: Double) {
10+
self.red = red
11+
self.green = green
12+
self.blue = blue
13+
self.alpha = alpha
14+
}
15+
}
16+
17+
#if canImport(SwiftUI)
18+
import SwiftUI
19+
public extension StorableColor {
20+
var swiftUIColor: SwiftUI.Color {
21+
SwiftUI.Color(.sRGB, red: red, green: green, blue: blue, opacity: alpha)
22+
}
23+
}
24+
#endif
25+
26+
#if canImport(AppKit)
27+
import AppKit
28+
public extension StorableColor {
29+
var nsColor: NSColor {
30+
NSColor(
31+
srgbRed: CGFloat(red),
32+
green: CGFloat(green),
33+
blue: CGFloat(blue),
34+
alpha: CGFloat(alpha)
35+
)
36+
}
37+
}
38+
#endif
39+

0 commit comments

Comments
 (0)