[code] Keyboard events translation, for script or command edition.

For instance, the "power" event should insert "**" in the text, not "^".
Added a universal i18n file in apps/code.

Change-Id: I5d067b0c5b86590af95aa98856522d54e42acba6
This commit is contained in:
Léa Saviot
2017-10-30 15:10:46 +01:00
committed by Romain Goyet
parent 681be23c30
commit b7baec4a40
10 changed files with 100 additions and 7 deletions

View File

@@ -1,6 +1,6 @@
#include "console_controller.h"
#include "script.h"
#include "app.h"
#include "helpers.h"
#include <apps/i18n.h>
#include <assert.h>
@@ -187,7 +187,18 @@ bool ConsoleController::textFieldShouldFinishEditing(TextField * textField, Ion:
}
bool ConsoleController::textFieldDidReceiveEvent(TextField * textField, Ion::Events::Event event) {
return false;
const char * pythonText = Helpers::PythonTextForEvent(event);
if (pythonText == nullptr) {
return false;
}
textField->setEditing(true, false);
if (textField->insertTextAtLocation(pythonText, textField->cursorLocation())) {
textField->setCursorLocation(textField->cursorLocation()+strlen(pythonText));
if (pythonText[strlen(pythonText)-1] == ')') {
textField->setCursorLocation(textField->cursorLocation()-1);
}
}
return true;
}
bool ConsoleController::textFieldDidFinishEditing(TextField * textField, const char * text, Ion::Events::Event event) {