Skip to content

Commit

Permalink
Improve selection
Browse files Browse the repository at this point in the history
  • Loading branch information
krzyzanowskim committed Jan 28, 2023
1 parent 6f1aa4a commit f9c8a1b
Showing 1 changed file with 21 additions and 24 deletions.
45 changes: 21 additions & 24 deletions Sources/STTextView/STTextView+Select.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,48 +17,45 @@ extension STTextView {
}

open override func selectLine(_ sender: Any?) {
guard let startSelection = textLayoutManager.textSelections.first else {
return
}

textLayoutManager.textSelections = [
textLayoutManager.textSelectionNavigation.textSelection(
for: .line,
enclosing: startSelection
for textSelection in textLayoutManager.textSelections {
textLayoutManager.textSelections.append(
textLayoutManager.textSelectionNavigation.textSelection(
for: .line,
enclosing: textSelection
)
)
]
}

needScrollToSelection = true
needsDisplay = true
}

open override func selectWord(_ sender: Any?) {
guard let startSelection = textLayoutManager.textSelections.first else {
return
}

textLayoutManager.textSelections = [
textLayoutManager.textSelectionNavigation.textSelection(
for: .word,
enclosing: startSelection
for textSelection in textLayoutManager.textSelections {
textLayoutManager.textSelections.append(
textLayoutManager.textSelectionNavigation.textSelection(
for: .word,
enclosing: textSelection
)
)
]
}

needScrollToSelection = true
needsDisplay = true
}

open override func selectParagraph(_ sender: Any?) {
guard let startSelection = textLayoutManager.textSelections.first else {
return
}

textLayoutManager.textSelections = [
textLayoutManager.textSelectionNavigation.textSelection(
for: .paragraph,
enclosing: startSelection
for textSelection in textLayoutManager.textSelections {
textLayoutManager.textSelections.append(
textLayoutManager.textSelectionNavigation.textSelection(
for: .paragraph,
enclosing: textSelection
)
)
]
}

needScrollToSelection = true
needsDisplay = true
Expand Down

0 comments on commit f9c8a1b

Please sign in to comment.