codemirror-rails 3.02 → 3.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +1 -1
- data/LICENSE +1 -1
- data/codemirror-rails.gemspec +1 -0
- data/doc/CodeMirror-LICENSE +5 -1
- data/lib/codemirror/rails/version.rb +2 -2
- data/vendor/assets/javascripts/codemirror/{utils → addons/dialog}/dialog.js +4 -0
- data/vendor/assets/javascripts/codemirror/addons/display/placeholder.js +54 -0
- data/vendor/assets/javascripts/codemirror/addons/edit/closebrackets.js +54 -0
- data/vendor/assets/javascripts/codemirror/{utils → addons/edit}/closetag.js +9 -8
- data/vendor/assets/javascripts/codemirror/{utils → addons/edit}/continuecomment.js +12 -4
- data/vendor/assets/javascripts/codemirror/addons/edit/continuelist.js +25 -0
- data/vendor/assets/javascripts/codemirror/{utils → addons/edit}/matchbrackets.js +30 -11
- data/vendor/assets/javascripts/codemirror/addons/fold/brace-fold.js +31 -0
- data/vendor/assets/javascripts/codemirror/addons/fold/foldcode.js +32 -0
- data/vendor/assets/javascripts/codemirror/addons/fold/indent-fold.js +11 -0
- data/vendor/assets/javascripts/codemirror/addons/fold/xml-fold.js +64 -0
- data/vendor/assets/javascripts/codemirror/addons/hint/html-hint.js +582 -0
- data/vendor/assets/javascripts/codemirror/{utils → addons/hint}/javascript-hint.js +15 -11
- data/vendor/assets/javascripts/codemirror/{utils → addons/hint}/pig-hint.js +19 -19
- data/vendor/assets/javascripts/codemirror/{utils → addons/hint}/python-hint.js +2 -2
- data/vendor/assets/javascripts/codemirror/addons/hint/show-hint.js +180 -0
- data/vendor/assets/javascripts/codemirror/{utils → addons/hint}/xml-hint.js +5 -18
- data/vendor/assets/javascripts/codemirror/addons/lint/javascript-lint.js +127 -0
- data/vendor/assets/javascripts/codemirror/addons/lint/json-lint.js +14 -0
- data/vendor/assets/javascripts/codemirror/addons/lint/lint.js +197 -0
- data/vendor/assets/javascripts/codemirror/{utils → addons/mode}/loadmode.js +0 -0
- data/vendor/assets/javascripts/codemirror/{utils → addons/mode}/multiplex.js +2 -2
- data/vendor/assets/javascripts/codemirror/{utils → addons/mode}/overlay.js +2 -2
- data/vendor/assets/javascripts/codemirror/{utils → addons/runmode}/colorize.js +0 -0
- data/vendor/assets/javascripts/codemirror/{utils → addons/runmode}/runmode-standalone.js +2 -3
- data/vendor/assets/javascripts/codemirror/{utils → addons/runmode}/runmode.js +0 -0
- data/vendor/assets/javascripts/codemirror/addons/runmode/runmode.node.js +89 -0
- data/vendor/assets/javascripts/codemirror/addons/search/match-highlighter.js +60 -0
- data/vendor/assets/javascripts/codemirror/{utils → addons/search}/search.js +5 -5
- data/vendor/assets/javascripts/codemirror/{utils → addons/search}/searchcursor.js +37 -30
- data/vendor/assets/javascripts/codemirror/addons/selection/active-line.js +39 -0
- data/vendor/assets/javascripts/codemirror/addons/selection/mark-selection.js +34 -0
- data/vendor/assets/javascripts/codemirror/keymaps/vim.js +721 -188
- data/vendor/assets/javascripts/codemirror/modes/asterisk.js +6 -6
- data/vendor/assets/javascripts/codemirror/modes/clike.js +14 -14
- data/vendor/assets/javascripts/codemirror/modes/clojure.js +23 -7
- data/vendor/assets/javascripts/codemirror/modes/coffeescript.js +2 -2
- data/vendor/assets/javascripts/codemirror/modes/css.js +337 -235
- data/vendor/assets/javascripts/codemirror/modes/ecl.js +12 -12
- data/vendor/assets/javascripts/codemirror/modes/erlang.js +1 -1
- data/vendor/assets/javascripts/codemirror/modes/gas.js +326 -0
- data/vendor/assets/javascripts/codemirror/modes/gfm.js +1 -0
- data/vendor/assets/javascripts/codemirror/modes/haskell.js +26 -26
- data/vendor/assets/javascripts/codemirror/modes/haxe.js +17 -17
- data/vendor/assets/javascripts/codemirror/modes/htmlembedded.js +6 -6
- data/vendor/assets/javascripts/codemirror/modes/htmlmixed.js +43 -23
- data/vendor/assets/javascripts/codemirror/modes/javascript.js +78 -33
- data/vendor/assets/javascripts/codemirror/modes/jinja2.js +2 -2
- data/vendor/assets/javascripts/codemirror/modes/less.js +38 -38
- data/vendor/assets/javascripts/codemirror/modes/livescript.js +267 -0
- data/vendor/assets/javascripts/codemirror/modes/lua.js +7 -7
- data/vendor/assets/javascripts/codemirror/modes/markdown.js +108 -57
- data/vendor/assets/javascripts/codemirror/modes/mirc.js +177 -0
- data/vendor/assets/javascripts/codemirror/modes/ntriples.js +22 -22
- data/vendor/assets/javascripts/codemirror/modes/ocaml.js +1 -1
- data/vendor/assets/javascripts/codemirror/modes/perl.js +791 -791
- data/vendor/assets/javascripts/codemirror/modes/php.js +1 -1
- data/vendor/assets/javascripts/codemirror/modes/pig.js +163 -163
- data/vendor/assets/javascripts/codemirror/modes/python.js +31 -31
- data/vendor/assets/javascripts/codemirror/modes/q.js +124 -0
- data/vendor/assets/javascripts/codemirror/modes/rst.js +486 -250
- data/vendor/assets/javascripts/codemirror/modes/sass.js +3 -3
- data/vendor/assets/javascripts/codemirror/modes/scss_test.js +80 -0
- data/vendor/assets/javascripts/codemirror/modes/shell.js +2 -2
- data/vendor/assets/javascripts/codemirror/modes/sieve.js +10 -10
- data/vendor/assets/javascripts/codemirror/modes/smalltalk.js +129 -129
- data/vendor/assets/javascripts/codemirror/modes/smarty.js +3 -3
- data/vendor/assets/javascripts/codemirror/modes/sparql.js +1 -1
- data/vendor/assets/javascripts/codemirror/modes/sql.js +23 -23
- data/vendor/assets/javascripts/codemirror/modes/stex.js +192 -121
- data/vendor/assets/javascripts/codemirror/modes/tcl.js +131 -0
- data/vendor/assets/javascripts/codemirror/modes/test.js +64 -0
- data/vendor/assets/javascripts/codemirror/modes/tiddlywiki.js +345 -345
- data/vendor/assets/javascripts/codemirror/modes/tiki.js +297 -298
- data/vendor/assets/javascripts/codemirror/modes/turtle.js +145 -0
- data/vendor/assets/javascripts/codemirror/modes/vb.js +31 -32
- data/vendor/assets/javascripts/codemirror/modes/vbscript.js +4 -4
- data/vendor/assets/javascripts/codemirror/modes/xml.js +10 -6
- data/vendor/assets/javascripts/codemirror/modes/xquery.js +55 -55
- data/vendor/assets/javascripts/codemirror/modes/yaml.js +90 -90
- data/vendor/assets/javascripts/codemirror/modes/z80.js +82 -110
- data/vendor/assets/javascripts/codemirror.js +1914 -1115
- data/vendor/assets/stylesheets/codemirror/{utils → addons/dialog}/dialog.css +0 -0
- data/vendor/assets/stylesheets/codemirror/addons/hint/show-hint.css +38 -0
- data/vendor/assets/stylesheets/codemirror/addons/lint/lint.css +96 -0
- data/vendor/assets/stylesheets/codemirror/modes/tiki.css +2 -2
- data/vendor/assets/stylesheets/codemirror/themes/ambiance-mobile.css +0 -1
- data/vendor/assets/stylesheets/codemirror/themes/ambiance.css +0 -1
- data/vendor/assets/stylesheets/codemirror/themes/eclipse.css +2 -2
- data/vendor/assets/stylesheets/codemirror/themes/erlang-dark.css +5 -5
- data/vendor/assets/stylesheets/codemirror/themes/midnight.css +52 -0
- data/vendor/assets/stylesheets/codemirror/themes/xq-light.css +43 -0
- data/vendor/assets/stylesheets/codemirror.css +16 -10
- metadata +60 -52
- data/vendor/assets/javascripts/codemirror/modes/mysql.js +0 -203
- data/vendor/assets/javascripts/codemirror/modes/plsql.js +0 -216
- data/vendor/assets/javascripts/codemirror/utils/collapserange.js +0 -68
- data/vendor/assets/javascripts/codemirror/utils/continuelist.js +0 -28
- data/vendor/assets/javascripts/codemirror/utils/foldcode.js +0 -183
- data/vendor/assets/javascripts/codemirror/utils/formatting.js +0 -114
- data/vendor/assets/javascripts/codemirror/utils/match-highlighter.js +0 -46
- data/vendor/assets/javascripts/codemirror/utils/simple-hint.js +0 -102
- data/vendor/assets/stylesheets/codemirror/utils/simple-hint.css +0 -16
@@ -1,183 +0,0 @@
|
|
1
|
-
// the tagRangeFinder function is
|
2
|
-
// Copyright (C) 2011 by Daniel Glazman <daniel@glazman.org>
|
3
|
-
// released under the MIT license (../../LICENSE) like the rest of CodeMirror
|
4
|
-
CodeMirror.tagRangeFinder = function(cm, start) {
|
5
|
-
var nameStartChar = "A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD";
|
6
|
-
var nameChar = nameStartChar + "\-\:\.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040";
|
7
|
-
var xmlNAMERegExp = new RegExp("^[" + nameStartChar + "][" + nameChar + "]*");
|
8
|
-
|
9
|
-
var lineText = cm.getLine(start.line);
|
10
|
-
var found = false;
|
11
|
-
var tag = null;
|
12
|
-
var pos = start.ch;
|
13
|
-
while (!found) {
|
14
|
-
pos = lineText.indexOf("<", pos);
|
15
|
-
if (-1 == pos) // no tag on line
|
16
|
-
return;
|
17
|
-
if (pos + 1 < lineText.length && lineText[pos + 1] == "/") { // closing tag
|
18
|
-
pos++;
|
19
|
-
continue;
|
20
|
-
}
|
21
|
-
// ok we seem to have a start tag
|
22
|
-
if (!lineText.substr(pos + 1).match(xmlNAMERegExp)) { // not a tag name...
|
23
|
-
pos++;
|
24
|
-
continue;
|
25
|
-
}
|
26
|
-
var gtPos = lineText.indexOf(">", pos + 1);
|
27
|
-
if (-1 == gtPos) { // end of start tag not in line
|
28
|
-
var l = start.line + 1;
|
29
|
-
var foundGt = false;
|
30
|
-
var lastLine = cm.lineCount();
|
31
|
-
while (l < lastLine && !foundGt) {
|
32
|
-
var lt = cm.getLine(l);
|
33
|
-
gtPos = lt.indexOf(">");
|
34
|
-
if (-1 != gtPos) { // found a >
|
35
|
-
foundGt = true;
|
36
|
-
var slash = lt.lastIndexOf("/", gtPos);
|
37
|
-
if (-1 != slash && slash < gtPos) {
|
38
|
-
var str = lineText.substr(slash, gtPos - slash + 1);
|
39
|
-
if (!str.match( /\/\s*\>/ )) // yep, that's the end of empty tag
|
40
|
-
return;
|
41
|
-
}
|
42
|
-
}
|
43
|
-
l++;
|
44
|
-
}
|
45
|
-
found = true;
|
46
|
-
}
|
47
|
-
else {
|
48
|
-
var slashPos = lineText.lastIndexOf("/", gtPos);
|
49
|
-
if (-1 == slashPos) { // cannot be empty tag
|
50
|
-
found = true;
|
51
|
-
// don't continue
|
52
|
-
}
|
53
|
-
else { // empty tag?
|
54
|
-
// check if really empty tag
|
55
|
-
var str = lineText.substr(slashPos, gtPos - slashPos + 1);
|
56
|
-
if (!str.match( /\/\s*\>/ )) { // finally not empty
|
57
|
-
found = true;
|
58
|
-
// don't continue
|
59
|
-
}
|
60
|
-
}
|
61
|
-
}
|
62
|
-
if (found) {
|
63
|
-
var subLine = lineText.substr(pos + 1);
|
64
|
-
tag = subLine.match(xmlNAMERegExp);
|
65
|
-
if (tag) {
|
66
|
-
// we have an element name, wooohooo !
|
67
|
-
tag = tag[0];
|
68
|
-
// do we have the close tag on same line ???
|
69
|
-
if (-1 != lineText.indexOf("</" + tag + ">", pos)) // yep
|
70
|
-
{
|
71
|
-
found = false;
|
72
|
-
}
|
73
|
-
// we don't, so we have a candidate...
|
74
|
-
}
|
75
|
-
else
|
76
|
-
found = false;
|
77
|
-
}
|
78
|
-
if (!found)
|
79
|
-
pos++;
|
80
|
-
}
|
81
|
-
|
82
|
-
if (found) {
|
83
|
-
var startTag = "(\\<\\/" + tag + "\\>)|(\\<" + tag + "\\>)|(\\<" + tag + "\\s)|(\\<" + tag + "$)";
|
84
|
-
var startTagRegExp = new RegExp(startTag);
|
85
|
-
var endTag = "</" + tag + ">";
|
86
|
-
var depth = 1;
|
87
|
-
var l = start.line + 1;
|
88
|
-
var lastLine = cm.lineCount();
|
89
|
-
while (l < lastLine) {
|
90
|
-
lineText = cm.getLine(l);
|
91
|
-
var match = lineText.match(startTagRegExp);
|
92
|
-
if (match) {
|
93
|
-
for (var i = 0; i < match.length; i++) {
|
94
|
-
if (match[i] == endTag)
|
95
|
-
depth--;
|
96
|
-
else
|
97
|
-
depth++;
|
98
|
-
if (!depth) return {from: {line: start.line, ch: gtPos + 1},
|
99
|
-
to: {line: l, ch: match.index}};
|
100
|
-
}
|
101
|
-
}
|
102
|
-
l++;
|
103
|
-
}
|
104
|
-
return;
|
105
|
-
}
|
106
|
-
};
|
107
|
-
|
108
|
-
CodeMirror.braceRangeFinder = function(cm, start) {
|
109
|
-
var line = start.line, lineText = cm.getLine(line);
|
110
|
-
var at = lineText.length, startChar, tokenType;
|
111
|
-
for (;;) {
|
112
|
-
var found = lineText.lastIndexOf("{", at);
|
113
|
-
if (found < start.ch) break;
|
114
|
-
tokenType = cm.getTokenAt({line: line, ch: found}).type;
|
115
|
-
if (!/^(comment|string)/.test(tokenType)) { startChar = found; break; }
|
116
|
-
at = found - 1;
|
117
|
-
}
|
118
|
-
if (startChar == null || lineText.lastIndexOf("}") > startChar) return;
|
119
|
-
var count = 1, lastLine = cm.lineCount(), end, endCh;
|
120
|
-
outer: for (var i = line + 1; i < lastLine; ++i) {
|
121
|
-
var text = cm.getLine(i), pos = 0;
|
122
|
-
for (;;) {
|
123
|
-
var nextOpen = text.indexOf("{", pos), nextClose = text.indexOf("}", pos);
|
124
|
-
if (nextOpen < 0) nextOpen = text.length;
|
125
|
-
if (nextClose < 0) nextClose = text.length;
|
126
|
-
pos = Math.min(nextOpen, nextClose);
|
127
|
-
if (pos == text.length) break;
|
128
|
-
if (cm.getTokenAt({line: i, ch: pos + 1}).type == tokenType) {
|
129
|
-
if (pos == nextOpen) ++count;
|
130
|
-
else if (!--count) { end = i; endCh = pos; break outer; }
|
131
|
-
}
|
132
|
-
++pos;
|
133
|
-
}
|
134
|
-
}
|
135
|
-
if (end == null || end == line + 1) return;
|
136
|
-
return {from: {line: line, ch: startChar + 1},
|
137
|
-
to: {line: end, ch: endCh}};
|
138
|
-
};
|
139
|
-
|
140
|
-
CodeMirror.indentRangeFinder = function(cm, start) {
|
141
|
-
var tabSize = cm.getOption("tabSize"), firstLine = cm.getLine(start.line);
|
142
|
-
var myIndent = CodeMirror.countColumn(firstLine, null, tabSize);
|
143
|
-
for (var i = start.line + 1, end = cm.lineCount(); i < end; ++i) {
|
144
|
-
var curLine = cm.getLine(i);
|
145
|
-
if (CodeMirror.countColumn(curLine, null, tabSize) < myIndent &&
|
146
|
-
CodeMirror.countColumn(cm.getLine(i-1), null, tabSize) > myIndent)
|
147
|
-
return {from: {line: start.line, ch: firstLine.length},
|
148
|
-
to: {line: i, ch: curLine.length}};
|
149
|
-
}
|
150
|
-
};
|
151
|
-
|
152
|
-
CodeMirror.newFoldFunction = function(rangeFinder, widget) {
|
153
|
-
if (widget == null) widget = "\u2194";
|
154
|
-
if (typeof widget == "string") {
|
155
|
-
var text = document.createTextNode(widget);
|
156
|
-
widget = document.createElement("span");
|
157
|
-
widget.appendChild(text);
|
158
|
-
widget.className = "CodeMirror-foldmarker";
|
159
|
-
}
|
160
|
-
|
161
|
-
return function(cm, pos) {
|
162
|
-
if (typeof pos == "number") pos = {line: pos, ch: 0};
|
163
|
-
var range = rangeFinder(cm, pos);
|
164
|
-
if (!range) return;
|
165
|
-
|
166
|
-
var present = cm.findMarksAt(range.from), cleared = 0;
|
167
|
-
for (var i = 0; i < present.length; ++i) {
|
168
|
-
if (present[i].__isFold) {
|
169
|
-
++cleared;
|
170
|
-
present[i].clear();
|
171
|
-
}
|
172
|
-
}
|
173
|
-
if (cleared) return;
|
174
|
-
|
175
|
-
var myWidget = widget.cloneNode(true);
|
176
|
-
CodeMirror.on(myWidget, "mousedown", function() {myRange.clear();});
|
177
|
-
var myRange = cm.markText(range.from, range.to, {
|
178
|
-
replacedWith: myWidget,
|
179
|
-
clearOnEnter: true,
|
180
|
-
__isFold: true
|
181
|
-
});
|
182
|
-
};
|
183
|
-
};
|
@@ -1,114 +0,0 @@
|
|
1
|
-
(function() {
|
2
|
-
|
3
|
-
CodeMirror.extendMode("css", {
|
4
|
-
commentStart: "/*",
|
5
|
-
commentEnd: "*/",
|
6
|
-
newlineAfterToken: function(_type, content) {
|
7
|
-
return /^[;{}]$/.test(content);
|
8
|
-
}
|
9
|
-
});
|
10
|
-
|
11
|
-
CodeMirror.extendMode("javascript", {
|
12
|
-
commentStart: "/*",
|
13
|
-
commentEnd: "*/",
|
14
|
-
// FIXME semicolons inside of for
|
15
|
-
newlineAfterToken: function(_type, content, textAfter, state) {
|
16
|
-
if (this.jsonMode) {
|
17
|
-
return /^[\[,{]$/.test(content) || /^}/.test(textAfter);
|
18
|
-
} else {
|
19
|
-
if (content == ";" && state.lexical && state.lexical.type == ")") return false;
|
20
|
-
return /^[;{}]$/.test(content) && !/^;/.test(textAfter);
|
21
|
-
}
|
22
|
-
}
|
23
|
-
});
|
24
|
-
|
25
|
-
var inlineElements = /^(a|abbr|acronym|area|base|bdo|big|br|button|caption|cite|code|col|colgroup|dd|del|dfn|em|frame|hr|iframe|img|input|ins|kbd|label|legend|link|map|object|optgroup|option|param|q|samp|script|select|small|span|strong|sub|sup|textarea|tt|var)$/;
|
26
|
-
|
27
|
-
CodeMirror.extendMode("xml", {
|
28
|
-
commentStart: "<!--",
|
29
|
-
commentEnd: "-->",
|
30
|
-
newlineAfterToken: function(type, content, textAfter, state) {
|
31
|
-
var inline = false;
|
32
|
-
if (this.configuration == "html")
|
33
|
-
inline = state.context ? inlineElements.test(state.context.tagName) : false;
|
34
|
-
return !inline && ((type == "tag" && />$/.test(content) && state.context) ||
|
35
|
-
/^</.test(textAfter));
|
36
|
-
}
|
37
|
-
});
|
38
|
-
|
39
|
-
// Comment/uncomment the specified range
|
40
|
-
CodeMirror.defineExtension("commentRange", function (isComment, from, to) {
|
41
|
-
var cm = this, curMode = CodeMirror.innerMode(cm.getMode(), cm.getTokenAt(from).state).mode;
|
42
|
-
cm.operation(function() {
|
43
|
-
if (isComment) { // Comment range
|
44
|
-
cm.replaceRange(curMode.commentEnd, to);
|
45
|
-
cm.replaceRange(curMode.commentStart, from);
|
46
|
-
if (from.line == to.line && from.ch == to.ch) // An empty comment inserted - put cursor inside
|
47
|
-
cm.setCursor(from.line, from.ch + curMode.commentStart.length);
|
48
|
-
} else { // Uncomment range
|
49
|
-
var selText = cm.getRange(from, to);
|
50
|
-
var startIndex = selText.indexOf(curMode.commentStart);
|
51
|
-
var endIndex = selText.lastIndexOf(curMode.commentEnd);
|
52
|
-
if (startIndex > -1 && endIndex > -1 && endIndex > startIndex) {
|
53
|
-
// Take string till comment start
|
54
|
-
selText = selText.substr(0, startIndex)
|
55
|
-
// From comment start till comment end
|
56
|
-
+ selText.substring(startIndex + curMode.commentStart.length, endIndex)
|
57
|
-
// From comment end till string end
|
58
|
-
+ selText.substr(endIndex + curMode.commentEnd.length);
|
59
|
-
}
|
60
|
-
cm.replaceRange(selText, from, to);
|
61
|
-
}
|
62
|
-
});
|
63
|
-
});
|
64
|
-
|
65
|
-
// Applies automatic mode-aware indentation to the specified range
|
66
|
-
CodeMirror.defineExtension("autoIndentRange", function (from, to) {
|
67
|
-
var cmInstance = this;
|
68
|
-
this.operation(function () {
|
69
|
-
for (var i = from.line; i <= to.line; i++) {
|
70
|
-
cmInstance.indentLine(i, "smart");
|
71
|
-
}
|
72
|
-
});
|
73
|
-
});
|
74
|
-
|
75
|
-
// Applies automatic formatting to the specified range
|
76
|
-
CodeMirror.defineExtension("autoFormatRange", function (from, to) {
|
77
|
-
var cm = this;
|
78
|
-
var outer = cm.getMode(), text = cm.getRange(from, to).split("\n");
|
79
|
-
var state = CodeMirror.copyState(outer, cm.getTokenAt(from).state);
|
80
|
-
var tabSize = cm.getOption("tabSize");
|
81
|
-
|
82
|
-
var out = "", lines = 0, atSol = from.ch == 0;
|
83
|
-
function newline() {
|
84
|
-
out += "\n";
|
85
|
-
atSol = true;
|
86
|
-
++lines;
|
87
|
-
}
|
88
|
-
|
89
|
-
for (var i = 0; i < text.length; ++i) {
|
90
|
-
var stream = new CodeMirror.StringStream(text[i], tabSize);
|
91
|
-
while (!stream.eol()) {
|
92
|
-
var inner = CodeMirror.innerMode(outer, state);
|
93
|
-
var style = outer.token(stream, state), cur = stream.current();
|
94
|
-
stream.start = stream.pos;
|
95
|
-
if (!atSol || /\S/.test(cur)) {
|
96
|
-
out += cur;
|
97
|
-
atSol = false;
|
98
|
-
}
|
99
|
-
if (!atSol && inner.mode.newlineAfterToken &&
|
100
|
-
inner.mode.newlineAfterToken(style, cur, stream.string.slice(stream.pos) || text[i+1] || "", inner.state))
|
101
|
-
newline();
|
102
|
-
}
|
103
|
-
if (!stream.pos && outer.blankLine) outer.blankLine(state);
|
104
|
-
if (!atSol && i < text.length - 1) newline();
|
105
|
-
}
|
106
|
-
|
107
|
-
cm.operation(function () {
|
108
|
-
cm.replaceRange(out, from, to);
|
109
|
-
for (var cur = from.line + 1, end = from.line + lines; cur <= end; ++cur)
|
110
|
-
cm.indentLine(cur, "smart");
|
111
|
-
cm.setSelection(from, cm.getCursor(false));
|
112
|
-
});
|
113
|
-
});
|
114
|
-
})();
|
@@ -1,46 +0,0 @@
|
|
1
|
-
// Define match-highlighter commands. Depends on searchcursor.js
|
2
|
-
// Use by attaching the following function call to the cursorActivity event:
|
3
|
-
//myCodeMirror.matchHighlight(minChars);
|
4
|
-
// And including a special span.CodeMirror-matchhighlight css class (also optionally a separate one for .CodeMirror-focused -- see demo matchhighlighter.html)
|
5
|
-
|
6
|
-
(function() {
|
7
|
-
var DEFAULT_MIN_CHARS = 2;
|
8
|
-
|
9
|
-
function MatchHighlightState() {
|
10
|
-
this.marked = [];
|
11
|
-
}
|
12
|
-
function getMatchHighlightState(cm) {
|
13
|
-
return cm._matchHighlightState || (cm._matchHighlightState = new MatchHighlightState());
|
14
|
-
}
|
15
|
-
|
16
|
-
function clearMarks(cm) {
|
17
|
-
var state = getMatchHighlightState(cm);
|
18
|
-
for (var i = 0; i < state.marked.length; ++i)
|
19
|
-
state.marked[i].clear();
|
20
|
-
state.marked = [];
|
21
|
-
}
|
22
|
-
|
23
|
-
function markDocument(cm, className, minChars) {
|
24
|
-
clearMarks(cm);
|
25
|
-
minChars = (typeof minChars !== 'undefined' ? minChars : DEFAULT_MIN_CHARS);
|
26
|
-
if (cm.somethingSelected() && cm.getSelection().replace(/^\s+|\s+$/g, "").length >= minChars) {
|
27
|
-
var state = getMatchHighlightState(cm);
|
28
|
-
var query = cm.getSelection();
|
29
|
-
cm.operation(function() {
|
30
|
-
if (cm.lineCount() < 2000) { // This is too expensive on big documents.
|
31
|
-
for (var cursor = cm.getSearchCursor(query); cursor.findNext();) {
|
32
|
-
//Only apply matchhighlight to the matches other than the one actually selected
|
33
|
-
if (cursor.from().line !== cm.getCursor(true).line ||
|
34
|
-
cursor.from().ch !== cm.getCursor(true).ch)
|
35
|
-
state.marked.push(cm.markText(cursor.from(), cursor.to(),
|
36
|
-
{className: className}));
|
37
|
-
}
|
38
|
-
}
|
39
|
-
});
|
40
|
-
}
|
41
|
-
}
|
42
|
-
|
43
|
-
CodeMirror.defineExtension("matchHighlight", function(className, minChars) {
|
44
|
-
markDocument(this, className, minChars);
|
45
|
-
});
|
46
|
-
})();
|
@@ -1,102 +0,0 @@
|
|
1
|
-
(function() {
|
2
|
-
CodeMirror.simpleHint = function(editor, getHints, givenOptions) {
|
3
|
-
// Determine effective options based on given values and defaults.
|
4
|
-
var options = {}, defaults = CodeMirror.simpleHint.defaults;
|
5
|
-
for (var opt in defaults)
|
6
|
-
if (defaults.hasOwnProperty(opt))
|
7
|
-
options[opt] = (givenOptions && givenOptions.hasOwnProperty(opt) ? givenOptions : defaults)[opt];
|
8
|
-
|
9
|
-
function collectHints(previousToken) {
|
10
|
-
// We want a single cursor position.
|
11
|
-
if (editor.somethingSelected()) return;
|
12
|
-
|
13
|
-
var tempToken = editor.getTokenAt(editor.getCursor());
|
14
|
-
|
15
|
-
// Don't show completions if token has changed and the option is set.
|
16
|
-
if (options.closeOnTokenChange && previousToken != null &&
|
17
|
-
(tempToken.start != previousToken.start || tempToken.type != previousToken.type)) {
|
18
|
-
return;
|
19
|
-
}
|
20
|
-
|
21
|
-
var result = getHints(editor, givenOptions);
|
22
|
-
if (!result || !result.list.length) return;
|
23
|
-
var completions = result.list;
|
24
|
-
function insert(str) {
|
25
|
-
editor.replaceRange(str, result.from, result.to);
|
26
|
-
}
|
27
|
-
// When there is only one completion, use it directly.
|
28
|
-
if (options.completeSingle && completions.length == 1) {
|
29
|
-
insert(completions[0]);
|
30
|
-
return true;
|
31
|
-
}
|
32
|
-
|
33
|
-
// Build the select widget
|
34
|
-
var complete = document.createElement("div");
|
35
|
-
complete.className = "CodeMirror-completions";
|
36
|
-
var sel = complete.appendChild(document.createElement("select"));
|
37
|
-
// Opera doesn't move the selection when pressing up/down in a
|
38
|
-
// multi-select, but it does properly support the size property on
|
39
|
-
// single-selects, so no multi-select is necessary.
|
40
|
-
if (!window.opera) sel.multiple = true;
|
41
|
-
for (var i = 0; i < completions.length; ++i) {
|
42
|
-
var opt = sel.appendChild(document.createElement("option"));
|
43
|
-
opt.appendChild(document.createTextNode(completions[i]));
|
44
|
-
}
|
45
|
-
sel.firstChild.selected = true;
|
46
|
-
sel.size = Math.min(10, completions.length);
|
47
|
-
var pos = editor.cursorCoords(options.alignWithWord ? result.from : null);
|
48
|
-
complete.style.left = pos.left + "px";
|
49
|
-
complete.style.top = pos.bottom + "px";
|
50
|
-
document.body.appendChild(complete);
|
51
|
-
// If we're at the edge of the screen, then we want the menu to appear on the left of the cursor.
|
52
|
-
var winW = window.innerWidth || Math.max(document.body.offsetWidth, document.documentElement.offsetWidth);
|
53
|
-
if(winW - pos.left < sel.clientWidth)
|
54
|
-
complete.style.left = (pos.left - sel.clientWidth) + "px";
|
55
|
-
// Hack to hide the scrollbar.
|
56
|
-
if (completions.length <= 10)
|
57
|
-
complete.style.width = (sel.clientWidth - 1) + "px";
|
58
|
-
|
59
|
-
var done = false;
|
60
|
-
function close() {
|
61
|
-
if (done) return;
|
62
|
-
done = true;
|
63
|
-
complete.parentNode.removeChild(complete);
|
64
|
-
}
|
65
|
-
function pick() {
|
66
|
-
insert(completions[sel.selectedIndex]);
|
67
|
-
close();
|
68
|
-
setTimeout(function(){editor.focus();}, 50);
|
69
|
-
}
|
70
|
-
CodeMirror.on(sel, "blur", close);
|
71
|
-
CodeMirror.on(sel, "keydown", function(event) {
|
72
|
-
var code = event.keyCode;
|
73
|
-
// Enter
|
74
|
-
if (code == 13) {CodeMirror.e_stop(event); pick();}
|
75
|
-
// Escape
|
76
|
-
else if (code == 27) {CodeMirror.e_stop(event); close(); editor.focus();}
|
77
|
-
else if (code != 38 && code != 40 && code != 33 && code != 34 && !CodeMirror.isModifierKey(event)) {
|
78
|
-
close(); editor.focus();
|
79
|
-
// Pass the event to the CodeMirror instance so that it can handle things like backspace properly.
|
80
|
-
editor.triggerOnKeyDown(event);
|
81
|
-
// Don't show completions if the code is backspace and the option is set.
|
82
|
-
if (!options.closeOnBackspace || code != 8) {
|
83
|
-
setTimeout(function(){collectHints(tempToken);}, 50);
|
84
|
-
}
|
85
|
-
}
|
86
|
-
});
|
87
|
-
CodeMirror.on(sel, "dblclick", pick);
|
88
|
-
|
89
|
-
sel.focus();
|
90
|
-
// Opera sometimes ignores focusing a freshly created node
|
91
|
-
if (window.opera) setTimeout(function(){if (!done) sel.focus();}, 100);
|
92
|
-
return true;
|
93
|
-
}
|
94
|
-
return collectHints();
|
95
|
-
};
|
96
|
-
CodeMirror.simpleHint.defaults = {
|
97
|
-
closeOnBackspace: true,
|
98
|
-
closeOnTokenChange: false,
|
99
|
-
completeSingle: true,
|
100
|
-
alignWithWord: true
|
101
|
-
};
|
102
|
-
})();
|
@@ -1,16 +0,0 @@
|
|
1
|
-
.CodeMirror-completions {
|
2
|
-
position: absolute;
|
3
|
-
z-index: 10;
|
4
|
-
overflow: hidden;
|
5
|
-
-webkit-box-shadow: 2px 3px 5px rgba(0,0,0,.2);
|
6
|
-
-moz-box-shadow: 2px 3px 5px rgba(0,0,0,.2);
|
7
|
-
box-shadow: 2px 3px 5px rgba(0,0,0,.2);
|
8
|
-
}
|
9
|
-
.CodeMirror-completions select {
|
10
|
-
background: #fafafa;
|
11
|
-
outline: none;
|
12
|
-
border: none;
|
13
|
-
padding: 0;
|
14
|
-
margin: 0;
|
15
|
-
font-family: monospace;
|
16
|
-
}
|