private string CreateIndentForNextLine(ISpanned dest, int dend, int istart) { if (istart > -1) { int iend; for (iend = ++istart; iend < dend; ++iend) { char c = dest.CharAt(iend); if (c != ' ' && c != '\t') { break; } } var subsequence = dest.SubSequence(istart, iend); return(subsequence + AddBulletPointIfNeeded(dest.CharAt(iend))); } else { return(""); } }
private int FindLineBreakPosition(ISpanned dest, int dstart) { int istart = dstart - 1; for (; istart > -1; --istart) { char c = dest.CharAt(istart); if (c == '\n') { break; } } return(istart); }
public override ICharSequence FilterFormatted(ICharSequence source, int start, int end, ISpanned dest, int dstart, int dend) { // Borrowed heavily from the Android source ICharSequence filterFormatted = base.FilterFormatted(source, start, end, dest, dstart, dend); if (filterFormatted != null) { source = filterFormatted; start = 0; end = filterFormatted.Length(); } int sign = -1; int dec = -1; int dlen = dest.Length(); // Find out if the existing text has a sign or decimal point characters. for (var i = 0; i < dstart; i++) { char c = dest.CharAt(i); if (IsSignChar(c)) { sign = i; } else if (IsDecimalPointChar(c)) { dec = i; } } for (int i = dend; i < dlen; i++) { char c = dest.CharAt(i); if (IsSignChar(c)) { return(new String("")); // Nothing can be inserted in front of a sign character. } if (IsDecimalPointChar(c)) { dec = i; } } // If it does, we must strip them out from the source. // In addition, a sign character must be the very first character, // and nothing can be inserted before an existing sign character. // Go in reverse order so the offsets are stable. SpannableStringBuilder stripped = null; for (int i = end - 1; i >= start; i--) { char c = source.CharAt(i); var strip = false; if (IsSignChar(c)) { if (i != start || dstart != 0) { strip = true; } else if (sign >= 0) { strip = true; } else { sign = i; } } else if (IsDecimalPointChar(c)) { if (dec >= 0) { strip = true; } else { dec = i; } } if (strip) { if (end == start + 1) { return(new String("")); // Only one character, and it was stripped. } if (stripped == null) { stripped = new SpannableStringBuilder(source, start, end); } stripped.Delete(i - start, i + 1 - start); } } return(stripped ?? filterFormatted); }