diff options
author | Roopesh Chander <roop@roopc.net> | 2019-01-22 01:19:16 +0530 |
---|---|---|
committer | Roopesh Chander <roop@roopc.net> | 2019-01-22 01:19:16 +0530 |
commit | 1bc21778833c2031d6f10819a9f19ff1d7a00648 (patch) | |
tree | 327bbf2393fc03c7fe1315755735ce280c44f363 /WireGuard/WireGuard/UI/macOS/View/ConfTextStorage.swift | |
parent | macOS: Refactor syntax highlighting (diff) | |
download | wireguard-apple-1bc21778833c2031d6f10819a9f19ff1d7a00648.tar.xz wireguard-apple-1bc21778833c2031d6f10819a9f19ff1d7a00648.zip |
macOS: Reset attributes for each syntax highlight cycle
Signed-off-by: Roopesh Chander <roop@roopc.net>
Diffstat (limited to 'WireGuard/WireGuard/UI/macOS/View/ConfTextStorage.swift')
-rw-r--r-- | WireGuard/WireGuard/UI/macOS/View/ConfTextStorage.swift | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/WireGuard/WireGuard/UI/macOS/View/ConfTextStorage.swift b/WireGuard/WireGuard/UI/macOS/View/ConfTextStorage.swift index 0a38d4e..511a35c 100644 --- a/WireGuard/WireGuard/UI/macOS/View/ConfTextStorage.swift +++ b/WireGuard/WireGuard/UI/macOS/View/ConfTextStorage.swift @@ -85,7 +85,16 @@ class ConfTextStorage: NSTextStorage { hasError = false privateKeyString = nil + let fullTextRange = NSRange(location: 0, length: (backingStore.string as NSString).length) + backingStore.beginEditing() + if let textColorTheme = textColorTheme { + let defaultAttributes: [NSAttributedString.Key: Any] = [ + .foregroundColor: textColorTheme.defaultColor, + .font: defaultFont + ] + backingStore.setAttributes(defaultAttributes, range: fullTextRange) + } var spans = highlight_config(backingStore.string.cString(using: String.Encoding.utf8))! while spans.pointee.type != HighlightEnd { @@ -111,7 +120,7 @@ class ConfTextStorage: NSTextStorage { backingStore.endEditing() beginEditing() - edited(.editedAttributes, range: NSRange(location: 0, length: (backingStore.string as NSString).length), changeInLength: 0) + edited(.editedAttributes, range: fullTextRange, changeInLength: 0) endEditing() } |