Lines Matching refs:text

17 package android.text;
19 import java.text.BreakIterator;
37 public static final int getSelectionStart(CharSequence text) {
38 if (text instanceof Spanned)
39 return ((Spanned) text).getSpanStart(SELECTION_START);
48 public static final int getSelectionEnd(CharSequence text) {
49 if (text instanceof Spanned)
50 return ((Spanned) text).getSpanStart(SELECTION_END);
67 public static void setSelection(Spannable text, int start, int stop) {
68 // int len = text.length();
72 int ostart = getSelectionStart(text);
73 int oend = getSelectionEnd(text);
76 text.setSpan(SELECTION_START, start, start,
78 text.setSpan(SELECTION_END, stop, stop,
86 public static final void setSelection(Spannable text, int index) {
87 setSelection(text, index, index);
91 * Select the entire text.
93 public static final void selectAll(Spannable text) {
94 setSelection(text, 0, text.length());
100 public static final void extendSelection(Spannable text, int index) {
101 if (text.getSpanStart(SELECTION_END) != index)
102 text.setSpan(SELECTION_END, index, index, Spanned.SPAN_POINT_POINT);
106 * Remove the selection or cursor, if any, from the text.
108 public static final void removeSelection(Spannable text) {
109 text.removeSpan(SELECTION_START);
110 text.removeSpan(SELECTION_END);
121 public static boolean moveUp(Spannable text, Layout layout) {
122 int start = getSelectionStart(text);
123 int end = getSelectionEnd(text);
129 setSelection(text, min);
131 if (min == 0 && max == text.length()) {
150 setSelection(text, move);
162 public static boolean moveDown(Spannable text, Layout layout) {
163 int start = getSelectionStart(text);
164 int end = getSelectionEnd(text);
170 setSelection(text, max);
172 if (min == 0 && max == text.length()) {
191 setSelection(text, move);
204 public static boolean moveLeft(Spannable text, Layout layout) {
205 int start = getSelectionStart(text);
206 int end = getSelectionEnd(text);
209 setSelection(text, chooseHorizontal(layout, -1, start, end));
215 setSelection(text, to);
229 public static boolean moveRight(Spannable text, Layout layout) {
230 int start = getSelectionStart(text);
231 int end = getSelectionEnd(text);
234 setSelection(text, chooseHorizontal(layout, 1, start, end));
240 setSelection(text, to);
252 public static boolean extendUp(Spannable text, Layout layout) {
253 int end = getSelectionEnd(text);
267 extendSelection(text, move);
270 extendSelection(text, 0);
281 public static boolean extendDown(Spannable text, Layout layout) {
282 int end = getSelectionEnd(text);
296 extendSelection(text, move);
298 } else if (end != text.length()) {
299 extendSelection(text, text.length());
310 public static boolean extendLeft(Spannable text, Layout layout) {
311 int end = getSelectionEnd(text);
315 extendSelection(text, to);
326 public static boolean extendRight(Spannable text, Layout layout) {
327 int end = getSelectionEnd(text);
331 extendSelection(text, to);
338 public static boolean extendToLeftEdge(Spannable text, Layout layout) {
339 int where = findEdge(text, layout, -1);
340 extendSelection(text, where);
344 public static boolean extendToRightEdge(Spannable text, Layout layout) {
345 int where = findEdge(text, layout, 1);
346 extendSelection(text, where);
350 public static boolean moveToLeftEdge(Spannable text, Layout layout) {
351 int where = findEdge(text, layout, -1);
352 setSelection(text, where);
356 public static boolean moveToRightEdge(Spannable text, Layout layout) {
357 int where = findEdge(text, layout, 1);
358 setSelection(text, where);
372 Spannable text, PositionIterator iter, boolean extendSelection) {
373 final int offset = iter.preceding(getSelectionEnd(text));
376 extendSelection(text, offset);
378 setSelection(text, offset);
386 Spannable text, PositionIterator iter, boolean extendSelection) {
387 final int offset = iter.following(getSelectionEnd(text));
390 extendSelection(text, offset);
392 setSelection(text, offset);
398 private static int findEdge(Spannable text, Layout layout, int dir) {
399 int pt = getSelectionEnd(text);
443 // depends upon the directionality of the text