diff options
author | Timotej Lazar <timotej.lazar@fri.uni-lj.si> | 2015-11-18 18:39:25 +0100 |
---|---|---|
committer | Timotej Lazar <timotej.lazar@fri.uni-lj.si> | 2015-11-18 18:39:25 +0100 |
commit | e92caf57bbad2af886b48d8ff82d8fece214b783 (patch) | |
tree | 29d097ca936dd9ddd982f17a97120ca8e48cc9af /js | |
parent | 4ff70466bf0fea1fa91c130e3864868459bfbe9e (diff) |
Escape from editor using the escape key
Diffstat (limited to 'js')
-rw-r--r-- | js/codeq/editor.js | 4 | ||||
-rw-r--r-- | js/codeq/prolog.js | 14 | ||||
-rw-r--r-- | js/codeq/python.js | 14 | ||||
-rw-r--r-- | js/codeq/robot.js | 14 |
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) { |