summaryrefslogtreecommitdiff
path: root/js/codeq/editor.js
diff options
context:
space:
mode:
authorTimotej Lazar <timotej.lazar@araneo.org>2015-09-30 21:11:52 +0200
committerTimotej Lazar <timotej.lazar@araneo.org>2015-09-30 21:11:52 +0200
commitffa31a965e2121d7dd0eb7a582d2b82bd1204c7a (patch)
treeb5fa6a77f4304e27cf07a62a326e491d1a5cf314 /js/codeq/editor.js
parent23d0fcbd4d152f2cc19a09e2d776e694ca73d42a (diff)
Do not override user options in codeq.makeEditor
Also clean up remains of previous CodeMirror panel support.
Diffstat (limited to 'js/codeq/editor.js')
-rw-r--r--js/codeq/editor.js33
1 files changed, 14 insertions, 19 deletions
diff --git a/js/codeq/editor.js b/js/codeq/editor.js
index f84bd05..d0b365e 100644
--- a/js/codeq/editor.js
+++ b/js/codeq/editor.js
@@ -1,28 +1,23 @@
codeq.makeEditor = function (elt, options) {
- var statusBar = document.createElement("div"),
+ var statusBar = $(elt).siblings(".block-statusbar")[0],
updateStatusBar = function (pos) {
statusBar.innerHTML = 'line ' + (pos.line+1) + ', column ' + (pos.ch+1);
},
- editor;
+ allOptions = $.extend({
+ cursorHeight: 0.85,
+ lineNumbers: true,
+ matchBrackets: true,
+ extraKeys: {
+ // replace tabs with spaces
+ Tab: function (cm) {
+ var spaces = Array(cm.getOption("indentUnit") + 1).join(" ");
+ cm.replaceSelection(spaces);
+ }
+ }
+ }, options),
+ editor = CodeMirror(elt, allOptions);
- options.cursorHeight = 0.85;
- options.lineNumbers = true;
- options.matchBrackets = true;
- options.extraKeys = {
- // replace tabs with spaces
- Tab: function (cm) {
- var spaces = Array(cm.getOption("indentUnit") + 1).join(" ");
- cm.replaceSelection(spaces);
- }
- };
- editor = CodeMirror(elt, options),
-
- //since addPanel brakes CodeMirrot responsiveness no mather what, we manually added block-statusbar located at the bottom of editor block
- //statusBar.className = 'editor-statusbar';
- statusBar = statusBar = $(elt).siblings(".block-statusbar")[0];
updateStatusBar({line: 0, ch: 0});
-
- //editor.addPanel(statusBar, {position: 'bottom'});
editor.on('cursorActivity', function (instance) {
var pos = instance.getDoc().getCursor();
updateStatusBar(pos);