Skip to content

Commit cef6d05

Browse files
committed
Merge branch 'feature/font-picker' into develop
2 parents f315e0b + abcaaec commit cef6d05

17 files changed

Lines changed: 294 additions & 104 deletions

File tree

Core/Sources/ChatGPTChatTab/ChatPanel.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -533,12 +533,12 @@ struct ChatPanel_EmptyChat_Preview: PreviewProvider {
533533

534534
struct ChatCodeSyntaxHighlighter: CodeSyntaxHighlighter {
535535
let brightMode: Bool
536-
let fontSize: Double
536+
let font: NSFont
537537
let colorChange: Color?
538538

539-
init(brightMode: Bool, fontSize: Double, colorChange: Color?) {
539+
init(brightMode: Bool, font: NSFont, colorChange: Color?) {
540540
self.brightMode = brightMode
541-
self.fontSize = fontSize
541+
self.font = font
542542
self.colorChange = colorChange
543543
}
544544

@@ -548,7 +548,7 @@ struct ChatCodeSyntaxHighlighter: CodeSyntaxHighlighter {
548548
language: language ?? "",
549549
scenario: "chat",
550550
brightMode: brightMode,
551-
fontSize: fontSize
551+
font: font
552552
)
553553
return Text(AttributedString(content))
554554
}

Core/Sources/ChatGPTChatTab/Styles.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ struct ThemedMarkdownText: View {
8181
@AppStorage(\.codeForegroundColorDark) var codeForegroundColorDark
8282
@AppStorage(\.codeBackgroundColorDark) var codeBackgroundColorDark
8383
@AppStorage(\.chatFontSize) var chatFontSize
84-
@AppStorage(\.chatCodeFontSize) var chatCodeFontSize
84+
@AppStorage(\.chatCodeFont) var chatCodeFont
8585
@Environment(\.colorScheme) var colorScheme
8686

8787
let text: String
@@ -122,7 +122,7 @@ struct ThemedMarkdownText: View {
122122
.markdownCodeSyntaxHighlighter(
123123
ChatCodeSyntaxHighlighter(
124124
brightMode: colorScheme != .dark,
125-
fontSize: chatCodeFontSize,
125+
font: chatCodeFont.value.nsFont,
126126
colorChange: colorScheme == .dark
127127
? codeForegroundColorDark.value?.swiftUIColor
128128
: codeForegroundColorLight.value?.swiftUIColor

Core/Sources/HostApp/FeatureSettings/ChatSettingsView.swift

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ struct ChatSettingsView: View {
1313
@AppStorage(\.chatGPTTemperature) var chatGPTTemperature
1414
@AppStorage(\.chatGPTMaxMessageCount) var chatGPTMaxMessageCount
1515
@AppStorage(\.chatFontSize) var chatFontSize
16-
@AppStorage(\.chatCodeFontSize) var chatCodeFontSize
16+
@AppStorage(\.chatCodeFont) var chatCodeFont
1717

1818
@AppStorage(\.defaultChatFeatureChatModelId) var defaultChatFeatureChatModelId
1919
@AppStorage(\.defaultChatSystemPrompt) var defaultChatSystemPrompt
@@ -150,17 +150,8 @@ struct ChatSettingsView: View {
150150
Text("pt")
151151
}
152152

153-
HStack {
154-
TextField(text: .init(get: {
155-
"\(Int(settings.chatCodeFontSize))"
156-
}, set: {
157-
settings.chatCodeFontSize = Double(Int($0) ?? 0)
158-
})) {
159-
Text("Font size of code block")
160-
}
161-
.textFieldStyle(.roundedBorder)
162-
163-
Text("pt")
153+
FontPicker(font: $settings.chatCodeFont) {
154+
Text("Font of code")
164155
}
165156

166157
Toggle(isOn: $settings.wrapCodeInCodeBlock) {

Core/Sources/HostApp/FeatureSettings/PromptToCodeSettingsView.swift

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ struct PromptToCodeSettingsView: View {
1010
final class Settings: ObservableObject {
1111
@AppStorage(\.hideCommonPrecedingSpacesInPromptToCode)
1212
var hideCommonPrecedingSpaces
13-
@AppStorage(\.promptToCodeCodeFontSize)
14-
var fontSize
13+
@AppStorage(\.promptToCodeCodeFont)
14+
var font
1515
@AppStorage(\.promptToCodeGenerateDescription)
1616
var promptToCodeGenerateDescription
1717
@AppStorage(\.promptToCodeGenerateDescriptionInUserPreferredLanguage)
@@ -91,24 +91,15 @@ struct PromptToCodeSettingsView: View {
9191
Text("Hide Common Preceding Spaces")
9292
}
9393

94-
HStack {
95-
TextField(text: .init(get: {
96-
"\(Int(settings.fontSize))"
97-
}, set: {
98-
settings.fontSize = Double(Int($0) ?? 0)
99-
})) {
100-
Text("Font size of suggestion code")
101-
}
102-
.textFieldStyle(.roundedBorder)
103-
104-
Text("pt")
105-
}
106-
10794
#if canImport(ProHostApp)
10895

10996
CodeHighlightThemePicker(scenario: .promptToCode)
11097

11198
#endif
99+
100+
FontPicker(font: $settings.font) {
101+
Text("Font")
102+
}
112103
}
113104

114105
ScopeForm()

Core/Sources/HostApp/FeatureSettings/SuggestionSettingsView.swift

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ struct SuggestionSettingsView: View {
4646
var suggestionFeatureEnabledProjectList
4747
@AppStorage(\.hideCommonPrecedingSpacesInSuggestion)
4848
var hideCommonPrecedingSpacesInSuggestion
49-
@AppStorage(\.suggestionCodeFontSize)
50-
var suggestionCodeFontSize
49+
@AppStorage(\.suggestionCodeFont)
50+
var font
5151
@AppStorage(\.suggestionFeatureProvider)
5252
var suggestionFeatureProvider
5353
@AppStorage(\.suggestionDisplayCompactMode)
@@ -247,24 +247,15 @@ struct SuggestionSettingsView: View {
247247
Text("Hide Common Preceding Spaces")
248248
}
249249

250-
HStack {
251-
TextField(text: .init(get: {
252-
"\(Int(settings.suggestionCodeFontSize))"
253-
}, set: {
254-
settings.suggestionCodeFontSize = Double(Int($0) ?? 0)
255-
})) {
256-
Text("Font size of suggestion code")
257-
}
258-
.textFieldStyle(.roundedBorder)
259-
260-
Text("pt")
261-
}
262-
263250
#if canImport(ProHostApp)
264251

265252
CodeHighlightThemePicker(scenario: .suggestion)
266-
253+
267254
#endif
255+
256+
FontPicker(font: $settings.font) {
257+
Text("Font")
258+
}
268259
}
269260
}
270261
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import Preferences
2+
import SharedUIComponents
3+
import SwiftUI
4+
5+
#if canImport(ProHostApp)
6+
import ProHostApp
7+
#endif
8+
9+
struct TerminalSettingsView: View {
10+
class Settings: ObservableObject {
11+
@AppStorage(\.terminalFont) var terminalFont
12+
init() {}
13+
}
14+
15+
@StateObject var settings = Settings()
16+
17+
var body: some View {
18+
ScrollView {
19+
Form {
20+
FontPicker(font: $settings.terminalFont) {
21+
Text("Font of code")
22+
}
23+
}
24+
}
25+
26+
}
27+
}

Core/Sources/HostApp/FeatureSettingsView.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,18 @@ struct FeatureSettingsView: View {
3434
subtitle: "Write code with natural language",
3535
image: "paintbrush"
3636
)
37+
38+
// #if canImport(ProHostApp)
39+
// ScrollView {
40+
// TerminalSettingsView().padding()
41+
// }
42+
// .sidebarItem(
43+
// tag: 3,
44+
// title: "Terminal",
45+
// subtitle: "Terminal chat tab",
46+
// image: "terminal"
47+
// )
48+
// #endif
3749
}
3850
}
3951
}

Core/Sources/SuggestionWidget/SuggestionPanelContent/CodeBlockSuggestionPanel.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import SwiftUI
44
struct CodeBlockSuggestionPanel: View {
55
@ObservedObject var suggestion: CodeSuggestionProvider
66
@Environment(\.colorScheme) var colorScheme
7-
@AppStorage(\.suggestionCodeFontSize) var fontSize
7+
@AppStorage(\.suggestionCodeFont) var codeFont
88
@AppStorage(\.suggestionDisplayCompactMode) var suggestionDisplayCompactMode
99
@AppStorage(\.suggestionPresentationMode) var suggestionPresentationMode
1010
@AppStorage(\.hideCommonPrecedingSpacesInSuggestion) var hideCommonPrecedingSpaces
@@ -108,7 +108,7 @@ struct CodeBlockSuggestionPanel: View {
108108
startLineIndex: suggestion.startLineIndex,
109109
scenario: "suggestion",
110110
colorScheme: colorScheme,
111-
fontSize: fontSize,
111+
font: codeFont.value.nsFont,
112112
droppingLeadingSpaces: hideCommonPrecedingSpaces,
113113
proposedForegroundColor: {
114114
if syncHighlightTheme {

Core/Sources/SuggestionWidget/SuggestionPanelContent/PromptToCodePanel.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ extension PromptToCodePanel {
202202
struct Content: View {
203203
let store: StoreOf<PromptToCode>
204204
@Environment(\.colorScheme) var colorScheme
205-
@AppStorage(\.promptToCodeCodeFontSize) var fontSize
205+
@AppStorage(\.promptToCodeCodeFont) var codeFont
206206
@AppStorage(\.hideCommonPrecedingSpacesInPromptToCode) var hideCommonPrecedingSpaces
207207
@AppStorage(\.syncPromptToCodeHighlightTheme) var syncHighlightTheme
208208
@AppStorage(\.codeForegroundColorLight) var codeForegroundColorLight
@@ -312,7 +312,7 @@ extension PromptToCodePanel {
312312
colorScheme: colorScheme,
313313
firstLinePrecedingSpaceCount: viewStore.state
314314
.firstLinePrecedingSpaceCount,
315-
fontSize: fontSize,
315+
font: codeFont.value.nsFont,
316316
droppingLeadingSpaces: hideCommonPrecedingSpaces,
317317
proposedForegroundColor:codeForegroundColor
318318
)

Pro

Submodule Pro updated from 43e5416 to c44d3a0

0 commit comments

Comments
 (0)