diff --git a/README.md b/README.md index 8f65345..215bdbe 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ import NeonPlugin textView.addPlugin( NeonPlugin( theme: .default, - language: .go + language: .swift ) ) ``` @@ -29,7 +29,7 @@ struct ContentView: View { text: $text, selection: $selection, options: [.wrapLines, .highlightSelectedLine], - plugins: [NeonPlugin(theme: .default, language: .go)] + plugins: [NeonPlugin(theme: .default, language: .swift)] ) .textViewFont(.monospacedDigitSystemFont(ofSize: NSFont.systemFontSize, weight: .regular)) .onAppear { diff --git a/Sources/NeonPlugin/Coordinator.swift b/Sources/NeonPlugin/Coordinator.swift index dc249a6..af62eee 100644 --- a/Sources/NeonPlugin/Coordinator.swift +++ b/Sources/NeonPlugin/Coordinator.swift @@ -64,7 +64,12 @@ public class Coordinator { // initial parse of the whole content tsClient.willChangeContent(in: NSRange(textView.textContentManager.documentRange, in: textView.textContentManager)) - tsClient.didChangeContent(in: NSRange(textView.textContentManager.documentRange, in: textView.textContentManager), delta: textView.textContentManager.length, limit: textView.textContentManager.length, readHandler: Parser.readFunction(for: textView.textContentManager.attributedString(in: nil)?.string ?? ""), completionHandler: {}) + tsClient.didChangeContent(in: NSRange(textView.textContentManager.documentRange, in: textView.textContentManager), + delta: textView.textContentManager.length, + limit: textView.textContentManager.length, + readHandler: Parser.readFunction(for: textView.textContentManager.attributedString(in: nil)?.string ?? ""), + completionHandler: { + }) } private func tokenProvider(textContentManager: NSTextContentManager) -> Neon.TokenProvider? { diff --git a/Sources/NeonPlugin/STTextViewSystemInterface.swift b/Sources/NeonPlugin/STTextViewSystemInterface.swift index 3c9b0cb..9b9551a 100644 --- a/Sources/NeonPlugin/STTextViewSystemInterface.swift +++ b/Sources/NeonPlugin/STTextViewSystemInterface.swift @@ -20,7 +20,7 @@ class STTextViewSystemInterface: TextSystemInterface { return } - textView.textLayoutManager.removeRenderingAttribute(.foregroundColor, for: textRange) + textView.removeAttribute(.foregroundColor, range: textRange) if let defaultFont = textView.font { textView.addAttributes([.font: defaultFont], range: range) } @@ -34,7 +34,7 @@ class STTextViewSystemInterface: TextSystemInterface { } for attr in attrs { - textView.textLayoutManager.addRenderingAttribute(attr.key, value: attr.value, for: textRange) + textView.addAttributes([attr.key: attr.value], range: textRange) } } diff --git a/Sources/NeonPlugin/Theme+Default.swift b/Sources/NeonPlugin/Theme+Default.swift index 43af1e6..6f093fe 100644 --- a/Sources/NeonPlugin/Theme+Default.swift +++ b/Sources/NeonPlugin/Theme+Default.swift @@ -8,8 +8,8 @@ extension Theme { tokensCustomFontDict: [ "default": NSFont.monospacedSystemFont(ofSize: 0, weight: .regular), "keyword": NSFont.monospacedSystemFont(ofSize: 0, weight: .bold), - "constructor": NSFont.monospacedSystemFont(ofSize: 0, weight: .bold) - + "constructor": NSFont.monospacedSystemFont(ofSize: 0, weight: .bold), + "text.title": NSFont.monospacedSystemFont(ofSize: 0, weight: .bold) ] ) } diff --git a/Sources/NeonPlugin/Theme.swift b/Sources/NeonPlugin/Theme.swift index 74bedf4..28b169b 100644 --- a/Sources/NeonPlugin/Theme.swift +++ b/Sources/NeonPlugin/Theme.swift @@ -13,15 +13,15 @@ public struct Theme { } public var defaultFont: NSFont? { - return tokensCustomFontDict["default"] + tokensCustomFontDict["default"] } public var defaultColor: NSColor? { - return color(forToken: "default") + color(forToken: "default") } public func color(forToken tokenName: TokenName) -> NSColor? { - return colors.color(forToken: tokenName) + colors.color(forToken: tokenName) } public func font(forToken tokenName: TokenName) -> NSFont? {