Line based indendation

pull/199/head
M66B 4 years ago
parent 3a70fc1b2a
commit 8d49b7e676

@ -550,24 +550,30 @@ public class StyleHelper {
if (paragraph == null) if (paragraph == null)
return false; return false;
if (item.getItemId() == R.id.menu_style_indentation_decrease) { Context context = etBody.getContext();
IndentSpan[] indents = edit.getSpans(paragraph.first, paragraph.second, IndentSpan.class); int intentSize = context.getResources().getDimensionPixelSize(R.dimen.indent_size);
for (IndentSpan indent : indents) {
int s = edit.getSpanStart(indent); QuoteSpan[] quotes = edit.getSpans(start, end, QuoteSpan.class);
int e = edit.getSpanEnd(indent); for (QuoteSpan quote : quotes)
if (s >= start && e <= end) edit.removeSpan(quote);
edit.removeSpan(indent);
}
} else {
Context context = etBody.getContext();
int intentSize = context.getResources().getDimensionPixelSize(R.dimen.indent_size);
QuoteSpan[] quotes = edit.getSpans(start, end, QuoteSpan.class); int prev = paragraph.first;
for (QuoteSpan quote : quotes) int next = paragraph.first;
edit.removeSpan(quote); while (next < paragraph.second) {
while (next < paragraph.second && edit.charAt(next) != '\n')
next++;
if (item.getItemId() == R.id.menu_style_indentation_decrease) {
IndentSpan[] indents = edit.getSpans(prev, prev, IndentSpan.class);
if (indents.length > 0)
edit.removeSpan(indents[0]);
} else {
IndentSpan is = new IndentSpan(intentSize);
edit.setSpan(is, prev, next + 1, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
}
IndentSpan is = new IndentSpan(intentSize); next++;
edit.setSpan(is, paragraph.first, paragraph.second, Spanned.SPAN_INCLUSIVE_EXCLUSIVE); prev = next;
} }
etBody.setText(edit); etBody.setText(edit);

Loading…
Cancel
Save