core/textfield/selection.go
Functions
func ClearSelection
func (s *selection) ClearSelection() {
s.anchor = s.cursor
}
func HasSelection
HasSelection returns true if text is selected (anchor != cursor).
func (s *selection) HasSelection() bool {
return s.anchor != s.cursor
}
func OrderedRange
OrderedRange returns the selection range as (start, end) where start <= end.
func (s *selection) OrderedRange() (int, int) {
if s.anchor <= s.cursor {
return s.anchor, s.cursor
}
return s.cursor, s.anchor
}
func SelectAll
SelectAll selects all text given the total rune count.
func (s *selection) SelectAll(runeCount int) {
s.anchor = 0
s.cursor = runeCount
}
func SetCursor
SetCursor moves the cursor to the given position and clears selection.
func (s *selection) SetCursor(pos int) {
s.cursor = pos
s.anchor = pos
}
func SetCursorKeepSelection
SetCursorKeepSelection moves the cursor without clearing the anchor,
extending or shrinking the selection.
func (s *selection) SetCursorKeepSelection(pos int) {
s.cursor = pos
}
ClearSelection collapses the selection to the cursor position.