Skip to content

Commit

Permalink
TextRange initializer, NSTextSelection.Granularity -> TextGranularity
Browse files Browse the repository at this point in the history
  • Loading branch information
mattmassicotte committed Sep 2, 2024
1 parent c415ac7 commit 682d26a
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions Sources/Ligature/Platform.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ open class TextRange: NSObject {
self.end = UTF16TextPosition(value: 0)
}

init(start: TextPosition, end: TextPosition) {
self.start = start
self.end = end
}

var isEmpty: Bool {
return true
}
Expand Down Expand Up @@ -197,4 +202,21 @@ extension NSTextSelection.Granularity {
self = .character
}
}

public var textGranularity: TextGranularity {
switch self {
case .character:
.character
case .line:
.line
case .paragraph:
.paragraph
case .sentence:
.sentence
case .word:
.word
@unknown default:
.character
}
}
}

0 comments on commit 682d26a

Please sign in to comment.