/**
* Used to get the correct selection end range depending on the text size
* of the preferred mark_down styling.
*
* @param selection The menu item from the selection mode
* @return end selection size with applied offset
*/
private int getSelectionEnd(@IdRes int selection) {
int end = getSelectionEnd();
final int init_end = getSelectionEnd();
switch (selection) {
case R.id.menu_bold:
end += MD_BOLD.length();
break;
case R.id.menu_italic:
end += MD_ITALIC.length();
break;
case R.id.menu_strike:
end += MD_STRIKE.length();
break;
case R.id.menu_list:
end += MD_NUMBER.length();
break;
case R.id.menu_bullet:
end += MD_BULLET.length();
break;
case R.id.menu_heading:
end += MD_HEADING.length();
break;
case R.id.menu_center:
end += MD_CENTER_ALIGN.length();
break;
case R.id.menu_quote:
end += MD_QUOTE.length();
break;
case R.id.menu_code:
end += MD_CODE.length();
break;
}
// Rare case but if it ever happens reduce end by 1
final int text_length = getText().length();
if(end > text_length + (end - init_end))
end -= (end - init_end) - 1;
return end;
}
MarkdownInputEditor.java 文件源码
java
阅读 32
收藏 0
点赞 0
评论 0
项目:anitrend-app
作者:
评论列表
文章目录