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);
122 public static boolean moveUp(Spannable text, Layout layout) {
123 int start = getSelectionStart(text);
124 int end = getSelectionEnd(text);
130 setSelection(text, min);
132 if (min == 0 && max == text.length()) {
151 setSelection(text, move);
154 setSelection(text, 0);
168 public static boolean moveDown(Spannable text, Layout layout) {
169 int start = getSelectionStart(text);
170 int end = getSelectionEnd(text);
176 setSelection(text, max);
178 if (min == 0 && max == text.length()) {
197 setSelection(text, move);
199 } else if (end != text.length()) {
200 setSelection(text, text.length());
213 public static boolean moveLeft(Spannable text, Layout layout) {
214 int start = getSelectionStart(text);
215 int end = getSelectionEnd(text);
218 setSelection(text, chooseHorizontal(layout, -1, start, end));
224 setSelection(text, to);
238 public static boolean moveRight(Spannable text, Layout layout) {
239 int start = getSelectionStart(text);
240 int end = getSelectionEnd(text);
243 setSelection(text, chooseHorizontal(layout, 1, start, end));
249 setSelection(text, to);
261 public static boolean extendUp(Spannable text, Layout layout) {
262 int end = getSelectionEnd(text);
276 extendSelection(text, move);
279 extendSelection(text, 0);
290 public static boolean extendDown(Spannable text, Layout layout) {
291 int end = getSelectionEnd(text);
305 extendSelection(text, move);
307 } else if (end != text.length()) {
308 extendSelection(text, text.length());
319 public static boolean extendLeft(Spannable text, Layout layout) {
320 int end = getSelectionEnd(text);
324 extendSelection(text, to);
335 public static boolean extendRight(Spannable text, Layout layout) {
336 int end = getSelectionEnd(text);
340 extendSelection(text, to);
347 public static boolean extendToLeftEdge(Spannable text, Layout layout) {
348 int where = findEdge(text, layout, -1);
349 extendSelection(text, where);
353 public static boolean extendToRightEdge(Spannable text, Layout layout) {
354 int where = findEdge(text, layout, 1);
355 extendSelection(text, where);
359 public static boolean moveToLeftEdge(Spannable text, Layout layout) {
360 int where = findEdge(text, layout, -1);
361 setSelection(text, where);
365 public static boolean moveToRightEdge(Spannable text, Layout layout) {
366 int where = findEdge(text, layout, 1);
367 setSelection(text, where);
381 Spannable text, PositionIterator iter, boolean extendSelection) {
382 final int offset = iter.preceding(getSelectionEnd(text));
385 extendSelection(text, offset);
387 setSelection(text, offset);
395 Spannable text, PositionIterator iter, boolean extendSelection) {
396 final int offset = iter.following(getSelectionEnd(text));
399 extendSelection(text, offset);
401 setSelection(text, offset);
407 private static int findEdge(Spannable text, Layout layout, int dir) {
408 int pt = getSelectionEnd(text);
452 // depends upon the directionality of the text