Search in sources :

Example 36 with Spanned

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;
}
Also used : AlignmentSpan(jp.sblo.pandora.jota.text.style.AlignmentSpan) Spanned(android.text.Spanned) TextPaint(android.text.TextPaint) Paint(android.graphics.Paint)

Example 37 with Spanned

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;
}
Also used : LeadingMarginSpan(jp.sblo.pandora.jota.text.style.LeadingMarginSpan) Spanned(android.text.Spanned) TextPaint(android.text.TextPaint) Paint(android.graphics.Paint)

Example 38 with Spanned

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);
}
Also used : TabStopSpan(jp.sblo.pandora.jota.text.style.TabStopSpan) Spanned(android.text.Spanned) TextPaint(android.text.TextPaint) Paint(android.graphics.Paint)

Example 39 with Spanned

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;
}
Also used : ReplacementSpan(jp.sblo.pandora.jota.text.style.ReplacementSpan) Spanned(android.text.Spanned) TextPaint(android.text.TextPaint) Paint(android.graphics.Paint)

Example 40 with Spanned

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;
}
Also used : TabStopSpan(jp.sblo.pandora.jota.text.style.TabStopSpan) Spanned(android.text.Spanned) TextPaint(android.text.TextPaint) Paint(android.graphics.Paint)

Aggregations

Spanned (android.text.Spanned)204 Paint (android.graphics.Paint)81 TextPaint (android.text.TextPaint)63 Spannable (android.text.Spannable)32 SpannableStringBuilder (android.text.SpannableStringBuilder)27 SpannableString (android.text.SpannableString)25 SuggestionSpan (android.text.style.SuggestionSpan)24 Editable (android.text.Editable)22 TextAppearanceSpan (android.text.style.TextAppearanceSpan)15 SpannedString (android.text.SpannedString)14 TypedArray (android.content.res.TypedArray)12 URLSpan (android.text.style.URLSpan)12 View (android.view.View)12 Context (android.content.Context)10 StyleSpan (android.text.style.StyleSpan)9 InputMethodManager (android.view.inputmethod.InputMethodManager)9 TextView (android.widget.TextView)9 Parcelable (android.os.Parcelable)8 WordIterator (android.text.method.WordIterator)7 CharacterStyle (android.text.style.CharacterStyle)7