diff --git a/src/index.html b/src/index.html
index 499d104..f089d3a 100644
--- a/src/index.html
+++ b/src/index.html
@@ -96,6 +96,9 @@
Loading Python Interpreter
delete
+ refresh
@@ -162,6 +165,9 @@ Configuration
class="material-icons">remove
+ refreshReset
+ Python Interpreter
Help
codeShortcuts
@@ -336,8 +342,11 @@ Graphics main window
addEventListener("mpy:ready", () => {
// show running for an instance
+ console.log("Python interpreter ready")
$('#loader-wrapper').addClass("tester")
- terminal.terminal.loadAddon(terminalFitter);
+ // check if the terminal is ready
+ let local_terminal = document.querySelector("#toplevel-terminal");
+ local_terminal.terminal.loadAddon(terminalFitter);
terminalFitter.fit();
change_font_size("toplevel",0);
});
diff --git a/src/js/editor_change.js b/src/js/editor_change.js
index 7c36fc3..7594bf3 100644
--- a/src/js/editor_change.js
+++ b/src/js/editor_change.js
@@ -10,7 +10,7 @@ const files = document.getElementById("editor-files");
const mobile_sidenav = document.getElementById("mobile-sidenav");
const buttons = document.getElementById("menu-button");
-const terminal = document.querySelector("#toplevel-terminal");
+var terminal = document.querySelector("#toplevel-terminal");
var MOBILE = false;
@@ -220,6 +220,19 @@ let current_bloc_selected = function (instance) {
return { start: undefined, end: undefined };
}
+let restart_toplevel = function () {
+ // Get the worker to stop
+ terminal.xworker.terminate();
+ // Delete the node
+ let parent = terminal.parentNode;
+ terminal.parentNode.removeChild(terminal.parentNode.querySelector("py-terminal"))
+ let interpreter_code = parent.innerHTML;
+ parent.innerHTML = "";
+ // Inject the exact same node
+ parent.innerHTML = interpreter_code;
+ // Restart the terminal
+ terminal = document.querySelector("#toplevel-terminal");
+}
/**
* Calculate the cursor of the code to highlight