diff --git a/README.md b/README.md index 3db556b..5011c56 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ dependencies: [ ### `NSTextContainer` Additions ```swift -func textSet(for rect: CGRect) -> IndexSet +func characterIndexes(within rect: CGRect) -> IndexSet func enumerateLineFragments(for rect: CGRect, strictIntersection: Bool, block: (CGRect, NSRange, inout Bool) -> Void) func enumerateLineFragments(in range: NSRange, block: (CGRect, NSRange, inout Bool) -> Void) ``` @@ -45,8 +45,9 @@ func enumerateLineFragments(with provider: NSTextElementProvider, block: (NSText ### `NSTextView`/`UITextView` Additions -```swift -var visibleTextSet: IndexSet +``` +func characterIndexes(within rect: CGRect) -> IndexSet +var visibleCharacterIndexes: IndexSet ``` ## Contributing and Collaboration diff --git a/Sources/Glyph/NSTextContainer+Additions.swift b/Sources/Glyph/NSTextContainer+Additions.swift index 4603c56..9c123da 100644 --- a/Sources/Glyph/NSTextContainer+Additions.swift +++ b/Sources/Glyph/NSTextContainer+Additions.swift @@ -54,7 +54,7 @@ extension NSTextContainer { } /// Returns an IndexSet representing the content within `rect`. - public func textSet(for rect: CGRect) -> IndexSet { + public func characterIndexes(within rect: CGRect) -> IndexSet { var set = IndexSet() enumerateLineFragments(for: rect, strictIntersection: true) { _, range, _ in diff --git a/Sources/Glyph/NSTextView+Additions.swift b/Sources/Glyph/NSTextView+Additions.swift index 39f3463..e589df9 100644 --- a/Sources/Glyph/NSTextView+Additions.swift +++ b/Sources/Glyph/NSTextView+Additions.swift @@ -21,17 +21,17 @@ extension TextView { } /// Returns an IndexSet representing the content within `rect`. - public func textSet(for rect: CGRect) -> IndexSet { + public func characterIndexes(within rect: CGRect) -> IndexSet { #if os(macOS) && !targetEnvironment(macCatalyst) - return textContainer?.textSet(for: rect) ?? IndexSet() + return textContainer?.characterIndexes(within: rect) ?? IndexSet() #elseif os(iOS) || os(visionOS) - return textContainer.textSet(for: rect) + return textContainer.characterIndexes(within: rect) #endif } /// Returns an IndexSet representing the visible content. - public var visibleTextSet: IndexSet { - textSet(for: visibleContainerRect) + public var visibleCharacterIndexes: IndexSet { + characterIndexes(within: visibleContainerRect) } } #endif