diff options
Diffstat (limited to 'codemirror_ui/lib/CodeMirror-2.3/mode/diff/diff.js')
-rw-r--r-- | codemirror_ui/lib/CodeMirror-2.3/mode/diff/diff.js | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/codemirror_ui/lib/CodeMirror-2.3/mode/diff/diff.js b/codemirror_ui/lib/CodeMirror-2.3/mode/diff/diff.js new file mode 100644 index 0000000..3402f3b --- /dev/null +++ b/codemirror_ui/lib/CodeMirror-2.3/mode/diff/diff.js @@ -0,0 +1,32 @@ +CodeMirror.defineMode("diff", function() { + + var TOKEN_NAMES = { + '+': 'tag', + '-': 'string', + '@': 'meta' + }; + + return { + token: function(stream) { + 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; + } + }; +}); + +CodeMirror.defineMIME("text/x-diff", "diff"); |