use of android.text.Spanned in project Jota-Text-Editor-old by jiro-aqua.
the class Layout method getParagraphAlignment.
/**
* Get the alignment of the specified paragraph, taking into account
* markup attached to it.
*/
public final Alignment getParagraphAlignment(int line) {
Alignment align = mAlignment;
if (mSpannedText) {
Spanned sp = (Spanned) mText;
AlignmentSpan[] spans = sp.getSpans(getLineStart(line), getLineEnd(line), AlignmentSpan.class);
int spanLength = spans.length;
if (spanLength > 0) {
align = spans[spanLength - 1].getAlignment();
}
}
return align;
}
use of android.text.Spanned in project Jota-Text-Editor-old by jiro-aqua.
the class Layout method getParagraphLeft.
/**
* Get the left edge of the specified paragraph, inset by left margins.
*/
public final int getParagraphLeft(int line) {
int dir = getParagraphDirection(line);
int left = 0;
boolean par = false;
int off = getLineStart(line);
if (off == 0 || mText.charAt(off - 1) == '\n')
par = true;
if (dir == DIR_LEFT_TO_RIGHT) {
if (mSpannedText) {
Spanned sp = (Spanned) mText;
LeadingMarginSpan[] spans = sp.getSpans(getLineStart(line), getLineEnd(line), LeadingMarginSpan.class);
for (int i = 0; i < spans.length; i++) {
boolean margin = par;
LeadingMarginSpan span = spans[i];
if (span instanceof LeadingMarginSpan.LeadingMarginSpan2) {
int count = ((LeadingMarginSpan.LeadingMarginSpan2) span).getLeadingMarginLineCount();
margin = count >= line;
}
left += span.getLeadingMargin(margin);
}
}
}
return left;
}
use of android.text.Spanned in project Jota-Text-Editor-old by jiro-aqua.
the class Layout method getLineMax.
private float getLineMax(int line, Object[] tabs, boolean full) {
int start = getLineStart(line);
int end;
if (full) {
end = getLineEnd(line);
} else {
end = getLineVisibleEnd(line);
}
boolean tab = getLineContainsTab(line);
if (tabs == null && tab && mText instanceof Spanned) {
tabs = ((Spanned) mText).getSpans(start, end, TabStopSpan.class);
}
return measureText(mPaint, mWorkPaint, mText, start, end, null, tab, tabs);
}
use of android.text.Spanned in project Jota-Text-Editor-old by jiro-aqua.
the class Layout method getOffsetAtStartOf.
private int getOffsetAtStartOf(int offset) {
if (offset == 0)
return 0;
CharSequence text = mText;
char c = text.charAt(offset);
if (c >= '�' && c <= '�') {
char c1 = text.charAt(offset - 1);
if (c1 >= '�' && c1 <= '�')
offset -= 1;
}
if (mSpannedText) {
ReplacementSpan[] spans = ((Spanned) text).getSpans(offset, offset, ReplacementSpan.class);
for (int i = 0; i < spans.length; i++) {
int start = ((Spanned) text).getSpanStart(spans[i]);
int end = ((Spanned) text).getSpanEnd(spans[i]);
if (start < offset && end > offset)
offset = start;
}
}
return offset;
}
use of android.text.Spanned in project Jota-Text-Editor-old by jiro-aqua.
the class Layout method nextTab.
/**
* Returns the position of the next tab stop after h on the line.
*
* @param text the text
* @param start start of the line
* @param end limit of the line
* @param h the current horizontal offset
* @param tabs the tabs, can be null. If it is null, any tabs in effect
* on the line will be used. If there are no tabs, a default offset
* will be used to compute the tab stop.
* @return the offset of the next tab stop.
*/
/* package */
static float nextTab(CharSequence text, int start, int end, float h, Object[] tabs) {
float nh = Float.MAX_VALUE;
boolean alltabs = false;
if (text instanceof Spanned) {
if (tabs == null) {
tabs = ((Spanned) text).getSpans(start, end, TabStopSpan.class);
alltabs = true;
}
for (int i = 0; i < tabs.length; i++) {
if (!alltabs) {
if (!(tabs[i] instanceof TabStopSpan))
continue;
}
int where = ((TabStopSpan) tabs[i]).getTabStop();
if (where < nh && where > h)
nh = where;
}
if (nh != Float.MAX_VALUE)
return nh;
}
return ((int) ((h + TAB_INCREMENT) / TAB_INCREMENT)) * TAB_INCREMENT;
}
Aggregations