diff options
Diffstat (limited to 'Map/Presentation/Base Components/MapTextEditor/MapTextEditor.swift')
| -rw-r--r-- | Map/Presentation/Base Components/MapTextEditor/MapTextEditor.swift | 15 |
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) } } |