[apps/escher] Factorize TxtArea and Code::EditorCtrlr's k_indentSpaces

This commit is contained in:
Léa Saviot
2019-06-28 14:18:07 +02:00
committed by Émilie Feral
parent 1d5220ccb2
commit e8be088478
3 changed files with 7 additions and 7 deletions

View File

@@ -82,8 +82,8 @@ bool EditorController::textAreaDidReceiveEvent(TextArea * textArea, Ion::Events:
cursorIsPrecededOnTheLineBySpacesOnly = true;
}
numberOfSpaces = numberOfSpaces / UTF8Decoder::CharSizeOfCodePoint(' ');
if (cursorIsPrecededOnTheLineBySpacesOnly && numberOfSpaces >= k_indentationSpacesNumber) {
for (int i = 0; i < k_indentationSpacesNumber; i++) {
if (cursorIsPrecededOnTheLineBySpacesOnly && numberOfSpaces >= TextArea::k_indentationSpaces) {
for (int i = 0; i < TextArea::k_indentationSpaces; i++) {
textArea->removePreviousGlyph();
}
return true;
@@ -96,11 +96,11 @@ bool EditorController::textAreaDidReceiveEvent(TextArea * textArea, Ion::Events:
assert(firstNonSpace >= text);
if (UTF8Helper::CodePointIs(firstNonSpace, '\n')) {
assert(UTF8Decoder::CharSizeOfCodePoint(' ') == 1);
char indentationBuffer[k_indentationSpacesNumber+1];
for (int i = 0; i < k_indentationSpacesNumber; i++) {
char indentationBuffer[TextArea::k_indentationSpaces+1];
for (int i = 0; i < TextArea::k_indentationSpaces; i++) {
indentationBuffer[i] = ' ';
}
indentationBuffer[k_indentationSpacesNumber] = 0;
indentationBuffer[TextArea::k_indentationSpaces] = 0;
textArea->handleEventWithText(indentationBuffer);
return true;
}