Show More
@@ -5,7 +5,7 | |||
|
5 | 5 | We carry a mostly unmodified copy of CodeMirror. The current version we use |
|
6 | 6 | is (*please update this information when updating versions*):: |
|
7 | 7 | |
|
8 |
CodeMirror |
|
|
8 | CodeMirror c813c94 | |
|
9 | 9 | |
|
10 | 10 | The only changes we've applied so far are these:: |
|
11 | 11 |
@@ -149,8 +149,10 var CodeMirror = (function() { | |||
|
149 | 149 | else if (option == "theme") themeChanged(); |
|
150 | 150 | else if (option == "lineWrapping" && oldVal != value) operation(wrappingChanged)(); |
|
151 | 151 | else if (option == "tabSize") operation(tabsChanged)(); |
|
152 | if (option == "lineNumbers" || option == "gutter" || option == "firstLineNumber" || option == "theme") | |
|
152 | if (option == "lineNumbers" || option == "gutter" || option == "firstLineNumber" || option == "theme") { | |
|
153 | gutterChanged(); | |
|
153 | 154 | updateDisplay(true); |
|
155 | } | |
|
154 | 156 | }, |
|
155 | 157 | getOption: function(option) {return options[option];}, |
|
156 | 158 | undo: operation(undo), |
@@ -278,8 +280,8 var CodeMirror = (function() { | |||
|
278 | 280 | return index; |
|
279 | 281 | }, |
|
280 | 282 | scrollTo: function(x, y) { |
|
281 |
if (x != null) scroller.scroll |
|
|
282 |
if (y != null) scroller.scroll |
|
|
283 | if (x != null) scroller.scrollLeft = x; | |
|
284 | if (y != null) scroller.scrollTop = y; | |
|
283 | 285 | updateDisplay([]); |
|
284 | 286 | }, |
|
285 | 287 | |
@@ -440,10 +442,10 var CodeMirror = (function() { | |||
|
440 | 442 | try { |
|
441 | 443 | var text = e.dataTransfer.getData("Text"); |
|
442 | 444 | if (text) { |
|
443 | var end = replaceRange(text, pos, pos); | |
|
444 | 445 |
|
|
445 |
|
|
|
446 | setSelectionUser(pos, pos); | |
|
446 | 447 | if (draggingText) replaceRange("", curFrom, curTo); |
|
448 | replaceSelection(text); | |
|
447 | 449 | focusInput(); |
|
448 | 450 | } |
|
449 | 451 | } |
@@ -511,9 +513,9 var CodeMirror = (function() { | |||
|
511 | 513 | } |
|
512 | 514 | } |
|
513 | 515 | function onKeyPress(e) { |
|
516 | if (options.onKeyEvent && options.onKeyEvent(instance, addStop(e))) return; | |
|
514 | 517 | var keyCode = e_prop(e, "keyCode"), charCode = e_prop(e, "charCode"); |
|
515 | 518 | if (window.opera && keyCode == lastStoppedKey) {lastStoppedKey = null; e_preventDefault(e); return;} |
|
516 | if (options.onKeyEvent && options.onKeyEvent(instance, addStop(e))) return; | |
|
517 | 519 | if (window.opera && !e.which && handleKeyBinding(e)) return; |
|
518 | 520 | if (options.electricChars && mode.electricChars && options.smartIndent && !options.readOnly) { |
|
519 | 521 | var ch = String.fromCharCode(charCode == null ? keyCode : charCode); |
@@ -565,20 +567,22 var CodeMirror = (function() { | |||
|
565 | 567 | } |
|
566 | 568 | updateLinesNoUndo(from, to, newText, selFrom, selTo); |
|
567 | 569 | } |
|
568 | function unredoHelper(from, to) { | |
|
569 | var change = from.pop(); | |
|
570 | if (change) { | |
|
570 | function unredoHelper(from, to, dir) { | |
|
571 | var set = from.pop(), len = set ? set.length : 0, out = []; | |
|
572 | for (var i = dir > 0 ? 0 : len - 1, e = dir > 0 ? len : -1; i != e; i += dir) { | |
|
573 | var change = set[i]; | |
|
571 | 574 | var replaced = [], end = change.start + change.added; |
|
572 | 575 | doc.iter(change.start, end, function(line) { replaced.push(line.text); }); |
|
573 |
t |
|
|
576 | out.push({start: change.start, added: change.old.length, old: replaced}); | |
|
574 | 577 | var pos = clipPos({line: change.start + change.old.length - 1, |
|
575 | 578 | ch: editEnd(replaced[replaced.length-1], change.old[change.old.length-1])}); |
|
576 | 579 | updateLinesNoUndo({line: change.start, ch: 0}, {line: end - 1, ch: getLine(end-1).text.length}, change.old, pos, pos); |
|
577 | updateInput = true; | |
|
578 | 580 | } |
|
581 | updateInput = true; | |
|
582 | to.push(out); | |
|
579 | 583 | } |
|
580 | function undo() {unredoHelper(history.done, history.undone);} | |
|
581 | function redo() {unredoHelper(history.undone, history.done);} | |
|
584 | function undo() {unredoHelper(history.done, history.undone, -1);} | |
|
585 | function redo() {unredoHelper(history.undone, history.done, 1);} | |
|
582 | 586 | |
|
583 | 587 | function updateLinesNoUndo(from, to, newText, selFrom, selTo) { |
|
584 | 588 | if (suppressEdits) return; |
@@ -780,7 +784,7 var CodeMirror = (function() { | |||
|
780 | 784 | if (!posEq(sel.from, sel.to)) { |
|
781 | 785 | prevInput = ""; |
|
782 | 786 | input.value = getSelection(); |
|
783 |
input |
|
|
787 | selectInput(input); | |
|
784 | 788 | } else if (user) prevInput = input.value = ""; |
|
785 | 789 | } |
|
786 | 790 | |
@@ -1537,7 +1541,7 var CodeMirror = (function() { | |||
|
1537 | 1541 | leaveInputAlone = true; |
|
1538 | 1542 | var val = input.value = getSelection(); |
|
1539 | 1543 | focusInput(); |
|
1540 |
input |
|
|
1544 | selectInput(input); | |
|
1541 | 1545 | function rehide() { |
|
1542 | 1546 | var newVal = splitLines(input.value).join("\n"); |
|
1543 | 1547 | if (newVal != val) operation(replaceSelection)(newVal, "end"); |
@@ -2551,11 +2555,13 var CodeMirror = (function() { | |||
|
2551 | 2555 | History.prototype = { |
|
2552 | 2556 | addChange: function(start, added, old) { |
|
2553 | 2557 | this.undone.length = 0; |
|
2554 |
var time = +new Date, |
|
|
2555 |
|
|
|
2556 | last.start > start + added || last.start + last.added < start - last.added + last.old.length) | |
|
2557 | this.done.push({start: start, added: added, old: old}); | |
|
2558 | else { | |
|
2558 | var time = +new Date, cur = this.done[this.done.length - 1], last = cur && cur[cur.length - 1]; | |
|
2559 | var dtime = time - this.time; | |
|
2560 | if (dtime > 400 || !last) { | |
|
2561 | this.done.push([{start: start, added: added, old: old}]); | |
|
2562 | } else if (last.start > start + added || last.start + last.added < start - last.added + last.old.length) { | |
|
2563 | cur.push({start: start, added: added, old: old}); | |
|
2564 | } else { | |
|
2559 | 2565 | var oldoff = 0; |
|
2560 | 2566 | if (start < last.start) { |
|
2561 | 2567 | for (var i = last.start - start - 1; i >= 0; --i) |
@@ -15,7 +15,7 CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { | |||
|
15 | 15 | |
|
16 | 16 | var hrRE = /^[*-=_]/ |
|
17 | 17 | , ulRE = /^[*-+]\s+/ |
|
18 | , olRE = /^[0-9]\.\s+/ | |
|
18 | , olRE = /^[0-9]+\.\s+/ | |
|
19 | 19 | , headerRE = /^(?:\={3,}|-{3,})$/ |
|
20 | 20 | , codeRE = /^(k:\t|\s{4,})/ |
|
21 | 21 | , textRE = /^[^\[*_\\<>`]+/; |
@@ -213,6 +213,10 CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { | |||
|
213 | 213 | |
|
214 | 214 | token: function(stream, state) { |
|
215 | 215 | if (stream.sol()) { |
|
216 | // Reset EM state | |
|
217 | state.em = false; | |
|
218 | // Reset STRONG state | |
|
219 | state.strong = false; | |
|
216 | 220 | state.f = state.block; |
|
217 | 221 | var previousIndentation = state.indentation |
|
218 | 222 | , currentIndentation = 0; |
General Comments 0
You need to be logged in to leave comments.
Login now