[escher/text_input] Factorize and clean handleEvent Right and Left

This commit is contained in:
Léa Saviot
2019-06-21 14:42:22 +02:00
committed by EmilieNumworks
parent 5a8596acd7
commit cc8403e020
4 changed files with 34 additions and 26 deletions

View File

@@ -96,6 +96,23 @@ bool TextInput::removeEndOfLine() {
return false;
}
bool TextInput::moveCursorLeft() {
if (cursorLocation() <= text()) {
assert(cursorLocation() == text());
return false;
}
UTF8Decoder decoder(text(), cursorLocation());
return setCursorLocation(decoder.previousGlyphPosition());
}
bool TextInput::moveCursorRight() {
if (UTF8Helper::CodePointIs(cursorLocation(), UCodePointNull)) {
return false;
}
UTF8Decoder decoder(cursorLocation());
return setCursorLocation(decoder.nextGlyphPosition());
}
bool TextInput::privateRemoveEndOfLine() {
return contentView()->removeEndOfLine();
}