summaryrefslogtreecommitdiff
path: root/public/vendor/codemirror/addon
diff options
context:
space:
mode:
Diffstat (limited to 'public/vendor/codemirror/addon')
-rw-r--r--[-rwxr-xr-x]public/vendor/codemirror/addon/comment/comment.js27
-rw-r--r--[-rwxr-xr-x]public/vendor/codemirror/addon/comment/continuecomment.js0
-rw-r--r--[-rwxr-xr-x]public/vendor/codemirror/addon/dialog/dialog.js0
-rw-r--r--public/vendor/codemirror/addon/display/autorefresh.js47
-rw-r--r--[-rwxr-xr-x]public/vendor/codemirror/addon/display/fullscreen.css2
-rw-r--r--[-rwxr-xr-x]public/vendor/codemirror/addon/display/fullscreen.js0
-rw-r--r--[-rwxr-xr-x]public/vendor/codemirror/addon/display/panel.js0
-rw-r--r--[-rwxr-xr-x]public/vendor/codemirror/addon/display/placeholder.js4
-rw-r--r--[-rwxr-xr-x]public/vendor/codemirror/addon/display/rulers.js0
-rw-r--r--[-rwxr-xr-x]public/vendor/codemirror/addon/edit/closebrackets.js18
-rw-r--r--[-rwxr-xr-x]public/vendor/codemirror/addon/edit/closetag.js11
-rw-r--r--[-rwxr-xr-x]public/vendor/codemirror/addon/edit/continuelist.js8
-rw-r--r--[-rwxr-xr-x]public/vendor/codemirror/addon/edit/matchbrackets.js0
-rw-r--r--[-rwxr-xr-x]public/vendor/codemirror/addon/edit/matchtags.js0
-rw-r--r--[-rwxr-xr-x]public/vendor/codemirror/addon/edit/trailingspace.js0
-rw-r--r--[-rwxr-xr-x]public/vendor/codemirror/addon/fold/brace-fold.js0
-rw-r--r--[-rwxr-xr-x]public/vendor/codemirror/addon/fold/comment-fold.js4
-rw-r--r--[-rwxr-xr-x]public/vendor/codemirror/addon/fold/foldcode.js0
-rw-r--r--[-rwxr-xr-x]public/vendor/codemirror/addon/fold/foldgutter.css0
-rw-r--r--[-rwxr-xr-x]public/vendor/codemirror/addon/fold/foldgutter.js4
-rw-r--r--[-rwxr-xr-x]public/vendor/codemirror/addon/fold/indent-fold.js0
-rw-r--r--[-rwxr-xr-x]public/vendor/codemirror/addon/fold/markdown-fold.js0
-rw-r--r--[-rwxr-xr-x]public/vendor/codemirror/addon/fold/xml-fold.js0
-rw-r--r--[-rwxr-xr-x]public/vendor/codemirror/addon/hint/anyword-hint.js2
-rw-r--r--[-rwxr-xr-x]public/vendor/codemirror/addon/hint/css-hint.js0
-rw-r--r--[-rwxr-xr-x]public/vendor/codemirror/addon/hint/html-hint.js0
-rw-r--r--[-rwxr-xr-x]public/vendor/codemirror/addon/hint/javascript-hint.js0
-rw-r--r--[-rwxr-xr-x]public/vendor/codemirror/addon/hint/show-hint.css0
-rw-r--r--[-rwxr-xr-x]public/vendor/codemirror/addon/hint/show-hint.js119
-rw-r--r--[-rwxr-xr-x]public/vendor/codemirror/addon/hint/sql-hint.js0
-rw-r--r--[-rwxr-xr-x]public/vendor/codemirror/addon/hint/xml-hint.js0
-rw-r--r--[-rwxr-xr-x]public/vendor/codemirror/addon/lint/coffeescript-lint.js0
-rw-r--r--[-rwxr-xr-x]public/vendor/codemirror/addon/lint/css-lint.js0
-rw-r--r--public/vendor/codemirror/addon/lint/html-lint.js46
-rw-r--r--[-rwxr-xr-x]public/vendor/codemirror/addon/lint/javascript-lint.js0
-rw-r--r--[-rwxr-xr-x]public/vendor/codemirror/addon/lint/json-lint.js0
-rw-r--r--[-rwxr-xr-x]public/vendor/codemirror/addon/lint/lint.css0
-rw-r--r--[-rwxr-xr-x]public/vendor/codemirror/addon/lint/lint.js34
-rw-r--r--[-rwxr-xr-x]public/vendor/codemirror/addon/lint/yaml-lint.js0
-rw-r--r--[-rwxr-xr-x]public/vendor/codemirror/addon/merge/merge.css0
-rw-r--r--[-rwxr-xr-x]public/vendor/codemirror/addon/merge/merge.js13
-rw-r--r--[-rwxr-xr-x]public/vendor/codemirror/addon/mode/loadmode.js0
-rw-r--r--[-rwxr-xr-x]public/vendor/codemirror/addon/mode/multiplex.js6
-rw-r--r--[-rwxr-xr-x]public/vendor/codemirror/addon/mode/multiplex_test.js2
-rw-r--r--[-rwxr-xr-x]public/vendor/codemirror/addon/mode/overlay.js0
-rw-r--r--[-rwxr-xr-x]public/vendor/codemirror/addon/mode/simple.js2
-rw-r--r--[-rwxr-xr-x]public/vendor/codemirror/addon/runmode/colorize.js0
-rw-r--r--[-rwxr-xr-x]public/vendor/codemirror/addon/runmode/runmode-standalone.js0
-rw-r--r--[-rwxr-xr-x]public/vendor/codemirror/addon/runmode/runmode.js2
-rw-r--r--[-rwxr-xr-x]public/vendor/codemirror/addon/runmode/runmode.node.js1
-rw-r--r--[-rwxr-xr-x]public/vendor/codemirror/addon/scroll/annotatescrollbar.js5
-rw-r--r--[-rwxr-xr-x]public/vendor/codemirror/addon/scroll/scrollpastend.js0
-rw-r--r--[-rwxr-xr-x]public/vendor/codemirror/addon/scroll/simplescrollbars.js0
-rw-r--r--public/vendor/codemirror/addon/search/jump-to-line.js49
-rw-r--r--[-rwxr-xr-x]public/vendor/codemirror/addon/search/match-highlighter.js43
-rw-r--r--[-rwxr-xr-x]public/vendor/codemirror/addon/search/matchesonscrollbar.js0
-rw-r--r--[-rwxr-xr-x]public/vendor/codemirror/addon/search/search.js125
-rw-r--r--[-rwxr-xr-x]public/vendor/codemirror/addon/search/searchcursor.js0
-rw-r--r--[-rwxr-xr-x]public/vendor/codemirror/addon/selection/active-line.js0
-rw-r--r--[-rwxr-xr-x]public/vendor/codemirror/addon/selection/mark-selection.js0
-rw-r--r--[-rwxr-xr-x]public/vendor/codemirror/addon/selection/selection-pointer.js0
-rw-r--r--[-rwxr-xr-x]public/vendor/codemirror/addon/tern/tern.css1
-rw-r--r--[-rwxr-xr-x]public/vendor/codemirror/addon/tern/tern.js14
-rw-r--r--[-rwxr-xr-x]public/vendor/codemirror/addon/tern/worker.js0
-rw-r--r--[-rwxr-xr-x]public/vendor/codemirror/addon/wrap/hardwrap.js15
65 files changed, 473 insertions, 131 deletions
diff --git a/public/vendor/codemirror/addon/comment/comment.js b/public/vendor/codemirror/addon/comment/comment.js
index 2dd114d3..3aa46808 100755..100644
--- a/public/vendor/codemirror/addon/comment/comment.js
+++ b/public/vendor/codemirror/addon/comment/comment.js
@@ -21,22 +21,28 @@
}
CodeMirror.commands.toggleComment = function(cm) {
- var minLine = Infinity, ranges = cm.listSelections(), mode = null;
+ cm.toggleComment();
+ };
+
+ CodeMirror.defineExtension("toggleComment", function(options) {
+ if (!options) options = noOptions;
+ var cm = this;
+ var minLine = Infinity, ranges = this.listSelections(), mode = null;
for (var i = ranges.length - 1; i >= 0; i--) {
var from = ranges[i].from(), to = ranges[i].to();
if (from.line >= minLine) continue;
if (to.line >= minLine) to = Pos(minLine, 0);
minLine = from.line;
if (mode == null) {
- if (cm.uncomment(from, to)) mode = "un";
- else { cm.lineComment(from, to); mode = "line"; }
+ if (cm.uncomment(from, to, options)) mode = "un";
+ else { cm.lineComment(from, to, options); mode = "line"; }
} else if (mode == "un") {
- cm.uncomment(from, to);
+ cm.uncomment(from, to, options);
} else {
- cm.lineComment(from, to);
+ cm.lineComment(from, to, options);
}
}
- };
+ });
CodeMirror.defineExtension("lineComment", function(from, to, options) {
if (!options) options = noOptions;
@@ -57,7 +63,14 @@
self.operation(function() {
if (options.indent) {
- var baseString = firstLine.slice(0, firstNonWS(firstLine));
+ var baseString = null;
+ for (var i = from.line; i < end; ++i) {
+ var line = self.getLine(i);
+ var whitespace = line.slice(0, firstNonWS(line));
+ if (baseString == null || baseString.length > whitespace.length) {
+ baseString = whitespace;
+ }
+ }
for (var i = from.line; i < end; ++i) {
var line = self.getLine(i), cut = baseString.length;
if (!blankLines && !nonWS.test(line)) continue;
diff --git a/public/vendor/codemirror/addon/comment/continuecomment.js b/public/vendor/codemirror/addon/comment/continuecomment.js
index b11d51e6..b11d51e6 100755..100644
--- a/public/vendor/codemirror/addon/comment/continuecomment.js
+++ b/public/vendor/codemirror/addon/comment/continuecomment.js
diff --git a/public/vendor/codemirror/addon/dialog/dialog.js b/public/vendor/codemirror/addon/dialog/dialog.js
index 323b2007..323b2007 100755..100644
--- a/public/vendor/codemirror/addon/dialog/dialog.js
+++ b/public/vendor/codemirror/addon/dialog/dialog.js
diff --git a/public/vendor/codemirror/addon/display/autorefresh.js b/public/vendor/codemirror/addon/display/autorefresh.js
new file mode 100644
index 00000000..1e0e8504
--- /dev/null
+++ b/public/vendor/codemirror/addon/display/autorefresh.js
@@ -0,0 +1,47 @@
+// CodeMirror, copyright (c) by Marijn Haverbeke and others
+// Distributed under an MIT license: http://codemirror.net/LICENSE
+
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"))
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod)
+ else // Plain browser env
+ mod(CodeMirror)
+})(function(CodeMirror) {
+ "use strict"
+
+ CodeMirror.defineOption("autoRefresh", false, function(cm, val) {
+ if (cm.state.autoRefresh) {
+ stopListening(cm, cm.state.autoRefresh)
+ cm.state.autoRefresh = null
+ }
+ if (val && cm.display.wrapper.offsetHeight == 0)
+ startListening(cm, cm.state.autoRefresh = {delay: val.delay || 250})
+ })
+
+ function startListening(cm, state) {
+ function check() {
+ if (cm.display.wrapper.offsetHeight) {
+ stopListening(cm, state)
+ if (cm.display.lastWrapHeight != cm.display.wrapper.clientHeight)
+ cm.refresh()
+ } else {
+ state.timeout = setTimeout(check, state.delay)
+ }
+ }
+ state.timeout = setTimeout(check, state.delay)
+ state.hurry = function() {
+ clearTimeout(state.timeout)
+ state.timeout = setTimeout(check, 50)
+ }
+ CodeMirror.on(window, "mouseup", state.hurry)
+ CodeMirror.on(window, "keyup", state.hurry)
+ }
+
+ function stopListening(_cm, state) {
+ clearTimeout(state.timeout)
+ CodeMirror.off(window, "mouseup", state.hurry)
+ CodeMirror.off(window, "keyup", state.hurry)
+ }
+});
diff --git a/public/vendor/codemirror/addon/display/fullscreen.css b/public/vendor/codemirror/addon/display/fullscreen.css
index 437acd89..e258ad66 100755..100644
--- a/public/vendor/codemirror/addon/display/fullscreen.css
+++ b/public/vendor/codemirror/addon/display/fullscreen.css
@@ -2,5 +2,5 @@
position: fixed;
top: 0; left: 0; right: 0; bottom: 0;
height: auto;
- z-index: 9;
+ z-index: 2000;
}
diff --git a/public/vendor/codemirror/addon/display/fullscreen.js b/public/vendor/codemirror/addon/display/fullscreen.js
index cd3673b9..cd3673b9 100755..100644
--- a/public/vendor/codemirror/addon/display/fullscreen.js
+++ b/public/vendor/codemirror/addon/display/fullscreen.js
diff --git a/public/vendor/codemirror/addon/display/panel.js b/public/vendor/codemirror/addon/display/panel.js
index ba29484d..ba29484d 100755..100644
--- a/public/vendor/codemirror/addon/display/panel.js
+++ b/public/vendor/codemirror/addon/display/panel.js
diff --git a/public/vendor/codemirror/addon/display/placeholder.js b/public/vendor/codemirror/addon/display/placeholder.js
index bb0c3931..babddfb1 100755..100644
--- a/public/vendor/codemirror/addon/display/placeholder.js
+++ b/public/vendor/codemirror/addon/display/placeholder.js
@@ -37,7 +37,9 @@
var elt = cm.state.placeholder = document.createElement("pre");
elt.style.cssText = "height: 0; overflow: visible";
elt.className = "CodeMirror-placeholder";
- elt.appendChild(document.createTextNode(cm.getOption("placeholder")));
+ var placeHolder = cm.getOption("placeholder")
+ if (typeof placeHolder == "string") placeHolder = document.createTextNode(placeHolder)
+ elt.appendChild(placeHolder)
cm.display.lineSpace.insertBefore(elt, cm.display.lineSpace.firstChild);
}
diff --git a/public/vendor/codemirror/addon/display/rulers.js b/public/vendor/codemirror/addon/display/rulers.js
index 01f65667..01f65667 100755..100644
--- a/public/vendor/codemirror/addon/display/rulers.js
+++ b/public/vendor/codemirror/addon/display/rulers.js
diff --git a/public/vendor/codemirror/addon/edit/closebrackets.js b/public/vendor/codemirror/addon/edit/closebrackets.js
index 1ceda4e3..3eb9d8ea 100755..100644
--- a/public/vendor/codemirror/addon/edit/closebrackets.js
+++ b/public/vendor/codemirror/addon/edit/closebrackets.js
@@ -79,7 +79,7 @@
if (!around || explode.indexOf(around) % 2 != 0) return CodeMirror.Pass;
}
cm.operation(function() {
- cm.replaceSelection("\n\n", null, "+input");
+ cm.replaceSelection("\n\n", null);
cm.execCommand("goCharLeft");
ranges = cm.listSelections();
for (var i = 0; i < ranges.length; i++) {
@@ -90,6 +90,12 @@
});
}
+ function contractSelection(sel) {
+ var inverted = CodeMirror.cmpPos(sel.anchor, sel.head) > 0;
+ return {anchor: new Pos(sel.anchor.line, sel.anchor.ch + (inverted ? -1 : 1)),
+ head: new Pos(sel.head.line, sel.head.ch + (inverted ? 1 : -1))};
+ }
+
function handleChar(cm, ch) {
var conf = getConfig(cm);
if (!conf || cm.getOption("disableInput")) return CodeMirror.Pass;
@@ -144,13 +150,17 @@
var sels = cm.getSelections();
for (var i = 0; i < sels.length; i++)
sels[i] = left + sels[i] + right;
- cm.replaceSelections(sels, "around", "+input");
+ cm.replaceSelections(sels, "around");
+ sels = cm.listSelections().slice();
+ for (var i = 0; i < sels.length; i++)
+ sels[i] = contractSelection(sels[i]);
+ cm.setSelections(sels);
} else if (type == "both") {
- cm.replaceSelection(left + right, null, "+input");
+ cm.replaceSelection(left + right, null);
cm.triggerElectric(left + right);
cm.execCommand("goCharLeft");
} else if (type == "addFour") {
- cm.replaceSelection(left + left + left + left, "before", "+input");
+ cm.replaceSelection(left + left + left + left, "before");
cm.execCommand("goCharRight");
}
});
diff --git a/public/vendor/codemirror/addon/edit/closetag.js b/public/vendor/codemirror/addon/edit/closetag.js
index c2d2263e..a518da3e 100755..100644
--- a/public/vendor/codemirror/addon/edit/closetag.js
+++ b/public/vendor/codemirror/addon/edit/closetag.js
@@ -108,21 +108,24 @@
// when completing in JS/CSS snippet in htmlmixed mode. Does not
// work for other XML embedded languages (there is no general
// way to go from a mixed mode to its current XML state).
+ var replacement;
if (inner.mode.name != "xml") {
if (cm.getMode().name == "htmlmixed" && inner.mode.name == "javascript")
- replacements[i] = head + "script>";
+ replacement = head + "script";
else if (cm.getMode().name == "htmlmixed" && inner.mode.name == "css")
- replacements[i] = head + "style>";
+ replacement = head + "style";
else
return CodeMirror.Pass;
} else {
if (!state.context || !state.context.tagName ||
closingTagExists(cm, state.context.tagName, pos, state))
return CodeMirror.Pass;
- replacements[i] = head + state.context.tagName + ">";
+ replacement = head + state.context.tagName;
}
+ if (cm.getLine(pos.line).charAt(tok.end) != ">") replacement += ">";
+ replacements[i] = replacement;
}
- cm.replaceSelections(replacements, null, '+input');
+ cm.replaceSelections(replacements);
ranges = cm.listSelections();
for (var i = 0; i < ranges.length; i++)
if (i == ranges.length - 1 || ranges[i].head.line < ranges[i + 1].head.line)
diff --git a/public/vendor/codemirror/addon/edit/continuelist.js b/public/vendor/codemirror/addon/edit/continuelist.js
index a0941d4f..df5179fe 100755..100644
--- a/public/vendor/codemirror/addon/edit/continuelist.js
+++ b/public/vendor/codemirror/addon/edit/continuelist.js
@@ -11,8 +11,8 @@
})(function(CodeMirror) {
"use strict";
- var listRE = /^(\s*)(>[> ]*|[*+-]\s|(\d+)([.)]))(\[\s\]\s|\[x\]\s|\s*)/,
- emptyListRE = /^(\s*)(>[> ]*|[*+-]\s|(\d+)[.)])(\[\s\]\s*|\[x\]\s|\s*)$/,
+ var listRE = /^(\s*)(>[> ]*|[*+-]\s|(\d+)([.)]))(\s*)/,
+ emptyListRE = /^(\s*)(>[> ]*|[*+-]|(\d+)[.)])(\s*)$/,
unorderedListRE = /[*+-]\s/;
CodeMirror.commands.newlineAndIndentContinueMarkdownList = function(cm) {
@@ -34,7 +34,7 @@
line: pos.line, ch: 0
}, {
line: pos.line, ch: pos.ch + 1
- }, "+delete");
+ });
replacements[i] = "\n";
} else {
var indent = match[1], after = match[5];
@@ -46,6 +46,6 @@
}
}
- cm.replaceSelections(replacements, null, "+input");
+ cm.replaceSelections(replacements);
};
});
diff --git a/public/vendor/codemirror/addon/edit/matchbrackets.js b/public/vendor/codemirror/addon/edit/matchbrackets.js
index 70e1ae18..70e1ae18 100755..100644
--- a/public/vendor/codemirror/addon/edit/matchbrackets.js
+++ b/public/vendor/codemirror/addon/edit/matchbrackets.js
diff --git a/public/vendor/codemirror/addon/edit/matchtags.js b/public/vendor/codemirror/addon/edit/matchtags.js
index fb1911a8..fb1911a8 100755..100644
--- a/public/vendor/codemirror/addon/edit/matchtags.js
+++ b/public/vendor/codemirror/addon/edit/matchtags.js
diff --git a/public/vendor/codemirror/addon/edit/trailingspace.js b/public/vendor/codemirror/addon/edit/trailingspace.js
index fa7b56be..fa7b56be 100755..100644
--- a/public/vendor/codemirror/addon/edit/trailingspace.js
+++ b/public/vendor/codemirror/addon/edit/trailingspace.js
diff --git a/public/vendor/codemirror/addon/fold/brace-fold.js b/public/vendor/codemirror/addon/fold/brace-fold.js
index 1605f6c2..1605f6c2 100755..100644
--- a/public/vendor/codemirror/addon/fold/brace-fold.js
+++ b/public/vendor/codemirror/addon/fold/brace-fold.js
diff --git a/public/vendor/codemirror/addon/fold/comment-fold.js b/public/vendor/codemirror/addon/fold/comment-fold.js
index b75db7ea..60fa3e43 100755..100644
--- a/public/vendor/codemirror/addon/fold/comment-fold.js
+++ b/public/vendor/codemirror/addon/fold/comment-fold.js
@@ -28,7 +28,9 @@ CodeMirror.registerGlobalHelper("fold", "comment", function(mode) {
continue;
}
if (pass == 1 && found < start.ch) return;
- if (/comment/.test(cm.getTokenTypeAt(CodeMirror.Pos(line, found + 1)))) {
+ if (/comment/.test(cm.getTokenTypeAt(CodeMirror.Pos(line, found + 1))) &&
+ (lineText.slice(found - endToken.length, found) == endToken ||
+ !/comment/.test(cm.getTokenTypeAt(CodeMirror.Pos(line, found))))) {
startCh = found + startToken.length;
break;
}
diff --git a/public/vendor/codemirror/addon/fold/foldcode.js b/public/vendor/codemirror/addon/fold/foldcode.js
index 62911f93..62911f93 100755..100644
--- a/public/vendor/codemirror/addon/fold/foldcode.js
+++ b/public/vendor/codemirror/addon/fold/foldcode.js
diff --git a/public/vendor/codemirror/addon/fold/foldgutter.css b/public/vendor/codemirror/addon/fold/foldgutter.css
index ad19ae2d..ad19ae2d 100755..100644
--- a/public/vendor/codemirror/addon/fold/foldgutter.css
+++ b/public/vendor/codemirror/addon/fold/foldgutter.css
diff --git a/public/vendor/codemirror/addon/fold/foldgutter.js b/public/vendor/codemirror/addon/fold/foldgutter.js
index ed7bd87d..f101e267 100755..100644
--- a/public/vendor/codemirror/addon/fold/foldgutter.js
+++ b/public/vendor/codemirror/addon/fold/foldgutter.js
@@ -20,7 +20,7 @@
cm.off("viewportChange", onViewportChange);
cm.off("fold", onFold);
cm.off("unfold", onFold);
- cm.off("swapDoc", updateInViewport);
+ cm.off("swapDoc", onChange);
}
if (val) {
cm.state.foldGutter = new State(parseOptions(val));
@@ -30,7 +30,7 @@
cm.on("viewportChange", onViewportChange);
cm.on("fold", onFold);
cm.on("unfold", onFold);
- cm.on("swapDoc", updateInViewport);
+ cm.on("swapDoc", onChange);
}
});
diff --git a/public/vendor/codemirror/addon/fold/indent-fold.js b/public/vendor/codemirror/addon/fold/indent-fold.js
index e29f15e9..e29f15e9 100755..100644
--- a/public/vendor/codemirror/addon/fold/indent-fold.js
+++ b/public/vendor/codemirror/addon/fold/indent-fold.js
diff --git a/public/vendor/codemirror/addon/fold/markdown-fold.js b/public/vendor/codemirror/addon/fold/markdown-fold.js
index ce84c946..ce84c946 100755..100644
--- a/public/vendor/codemirror/addon/fold/markdown-fold.js
+++ b/public/vendor/codemirror/addon/fold/markdown-fold.js
diff --git a/public/vendor/codemirror/addon/fold/xml-fold.js b/public/vendor/codemirror/addon/fold/xml-fold.js
index 504727f3..504727f3 100755..100644
--- a/public/vendor/codemirror/addon/fold/xml-fold.js
+++ b/public/vendor/codemirror/addon/fold/xml-fold.js
diff --git a/public/vendor/codemirror/addon/hint/anyword-hint.js b/public/vendor/codemirror/addon/hint/anyword-hint.js
index 8e74a920..dae78e2e 100755..100644
--- a/public/vendor/codemirror/addon/hint/anyword-hint.js
+++ b/public/vendor/codemirror/addon/hint/anyword-hint.js
@@ -21,7 +21,7 @@
while (start && word.test(curLine.charAt(start - 1))) --start;
var curWord = start != end && curLine.slice(start, end);
- var list = [], seen = {};
+ var list = options && options.list || [], seen = {};
var re = new RegExp(word.source, "g");
for (var dir = -1; dir <= 1; dir += 2) {
var line = cur.line, endLine = Math.min(Math.max(line + dir * range, editor.firstLine()), editor.lastLine()) + dir;
diff --git a/public/vendor/codemirror/addon/hint/css-hint.js b/public/vendor/codemirror/addon/hint/css-hint.js
index 22642727..22642727 100755..100644
--- a/public/vendor/codemirror/addon/hint/css-hint.js
+++ b/public/vendor/codemirror/addon/hint/css-hint.js
diff --git a/public/vendor/codemirror/addon/hint/html-hint.js b/public/vendor/codemirror/addon/hint/html-hint.js
index c6769bca..c6769bca 100755..100644
--- a/public/vendor/codemirror/addon/hint/html-hint.js
+++ b/public/vendor/codemirror/addon/hint/html-hint.js
diff --git a/public/vendor/codemirror/addon/hint/javascript-hint.js b/public/vendor/codemirror/addon/hint/javascript-hint.js
index 7bcbf4a0..7bcbf4a0 100755..100644
--- a/public/vendor/codemirror/addon/hint/javascript-hint.js
+++ b/public/vendor/codemirror/addon/hint/javascript-hint.js
diff --git a/public/vendor/codemirror/addon/hint/show-hint.css b/public/vendor/codemirror/addon/hint/show-hint.css
index 924e638f..924e638f 100755..100644
--- a/public/vendor/codemirror/addon/hint/show-hint.css
+++ b/public/vendor/codemirror/addon/hint/show-hint.css
diff --git a/public/vendor/codemirror/addon/hint/show-hint.js b/public/vendor/codemirror/addon/hint/show-hint.js
index d228fc88..cbe3b39a 100755..100644
--- a/public/vendor/codemirror/addon/hint/show-hint.js
+++ b/public/vendor/codemirror/addon/hint/show-hint.js
@@ -25,8 +25,18 @@
};
CodeMirror.defineExtension("showHint", function(options) {
- // We want a single cursor position.
- if (this.listSelections().length > 1 || this.somethingSelected()) return;
+ options = parseOptions(this, this.getCursor("start"), options);
+ var selections = this.listSelections()
+ if (selections.length > 1) return;
+ // By default, don't allow completion when something is selected.
+ // A hint function can have a `supportsSelection` property to
+ // indicate that it can handle selections.
+ if (this.somethingSelected()) {
+ if (!options.hint.supportsSelection) return;
+ // Don't try with cross-line selections
+ for (var i = 0; i < selections.length; i++)
+ if (selections[i].head.line != selections[i].anchor.line) return;
+ }
if (this.state.completionActive) this.state.completionActive.close();
var completion = this.state.completionActive = new Completion(this, options);
@@ -38,12 +48,12 @@
function Completion(cm, options) {
this.cm = cm;
- this.options = this.buildOptions(options);
+ this.options = options;
this.widget = null;
this.debounce = 0;
this.tick = 0;
- this.startPos = this.cm.getCursor();
- this.startLen = this.cm.getLine(this.startPos.line).length;
+ this.startPos = this.cm.getCursor("start");
+ this.startLen = this.cm.getLine(this.startPos.line).length - this.cm.getSelection().length;
var self = this;
cm.on("cursorActivity", this.activityFunc = function() { self.cursorActivity(); });
@@ -99,7 +109,6 @@
update: function(first) {
if (this.tick == null) return;
- if (this.data) CodeMirror.signal(this.data, "update");
if (!this.options.hint.async) {
this.finishUpdate(this.options.hint(this.cm, this.options), first);
} else {
@@ -111,6 +120,8 @@
},
finishUpdate: function(data, first) {
+ if (this.data) CodeMirror.signal(this.data, "update");
+ if (data && this.data && CodeMirror.cmpPos(data.from, this.data.from)) data = null;
this.data = data;
var picked = (this.widget && this.widget.picked) || (first && this.options.completeSingle);
@@ -123,20 +134,21 @@
CodeMirror.signal(data, "shown");
}
}
- },
-
- buildOptions: function(options) {
- var editor = this.cm.options.hintOptions;
- var out = {};
- for (var prop in defaultOptions) out[prop] = defaultOptions[prop];
- if (editor) for (var prop in editor)
- if (editor[prop] !== undefined) out[prop] = editor[prop];
- if (options) for (var prop in options)
- if (options[prop] !== undefined) out[prop] = options[prop];
- return out;
}
};
+ function parseOptions(cm, pos, options) {
+ var editor = cm.options.hintOptions;
+ var out = {};
+ for (var prop in defaultOptions) out[prop] = defaultOptions[prop];
+ if (editor) for (var prop in editor)
+ if (editor[prop] !== undefined) out[prop] = editor[prop];
+ if (options) for (var prop in options)
+ if (options[prop] !== undefined) out[prop] = options[prop];
+ if (out.hint.resolve) out.hint = out.hint.resolve(cm, pos)
+ return out;
+ }
+
function getText(completion) {
if (typeof completion == "string") return completion;
else return completion.text;
@@ -335,34 +347,79 @@
}
};
- CodeMirror.registerHelper("hint", "auto", function(cm, options) {
- var helpers = cm.getHelpers(cm.getCursor(), "hint"), words;
+ function applicableHelpers(cm, helpers) {
+ if (!cm.somethingSelected()) return helpers
+ var result = []
+ for (var i = 0; i < helpers.length; i++)
+ if (helpers[i].supportsSelection) result.push(helpers[i])
+ return result
+ }
+
+ function resolveAutoHints(cm, pos) {
+ var helpers = cm.getHelpers(pos, "hint"), words
if (helpers.length) {
- for (var i = 0; i < helpers.length; i++) {
- var cur = helpers[i](cm, options);
- if (cur && cur.list.length) return cur;
+ var async = false, resolved
+ for (var i = 0; i < helpers.length; i++) if (helpers[i].async) async = true
+ if (async) {
+ resolved = function(cm, callback, options) {
+ var app = applicableHelpers(cm, helpers)
+ function run(i, result) {
+ if (i == app.length) return callback(null)
+ var helper = app[i]
+ if (helper.async) {
+ helper(cm, function(result) {
+ if (result) callback(result)
+ else run(i + 1)
+ }, options)
+ } else {
+ var result = helper(cm, options)
+ if (result) callback(result)
+ else run(i + 1)
+ }
+ }
+ run(0)
+ }
+ resolved.async = true
+ } else {
+ resolved = function(cm, options) {
+ var app = applicableHelpers(cm, helpers)
+ for (var i = 0; i < app.length; i++) {
+ var cur = app[i](cm, options)
+ if (cur && cur.list.length) return cur
+ }
+ }
}
+ resolved.supportsSelection = true
+ return resolved
} else if (words = cm.getHelper(cm.getCursor(), "hintWords")) {
- if (words) return CodeMirror.hint.fromList(cm, {words: words});
+ return function(cm) { return CodeMirror.hint.fromList(cm, {words: words}) }
} else if (CodeMirror.hint.anyword) {
- return CodeMirror.hint.anyword(cm, options);
+ return function(cm, options) { return CodeMirror.hint.anyword(cm, options) }
+ } else {
+ return function() {}
}
+ }
+
+ CodeMirror.registerHelper("hint", "auto", {
+ resolve: resolveAutoHints
});
CodeMirror.registerHelper("hint", "fromList", function(cm, options) {
var cur = cm.getCursor(), token = cm.getTokenAt(cur);
+ var to = CodeMirror.Pos(cur.line, token.end);
+ if (token.string && /\w/.test(token.string[token.string.length - 1])) {
+ var term = token.string, from = CodeMirror.Pos(cur.line, token.start);
+ } else {
+ var term = "", from = to;
+ }
var found = [];
for (var i = 0; i < options.words.length; i++) {
var word = options.words[i];
- if (word.slice(0, token.string.length) == token.string)
+ if (word.slice(0, term.length) == term)
found.push(word);
}
- if (found.length) return {
- list: found,
- from: CodeMirror.Pos(cur.line, token.start),
- to: CodeMirror.Pos(cur.line, token.end)
- };
+ if (found.length) return {list: found, from: from, to: to};
});
CodeMirror.commands.autocomplete = CodeMirror.showHint;
@@ -373,7 +430,7 @@
alignWithWord: true,
closeCharacters: /[\s()\[\]{};:>,]/,
closeOnUnfocus: true,
- completeOnSingleClick: false,
+ completeOnSingleClick: true,
container: null,
customKeys: null,
extraKeys: null
diff --git a/public/vendor/codemirror/addon/hint/sql-hint.js b/public/vendor/codemirror/addon/hint/sql-hint.js
index 22124b58..22124b58 100755..100644
--- a/public/vendor/codemirror/addon/hint/sql-hint.js
+++ b/public/vendor/codemirror/addon/hint/sql-hint.js
diff --git a/public/vendor/codemirror/addon/hint/xml-hint.js b/public/vendor/codemirror/addon/hint/xml-hint.js
index 9b9baa0c..9b9baa0c 100755..100644
--- a/public/vendor/codemirror/addon/hint/xml-hint.js
+++ b/public/vendor/codemirror/addon/hint/xml-hint.js
diff --git a/public/vendor/codemirror/addon/lint/coffeescript-lint.js b/public/vendor/codemirror/addon/lint/coffeescript-lint.js
index 7e39428f..7e39428f 100755..100644
--- a/public/vendor/codemirror/addon/lint/coffeescript-lint.js
+++ b/public/vendor/codemirror/addon/lint/coffeescript-lint.js
diff --git a/public/vendor/codemirror/addon/lint/css-lint.js b/public/vendor/codemirror/addon/lint/css-lint.js
index 1f61b479..1f61b479 100755..100644
--- a/public/vendor/codemirror/addon/lint/css-lint.js
+++ b/public/vendor/codemirror/addon/lint/css-lint.js
diff --git a/public/vendor/codemirror/addon/lint/html-lint.js b/public/vendor/codemirror/addon/lint/html-lint.js
new file mode 100644
index 00000000..1e841709
--- /dev/null
+++ b/public/vendor/codemirror/addon/lint/html-lint.js
@@ -0,0 +1,46 @@
+// CodeMirror, copyright (c) by Marijn Haverbeke and others
+// Distributed under an MIT license: http://codemirror.net/LICENSE
+
+// Depends on htmlhint.js from http://htmlhint.com/js/htmlhint.js
+
+// declare global: HTMLHint
+
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"), require("htmlhint"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror", "htmlhint"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+ "use strict";
+
+ var defaultRules = {
+ "tagname-lowercase": true,
+ "attr-lowercase": true,
+ "attr-value-double-quotes": true,
+ "doctype-first": false,
+ "tag-pair": true,
+ "spec-char-escape": true,
+ "id-unique": true,
+ "src-not-empty": true,
+ "attr-no-duplication": true
+ };
+
+ CodeMirror.registerHelper("lint", "html", function(text, options) {
+ var found = [];
+ if (!window.HTMLHint) return found;
+ var messages = HTMLHint.verify(text, options && options.rules || defaultRules);
+ for (var i = 0; i < messages.length; i++) {
+ var message = messages[i];
+ var startLine = message.line - 1, endLine = message.line - 1, startCol = message.col - 1, endCol = message.col;
+ found.push({
+ from: CodeMirror.Pos(startLine, startCol),
+ to: CodeMirror.Pos(endLine, endCol),
+ message: message.message,
+ severity : message.type
+ });
+ }
+ return found;
+ });
+});
diff --git a/public/vendor/codemirror/addon/lint/javascript-lint.js b/public/vendor/codemirror/addon/lint/javascript-lint.js
index d4f2ae9a..d4f2ae9a 100755..100644
--- a/public/vendor/codemirror/addon/lint/javascript-lint.js
+++ b/public/vendor/codemirror/addon/lint/javascript-lint.js
diff --git a/public/vendor/codemirror/addon/lint/json-lint.js b/public/vendor/codemirror/addon/lint/json-lint.js
index 9dbb616b..9dbb616b 100755..100644
--- a/public/vendor/codemirror/addon/lint/json-lint.js
+++ b/public/vendor/codemirror/addon/lint/json-lint.js
diff --git a/public/vendor/codemirror/addon/lint/lint.css b/public/vendor/codemirror/addon/lint/lint.css
index 414a9a0e..414a9a0e 100755..100644
--- a/public/vendor/codemirror/addon/lint/lint.css
+++ b/public/vendor/codemirror/addon/lint/lint.css
diff --git a/public/vendor/codemirror/addon/lint/lint.js b/public/vendor/codemirror/addon/lint/lint.js
index 3eea203c..5afe49d0 100755..100644
--- a/public/vendor/codemirror/addon/lint/lint.js
+++ b/public/vendor/codemirror/addon/lint/lint.js
@@ -61,6 +61,7 @@
this.timeout = null;
this.hasGutter = hasGutter;
this.onMouseOver = function(e) { onMouseOver(cm, e); };
+ this.waitingFor = 0
}
function parseOptions(_cm, options) {
@@ -115,15 +116,32 @@
return tip;
}
+ function lintAsync(cm, getAnnotations, passOptions) {
+ var state = cm.state.lint
+ var id = ++state.waitingFor
+ function abort() {
+ id = -1
+ cm.off("change", abort)
+ }
+ cm.on("change", abort)
+ getAnnotations(cm.getValue(), function(annotations, arg2) {
+ cm.off("change", abort)
+ if (state.waitingFor != id) return
+ if (arg2 && annotations instanceof CodeMirror) annotations = arg2
+ updateLinting(cm, annotations)
+ }, passOptions, cm);
+ }
+
function startLinting(cm) {
var state = cm.state.lint, options = state.options;
var passOptions = options.options || options; // Support deprecated passing of `options` property in options
var getAnnotations = options.getAnnotations || cm.getHelper(CodeMirror.Pos(0, 0), "lint");
if (!getAnnotations) return;
- if (options.async || getAnnotations.async)
- getAnnotations(cm.getValue(), updateLinting, passOptions, cm);
- else
+ if (options.async || getAnnotations.async) {
+ lintAsync(cm, getAnnotations, passOptions)
+ } else {
updateLinting(cm, getAnnotations(cm.getValue(), passOptions, cm));
+ }
}
function updateLinting(cm, annotationsNotSorted) {
@@ -187,7 +205,8 @@
CodeMirror.defineOption("lint", false, function(cm, val, old) {
if (old && old != CodeMirror.Init) {
clearMarks(cm);
- cm.off("change", onChange);
+ if (cm.state.lint.options.lintOnChange !== false)
+ cm.off("change", onChange);
CodeMirror.off(cm.getWrapperElement(), "mouseover", cm.state.lint.onMouseOver);
clearTimeout(cm.state.lint.timeout);
delete cm.state.lint;
@@ -197,11 +216,16 @@
var gutters = cm.getOption("gutters"), hasLintGutter = false;
for (var i = 0; i < gutters.length; ++i) if (gutters[i] == GUTTER_ID) hasLintGutter = true;
var state = cm.state.lint = new LintState(cm, parseOptions(cm, val), hasLintGutter);
- cm.on("change", onChange);
+ if (state.options.lintOnChange !== false)
+ cm.on("change", onChange);
if (state.options.tooltips != false)
CodeMirror.on(cm.getWrapperElement(), "mouseover", state.onMouseOver);
startLinting(cm);
}
});
+
+ CodeMirror.defineExtension("performLint", function() {
+ if (this.state.lint) startLinting(this);
+ });
});
diff --git a/public/vendor/codemirror/addon/lint/yaml-lint.js b/public/vendor/codemirror/addon/lint/yaml-lint.js
index 3f77e525..3f77e525 100755..100644
--- a/public/vendor/codemirror/addon/lint/yaml-lint.js
+++ b/public/vendor/codemirror/addon/lint/yaml-lint.js
diff --git a/public/vendor/codemirror/addon/merge/merge.css b/public/vendor/codemirror/addon/merge/merge.css
index a6a80e43..a6a80e43 100755..100644
--- a/public/vendor/codemirror/addon/merge/merge.css
+++ b/public/vendor/codemirror/addon/merge/merge.css
diff --git a/public/vendor/codemirror/addon/merge/merge.js b/public/vendor/codemirror/addon/merge/merge.js
index 5b04b032..830a5f02 100755..100644
--- a/public/vendor/codemirror/addon/merge/merge.js
+++ b/public/vendor/codemirror/addon/merge/merge.js
@@ -5,12 +5,12 @@
(function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS
- mod(require("../../lib/codemirror"), require("diff_match_patch"));
+ mod(require("../../lib/codemirror")); // Note non-packaged dependency diff_match_patch
else if (typeof define == "function" && define.amd) // AMD
define(["../../lib/codemirror", "diff_match_patch"], mod);
else // Plain browser env
- mod(CodeMirror, diff_match_patch);
-})(function(CodeMirror, diff_match_patch) {
+ mod(CodeMirror);
+})(function(CodeMirror) {
"use strict";
var Pos = CodeMirror.Pos;
var svgNS = "http://www.w3.org/2000/svg";
@@ -471,13 +471,10 @@
if (left) left.init(leftPane, origLeft, options);
if (right) right.init(rightPane, origRight, options);
- if (options.collapseIdentical) {
- updating = true;
+ if (options.collapseIdentical)
this.editor().operation(function() {
collapseIdenticalStretches(self, options.collapseIdentical);
});
- updating = false;
- }
if (options.connect == "align") {
this.aligners = [];
alignChunks(this.left || this.right, true);
@@ -640,7 +637,7 @@
mark.clear();
cm.removeLineClass(from, "wrap", "CodeMirror-merge-collapsed-line");
}
- widget.addEventListener("click", clear);
+ CodeMirror.on(widget, "click", clear);
return {mark: mark, clear: clear};
}
diff --git a/public/vendor/codemirror/addon/mode/loadmode.js b/public/vendor/codemirror/addon/mode/loadmode.js
index 10117ec2..10117ec2 100755..100644
--- a/public/vendor/codemirror/addon/mode/loadmode.js
+++ b/public/vendor/codemirror/addon/mode/loadmode.js
diff --git a/public/vendor/codemirror/addon/mode/multiplex.js b/public/vendor/codemirror/addon/mode/multiplex.js
index fe48c7fb..3d8b34c4 100755..100644
--- a/public/vendor/codemirror/addon/mode/multiplex.js
+++ b/public/vendor/codemirror/addon/mode/multiplex.js
@@ -51,7 +51,7 @@ CodeMirror.multiplexingMode = function(outer /*, others */) {
if (!other.parseDelimiters) stream.match(other.open);
state.innerActive = other;
state.inner = CodeMirror.startState(other.mode, outer.indent ? outer.indent(state.outer, "") : 0);
- return other.delimStyle;
+ return other.delimStyle && (other.delimStyle + " " + other.delimStyle + "-open");
} else if (found != -1 && found < cutOff) {
cutOff = found;
}
@@ -70,7 +70,7 @@ CodeMirror.multiplexingMode = function(outer /*, others */) {
if (found == stream.pos && !curInner.parseDelimiters) {
stream.match(curInner.close);
state.innerActive = state.inner = null;
- return curInner.delimStyle;
+ return curInner.delimStyle && (curInner.delimStyle + " " + curInner.delimStyle + "-close");
}
if (found > -1) stream.string = oldContent.slice(0, found);
var innerToken = curInner.mode.token(stream, state.inner);
@@ -80,7 +80,7 @@ CodeMirror.multiplexingMode = function(outer /*, others */) {
state.innerActive = state.inner = null;
if (curInner.innerStyle) {
- if (innerToken) innerToken = innerToken + ' ' + curInner.innerStyle;
+ if (innerToken) innerToken = innerToken + " " + curInner.innerStyle;
else innerToken = curInner.innerStyle;
}
diff --git a/public/vendor/codemirror/addon/mode/multiplex_test.js b/public/vendor/codemirror/addon/mode/multiplex_test.js
index d3394342..24e5e670 100755..100644
--- a/public/vendor/codemirror/addon/mode/multiplex_test.js
+++ b/public/vendor/codemirror/addon/mode/multiplex_test.js
@@ -29,5 +29,5 @@
MT(
"stexInsideMarkdown",
- "[strong **Equation:**] [delim $][inner&tag \\pi][delim $]");
+ "[strong **Equation:**] [delim&delim-open $][inner&tag \\pi][delim&delim-close $]");
})();
diff --git a/public/vendor/codemirror/addon/mode/overlay.js b/public/vendor/codemirror/addon/mode/overlay.js
index e1b9ed37..e1b9ed37 100755..100644
--- a/public/vendor/codemirror/addon/mode/overlay.js
+++ b/public/vendor/codemirror/addon/mode/overlay.js
diff --git a/public/vendor/codemirror/addon/mode/simple.js b/public/vendor/codemirror/addon/mode/simple.js
index 795328b8..df663365 100755..100644
--- a/public/vendor/codemirror/addon/mode/simple.js
+++ b/public/vendor/codemirror/addon/mode/simple.js
@@ -60,7 +60,7 @@
function ensureState(states, name) {
if (!states.hasOwnProperty(name))
- throw new Error("Undefined state " + name + "in simple mode");
+ throw new Error("Undefined state " + name + " in simple mode");
}
function toRegex(val, caret) {
diff --git a/public/vendor/codemirror/addon/runmode/colorize.js b/public/vendor/codemirror/addon/runmode/colorize.js
index eb7060d0..eb7060d0 100755..100644
--- a/public/vendor/codemirror/addon/runmode/colorize.js
+++ b/public/vendor/codemirror/addon/runmode/colorize.js
diff --git a/public/vendor/codemirror/addon/runmode/runmode-standalone.js b/public/vendor/codemirror/addon/runmode/runmode-standalone.js
index f4f352c8..f4f352c8 100755..100644
--- a/public/vendor/codemirror/addon/runmode/runmode-standalone.js
+++ b/public/vendor/codemirror/addon/runmode/runmode-standalone.js
diff --git a/public/vendor/codemirror/addon/runmode/runmode.js b/public/vendor/codemirror/addon/runmode/runmode.js
index 07d2279f..a51c6d0d 100755..100644
--- a/public/vendor/codemirror/addon/runmode/runmode.js
+++ b/public/vendor/codemirror/addon/runmode/runmode.js
@@ -16,7 +16,7 @@ CodeMirror.runMode = function(string, modespec, callback, options) {
var ie = /MSIE \d/.test(navigator.userAgent);
var ie_lt9 = ie && (document.documentMode == null || document.documentMode < 9);
- if (callback.nodeType == 1) {
+ if (callback.appendChild) {
var tabSize = (options && options.tabSize) || CodeMirror.defaults.tabSize;
var node = callback, col = 0;
node.innerHTML = "";
diff --git a/public/vendor/codemirror/addon/runmode/runmode.node.js b/public/vendor/codemirror/addon/runmode/runmode.node.js
index 8f345a32..b22a5187 100755..100644
--- a/public/vendor/codemirror/addon/runmode/runmode.node.js
+++ b/public/vendor/codemirror/addon/runmode/runmode.node.js
@@ -176,3 +176,4 @@ exports.runMode = function(string, modespec, callback, options) {
};
require.cache[require.resolve("../../lib/codemirror")] = require.cache[require.resolve("./runmode.node")];
+require.cache[require.resolve("../../addon/runmode/runmode")] = require.cache[require.resolve("./runmode.node")];
diff --git a/public/vendor/codemirror/addon/scroll/annotatescrollbar.js b/public/vendor/codemirror/addon/scroll/annotatescrollbar.js
index bbbfa59c..3f80f483 100755..100644
--- a/public/vendor/codemirror/addon/scroll/annotatescrollbar.js
+++ b/public/vendor/codemirror/addon/scroll/annotatescrollbar.js
@@ -51,7 +51,7 @@
Annotation.prototype.computeScale = function() {
var cm = this.cm;
var hScale = (cm.getWrapperElement().clientHeight - cm.display.barHeight - this.buttonHeight * 2) /
- cm.heightAtLine(cm.lastLine() + 1, "local");
+ cm.getScrollerElement().scrollHeight
if (hScale != this.hScale) {
this.hScale = hScale;
return true;
@@ -100,6 +100,9 @@
elt.style.cssText = "position: absolute; right: 0px; width: " + Math.max(cm.display.barWidth * 1.5, 2) + "px; top: "
+ (top + this.buttonHeight) + "px; height: " + height + "px";
elt.className = this.options.className;
+ if (ann.id) {
+ elt.setAttribute("annotation-id", ann.id);
+ }
}
this.div.textContent = "";
this.div.appendChild(frag);
diff --git a/public/vendor/codemirror/addon/scroll/scrollpastend.js b/public/vendor/codemirror/addon/scroll/scrollpastend.js
index 008ae4c7..008ae4c7 100755..100644
--- a/public/vendor/codemirror/addon/scroll/scrollpastend.js
+++ b/public/vendor/codemirror/addon/scroll/scrollpastend.js
diff --git a/public/vendor/codemirror/addon/scroll/simplescrollbars.js b/public/vendor/codemirror/addon/scroll/simplescrollbars.js
index f78353a1..f78353a1 100755..100644
--- a/public/vendor/codemirror/addon/scroll/simplescrollbars.js
+++ b/public/vendor/codemirror/addon/scroll/simplescrollbars.js
diff --git a/public/vendor/codemirror/addon/search/jump-to-line.js b/public/vendor/codemirror/addon/search/jump-to-line.js
new file mode 100644
index 00000000..8b599cbc
--- /dev/null
+++ b/public/vendor/codemirror/addon/search/jump-to-line.js
@@ -0,0 +1,49 @@
+// CodeMirror, copyright (c) by Marijn Haverbeke and others
+// Distributed under an MIT license: http://codemirror.net/LICENSE
+
+// Defines jumpToLine command. Uses dialog.js if present.
+
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"), require("../dialog/dialog"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror", "../dialog/dialog"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+ "use strict";
+
+ function dialog(cm, text, shortText, deflt, f) {
+ if (cm.openDialog) cm.openDialog(text, f, {value: deflt, selectValueOnOpen: true});
+ else f(prompt(shortText, deflt));
+ }
+
+ var jumpDialog =
+ 'Jump to line: <input type="text" style="width: 10em" class="CodeMirror-search-field"/> <span style="color: #888" class="CodeMirror-search-hint">(Use line:column or scroll% syntax)</span>';
+
+ function interpretLine(cm, string) {
+ var num = Number(string)
+ if (/^[-+]/.test(string)) return cm.getCursor().line + num
+ else return num - 1
+ }
+
+ CodeMirror.commands.jumpToLine = function(cm) {
+ var cur = cm.getCursor();
+ dialog(cm, jumpDialog, "Jump to line:", (cur.line + 1) + ":" + cur.ch, function(posStr) {
+ if (!posStr) return;
+
+ var match;
+ if (match = /^\s*([\+\-]?\d+)\s*\:\s*(\d+)\s*$/.exec(posStr)) {
+ cm.setCursor(interpretLine(cm, match[1]), Number(match[2]))
+ } else if (match = /^\s*([\+\-]?\d+(\.\d+)?)\%\s*/.exec(posStr)) {
+ var line = Math.round(cm.lineCount() * Number(match[1]) / 100);
+ if (/^[-+]/.test(match[1])) line = cur.line + line + 1;
+ cm.setCursor(line - 1, cur.ch);
+ } else if (match = /^\s*\:?\s*([\+\-]?\d+)\s*/.exec(posStr)) {
+ cm.setCursor(interpretLine(cm, match[1]), cur.ch);
+ }
+ });
+ };
+
+ CodeMirror.keyMap["default"]["Alt-G"] = "jumpToLine";
+});
diff --git a/public/vendor/codemirror/addon/search/match-highlighter.js b/public/vendor/codemirror/addon/search/match-highlighter.js
index e9a22721..8f02f01c 100755..100644
--- a/public/vendor/codemirror/addon/search/match-highlighter.js
+++ b/public/vendor/codemirror/addon/search/match-highlighter.js
@@ -16,13 +16,14 @@
// highlighted only if the selected text is a word. showToken, when enabled,
// will cause the current token to be highlighted when nothing is selected.
// delay is used to specify how much time to wait, in milliseconds, before
-// highlighting the matches.
+// highlighting the matches. If annotateScrollbar is enabled, the occurances
+// will be highlighted on the scrollbar via the matchesonscrollbar addon.
(function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS
- mod(require("../../lib/codemirror"));
+ mod(require("../../lib/codemirror"), require("./matchesonscrollbar"));
else if (typeof define == "function" && define.amd) // AMD
- define(["../../lib/codemirror"], mod);
+ define(["../../lib/codemirror", "./matchesonscrollbar"], mod);
else // Plain browser env
mod(CodeMirror);
})(function(CodeMirror) {
@@ -40,18 +41,19 @@
this.showToken = options.showToken;
this.delay = options.delay;
this.wordsOnly = options.wordsOnly;
+ this.annotateScrollbar = options.annotateScrollbar;
}
if (this.style == null) this.style = DEFAULT_TOKEN_STYLE;
if (this.minChars == null) this.minChars = DEFAULT_MIN_CHARS;
if (this.delay == null) this.delay = DEFAULT_DELAY;
if (this.wordsOnly == null) this.wordsOnly = DEFAULT_WORDS_ONLY;
this.overlay = this.timeout = null;
+ this.matchesonscroll = null;
}
CodeMirror.defineOption("highlightSelectionMatches", false, function(cm, val, old) {
if (old && old != CodeMirror.Init) {
- var over = cm.state.matchHighlighter.overlay;
- if (over) cm.removeOverlay(over);
+ removeOverlay(cm);
clearTimeout(cm.state.matchHighlighter.timeout);
cm.state.matchHighlighter = null;
cm.off("cursorActivity", cursorActivity);
@@ -69,20 +71,39 @@
state.timeout = setTimeout(function() {highlightMatches(cm);}, state.delay);
}
+ function addOverlay(cm, query, hasBoundary, style) {
+ var state = cm.state.matchHighlighter;
+ cm.addOverlay(state.overlay = makeOverlay(query, hasBoundary, style));
+ if (state.annotateScrollbar) {
+ var searchFor = hasBoundary ? new RegExp("\\b" + query + "\\b") : query;
+ state.matchesonscroll = cm.showMatchesOnScrollbar(searchFor, true,
+ {className: "CodeMirror-selection-highlight-scrollbar"});
+ }
+ }
+
+ function removeOverlay(cm) {
+ var state = cm.state.matchHighlighter;
+ if (state.overlay) {
+ cm.removeOverlay(state.overlay);
+ state.overlay = null;
+ if (state.annotateScrollbar) {
+ state.matchesonscroll.clear();
+ state.matchesonscroll = null;
+ }
+ }
+ }
+
function highlightMatches(cm) {
cm.operation(function() {
var state = cm.state.matchHighlighter;
- if (state.overlay) {
- cm.removeOverlay(state.overlay);
- state.overlay = null;
- }
+ removeOverlay(cm);
if (!cm.somethingSelected() && state.showToken) {
var re = state.showToken === true ? /[\w$]/ : state.showToken;
var cur = cm.getCursor(), line = cm.getLine(cur.line), start = cur.ch, end = start;
while (start && re.test(line.charAt(start - 1))) --start;
while (end < line.length && re.test(line.charAt(end))) ++end;
if (start < end)
- cm.addOverlay(state.overlay = makeOverlay(line.slice(start, end), re, state.style));
+ addOverlay(cm, line.slice(start, end), re, state.style);
return;
}
var from = cm.getCursor("from"), to = cm.getCursor("to");
@@ -90,7 +111,7 @@
if (state.wordsOnly && !isWord(cm, from, to)) return;
var selection = cm.getRange(from, to).replace(/^\s+|\s+$/g, "");
if (selection.length >= state.minChars)
- cm.addOverlay(state.overlay = makeOverlay(selection, false, state.style));
+ addOverlay(cm, selection, false, state.style);
});
}
diff --git a/public/vendor/codemirror/addon/search/matchesonscrollbar.js b/public/vendor/codemirror/addon/search/matchesonscrollbar.js
index 8d192289..8d192289 100755..100644
--- a/public/vendor/codemirror/addon/search/matchesonscrollbar.js
+++ b/public/vendor/codemirror/addon/search/matchesonscrollbar.js
diff --git a/public/vendor/codemirror/addon/search/search.js b/public/vendor/codemirror/addon/search/search.js
index afa85ebe..93e90b36 100755..100644
--- a/public/vendor/codemirror/addon/search/search.js
+++ b/public/vendor/codemirror/addon/search/search.js
@@ -18,6 +18,7 @@
mod(CodeMirror);
})(function(CodeMirror) {
"use strict";
+
function searchOverlay(query, caseInsensitive) {
if (typeof query == "string")
query = new RegExp(query.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"), caseInsensitive ? "gi" : "g");
@@ -28,7 +29,7 @@
query.lastIndex = stream.pos;
var match = query.exec(stream.string);
if (match && match.index == stream.pos) {
- stream.pos += match[0].length;
+ stream.pos += match[0].length || 1;
return "searching";
} else if (match) {
stream.pos = match.index;
@@ -42,57 +43,106 @@
this.posFrom = this.posTo = this.lastQuery = this.query = null;
this.overlay = null;
}
+
function getSearchState(cm) {
return cm.state.search || (cm.state.search = new SearchState());
}
+
function queryCaseInsensitive(query) {
return typeof query == "string" && query == query.toLowerCase();
}
+
function getSearchCursor(cm, query, pos) {
// Heuristic: if the query string is all lowercase, do a case insensitive search.
return cm.getSearchCursor(query, pos, queryCaseInsensitive(query));
}
+
+ function persistentDialog(cm, text, deflt, f) {
+ cm.openDialog(text, f, {
+ value: deflt,
+ selectValueOnOpen: true,
+ closeOnEnter: false,
+ onClose: function() { clearSearch(cm); }
+ });
+ }
+
function dialog(cm, text, shortText, deflt, f) {
if (cm.openDialog) cm.openDialog(text, f, {value: deflt, selectValueOnOpen: true});
else f(prompt(shortText, deflt));
}
+
function confirmDialog(cm, text, shortText, fs) {
if (cm.openConfirm) cm.openConfirm(text, fs);
else if (confirm(shortText)) fs[0]();
}
+
+ function parseString(string) {
+ return string.replace(/\\(.)/g, function(_, ch) {
+ if (ch == "n") return "\n"
+ if (ch == "r") return "\r"
+ return ch
+ })
+ }
+
function parseQuery(query) {
var isRE = query.match(/^\/(.*)\/([a-z]*)$/);
if (isRE) {
try { query = new RegExp(isRE[1], isRE[2].indexOf("i") == -1 ? "" : "i"); }
catch(e) {} // Not a regular expression after all, do a string search
+ } else {
+ query = parseString(query)
}
if (typeof query == "string" ? query == "" : query.test(""))
query = /x^/;
return query;
}
+
var queryDialog =
'Search: <input type="text" style="width: 10em" class="CodeMirror-search-field"/> <span style="color: #888" class="CodeMirror-search-hint">(Use /re/ syntax for regexp search)</span>';
- function doSearch(cm, rev) {
+
+ function startSearch(cm, state, query) {
+ state.queryText = query;
+ state.query = parseQuery(query);
+ cm.removeOverlay(state.overlay, queryCaseInsensitive(state.query));
+ state.overlay = searchOverlay(state.query, queryCaseInsensitive(state.query));
+ cm.addOverlay(state.overlay);
+ if (cm.showMatchesOnScrollbar) {
+ if (state.annotate) { state.annotate.clear(); state.annotate = null; }
+ state.annotate = cm.showMatchesOnScrollbar(state.query, queryCaseInsensitive(state.query));
+ }
+ }
+
+ function doSearch(cm, rev, persistent) {
var state = getSearchState(cm);
if (state.query) return findNext(cm, rev);
var q = cm.getSelection() || state.lastQuery;
- dialog(cm, queryDialog, "Search for:", q, function(query) {
- cm.operation(function() {
- if (!query || state.query) return;
- state.query = parseQuery(query);
- cm.removeOverlay(state.overlay, queryCaseInsensitive(state.query));
- state.overlay = searchOverlay(state.query, queryCaseInsensitive(state.query));
- cm.addOverlay(state.overlay);
- if (cm.showMatchesOnScrollbar) {
- if (state.annotate) { state.annotate.clear(); state.annotate = null; }
- state.annotate = cm.showMatchesOnScrollbar(state.query, queryCaseInsensitive(state.query));
- }
- state.posFrom = state.posTo = cm.getCursor();
- findNext(cm, rev);
+ if (persistent && cm.openDialog) {
+ var hiding = null
+ persistentDialog(cm, queryDialog, q, function(query, event) {
+ CodeMirror.e_stop(event);
+ if (!query) return;
+ if (query != state.queryText) startSearch(cm, state, query);
+ if (hiding) hiding.style.opacity = 1
+ findNext(cm, event.shiftKey, function(_, to) {
+ var dialog
+ if (to.line < 3 && document.querySelector &&
+ (dialog = cm.display.wrapper.querySelector(".CodeMirror-dialog")) &&
+ dialog.getBoundingClientRect().bottom - 4 > cm.cursorCoords(to, "window").top)
+ (hiding = dialog).style.opacity = .4
+ })
});
- });
+ } else {
+ dialog(cm, queryDialog, "Search for:", q, function(query) {
+ if (query && !state.query) cm.operation(function() {
+ startSearch(cm, state, query);
+ state.posFrom = state.posTo = cm.getCursor();
+ findNext(cm, rev);
+ });
+ });
+ }
}
- function findNext(cm, rev) {cm.operation(function() {
+
+ function findNext(cm, rev, callback) {cm.operation(function() {
var state = getSearchState(cm);
var cursor = getSearchCursor(cm, state.query, rev ? state.posFrom : state.posTo);
if (!cursor.find(rev)) {
@@ -100,38 +150,47 @@
if (!cursor.find(rev)) return;
}
cm.setSelection(cursor.from(), cursor.to());
- cm.scrollIntoView({from: cursor.from(), to: cursor.to()});
+ cm.scrollIntoView({from: cursor.from(), to: cursor.to()}, 20);
state.posFrom = cursor.from(); state.posTo = cursor.to();
+ if (callback) callback(cursor.from(), cursor.to())
});}
+
function clearSearch(cm) {cm.operation(function() {
var state = getSearchState(cm);
state.lastQuery = state.query;
if (!state.query) return;
- state.query = null;
+ state.query = state.queryText = null;
cm.removeOverlay(state.overlay);
if (state.annotate) { state.annotate.clear(); state.annotate = null; }
});}
var replaceQueryDialog =
- 'Replace: <input type="text" style="width: 10em" class="CodeMirror-search-field"/> <span style="color: #888" class="CodeMirror-search-hint">(Use /re/ syntax for regexp search)</span>';
+ ' <input type="text" style="width: 10em" class="CodeMirror-search-field"/> <span style="color: #888" class="CodeMirror-search-hint">(Use /re/ syntax for regexp search)</span>';
var replacementQueryDialog = 'With: <input type="text" style="width: 10em" class="CodeMirror-search-field"/>';
- var doReplaceConfirm = "Replace? <button>Yes</button> <button>No</button> <button>Stop</button>";
+ var doReplaceConfirm = "Replace? <button>Yes</button> <button>No</button> <button>All</button> <button>Stop</button>";
+
+ function replaceAll(cm, query, text) {
+ cm.operation(function() {
+ for (var cursor = getSearchCursor(cm, query); cursor.findNext();) {
+ if (typeof query != "string") {
+ var match = cm.getRange(cursor.from(), cursor.to()).match(query);
+ cursor.replace(text.replace(/\$(\d)/g, function(_, i) {return match[i];}));
+ } else cursor.replace(text);
+ }
+ });
+ }
+
function replace(cm, all) {
if (cm.getOption("readOnly")) return;
var query = cm.getSelection() || getSearchState(cm).lastQuery;
- dialog(cm, replaceQueryDialog, "Replace:", query, function(query) {
+ var dialogText = all ? "Replace all:" : "Replace:"
+ dialog(cm, dialogText + replaceQueryDialog, dialogText, query, function(query) {
if (!query) return;
query = parseQuery(query);
dialog(cm, replacementQueryDialog, "Replace with:", "", function(text) {
+ text = parseString(text)
if (all) {
- cm.operation(function() {
- for (var cursor = getSearchCursor(cm, query); cursor.findNext();) {
- if (typeof query != "string") {
- var match = cm.getRange(cursor.from(), cursor.to()).match(query);
- cursor.replace(text.replace(/\$(\d)/g, function(_, i) {return match[i];}), "+input");
- } else cursor.replace(text, "+input");
- }
- });
+ replaceAll(cm, query, text)
} else {
clearSearch(cm);
var cursor = getSearchCursor(cm, query, cm.getCursor());
@@ -145,11 +204,12 @@
cm.setSelection(cursor.from(), cursor.to());
cm.scrollIntoView({from: cursor.from(), to: cursor.to()});
confirmDialog(cm, doReplaceConfirm, "Replace?",
- [function() {doReplace(match);}, advance]);
+ [function() {doReplace(match);}, advance,
+ function() {replaceAll(cm, query, text)}]);
};
var doReplace = function(match) {
cursor.replace(typeof query == "string" ? text :
- text.replace(/\$(\d)/g, function(_, i) {return match[i];}), "+input");
+ text.replace(/\$(\d)/g, function(_, i) {return match[i];}));
advance();
};
advance();
@@ -159,6 +219,7 @@
}
CodeMirror.commands.find = function(cm) {clearSearch(cm); doSearch(cm);};
+ CodeMirror.commands.findPersistent = function(cm) {clearSearch(cm); doSearch(cm, false, true);};
CodeMirror.commands.findNext = doSearch;
CodeMirror.commands.findPrev = function(cm) {doSearch(cm, true);};
CodeMirror.commands.clearSearch = clearSearch;
diff --git a/public/vendor/codemirror/addon/search/searchcursor.js b/public/vendor/codemirror/addon/search/searchcursor.js
index b70242ee..b70242ee 100755..100644
--- a/public/vendor/codemirror/addon/search/searchcursor.js
+++ b/public/vendor/codemirror/addon/search/searchcursor.js
diff --git a/public/vendor/codemirror/addon/selection/active-line.js b/public/vendor/codemirror/addon/selection/active-line.js
index 22da2e0a..22da2e0a 100755..100644
--- a/public/vendor/codemirror/addon/selection/active-line.js
+++ b/public/vendor/codemirror/addon/selection/active-line.js
diff --git a/public/vendor/codemirror/addon/selection/mark-selection.js b/public/vendor/codemirror/addon/selection/mark-selection.js
index 5c42d21e..5c42d21e 100755..100644
--- a/public/vendor/codemirror/addon/selection/mark-selection.js
+++ b/public/vendor/codemirror/addon/selection/mark-selection.js
diff --git a/public/vendor/codemirror/addon/selection/selection-pointer.js b/public/vendor/codemirror/addon/selection/selection-pointer.js
index ef5e404a..ef5e404a 100755..100644
--- a/public/vendor/codemirror/addon/selection/selection-pointer.js
+++ b/public/vendor/codemirror/addon/selection/selection-pointer.js
diff --git a/public/vendor/codemirror/addon/tern/tern.css b/public/vendor/codemirror/addon/tern/tern.css
index 76fba33d..c4b8a2f7 100755..100644
--- a/public/vendor/codemirror/addon/tern/tern.css
+++ b/public/vendor/codemirror/addon/tern/tern.css
@@ -1,6 +1,7 @@
.CodeMirror-Tern-completion {
padding-left: 22px;
position: relative;
+ line-height: 1.5;
}
.CodeMirror-Tern-completion:before {
position: absolute;
diff --git a/public/vendor/codemirror/addon/tern/tern.js b/public/vendor/codemirror/addon/tern/tern.js
index dfb19b84..c345c497 100755..100644
--- a/public/vendor/codemirror/addon/tern/tern.js
+++ b/public/vendor/codemirror/addon/tern/tern.js
@@ -135,6 +135,7 @@
},
destroy: function () {
+ closeArgHints(this)
if (this.worker) {
this.worker.terminate();
this.worker = null;
@@ -216,7 +217,7 @@
var completion = data.completions[i], className = typeToIcon(completion.type);
if (data.guess) className += " " + cls + "guess";
completions.push({text: completion.name + after,
- displayText: completion.name,
+ displayText: completion.displayName || completion.name,
className: className,
data: completion});
}
@@ -266,7 +267,7 @@
child.target = "_blank";
}
}
- tempTooltip(cm, tip);
+ tempTooltip(cm, tip, ts);
if (c) c();
}, pos);
}
@@ -466,11 +467,12 @@
ts.request(cm, {type: "refs"}, function(error, data) {
if (error) return showError(ts, cm, error);
var ranges = [], cur = 0;
+ var curPos = cm.getCursor();
for (var i = 0; i < data.refs.length; i++) {
var ref = data.refs[i];
if (ref.file == name) {
ranges.push({anchor: ref.start, head: ref.end});
- if (cmpPos(cur, ref.start) >= 0 && cmpPos(cur, ref.end) <= 0)
+ if (cmpPos(curPos, ref.start) >= 0 && cmpPos(curPos, ref.end) <= 0)
cur = ranges.length - 1;
}
}
@@ -592,7 +594,7 @@
// Tooltips
- function tempTooltip(cm, content) {
+ function tempTooltip(cm, content, ts) {
if (cm.state.ternTooltip) remove(cm.state.ternTooltip);
var where = cm.cursorCoords();
var tip = cm.state.ternTooltip = makeTooltip(where.right + 1, where.bottom, content);
@@ -616,7 +618,7 @@
else mouseOnTip = false;
}
});
- setTimeout(maybeClear, 1700);
+ setTimeout(maybeClear, ts.options.hintDelay ? ts.options.hintDelay : 1700);
cm.on("cursorActivity", clear);
cm.on('blur', clear);
cm.on('scroll', clear);
@@ -644,7 +646,7 @@
if (ts.options.showError)
ts.options.showError(cm, msg);
else
- tempTooltip(cm, String(msg));
+ tempTooltip(cm, String(msg), ts);
}
function closeArgHints(ts) {
diff --git a/public/vendor/codemirror/addon/tern/worker.js b/public/vendor/codemirror/addon/tern/worker.js
index 887f906a..887f906a 100755..100644
--- a/public/vendor/codemirror/addon/tern/worker.js
+++ b/public/vendor/codemirror/addon/tern/worker.js
diff --git a/public/vendor/codemirror/addon/wrap/hardwrap.js b/public/vendor/codemirror/addon/wrap/hardwrap.js
index fe9b4dd6..8806fbe2 100755..100644
--- a/public/vendor/codemirror/addon/wrap/hardwrap.js
+++ b/public/vendor/codemirror/addon/wrap/hardwrap.js
@@ -32,11 +32,13 @@
function findBreakPoint(text, column, wrapOn, killTrailingSpace) {
for (var at = column; at > 0; --at)
if (wrapOn.test(text.slice(at - 1, at + 1))) break;
- if (at == 0) at = column;
- var endOfText = at;
- if (killTrailingSpace)
- while (text.charAt(endOfText - 1) == " ") --endOfText;
- return {from: endOfText, to: at};
+ for (var first = true;; first = false) {
+ var endOfText = at;
+ if (killTrailingSpace)
+ while (text.charAt(endOfText - 1) == " ") --endOfText;
+ if (endOfText == 0 && first) at = column;
+ else return {from: endOfText, to: at};
+ }
}
function wrapRange(cm, from, to, options) {
@@ -86,7 +88,8 @@
if (changes.length) cm.operation(function() {
for (var i = 0; i < changes.length; ++i) {
var change = changes[i];
- cm.replaceRange(change.text, change.from, change.to);
+ if (change.text || CodeMirror.cmpPos(change.from, change.to))
+ cm.replaceRange(change.text, change.from, change.to);
}
});
return changes.length ? {from: changes[0].from, to: CodeMirror.changeEnd(changes[changes.length - 1])} : null;