diff --git a/Edit.xcodeproj/project.pbxproj b/Edit.xcodeproj/project.pbxproj index 595943d..75f3640 100644 --- a/Edit.xcodeproj/project.pbxproj +++ b/Edit.xcodeproj/project.pbxproj @@ -5440,7 +5440,7 @@ repositoryURL = "https://github.com/ChimeHQ/Glyph"; requirement = { kind = revision; - revision = 28adcfc8585d119fac720dcb0c9123ee2148efec; + revision = 3c8095830e9b682f22bdaa866a1f2061998e40cc; }; }; C9C568562B7418B60093C068 /* XCRemoteSwiftPackageReference "Lowlight" */ = { diff --git a/Edit.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Edit.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index b0f4a0f..e4ea11f 100644 --- a/Edit.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/Edit.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -76,7 +76,7 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/ChimeHQ/Glyph", "state" : { - "revision" : "28adcfc8585d119fac720dcb0c9123ee2148efec" + "revision" : "3c8095830e9b682f22bdaa866a1f2061998e40cc" } }, { diff --git a/Edit/Modules/TextSystem/TextPresentation.swift b/Edit/Modules/TextSystem/TextPresentation.swift index 03cbff5..f8e9d42 100644 --- a/Edit/Modules/TextSystem/TextPresentation.swift +++ b/Edit/Modules/TextSystem/TextPresentation.swift @@ -1,7 +1,7 @@ import Foundation +import Glyph import NSUI -import Rearrange public struct TextPresentation { public let applyRenderingStyle: ([NSAttributedString.Key : Any], NSRange) -> Void @@ -10,44 +10,9 @@ public struct TextPresentation { extension TextPresentation { @MainActor public init(textView: NSUITextView) { - if let textLayoutManager = textView.textLayoutManager { - self.init(textLayoutManager: textLayoutManager, textView: textView) - } else { - self.init(layoutManager: textView.nsuiLayoutManager!) - } - } - - @MainActor - public init(textLayoutManager: NSTextLayoutManager, textView: NSUITextView) { - self.init( - applyRenderingStyle: { attrs, range in - guard - let contentManager = textLayoutManager.textContentManager, - let textRange = NSTextRange(range, provider: contentManager) - else { - return - } - - let selection = textView.selectedRanges - - textLayoutManager.setRenderingAttributes(attrs, for: textRange) - - textView.selectedRanges = [NSValue(range: range)] - - textView.selectedRanges = selection - } - ) - } - - @MainActor - public init(layoutManager: NSLayoutManager) { self.init( applyRenderingStyle: { attrs, range in -#if os(macOS) - layoutManager.setTemporaryAttributes(attrs, forCharacterRange: range) -#else - print("unsupported rendering style") -#endif + textView.setRenderingAttributes(attrs, for: range) } ) }