Skip to content

Commit 7a10c3b

Browse files
Add Option to Use the System Cursor (#1812)
* Option to Use the System Cursor * Only decode on valid macos version
1 parent a73d2e5 commit 7a10c3b

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

CodeEdit/Features/Editor/Views/CodeFileView.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ struct CodeFileView: View {
4040
var letterSpacing
4141
@AppSettings(\.textEditing.bracketHighlight)
4242
var bracketHighlight
43+
@AppSettings(\.textEditing.useSystemCursor)
44+
var useSystemCursor
4345

4446
@Environment(\.colorScheme)
4547
private var colorScheme
@@ -121,6 +123,7 @@ struct CodeFileView: View {
121123
isEditable: isEditable,
122124
letterSpacing: letterSpacing,
123125
bracketPairHighlight: bracketPairHighlight,
126+
useSystemCursor: useSystemCursor,
124127
undoManager: undoManager,
125128
coordinators: textViewCoordinators
126129
)

CodeEdit/Features/Settings/Pages/TextEditingSettings/Models/TextEditingSettings.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ extension SettingsData {
5959
/// The behavior of bracket pair highlights.
6060
var bracketHighlight: BracketPairHighlight = BracketPairHighlight()
6161

62+
/// Use the system cursor for the source editor.
63+
var useSystemCursor: Bool = true
64+
6265
/// Default initializer
6366
init() {
6467
self.populateCommands()
@@ -97,6 +100,11 @@ extension SettingsData {
97100
BracketPairHighlight.self,
98101
forKey: .bracketHighlight
99102
) ?? BracketPairHighlight()
103+
if #available(macOS 14, *) {
104+
self.useSystemCursor = try container.decodeIfPresent(Bool.self, forKey: .useSystemCursor) ?? true
105+
} else {
106+
self.useSystemCursor = false
107+
}
100108

101109
self.populateCommands()
102110
}

CodeEdit/Features/Settings/Pages/TextEditingSettings/TextEditingSettingsView.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ struct TextEditingSettingsView: View {
1818
indentOption
1919
defaultTabWidth
2020
wrapLinesToEditorWidth
21+
useSystemCursor
2122
}
2223
Section {
2324
fontSelector
@@ -71,6 +72,14 @@ private extension TextEditingSettingsView {
7172
Toggle("Wrap lines to editor width", isOn: $textEditing.wrapLinesToEditorWidth)
7273
}
7374

75+
@ViewBuilder private var useSystemCursor: some View {
76+
if #available(macOS 14, *) {
77+
Toggle("Use System Cursor", isOn: $textEditing.useSystemCursor)
78+
} else {
79+
EmptyView()
80+
}
81+
}
82+
7483
@ViewBuilder private var lineHeight: some View {
7584
Stepper(
7685
"Line Height",

0 commit comments

Comments
 (0)