Mercurial
comparison .cms/lib/codemirror/mode/diff/diff.js @ 0:78edf6b517a0 draft
24.10
author | Coffee CMS <info@coffee-cms.ru> |
---|---|
date | Fri, 11 Oct 2024 22:40:23 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:78edf6b517a0 |
---|---|
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others | |
2 // Distributed under an MIT license: https://codemirror.net/5/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 }); |