Package icyllis.modernui.text
Class Selection
java.lang.Object
icyllis.modernui.text.Selection
Utility class for manipulating cursors and selections in CharSequences.
A cursor is a selection where the start and end are at the same offset.
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
extendDown
(Spannable text, Layout layout) Move the selection end to the buffer offset physically below the current selection end.static boolean
extendLeft
(Spannable text, Layout layout) Move the selection end to the buffer offset physically to the left of the current selection end.static boolean
extendRight
(Spannable text, Layout layout) Move the selection end to the buffer offset physically to the right of the current selection end.static void
extendSelection
(Spannable text, int index) Move the selection edge to offsetindex
.static boolean
extendToLeftEdge
(Spannable text, Layout layout) static boolean
extendToRightEdge
(Spannable text, Layout layout) static boolean
Move the selection end to the buffer offset physically above the current selection end.static int
getSelectionEnd
(CharSequence text) Return the offset of the selection edge or cursor, or -1 if there is no selection or cursor.static int
Return the offset of the selection anchor or cursor, or -1 if there is no selection or cursor.static boolean
Move the cursor to the buffer offset physically below the current offset, to the end of the buffer if it is on the bottom line but not at the end, or return false if the cursor is already at the end of the buffer.static boolean
Move the cursor to the buffer offset physically to the left of the current offset, or return false if the cursor is already at the left edge of the line and there is not another line to move it to.static boolean
Move the cursor to the buffer offset physically to the right of the current offset, or return false if the cursor is already at at the right edge of the line and there is not another line to move it to.static boolean
moveToFollowing
(Spannable text, WordIterator iter, boolean extendSelection) static boolean
moveToLeftEdge
(Spannable text, Layout layout) static boolean
moveToPreceding
(Spannable text, WordIterator iter, boolean extendSelection) static boolean
moveToRightEdge
(Spannable text, Layout layout) static boolean
Move the cursor to the buffer offset physically above the current offset, to the beginning if it is on the top line but not at the start, or return false if the cursor is already on the top line.static void
removeSelection
(Spannable text) Remove the selection or cursor, if any, from the text.static void
Select the entire text.static void
setSelection
(Spannable text, int index) Move the cursor to offsetindex
.static void
setSelection
(Spannable text, int start, int stop) Set the selection anchor tostart
and the selection edge tostop
.
-
Field Details
-
SELECTION_START
-
SELECTION_END
-
-
Method Details
-
getSelectionStart
Return the offset of the selection anchor or cursor, or -1 if there is no selection or cursor. -
getSelectionEnd
Return the offset of the selection edge or cursor, or -1 if there is no selection or cursor. -
setSelection
Set the selection anchor tostart
and the selection edge tostop
. -
setSelection
Move the cursor to offsetindex
. -
selectAll
Select the entire text. -
extendSelection
Move the selection edge to offsetindex
. -
removeSelection
Remove the selection or cursor, if any, from the text. -
moveUp
Move the cursor to the buffer offset physically above the current offset, to the beginning if it is on the top line but not at the start, or return false if the cursor is already on the top line. -
moveDown
Move the cursor to the buffer offset physically below the current offset, to the end of the buffer if it is on the bottom line but not at the end, or return false if the cursor is already at the end of the buffer. -
moveLeft
Move the cursor to the buffer offset physically to the left of the current offset, or return false if the cursor is already at the left edge of the line and there is not another line to move it to. -
moveRight
Move the cursor to the buffer offset physically to the right of the current offset, or return false if the cursor is already at at the right edge of the line and there is not another line to move it to. -
extendUp
Move the selection end to the buffer offset physically above the current selection end. -
extendDown
Move the selection end to the buffer offset physically below the current selection end. -
extendLeft
Move the selection end to the buffer offset physically to the left of the current selection end. -
extendRight
Move the selection end to the buffer offset physically to the right of the current selection end. -
extendToLeftEdge
-
extendToRightEdge
-
moveToLeftEdge
-
moveToRightEdge
-
moveToPreceding
-
moveToFollowing
-