https://github.com/krzyzanowskim/sttextkitplus
Collection of TextKit 2 helpers used to build STTextView.
https://github.com/krzyzanowskim/sttextkitplus
sttextview textkit textkit2
Last synced: about 1 year ago
JSON representation
Collection of TextKit 2 helpers used to build STTextView.
- Host: GitHub
- URL: https://github.com/krzyzanowskim/sttextkitplus
- Owner: krzyzanowskim
- License: bsd-3-clause
- Created: 2023-10-19T11:39:24.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-04-06T11:40:26.000Z (about 2 years ago)
- Last Synced: 2024-04-14T07:11:18.713Z (about 2 years ago)
- Topics: sttextview, textkit, textkit2
- Language: Swift
- Homepage: https://github.com/krzyzanowskim/STTextView
- Size: 23.4 KB
- Stars: 15
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Collection of useful [TextKit 2](https://developer.apple.com/documentation/appkit/textkit) helpers.
Collection of TextKit 2 helpers used to build [STTextView](https://github.com/krzyzanowskim/STTextView).
## Usage
### NSRange Additions
```swift
NSRange.notFound
NSRange.isEmpty
NSRange.nsValue
NSRange(_ textRange: NSTextRange, in textContentManager: NSTextContentManager)
NSRange(_ textLocation: NSTextLocation, in textContentManager: NSTextContentManager)
```
### NSTextRange Additions
```swift
NSTextRange(_ nsRange: NSRange, in textContentManager: NSTextContentManager)
func length(in textContentManager: NSTextContentManager) -> Int
func clamped(to textRange: NSTextRange) -> NSTextRange?
```
### NSTextContentManager Additions
```swift
func location(at offset: Int) -> NSTextLocation?
func location(line lineIdx: Int, character characterIdx: Int? = 0) -> NSTextLocation?
func position(_ location: NSTextLocation) -> (row: Int, column: Int)?
func attributedString(in range: NSTextRange?) -> NSAttributedString?
```
### NSTextLayoutManager Additions
```swift
func textLineFragment(at location: NSTextLocation) -> NSTextLineFragment?
func textLineFragment(at point: CGPoint) -> NSTextLineFragment?
func extraLineTextLayoutFragment() -> NSTextLayoutFragment?
func extraLineTextLineFragment() -> NSTextLineFragment?
func location(interactingAt point: CGPoint, inContainerAt containerLocation: NSTextLocation) -> NSTextLocation?
func textSegmentFrame(at location: NSTextLocation, type: NSTextLayoutManager.SegmentType, options: SegmentOptions = [.upstreamAffinity]) -> CGRect?
func textSegmentFrame(in textRange: NSTextRange, type: NSTextLayoutManager.SegmentType, options: SegmentOptions = [.upstreamAffinity, .rangeNotRequired]) -> CGRect?
func typographicBounds(in textRange: NSTextRange) -> CGRect?
func enumerateTextLayoutFragments(in range: NSTextRange, options: NSTextLayoutFragment.EnumerationOptions = [], using block: (NSTextLayoutFragment) -> Bool) -> NSTextLocation?
var insertionPointLocations: [NSTextLocation]
var insertionPointSelections: [NSTextSelection]
```
### NSTextLayoutFragment Additions
```swift
var isExtraLineFragment: Bool
func textLineFragment(at location: NSTextLocation, in textContentManager: NSTextContentManager? = nil) -> NSTextLineFragment?
func textLineFragment(at location: CGPoint, in textContentManager: NSTextContentManager? = nil) -> NSTextLineFragment?
```
### NSTextLineFragment Additions
```swift
textRange(in textLayoutFragment: NSTextLayoutFragment) -> NSTextRange?
var isExtraLineFragment: Bool
```
### NSTextLocation Addition
```swift
static func == (lhs: Self, rhs: Self) -> Bool
static func != (lhs: Self, rhs: Self) -> Bool
static func < (lhs: Self, rhs: Self) -> Bool
static func <= (lhs: Self, rhs: Self) -> Bool
static func > (lhs: Self, rhs: Self) -> Bool
static func >= (lhs: Self, rhs: Self) -> Bool
static func ~= (lhs: Self, rhs: Self) -> Bool
```
## Contributing and Collaboration
I'd love to hear from you! Get in touch via an issue or pull request.