aboutsummaryrefslogtreecommitdiff
path: root/Map/Presentation/Base Components/MapTextEditor/MapTextEditor.swift
diff options
context:
space:
mode:
authorRuben Beltran del Rio <git@r.bdr.sh>2025-07-11 10:52:37 +0200
committerRuben Beltran del Rio <git@r.bdr.sh>2025-07-11 10:52:37 +0200
commitceb1654ced23d545e1b2437751a70113cb1a2d2a (patch)
treeb1ed19aa19929e16cd771e1cfa0faf656c4ff273 /Map/Presentation/Base Components/MapTextEditor/MapTextEditor.swift
parent8564439356f4bcc3e21b19738eb87b4c0722c623 (diff)
Improve text rendering and component detection.
Diffstat (limited to 'Map/Presentation/Base Components/MapTextEditor/MapTextEditor.swift')
-rw-r--r--Map/Presentation/Base Components/MapTextEditor/MapTextEditor.swift15
1 files changed, 10 insertions, 5 deletions
diff --git a/Map/Presentation/Base Components/MapTextEditor/MapTextEditor.swift b/Map/Presentation/Base Components/MapTextEditor/MapTextEditor.swift
index 6a1be83..c6ab483 100644
--- a/Map/Presentation/Base Components/MapTextEditor/MapTextEditor.swift
+++ b/Map/Presentation/Base Components/MapTextEditor/MapTextEditor.swift
@@ -85,6 +85,7 @@ class MapTextEditorController: NSViewController {
textView.string = self.text
textView.isEditable = true
textView.font = NSFont.Theme.Editor.regular
+ textView.textColor = NSColor.Theme.Syntax.text
textView.textContainerInset = NSSize(
width: Dimensions.Spacing.coziest, height: Dimensions.Spacing.coziest)
@@ -204,6 +205,7 @@ class MapTextEditorController: NSViewController {
private func handleMouseEvent(_ event: NSEvent) {
// Don't handle mouse events if we're already hovering over the hover view
if isHoveringHoverView {
+ NSCursor.arrow.set()
return
}
@@ -394,19 +396,22 @@ extension MapTextEditorController: NSTextStorageDelegate {
private func colorizeEditedText(textStorage: NSTextStorage, editedRange: NSRange) {
let string = textStorage.string as NSString
let lineRange = string.lineRange(for: editedRange)
-
- textStorage.removeAttribute(.foregroundColor, range: lineRange)
- textStorage.removeAttribute(.underlineStyle, range: lineRange)
- textStorage.removeAttribute(.underlineColor, range: lineRange)
- syntaxHighlighter.applySyntaxHighlighting(textStorage: textStorage, range: lineRange)
+ colorizeTextRange(textStorage: textStorage, range: lineRange)
}
private func colorizeText(textStorage: NSTextStorage) {
let range = NSMakeRange(0, textStorage.length)
+ colorizeTextRange(textStorage: textStorage, range: range)
+ }
+ private func colorizeTextRange(textStorage: NSTextStorage, range: NSRange) {
textStorage.removeAttribute(.foregroundColor, range: range)
textStorage.removeAttribute(.underlineStyle, range: range)
textStorage.removeAttribute(.underlineColor, range: range)
+
+ // Set default text color for the range
+ textStorage.addAttribute(.foregroundColor, value: NSColor.Theme.Syntax.text, range: range)
+
syntaxHighlighter.applySyntaxHighlighting(textStorage: textStorage, range: range)
}
}