From 99f904adcc37d93c90defcd8ce898598e25be212 Mon Sep 17 00:00:00 2001 From: Hugues Hiegel Date: Wed, 11 Mar 2015 16:55:04 +0100 Subject: Lot of plugins --- codemirror_ui/lib/CodeMirror-2.3/mode/diff/diff.js | 32 ++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 codemirror_ui/lib/CodeMirror-2.3/mode/diff/diff.js (limited to 'codemirror_ui/lib/CodeMirror-2.3/mode/diff/diff.js') 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"); -- cgit v1.2.3