summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--index.html2
-rw-r--r--js/codeq/comms.js11
-rw-r--r--js/codeq/python.js31
3 files changed, 37 insertions, 7 deletions
diff --git a/index.html b/index.html
index 87987d4..bde01cb 100644
--- a/index.html
+++ b/index.html
@@ -165,6 +165,8 @@
<button type="button" class="btn btn-default navbar-btn btn-plan">Plan</button>
<button type="button" class="btn btn-default navbar-btn btn-hint">Hint</button>
<button type="button" class="btn btn-default navbar-btn btn-test">Test</button>
+ <button type="button" class="btn btn-default navbar-btn btn-run">Run</button>
+ <button type="button" class="btn btn-default navbar-btn btn-stop">Stop</button>
</div>
</nav>
<div class="code_editor"></div>
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 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': ''
});