##// END OF EJS Templates
updated codemirror version
marcink -
r3036:31f98c85 beta
parent child Browse files
Show More
@@ -80,6 +80,7 b''
80 word-wrap: normal;
80 word-wrap: normal;
81 line-height: inherit;
81 line-height: inherit;
82 color: inherit;
82 color: inherit;
83 overflow: visible;
83 }
84 }
84
85
85 .CodeMirror-wrap pre {
86 .CodeMirror-wrap pre {
@@ -75,7 +75,7 b' window.CodeMirror = (function() {'
75 // Selection-related flags. shiftSelecting obviously tracks
75 // Selection-related flags. shiftSelecting obviously tracks
76 // whether the user is holding shift.
76 // whether the user is holding shift.
77 var shiftSelecting, lastClick, lastDoubleClick, lastScrollTop = 0, draggingText,
77 var shiftSelecting, lastClick, lastDoubleClick, lastScrollTop = 0, draggingText,
78 overwrite = false, suppressEdits = false;
78 overwrite = false, suppressEdits = false, pasteIncoming = false;
79 // Variables used by startOperation/endOperation to track what
79 // Variables used by startOperation/endOperation to track what
80 // happened during the operation.
80 // happened during the operation.
81 var updateInput, userSelChange, changes, textChanged, selectionChanged,
81 var updateInput, userSelChange, changes, textChanged, selectionChanged,
@@ -128,7 +128,7 b' window.CodeMirror = (function() {'
128 connect(scroller, "drop", operation(onDrop));
128 connect(scroller, "drop", operation(onDrop));
129 }
129 }
130 connect(scroller, "paste", function(){focusInput(); fastPoll();});
130 connect(scroller, "paste", function(){focusInput(); fastPoll();});
131 connect(input, "paste", fastPoll);
131 connect(input, "paste", function(){pasteIncoming = true; fastPoll();});
132 connect(input, "cut", operation(function(){
132 connect(input, "cut", operation(function(){
133 if (!options.readOnly) replaceSelection("");
133 if (!options.readOnly) replaceSelection("");
134 }));
134 }));
@@ -167,6 +167,7 b' window.CodeMirror = (function() {'
167 else if (option == "lineWrapping" && oldVal != value) operation(wrappingChanged)();
167 else if (option == "lineWrapping" && oldVal != value) operation(wrappingChanged)();
168 else if (option == "tabSize") updateDisplay(true);
168 else if (option == "tabSize") updateDisplay(true);
169 else if (option == "keyMap") keyMapChanged();
169 else if (option == "keyMap") keyMapChanged();
170 else if (option == "tabindex") input.tabIndex = value;
170 if (option == "lineNumbers" || option == "gutter" || option == "firstLineNumber" ||
171 if (option == "lineNumbers" || option == "gutter" || option == "firstLineNumber" ||
171 option == "theme" || option == "lineNumberFormatter") {
172 option == "theme" || option == "lineNumberFormatter") {
172 gutterChanged();
173 gutterChanged();
@@ -229,6 +230,7 b' window.CodeMirror = (function() {'
229 var off = eltOffset(lineSpace);
230 var off = eltOffset(lineSpace);
230 return coordsChar(coords.x - off.left, coords.y - off.top);
231 return coordsChar(coords.x - off.left, coords.y - off.top);
231 },
232 },
233 defaultTextHeight: function() { return textHeight(); },
232 markText: operation(markText),
234 markText: operation(markText),
233 setBookmark: setBookmark,
235 setBookmark: setBookmark,
234 findMarksAt: findMarksAt,
236 findMarksAt: findMarksAt,
@@ -343,6 +345,11 b' window.CodeMirror = (function() {'
343 return {x: scroller.scrollLeft, y: scrollbar.scrollTop,
345 return {x: scroller.scrollLeft, y: scrollbar.scrollTop,
344 height: scrollbar.scrollHeight, width: scroller.scrollWidth};
346 height: scrollbar.scrollHeight, width: scroller.scrollWidth};
345 },
347 },
348 scrollIntoView: function(pos) {
349 var coords = localCoords(pos ? clipPos(pos) : sel.inverted ? sel.from : sel.to);
350 scrollIntoView(coords.x, coords.y, coords.x, coords.yBot);
351 },
352
346 setSize: function(width, height) {
353 setSize: function(width, height) {
347 function interpret(val) {
354 function interpret(val) {
348 val = String(val);
355 val = String(val);
@@ -392,7 +399,7 b' window.CodeMirror = (function() {'
392 }
399 }
393
400
394 function onScrollBar(e) {
401 function onScrollBar(e) {
395 if (scrollbar.scrollTop != lastScrollTop) {
402 if (Math.abs(scrollbar.scrollTop - lastScrollTop) > 1) {
396 lastScrollTop = scroller.scrollTop = scrollbar.scrollTop;
403 lastScrollTop = scroller.scrollTop = scrollbar.scrollTop;
397 updateDisplay([]);
404 updateDisplay([]);
398 }
405 }
@@ -401,7 +408,7 b' window.CodeMirror = (function() {'
401 function onScrollMain(e) {
408 function onScrollMain(e) {
402 if (options.fixedGutter && gutter.style.left != scroller.scrollLeft + "px")
409 if (options.fixedGutter && gutter.style.left != scroller.scrollLeft + "px")
403 gutter.style.left = scroller.scrollLeft + "px";
410 gutter.style.left = scroller.scrollLeft + "px";
404 if (scroller.scrollTop != lastScrollTop) {
411 if (Math.abs(scroller.scrollTop - lastScrollTop) > 1) {
405 lastScrollTop = scroller.scrollTop;
412 lastScrollTop = scroller.scrollTop;
406 if (scrollbar.scrollTop != lastScrollTop)
413 if (scrollbar.scrollTop != lastScrollTop)
407 scrollbar.scrollTop = lastScrollTop;
414 scrollbar.scrollTop = lastScrollTop;
@@ -634,7 +641,7 b' window.CodeMirror = (function() {'
634 if (handled) {
641 if (handled) {
635 e_preventDefault(e);
642 e_preventDefault(e);
636 restartBlink();
643 restartBlink();
637 if (ie) { e.oldKeyCode = e.keyCode; e.keyCode = 0; }
644 if (ie_lt9) { e.oldKeyCode = e.keyCode; e.keyCode = 0; }
638 }
645 }
639 return handled;
646 return handled;
640 }
647 }
@@ -954,12 +961,13 b' window.CodeMirror = (function() {'
954 while (same < l && prevInput[same] == text[same]) ++same;
961 while (same < l && prevInput[same] == text[same]) ++same;
955 if (same < prevInput.length)
962 if (same < prevInput.length)
956 sel.from = {line: sel.from.line, ch: sel.from.ch - (prevInput.length - same)};
963 sel.from = {line: sel.from.line, ch: sel.from.ch - (prevInput.length - same)};
957 else if (overwrite && posEq(sel.from, sel.to))
964 else if (overwrite && posEq(sel.from, sel.to) && !pasteIncoming)
958 sel.to = {line: sel.to.line, ch: Math.min(getLine(sel.to.line).text.length, sel.to.ch + (text.length - same))};
965 sel.to = {line: sel.to.line, ch: Math.min(getLine(sel.to.line).text.length, sel.to.ch + (text.length - same))};
959 replaceSelection(text.slice(same), "end");
966 replaceSelection(text.slice(same), "end");
960 if (text.length > 1000) { input.value = prevInput = ""; }
967 if (text.length > 1000) { input.value = prevInput = ""; }
961 else prevInput = text;
968 else prevInput = text;
962 if (!nestedOperation) endOperation();
969 if (!nestedOperation) endOperation();
970 pasteIncoming = false;
963 return true;
971 return true;
964 }
972 }
965 function resetInput(user) {
973 function resetInput(user) {
@@ -1416,7 +1424,7 b' window.CodeMirror = (function() {'
1416 var startChar = line.charAt(start);
1424 var startChar = line.charAt(start);
1417 var check = isWordChar(startChar) ? isWordChar :
1425 var check = isWordChar(startChar) ? isWordChar :
1418 /\s/.test(startChar) ? function(ch) {return /\s/.test(ch);} :
1426 /\s/.test(startChar) ? function(ch) {return /\s/.test(ch);} :
1419 function(ch) {return !/\s/.test(ch) && !isWordChar(ch);};
1427 function(ch) {return !/\s/.test(ch) && isWordChar(ch);};
1420 while (start > 0 && check(line.charAt(start - 1))) --start;
1428 while (start > 0 && check(line.charAt(start - 1))) --start;
1421 while (end < line.length && check(line.charAt(end))) ++end;
1429 while (end < line.length && check(line.charAt(end))) ++end;
1422 }
1430 }
@@ -1460,6 +1468,7 b' window.CodeMirror = (function() {'
1460
1468
1461 if (indentString != curSpaceString)
1469 if (indentString != curSpaceString)
1462 replaceRange(indentString, {line: n, ch: 0}, {line: n, ch: curSpaceString.length});
1470 replaceRange(indentString, {line: n, ch: 0}, {line: n, ch: curSpaceString.length});
1471 line.stateAfter = null;
1463 }
1472 }
1464
1473
1465 function loadMode() {
1474 function loadMode() {
@@ -1505,18 +1514,17 b' window.CodeMirror = (function() {'
1505
1514
1506 function TextMarker(type, style) { this.lines = []; this.type = type; if (style) this.style = style; }
1515 function TextMarker(type, style) { this.lines = []; this.type = type; if (style) this.style = style; }
1507 TextMarker.prototype.clear = operation(function() {
1516 TextMarker.prototype.clear = operation(function() {
1508 var min = Infinity, max = -Infinity;
1517 var min, max;
1509 for (var i = 0; i < this.lines.length; ++i) {
1518 for (var i = 0; i < this.lines.length; ++i) {
1510 var line = this.lines[i];
1519 var line = this.lines[i];
1511 var span = getMarkedSpanFor(line.markedSpans, this, true);
1520 var span = getMarkedSpanFor(line.markedSpans, this);
1512 if (span.from != null || span.to != null) {
1521 if (span.from != null) min = lineNo(line);
1513 var lineN = lineNo(line);
1522 if (span.to != null) max = lineNo(line);
1514 min = Math.min(min, lineN); max = Math.max(max, lineN);
1523 line.markedSpans = removeMarkedSpan(line.markedSpans, span);
1515 }
1516 }
1524 }
1517 if (min != Infinity)
1525 if (min != null) changes.push({from: min, to: max + 1});
1518 changes.push({from: min, to: max + 1});
1519 this.lines.length = 0;
1526 this.lines.length = 0;
1527 this.explicitlyCleared = true;
1520 });
1528 });
1521 TextMarker.prototype.find = function() {
1529 TextMarker.prototype.find = function() {
1522 var from, to;
1530 var from, to;
@@ -1543,7 +1551,7 b' window.CodeMirror = (function() {'
1543 var span = {from: curLine == from.line ? from.ch : null,
1551 var span = {from: curLine == from.line ? from.ch : null,
1544 to: curLine == to.line ? to.ch : null,
1552 to: curLine == to.line ? to.ch : null,
1545 marker: marker};
1553 marker: marker};
1546 (line.markedSpans || (line.markedSpans = [])).push(span);
1554 line.markedSpans = (line.markedSpans || []).concat([span]);
1547 marker.lines.push(line);
1555 marker.lines.push(line);
1548 ++curLine;
1556 ++curLine;
1549 });
1557 });
@@ -1554,8 +1562,9 b' window.CodeMirror = (function() {'
1554 function setBookmark(pos) {
1562 function setBookmark(pos) {
1555 pos = clipPos(pos);
1563 pos = clipPos(pos);
1556 var marker = new TextMarker("bookmark"), line = getLine(pos.line);
1564 var marker = new TextMarker("bookmark"), line = getLine(pos.line);
1565 history.addChange(pos.line, 1, [newHL(line.text, line.markedSpans)], true);
1557 var span = {from: pos.ch, to: pos.ch, marker: marker};
1566 var span = {from: pos.ch, to: pos.ch, marker: marker};
1558 (line.markedSpans || (line.markedSpans = [])).push(span);
1567 line.markedSpans = (line.markedSpans || []).concat([span]);
1559 marker.lines.push(line);
1568 marker.lines.push(line);
1560 return marker;
1569 return marker;
1561 }
1570 }
@@ -1644,8 +1653,6 b' window.CodeMirror = (function() {'
1644
1653
1645 function measureLine(line, ch) {
1654 function measureLine(line, ch) {
1646 if (ch == 0) return {top: 0, left: 0};
1655 if (ch == 0) return {top: 0, left: 0};
1647 var wbr = options.lineWrapping && ch < line.text.length &&
1648 spanAffectsWrapping.test(line.text.slice(ch - 1, ch + 1));
1649 var pre = lineContent(line, ch);
1656 var pre = lineContent(line, ch);
1650 removeChildrenAndAdd(measure, pre);
1657 removeChildrenAndAdd(measure, pre);
1651 var anchor = pre.anchor;
1658 var anchor = pre.anchor;
@@ -1978,6 +1985,7 b' window.CodeMirror = (function() {'
1978 if (extensions.propertyIsEnumerable(ext) &&
1985 if (extensions.propertyIsEnumerable(ext) &&
1979 !instance.propertyIsEnumerable(ext))
1986 !instance.propertyIsEnumerable(ext))
1980 instance[ext] = extensions[ext];
1987 instance[ext] = extensions[ext];
1988 for (var i = 0; i < initHooks.length; ++i) initHooks[i](instance);
1981 return instance;
1989 return instance;
1982 } // (end of function CodeMirror)
1990 } // (end of function CodeMirror)
1983
1991
@@ -2075,6 +2083,9 b' window.CodeMirror = (function() {'
2075 extensions[name] = func;
2083 extensions[name] = func;
2076 };
2084 };
2077
2085
2086 var initHooks = [];
2087 CodeMirror.defineInitHook = function(f) {initHooks.push(f);};
2088
2078 var modeExtensions = CodeMirror.modeExtensions = {};
2089 var modeExtensions = CodeMirror.modeExtensions = {};
2079 CodeMirror.extendMode = function(mode, properties) {
2090 CodeMirror.extendMode = function(mode, properties) {
2080 var exts = modeExtensions.hasOwnProperty(mode) ? modeExtensions[mode] : (modeExtensions[mode] = {});
2091 var exts = modeExtensions.hasOwnProperty(mode) ? modeExtensions[mode] : (modeExtensions[mode] = {});
@@ -2167,7 +2178,7 b' window.CodeMirror = (function() {'
2167 keyMap.emacsy = {
2178 keyMap.emacsy = {
2168 "Ctrl-F": "goCharRight", "Ctrl-B": "goCharLeft", "Ctrl-P": "goLineUp", "Ctrl-N": "goLineDown",
2179 "Ctrl-F": "goCharRight", "Ctrl-B": "goCharLeft", "Ctrl-P": "goLineUp", "Ctrl-N": "goLineDown",
2169 "Alt-F": "goWordRight", "Alt-B": "goWordLeft", "Ctrl-A": "goLineStart", "Ctrl-E": "goLineEnd",
2180 "Alt-F": "goWordRight", "Alt-B": "goWordLeft", "Ctrl-A": "goLineStart", "Ctrl-E": "goLineEnd",
2170 "Ctrl-V": "goPageUp", "Shift-Ctrl-V": "goPageDown", "Ctrl-D": "delCharRight", "Ctrl-H": "delCharLeft",
2181 "Ctrl-V": "goPageDown", "Shift-Ctrl-V": "goPageUp", "Ctrl-D": "delCharRight", "Ctrl-H": "delCharLeft",
2171 "Alt-D": "delWordRight", "Alt-Backspace": "delWordLeft", "Ctrl-K": "killLine", "Ctrl-T": "transposeChars"
2182 "Alt-D": "delWordRight", "Alt-Backspace": "delWordLeft", "Ctrl-K": "killLine", "Ctrl-T": "transposeChars"
2172 };
2183 };
2173
2184
@@ -2204,6 +2215,7 b' window.CodeMirror = (function() {'
2204 var name = keyNames[e_prop(event, "keyCode")];
2215 var name = keyNames[e_prop(event, "keyCode")];
2205 return name == "Ctrl" || name == "Alt" || name == "Shift" || name == "Mod";
2216 return name == "Ctrl" || name == "Alt" || name == "Shift" || name == "Mod";
2206 }
2217 }
2218 CodeMirror.isModifierKey = isModifierKey;
2207
2219
2208 CodeMirror.fromTextArea = function(textarea, options) {
2220 CodeMirror.fromTextArea = function(textarea, options) {
2209 if (!options) options = {};
2221 if (!options) options = {};
@@ -2224,15 +2236,13 b' window.CodeMirror = (function() {'
2224 if (textarea.form) {
2236 if (textarea.form) {
2225 // Deplorable hack to make the submit method do the right thing.
2237 // Deplorable hack to make the submit method do the right thing.
2226 var rmSubmit = connect(textarea.form, "submit", save, true);
2238 var rmSubmit = connect(textarea.form, "submit", save, true);
2227 if (typeof textarea.form.submit == "function") {
2239 var realSubmit = textarea.form.submit;
2228 var realSubmit = textarea.form.submit;
2240 textarea.form.submit = function wrappedSubmit() {
2229 textarea.form.submit = function wrappedSubmit() {
2241 save();
2230 save();
2242 textarea.form.submit = realSubmit;
2231 textarea.form.submit = realSubmit;
2243 textarea.form.submit();
2232 textarea.form.submit();
2244 textarea.form.submit = wrappedSubmit;
2233 textarea.form.submit = wrappedSubmit;
2245 };
2234 };
2235 }
2236 }
2246 }
2237
2247
2238 textarea.style.display = "none";
2248 textarea.style.display = "none";
@@ -2353,16 +2363,20 b' window.CodeMirror = (function() {'
2353 this.from = from; this.to = to; this.marker = marker;
2363 this.from = from; this.to = to; this.marker = marker;
2354 }
2364 }
2355
2365
2356 function getMarkedSpanFor(spans, marker, del) {
2366 function getMarkedSpanFor(spans, marker) {
2357 if (spans) for (var i = 0; i < spans.length; ++i) {
2367 if (spans) for (var i = 0; i < spans.length; ++i) {
2358 var span = spans[i];
2368 var span = spans[i];
2359 if (span.marker == marker) {
2369 if (span.marker == marker) return span;
2360 if (del) spans.splice(i, 1);
2361 return span;
2362 }
2363 }
2370 }
2364 }
2371 }
2365
2372
2373 function removeMarkedSpan(spans, span) {
2374 var r;
2375 for (var i = 0; i < spans.length; ++i)
2376 if (spans[i] != span) (r || (r = [])).push(spans[i]);
2377 return r;
2378 }
2379
2366 function markedSpansBefore(old, startCh, endCh) {
2380 function markedSpansBefore(old, startCh, endCh) {
2367 if (old) for (var i = 0, nw; i < old.length; ++i) {
2381 if (old) for (var i = 0, nw; i < old.length; ++i) {
2368 var span = old[i], marker = span.marker;
2382 var span = old[i], marker = span.marker;
@@ -2446,7 +2460,15 b' window.CodeMirror = (function() {'
2446 // hl stands for history-line, a data structure that can be either a
2460 // hl stands for history-line, a data structure that can be either a
2447 // string (line without markers) or a {text, markedSpans} object.
2461 // string (line without markers) or a {text, markedSpans} object.
2448 function hlText(val) { return typeof val == "string" ? val : val.text; }
2462 function hlText(val) { return typeof val == "string" ? val : val.text; }
2449 function hlSpans(val) { return typeof val == "string" ? null : val.markedSpans; }
2463 function hlSpans(val) {
2464 if (typeof val == "string") return null;
2465 var spans = val.markedSpans, out = null;
2466 for (var i = 0; i < spans.length; ++i) {
2467 if (spans[i].marker.explicitlyCleared) { if (!out) out = spans.slice(0, i); }
2468 else if (out) out.push(spans[i]);
2469 }
2470 return !out ? spans : out.length ? out : null;
2471 }
2450 function newHL(text, spans) { return spans ? {text: text, markedSpans: spans} : text; }
2472 function newHL(text, spans) { return spans ? {text: text, markedSpans: spans} : text; }
2451
2473
2452 function detachMarkedSpans(line) {
2474 function detachMarkedSpans(line) {
@@ -2582,13 +2604,17 b' window.CodeMirror = (function() {'
2582 span = function(html, text, style) {
2604 span = function(html, text, style) {
2583 var l = text.length;
2605 var l = text.length;
2584 if (wrapAt >= outPos && wrapAt < outPos + l) {
2606 if (wrapAt >= outPos && wrapAt < outPos + l) {
2585 if (wrapAt > outPos) {
2607 var cut = wrapAt - outPos;
2586 span_(html, text.slice(0, wrapAt - outPos), style);
2608 if (cut) {
2609 span_(html, text.slice(0, cut), style);
2587 // See comment at the definition of spanAffectsWrapping
2610 // See comment at the definition of spanAffectsWrapping
2588 if (compensateForWrapping) html.appendChild(elt("wbr"));
2611 if (compensateForWrapping) {
2612 var view = text.slice(cut - 1, cut + 1);
2613 if (spanAffectsWrapping.test(view)) html.appendChild(elt("wbr"));
2614 else if (!ie_lt8 && /\w\w/.test(view)) html.appendChild(document.createTextNode("\u200d"));
2615 }
2589 }
2616 }
2590 html.appendChild(anchor);
2617 html.appendChild(anchor);
2591 var cut = wrapAt - outPos;
2592 span_(anchor, opera ? text.slice(cut, cut + 1) : text.slice(cut), style);
2618 span_(anchor, opera ? text.slice(cut, cut + 1) : text.slice(cut), style);
2593 if (opera) span_(html, text.slice(cut + 1), style);
2619 if (opera) span_(html, text.slice(cut + 1), style);
2594 wrapAt--;
2620 wrapAt--;
@@ -2872,7 +2898,7 b' window.CodeMirror = (function() {'
2872 var time = +new Date, cur = lst(this.done), last = cur && lst(cur);
2898 var time = +new Date, cur = lst(this.done), last = cur && lst(cur);
2873 var dtime = time - this.time;
2899 var dtime = time - this.time;
2874
2900
2875 if (this.compound && cur && !this.closed) {
2901 if (cur && !this.closed && this.compound) {
2876 cur.push({start: start, added: added, old: old});
2902 cur.push({start: start, added: added, old: old});
2877 } else if (dtime > 400 || !last || this.closed ||
2903 } else if (dtime > 400 || !last || this.closed ||
2878 last.start > start + old.length || last.start + last.added < start) {
2904 last.start > start + old.length || last.start + last.added < start) {
@@ -3078,8 +3104,10 b' window.CodeMirror = (function() {'
3078 if (collection[i] == elt) return i;
3104 if (collection[i] == elt) return i;
3079 return -1;
3105 return -1;
3080 }
3106 }
3107 var nonASCIISingleCaseWordChar = /[\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc]/;
3081 function isWordChar(ch) {
3108 function isWordChar(ch) {
3082 return /\w/.test(ch) || ch.toUpperCase() != ch.toLowerCase();
3109 return /\w/.test(ch) || ch > "\x80" &&
3110 (ch.toUpperCase() != ch.toLowerCase() || nonASCIISingleCaseWordChar.test(ch));
3083 }
3111 }
3084
3112
3085 // See if "".split is the broken IE version, if so, provide an
3113 // See if "".split is the broken IE version, if so, provide an
@@ -3135,7 +3163,7 b' window.CodeMirror = (function() {'
3135 for (var i = 1; i <= 12; i++) keyNames[i + 111] = keyNames[i + 63235] = "F" + i;
3163 for (var i = 1; i <= 12; i++) keyNames[i + 111] = keyNames[i + 63235] = "F" + i;
3136 })();
3164 })();
3137
3165
3138 CodeMirror.version = "2.34";
3166 CodeMirror.version = "2.36";
3139
3167
3140 return CodeMirror;
3168 return CodeMirror;
3141 })();
3169 })();
General Comments 0
You need to be logged in to leave comments. Login now