Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Avatar for KuCalc : devops.
Download
50672 views
1
// CodeMirror, copyright (c) by Marijn Haverbeke and others
2
// Distributed under an MIT license: http://codemirror.net/LICENSE
3
4
(function(mod) {
5
if (typeof exports == "object" && typeof module == "object") // CommonJS
6
mod(require("../../lib/codemirror"));
7
else if (typeof define == "function" && define.amd) // AMD
8
define(["../../lib/codemirror"], mod);
9
else // Plain browser env
10
mod(CodeMirror);
11
})(function(CodeMirror) {
12
"use strict";
13
14
CodeMirror.defineMode("diff", function() {
15
16
var TOKEN_NAMES = {
17
'+': 'positive',
18
'-': 'negative',
19
'@': 'meta'
20
};
21
22
return {
23
token: function(stream) {
24
var tw_pos = stream.string.search(/[\t ]+?$/);
25
26
if (!stream.sol() || tw_pos === 0) {
27
stream.skipToEnd();
28
return ("error " + (
29
TOKEN_NAMES[stream.string.charAt(0)] || '')).replace(/ $/, '');
30
}
31
32
var token_name = TOKEN_NAMES[stream.peek()] || stream.skipToEnd();
33
34
if (tw_pos === -1) {
35
stream.skipToEnd();
36
} else {
37
stream.pos = tw_pos;
38
}
39
40
return token_name;
41
}
42
};
43
});
44
45
CodeMirror.defineMIME("text/x-diff", "diff");
46
47
});
48
49