/// <summary> /// Move the selection end to the buffer offset physically below /// the current selection end. /// </summary> /// <remarks> /// Move the selection end to the buffer offset physically below /// the current selection end. /// </remarks> public static bool extendDown(android.text.Spannable text, android.text.Layout layout ) { int end = getSelectionEnd(text); int line = layout.getLineForOffset(end); if (line < layout.getLineCount() - 1) { int move; if (layout.getParagraphDirection(line) == layout.getParagraphDirection(line + 1)) { float h = layout.getPrimaryHorizontal(end); move = layout.getOffsetForHorizontal(line + 1, h); } else { move = layout.getLineStart(line + 1); } extendSelection(text, move); return(true); } else { if (end != text.Length) { extendSelection(text, text.Length); return(true); } } return(true); }
/// <summary> /// Move the cursor to the buffer offset physically below the current /// offset, or return false if the cursor is already on the bottom line. /// </summary> /// <remarks> /// Move the cursor to the buffer offset physically below the current /// offset, or return false if the cursor is already on the bottom line. /// </remarks> public static bool moveDown(android.text.Spannable text, android.text.Layout layout ) { int start = getSelectionStart(text); int end = getSelectionEnd(text); if (start != end) { int min = System.Math.Min(start, end); int max = System.Math.Max(start, end); setSelection(text, max); if (min == 0 && max == text.Length) { return(false); } return(true); } else { int line = layout.getLineForOffset(end); if (line < layout.getLineCount() - 1) { int move; if (layout.getParagraphDirection(line) == layout.getParagraphDirection(line + 1)) { float h = layout.getPrimaryHorizontal(end); move = layout.getOffsetForHorizontal(line + 1, h); } else { move = layout.getLineStart(line + 1); } setSelection(text, move); return(true); } } return(false); }