summaryrefslogtreecommitdiff
path: root/js/codeq
diff options
context:
space:
mode:
Diffstat (limited to 'js/codeq')
-rw-r--r--js/codeq/comms.js11
-rw-r--r--js/codeq/python.js31
2 files changed, 35 insertions, 7 deletions
diff --git a/js/codeq/comms.js b/js/codeq/comms.js
index 9e69526..b04a2fc 100644
--- a/js/codeq/comms.js
+++ b/js/codeq/comms.js
@@ -250,13 +250,18 @@
return this.send(query);
},
- sendPush: function commsSendPush (json) {
+ sendPythonExec: function commsSendPythonExec (json) {
+ json['action'] = 'python_exec';
+ return this.send(json);
+ },
+
+ sendPythonPush: function commsSendPythonPush (json) {
json['action'] = 'python_push';
return this.send(json);
},
- sendPull: function commsSendPull (json) {
- json['action'] = 'python_pull';
+ sendPythonStop: function commsSendPythonStop (json) {
+ json['action'] = 'python_stop';
return this.send(json);
},
diff --git a/js/codeq/python.js b/js/codeq/python.js
index e5b59c2..510c4c1 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)
@@ -76,10 +79,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));
});
@@ -120,7 +128,8 @@
};
terminal.onInput = function (text) {
- return codeq.comms.sendPush({
+ terminal.leftmostCol = 0;
+ return codeq.comms.sendPythonPush({
'text': text + '\n'
}).then(tcs, tcf);
};
@@ -260,9 +269,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': ''
});