if (caretPos==caret.getMark() && caretPos!=curLineEnd) {
if (curLine==lastLine)
caretPos = Math.min(caretPos+text.length(), curLineEnd);
else
caretPos = Math.min(caretPos+text.length(), curLineEnd-1);
caret.moveDot(caretPos);//moveCaretPosition(caretPos);
}
} catch (BadLocationException ble) { // Never happens
UIManager.getLookAndFeel().provideErrorFeedback(this);
ble.printStackTrace();