diff options
Diffstat (limited to 'js/codeq/python.js')
-rw-r--r-- | js/codeq/python.js | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/js/codeq/python.js b/js/codeq/python.js index 66f0371..37fdccd 100644 --- a/js/codeq/python.js +++ b/js/codeq/python.js @@ -20,7 +20,10 @@ jqBtnPlan = jqScreen.find('.btn-plan'), jqBtnHint = jqScreen.find('.btn-hint'), jqBtnTest = jqScreen.find('.btn-test'), - jqAllButtons = jqBtnPlan.add(jqBtnHint).add(jqBtnTest), // all the buttons + jqBtnRun = jqScreen.find('.btn-run'), + jqBtnStop = jqScreen.find('.btn-stop'), + jqInfoButtons = jqBtnPlan.add(jqBtnHint).add(jqBtnTest), // all info-focusing buttons + jqAllButtons = jqInfoButtons.add(jqBtnRun).add(jqBtnStop), // all buttons // misc currentSubState = null, transitionEventName = 'mousedown',//event name of the event which will trigger the transition between these substates - the most common transition at least (there are some corner cases on the hint and test buttons -> see the code below) @@ -82,10 +85,15 @@ /* Q.delay(100).then(function(){ jqAllQuadrants.addClass('transition');//for smooth animations - need to be delayed, because otherwise we get some weird "animations" while the page is loading }).done();*/ - jqAllButtons.on(transitionEventName, function (event) { + jqInfoButtons.on(transitionEventName, function (event) { subScreens.transition('info'); // set focus on the hints quadrant event.stopPropagation(); // don't allow the event to go on and trigger further transition }); + jqBtnRun.on(transitionEventName, function (event) { + subScreens.transition('console'); // set focus on the hints quadrant + event.stopPropagation(); // don't allow the event to go on and trigger further transition + }); + jqAllQuadrants.on(transitionEventName, function () { subScreens.transition($(this).data(stateNameTag)); }); @@ -132,7 +140,8 @@ }; terminal.onInput = function (text) { - return codeq.comms.sendPush({ + terminal.leftmostCol = 0; + return codeq.comms.sendPythonPush({ 'text': text + '\n' }).then(tcs, tcf); }; @@ -272,9 +281,23 @@ } ).done(); }); + jqBtnRun.on('click', function () { + var program = editor.getDoc().getValue(); + // TODO error handling + codeq.comms.sendPythonStop({}); + codeq.comms.sendPythonExec({ + 'program': program + }); + // focus the terminal + jqTerminal.click(); + }); + jqBtnStop.on('click', function () { + // TODO error handling + codeq.comms.sendPythonStop({}); + }); // TODO first line of interpreter output is buffered without this, why? - codeq.comms.sendPush({ + codeq.comms.sendPythonPush({ 'text': '' }); |