-
Notifications
You must be signed in to change notification settings - Fork 300
Description
The Jupyter interface is really good because it's gives a really productive interface that's half-way between using the python immediate command line and writing and rerunning scripts.
Webrepl links to a 6000 line terminal emulator library term.js -- which is a lot of trouble to make the browser look and feel like an old fashioned unfriendly terminal.
But instead of this we could have a very similar interface to the jupyter system with a series of boxes where the code is uploaded when you press "run" by bracketing it with Control-E and Control-D, as I've done in this experiment below. (I've had to put in a delay between each line because otherwise it chokes).
To make this efficient, does anyone know what are the limitations of this mysterious Control-E / Control-D type of block? Is it saving it all in the RAM before processing it (otherwise how could Control-C work to end processing), or does it stream it to a temporary file and then import it?
<input type="button" id="runblock1" value="run" onclick="runcodeblock('codeblock1'); return false;" />
</form>
<textarea id="codeblock1" cols="80" rows="10"></textarea>
codeblockSeries = [];
function runcodeblockSeries() {
if (codeblockSeries.length != 0) {
ws.send(codeblockSeries.shift());
ws.send('\r');
setTimeout(runcodeblockSeries, 50); // send one line at a time with a delay so it doesn't choke
} else {
ws.send(String.fromCharCode(4)); // Control-D
}
}
function runcodeblock(codeblockn) {
if (ws !== undefined) {
data = document.getElementById(codeblockn).value;
codeblockSeries = data.split("\n");
ws.send(String.fromCharCode(5)); // Control-E
setTimeout(runcodeblockSeries, 50);
}
}