[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,5 +1,7 @@
#include "editor_controller.h"
#include "script_parameter_controller.h"
#include "helpers.h"
#include <apps/code/app.h>
namespace Code {
@@ -36,6 +38,15 @@ bool EditorController::textAreaShouldFinishEditing(TextArea * textArea, Ion::Eve
}
bool EditorController::textAreaDidReceiveEvent(TextArea * textArea, Ion::Events::Event event) {
const char * pythonText = Helpers::PythonTextForEvent(event);
if (pythonText != nullptr) {
textArea->insertText(pythonText);
if (pythonText[strlen(pythonText)-1] == ')') {
textArea->moveCursor(-1);
}
return true;
}
if (event == Ion::Events::EXE) {
// Auto-Indent
char * text = const_cast<char *>(textArea->text());
@@ -62,7 +73,9 @@ bool EditorController::textAreaDidReceiveEvent(TextArea * textArea, Ion::Events:
textArea->insertText(" ");
}
return true;
} else if (event == Ion::Events::Backspace) {
}
if (event == Ion::Events::Backspace) {
// If the cursor is on the left of the text of a line,
// backspace one intentation space at a time.
char * text = const_cast<char *>(textArea->text());
@@ -95,6 +108,7 @@ bool EditorController::textAreaDidReceiveEvent(TextArea * textArea, Ion::Events:
return true;
}
}
return false;
}