diff options
Diffstat (limited to 'imports/codemirror/lib/util')
-rw-r--r-- | imports/codemirror/lib/util/closetag.js | 28 | ||||
-rw-r--r-- | imports/codemirror/lib/util/foldcode.js | 36 | ||||
-rw-r--r-- | imports/codemirror/lib/util/formatting.js | 9 | ||||
-rw-r--r-- | imports/codemirror/lib/util/loadmode.js | 51 | ||||
-rw-r--r-- | imports/codemirror/lib/util/match-highlighter.js | 2 | ||||
-rw-r--r-- | imports/codemirror/lib/util/multiplex.js | 72 | ||||
-rw-r--r-- | imports/codemirror/lib/util/overlay.js | 5 | ||||
-rw-r--r-- | imports/codemirror/lib/util/pig-hint.js | 123 | ||||
-rw-r--r-- | imports/codemirror/lib/util/search.js | 32 | ||||
-rw-r--r-- | imports/codemirror/lib/util/searchcursor.js | 2 |
10 files changed, 298 insertions, 62 deletions
diff --git a/imports/codemirror/lib/util/closetag.js b/imports/codemirror/lib/util/closetag.js index 44c2b435..20a43b9d 100644 --- a/imports/codemirror/lib/util/closetag.js +++ b/imports/codemirror/lib/util/closetag.js | |||
@@ -10,7 +10,6 @@ | |||
10 | * following CodeMirror modes and will ignore all others: | 10 | * following CodeMirror modes and will ignore all others: |
11 | * - htmlmixed | 11 | * - htmlmixed |
12 | * - xml | 12 | * - xml |
13 | * - xmlpure | ||
14 | * | 13 | * |
15 | * See demos/closetag.html for a usage example. | 14 | * See demos/closetag.html for a usage example. |
16 | * | 15 | * |
@@ -104,33 +103,6 @@ | |||
104 | } | 103 | } |
105 | } | 104 | } |
106 | 105 | ||
107 | } else if (mode == 'xmlpure') { | ||
108 | |||
109 | var pos = cm.getCursor(); | ||
110 | var tok = cm.getTokenAt(pos); | ||
111 | var tagName = tok.state.context.tagName; | ||
112 | |||
113 | if (ch == '>') { | ||
114 | // <foo> tagName=foo, string=foo | ||
115 | // <foo /> tagName=foo, string=/ # ignore | ||
116 | // <foo></foo> tagName=foo, string=/foo # ignore | ||
117 | if (tok.string == tagName) { | ||
118 | cm.replaceSelection('>'); // parity w/html modes | ||
119 | pos = {line: pos.line, ch: pos.ch + 1}; | ||
120 | cm.setCursor(pos); | ||
121 | |||
122 | insertEndTag(cm, indent, pos, tagName); | ||
123 | return; | ||
124 | } | ||
125 | |||
126 | } else if (ch == '/') { | ||
127 | // <foo / tagName=foo, string= # ignore | ||
128 | // <foo></ tagName=foo, string=< | ||
129 | if (tok.string == '<') { | ||
130 | completeEndTag(cm, pos, tagName); | ||
131 | return; | ||
132 | } | ||
133 | } | ||
134 | } | 106 | } |
135 | 107 | ||
136 | throw CodeMirror.Pass; // Bubble if not handled | 108 | throw CodeMirror.Pass; // Bubble if not handled |
diff --git a/imports/codemirror/lib/util/foldcode.js b/imports/codemirror/lib/util/foldcode.js index b700d860..02cfb50a 100644 --- a/imports/codemirror/lib/util/foldcode.js +++ b/imports/codemirror/lib/util/foldcode.js | |||
@@ -1,9 +1,9 @@ | |||
1 | // the tagRangeFinder function is | 1 | // the tagRangeFinder function is |
2 | // Copyright (C) 2011 by Daniel Glazman <daniel@glazman.org> | 2 | // Copyright (C) 2011 by Daniel Glazman <daniel@glazman.org> |
3 | // released under the MIT license (../../LICENSE) like the rest of CodeMirror | 3 | // released under the MIT license (../../LICENSE) like the rest of CodeMirror |
4 | CodeMirror.tagRangeFinder = function(cm, line) { | 4 | CodeMirror.tagRangeFinder = function(cm, line, hideEnd) { |
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"; | 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"; | 6 | var nameChar = nameStartChar + "\-\:\.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040"; |
7 | var xmlNAMERegExp = new RegExp("^[" + nameStartChar + "][" + nameChar + "]*"); | 7 | var xmlNAMERegExp = new RegExp("^[" + nameStartChar + "][" + nameChar + "]*"); |
8 | 8 | ||
9 | var lineText = cm.getLine(line); | 9 | var lineText = cm.getLine(line); |
@@ -36,8 +36,10 @@ CodeMirror.tagRangeFinder = function(cm, line) { | |||
36 | var slash = lt.lastIndexOf("/", gt); | 36 | var slash = lt.lastIndexOf("/", gt); |
37 | if (-1 != slash && slash < gt) { | 37 | if (-1 != slash && slash < gt) { |
38 | var str = lineText.substr(slash, gt - slash + 1); | 38 | var str = lineText.substr(slash, gt - slash + 1); |
39 | if (!str.match( /\/\s*\>/ )) // yep, that's the end of empty tag | 39 | if (!str.match( /\/\s*\>/ )) { // yep, that's the end of empty tag |
40 | return l+1; | 40 | if (hideEnd === true) l++; |
41 | return l; | ||
42 | } | ||
41 | } | 43 | } |
42 | } | 44 | } |
43 | l++; | 45 | l++; |
@@ -95,8 +97,10 @@ CodeMirror.tagRangeFinder = function(cm, line) { | |||
95 | depth--; | 97 | depth--; |
96 | else | 98 | else |
97 | depth++; | 99 | depth++; |
98 | if (!depth) | 100 | if (!depth) { |
99 | return l+1; | 101 | if (hideEnd === true) l++; |
102 | return l; | ||
103 | } | ||
100 | } | 104 | } |
101 | } | 105 | } |
102 | l++; | 106 | l++; |
@@ -105,11 +109,16 @@ CodeMirror.tagRangeFinder = function(cm, line) { | |||
105 | } | 109 | } |
106 | }; | 110 | }; |
107 | 111 | ||
108 | CodeMirror.braceRangeFinder = function(cm, line) { | 112 | CodeMirror.braceRangeFinder = function(cm, line, hideEnd) { |
109 | var lineText = cm.getLine(line); | 113 | var lineText = cm.getLine(line), at = lineText.length, startChar, tokenType; |
110 | var startChar = lineText.lastIndexOf("{"); | 114 | for (;;) { |
111 | if (startChar < 0 || lineText.lastIndexOf("}") > startChar) return; | 115 | var found = lineText.lastIndexOf("{", at); |
112 | var tokenType = cm.getTokenAt({line: line, ch: startChar}).className; | 116 | if (found < 0) break; |
117 | tokenType = cm.getTokenAt({line: line, ch: found}).className; | ||
118 | if (!/^(comment|string)/.test(tokenType)) { startChar = found; break; } | ||
119 | at = found - 1; | ||
120 | } | ||
121 | if (startChar == null || lineText.lastIndexOf("}") > startChar) return; | ||
113 | var count = 1, lastLine = cm.lineCount(), end; | 122 | var count = 1, lastLine = cm.lineCount(), end; |
114 | outer: for (var i = line + 1; i < lastLine; ++i) { | 123 | outer: for (var i = line + 1; i < lastLine; ++i) { |
115 | var text = cm.getLine(i), pos = 0; | 124 | var text = cm.getLine(i), pos = 0; |
@@ -127,6 +136,7 @@ CodeMirror.braceRangeFinder = function(cm, line) { | |||
127 | } | 136 | } |
128 | } | 137 | } |
129 | if (end == null || end == line + 1) return; | 138 | if (end == null || end == line + 1) return; |
139 | if (hideEnd === true) end++; | ||
130 | return end; | 140 | return end; |
131 | }; | 141 | }; |
132 | 142 | ||
@@ -144,7 +154,7 @@ CodeMirror.indentRangeFinder = function(cm, line) { | |||
144 | return last + 1; | 154 | return last + 1; |
145 | }; | 155 | }; |
146 | 156 | ||
147 | CodeMirror.newFoldFunction = function(rangeFinder, markText) { | 157 | CodeMirror.newFoldFunction = function(rangeFinder, markText, hideEnd) { |
148 | var folded = []; | 158 | var folded = []; |
149 | if (markText == null) markText = '<div style="position: absolute; left: 2px; color:#600">▼</div>%N%'; | 159 | if (markText == null) markText = '<div style="position: absolute; left: 2px; color:#600">▼</div>%N%'; |
150 | 160 | ||
@@ -169,7 +179,7 @@ CodeMirror.newFoldFunction = function(rangeFinder, markText) { | |||
169 | folded.splice(known.pos, 1); | 179 | folded.splice(known.pos, 1); |
170 | expand(cm, known.region); | 180 | expand(cm, known.region); |
171 | } else { | 181 | } else { |
172 | var end = rangeFinder(cm, line); | 182 | var end = rangeFinder(cm, line, hideEnd); |
173 | if (end == null) return; | 183 | if (end == null) return; |
174 | var hidden = []; | 184 | var hidden = []; |
175 | for (var i = line + 1; i < end; ++i) { | 185 | for (var i = line + 1; i < end; ++i) { |
diff --git a/imports/codemirror/lib/util/formatting.js b/imports/codemirror/lib/util/formatting.js index e1891191..3a1a9873 100644 --- a/imports/codemirror/lib/util/formatting.js +++ b/imports/codemirror/lib/util/formatting.js | |||
@@ -84,7 +84,8 @@ CodeMirror.modeExtensions["css"] = { | |||
84 | commentStart: "/*", | 84 | commentStart: "/*", |
85 | commentEnd: "*/", | 85 | commentEnd: "*/", |
86 | wordWrapChars: [";", "\\{", "\\}"], | 86 | wordWrapChars: [";", "\\{", "\\}"], |
87 | autoFormatLineBreaks: function (text) { | 87 | autoFormatLineBreaks: function (text, startPos, endPos) { |
88 | text = text.substring(startPos, endPos); | ||
88 | return text.replace(new RegExp("(;|\\{|\\})([^\r\n])", "g"), "$1\n$2"); | 89 | return text.replace(new RegExp("(;|\\{|\\})([^\r\n])", "g"), "$1\n$2"); |
89 | } | 90 | } |
90 | }; | 91 | }; |
@@ -125,7 +126,8 @@ CodeMirror.modeExtensions["javascript"] = { | |||
125 | return nonBreakableBlocks; | 126 | return nonBreakableBlocks; |
126 | }, | 127 | }, |
127 | 128 | ||
128 | autoFormatLineBreaks: function (text) { | 129 | autoFormatLineBreaks: function (text, startPos, endPos) { |
130 | text = text.substring(startPos, endPos); | ||
129 | var curPos = 0; | 131 | var curPos = 0; |
130 | var reLinesSplitter = new RegExp("(;|\\{|\\})([^\r\n])", "g"); | 132 | var reLinesSplitter = new RegExp("(;|\\{|\\})([^\r\n])", "g"); |
131 | var nonBreakableBlocks = this.getNonBreakableBlocks(text); | 133 | var nonBreakableBlocks = this.getNonBreakableBlocks(text); |
@@ -158,7 +160,8 @@ CodeMirror.modeExtensions["xml"] = { | |||
158 | commentEnd: "-->", | 160 | commentEnd: "-->", |
159 | wordWrapChars: [">"], | 161 | wordWrapChars: [">"], |
160 | 162 | ||
161 | autoFormatLineBreaks: function (text) { | 163 | autoFormatLineBreaks: function (text, startPos, endPos) { |
164 | text = text.substring(startPos, endPos); | ||
162 | var lines = text.split("\n"); | 165 | var lines = text.split("\n"); |
163 | var reProcessedPortion = new RegExp("(^\\s*?<|^[^<]*?)(.+)(>\\s*?$|[^>]*?$)"); | 166 | var reProcessedPortion = new RegExp("(^\\s*?<|^[^<]*?)(.+)(>\\s*?$|[^>]*?$)"); |
164 | var reOpenBrackets = new RegExp("<", "g"); | 167 | var reOpenBrackets = new RegExp("<", "g"); |
diff --git a/imports/codemirror/lib/util/loadmode.js b/imports/codemirror/lib/util/loadmode.js new file mode 100644 index 00000000..48d5a7ab --- /dev/null +++ b/imports/codemirror/lib/util/loadmode.js | |||
@@ -0,0 +1,51 @@ | |||
1 | (function() { | ||
2 | if (!CodeMirror.modeURL) CodeMirror.modeURL = "../mode/%N/%N.js"; | ||
3 | |||
4 | var loading = {}; | ||
5 | function splitCallback(cont, n) { | ||
6 | var countDown = n; | ||
7 | return function() { if (--countDown == 0) cont(); } | ||
8 | } | ||
9 | function ensureDeps(mode, cont) { | ||
10 | var deps = CodeMirror.modes[mode].dependencies; | ||
11 | if (!deps) return cont(); | ||
12 | var missing = []; | ||
13 | for (var i = 0; i < deps.length; ++i) { | ||
14 | if (!CodeMirror.modes.hasOwnProperty(deps[i])) | ||
15 | missing.push(deps[i]); | ||