From 0e04fff0ea80fa5cbe96b8354db38bd334aea83a Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Mon, 16 Jul 2012 16:04:05 -0700 Subject: upgrade to codemirror 2.3 Signed-off-by: Ananya Sen Conflicts: js/code-editor/codemirror-ninja/theme/lesser-dark-ninja.css Signed-off-by: Ananya Sen --- imports/codemirror/mode/diff/diff.css | 3 --- imports/codemirror/mode/diff/diff.js | 29 ++++++++++++++++++++++++----- imports/codemirror/mode/diff/index.html | 13 +++++++++---- 3 files changed, 33 insertions(+), 12 deletions(-) delete mode 100644 imports/codemirror/mode/diff/diff.css (limited to 'imports/codemirror/mode/diff') diff --git a/imports/codemirror/mode/diff/diff.css b/imports/codemirror/mode/diff/diff.css deleted file mode 100644 index 0e96ab21..00000000 --- a/imports/codemirror/mode/diff/diff.css +++ /dev/null @@ -1,3 +0,0 @@ -span.cm-rangeinfo {color: #a0b;} -span.cm-minus {color: red;} -span.cm-plus {color: #2b2;} diff --git a/imports/codemirror/mode/diff/diff.js b/imports/codemirror/mode/diff/diff.js index 725bb2c7..3402f3b3 100644 --- a/imports/codemirror/mode/diff/diff.js +++ b/imports/codemirror/mode/diff/diff.js @@ -1,11 +1,30 @@ CodeMirror.defineMode("diff", function() { + + var TOKEN_NAMES = { + '+': 'tag', + '-': 'string', + '@': 'meta' + }; + return { token: function(stream) { - var ch = stream.next(); - stream.skipToEnd(); - if (ch == "+") return "plus"; - if (ch == "-") return "minus"; - if (ch == "@") return "rangeinfo"; + var tw_pos = stream.string.search(/[\t ]+?$/); + + if (!stream.sol() || tw_pos === 0) { + stream.skipToEnd(); + return ("error " + ( + TOKEN_NAMES[stream.string.charAt(0)] || '')).replace(/ $/, ''); + } + + var token_name = TOKEN_NAMES[stream.peek()] || stream.skipToEnd(); + + if (tw_pos === -1) { + stream.skipToEnd(); + } else { + stream.pos = tw_pos; + } + + return token_name; } }; }); diff --git a/imports/codemirror/mode/diff/index.html b/imports/codemirror/mode/diff/index.html index 2540236c..b102c090 100644 --- a/imports/codemirror/mode/diff/index.html +++ b/imports/codemirror/mode/diff/index.html @@ -5,8 +5,13 @@ - - + @@ -34,12 +39,12 @@ index 04646a9..9a39cc7 100644 } function onMouseDown(e) { -- var start = posFromMouse(e), last = start; +- var start = posFromMouse(e), last = start; + var start = posFromMouse(e), last = start, target = e.target(); if (!start) return; setCursor(start.line, start.ch, false); if (e.button() != 1) return; -+ if (target.parentNode == gutter) { ++ if (target.parentNode == gutter) { + if (options.onGutterClick) + options.onGutterClick(indexOf(gutter.childNodes, target) + showingFrom); + return; -- cgit v1.2.3