[code] Execute a script from the script options.

A button in the options opens the console, with only the current script
imported.

Change-Id: Ia3053534d6fdb2bd1340ce3c42b7249510c97bbc
This commit is contained in:
Léa Saviot
2017-11-14 17:58:16 +01:00
committed by Romain Goyet
parent 57633829a9
commit 6baaa8547a
12 changed files with 55 additions and 58 deletions

View File

@@ -30,7 +30,7 @@ ConsoleController::~ConsoleController() {
unloadPythonEnvironment();
}
bool ConsoleController::loadPythonEnvironment() {
bool ConsoleController::loadPythonEnvironment(bool autoImportScripts) {
if(pythonEnvironmentIsLoaded()) {
return true;
}
@@ -43,7 +43,9 @@ bool ConsoleController::loadPythonEnvironment() {
}
MicroPython::init(m_pythonHeap, m_pythonHeap + k_pythonHeapSize);
MicroPython::registerScriptProvider(m_scriptStore);
autoImport();
if (autoImportScripts) {
autoImport();
}
return true;
}
@@ -72,8 +74,6 @@ void ConsoleController::runAndPrintForCommand(const char * command) {
runCode(command);
flushOutputAccumulationBufferToStore();
m_consoleStore.deleteLastLineIfEmpty();
m_selectableTableView.reloadData();
m_editCell.setEditing(true);
}
void ConsoleController::removeExtensionIfAny(char * name) {
@@ -211,6 +211,8 @@ bool ConsoleController::textFieldDidReceiveEvent(TextField * textField, Ion::Eve
bool ConsoleController::textFieldDidFinishEditing(TextField * textField, const char * text, Ion::Events::Event event) {
runAndPrintForCommand(text);
m_selectableTableView.reloadData();
m_editCell.setEditing(true);
textField->setText("");
m_selectableTableView.selectCellAtLocation(0, m_consoleStore.numberOfLines());
return true;