summaryrefslogtreecommitdiff
path: root/js/codeq
diff options
context:
space:
mode:
authorTimotej Lazar <timotej.lazar@fri.uni-lj.si>2015-11-18 18:39:25 +0100
committerTimotej Lazar <timotej.lazar@fri.uni-lj.si>2015-11-18 18:39:25 +0100
commite92caf57bbad2af886b48d8ff82d8fece214b783 (patch)
tree29d097ca936dd9ddd982f17a97120ca8e48cc9af /js/codeq
parent4ff70466bf0fea1fa91c130e3864868459bfbe9e (diff)
Escape from editor using the escape key
Diffstat (limited to 'js/codeq')
-rw-r--r--js/codeq/editor.js4
-rw-r--r--js/codeq/prolog.js14
-rw-r--r--js/codeq/python.js14
-rw-r--r--js/codeq/robot.js14
4 files changed, 30 insertions, 16 deletions
diff --git a/js/codeq/editor.js b/js/codeq/editor.js
index 27296d5..2f8476c 100644
--- a/js/codeq/editor.js
+++ b/js/codeq/editor.js
@@ -1,4 +1,4 @@
-codeq.makeEditor = function (elt, options) {
+codeq.makeEditor = function (elt, options, onEscape) {
var statusBar = $(elt).siblings(".block-statusbar")[0],
updateStatusBar = function (pos) {
statusBar.innerHTML = 'line ' + (pos.line+1) + ', column ' + (pos.ch+1);
@@ -8,6 +8,8 @@ codeq.makeEditor = function (elt, options) {
lineNumbers: true,
matchBrackets: true,
extraKeys: {
+ // allow a custom function to escape the editor (there is no blur)
+ 'Esc': onEscape || CodeMirror.Pass,
// replace tabs with spaces
'Tab': function (cm) {
var spaces = Array(cm.getOption("indentUnit") + 1).join(" ");
diff --git a/js/codeq/prolog.js b/js/codeq/prolog.js
index a9a1c26..47a88b2 100644
--- a/js/codeq/prolog.js
+++ b/js/codeq/prolog.js
@@ -204,11 +204,15 @@
jqEditor = jqCode.find('.code_editor'),
jqTerminal = jqConsole.find('.console'),
jqHints = jqInfo.find('.hints'),
- editor = codeq.makeEditor(jqEditor[0], {
- mode: 'prolog',
- indentUnit: 4,
- value: currentSolution || ''
- }),
+ editor = codeq.makeEditor(jqEditor[0],
+ {
+ mode: 'prolog',
+ indentUnit: 4,
+ value: currentSolution || ''
+ },
+ function () {
+ jqTerminal.click();
+ }),
activityHandler = codeq.makeActivityHandler(editor, problemDef.id),
terminal = makePrologTerminalHandler(jqTerminal, editor, problemDef.id, activityHandler),
hinter = codeq.makeHinter(jqHints, jqEditor, editor, 'prolog_hints', problemDef, commonDef),
diff --git a/js/codeq/python.js b/js/codeq/python.js
index bd5d96e..3c4caef 100644
--- a/js/codeq/python.js
+++ b/js/codeq/python.js
@@ -164,11 +164,15 @@
jqEditor = jqCode.find('.code_editor'),
jqTerminal = jqConsole.find('.console'),
jqHints = jqInfo.find('.hints'),
- editor = codeq.makeEditor(jqEditor[0], {
- mode: 'python',
- indentUnit: 4,
- value: currentSolution || ''
- }),
+ editor = codeq.makeEditor(jqEditor[0],
+ {
+ mode: 'python',
+ indentUnit: 4,
+ value: currentSolution || ''
+ },
+ function () {
+ jqTerminal.click()
+ }),
activityHandler = codeq.makeActivityHandler(editor, problemDef.id),
terminal = makePythonTerminalHandler(jqTerminal, editor, problemDef.id, activityHandler),
hinter = codeq.makeHinter(jqHints, jqEditor, editor, 'python_hints', problemDef, commonDef),
diff --git a/js/codeq/robot.js b/js/codeq/robot.js
index be164ee..88e889d 100644
--- a/js/codeq/robot.js
+++ b/js/codeq/robot.js
@@ -136,11 +136,15 @@
var jqDescriptionContent = jqDescription.find('.description'),
jqEditor = jqCode.find('.code_editor'),
jqHints = jqInfo.find('.hints'),
- editor = codeq.makeEditor(jqEditor[0], {
- mode: 'python',
- indentUnit: 4,
- value: currentSolution || ''
- }),
+ editor = codeq.makeEditor(jqEditor[0],
+ {
+ mode: 'python',
+ indentUnit: 4,
+ value: currentSolution || ''
+ },
+ function () {
+ jqBtnRun.focus();
+ }),
activityHandler = codeq.makeActivityHandler(editor, problemDef.id),
hinter = codeq.makeHinter(jqHints, jqEditor, editor, 'robot_hints', problemDef, commonDef),
commError = function (error) {