diff options
author | Jonathan Duran | 2012-07-17 11:42:09 -0700 |
---|---|---|
committer | Jonathan Duran | 2012-07-17 11:42:09 -0700 |
commit | b4b3e45d6684e77d361b4f8ca5be4889428320c5 (patch) | |
tree | 2156d9920ea1b7db49ed6460545fea7cda121bae /imports/codemirror/mode/diff | |
parent | 4a87ff575693509ac578d46af26fa137c0dc3f58 (diff) | |
parent | 4f737b24c19ddc02d20f9783b8b080fc6ef11142 (diff) | |
download | ninja-b4b3e45d6684e77d361b4f8ca5be4889428320c5.tar.gz |
Merge branch 'refs/heads/NINJA-master' into TimelineUber
Diffstat (limited to 'imports/codemirror/mode/diff')
-rw-r--r-- | imports/codemirror/mode/diff/diff.css | 3 | ||||
-rw-r--r-- | imports/codemirror/mode/diff/diff.js | 29 | ||||
-rw-r--r-- | imports/codemirror/mode/diff/index.html | 13 |
3 files changed, 33 insertions, 12 deletions
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 @@ | |||
1 | span.cm-rangeinfo {color: #a0b;} | ||
2 | span.cm-minus {color: red;} | ||
3 | 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 @@ | |||
1 | CodeMirror.defineMode("diff", function() { | 1 | CodeMirror.defineMode("diff", function() { |
2 | |||
3 | var TOKEN_NAMES = { | ||
4 | '+': 'tag', | ||
5 | '-': 'string', | ||
6 | '@': 'meta' | ||
7 | }; | ||
8 | |||
2 | return { | 9 | return { |
3 | token: function(stream) { | 10 | token: function(stream) { |
4 | var ch = stream.next(); | 11 | var tw_pos = stream.string.search(/[\t ]+?$/); |
5 | stream.skipToEnd(); | 12 | |
6 | if (ch == "+") return "plus"; | 13 | if (!stream.sol() || tw_pos === 0) { |
7 | if (ch == "-") return "minus"; | 14 | stream.skipToEnd(); |
8 | if (ch == "@") return "rangeinfo"; | 15 | return ("error " + ( |
16 | TOKEN_NAMES[stream.string.charAt(0)] || '')).replace(/ $/, ''); | ||
17 | } | ||
18 | |||
19 | var token_name = TOKEN_NAMES[stream.peek()] || stream.skipToEnd(); | ||
20 | |||
21 | if (tw_pos === -1) { | ||
22 | stream.skipToEnd(); | ||
23 | } else { | ||
24 | stream.pos = tw_pos; | ||
25 | } | ||
26 | |||
27 | return token_name; | ||
9 | } | 28 | } |
10 | }; | 29 | }; |
11 | }); | 30 | }); |
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 @@ | |||
5 | <link rel="stylesheet" href="../../lib/codemirror.css"> | 5 | <link rel="stylesheet" href="../../lib/codemirror.css"> |
6 | <script src="../../lib/codemirror.js"></script> | 6 | <script src="../../lib/codemirror.js"></script> |
7 | <script src="diff.js"></script> | 7 | <script src="diff.js"></script> |
8 | <link rel="stylesheet" href="diff.css"> | 8 | <style> |
9 | <style>.CodeMirror {border-top: 1px solid #ddd; border-bottom: 1px solid #ddd;}</style> | 9 | .CodeMirror {border-top: 1px solid #ddd; border-bottom: 1px solid #ddd;} |
10 | span.cm-meta {color: #a0b !important;} | ||
11 | span.cm-error { background-color: black; opacity: 0.4;} | ||
12 | span.cm-error.cm-string { background-color: red; } | ||
13 | span.cm-error.cm-tag { background-color: #2b2; } | ||
14 | </style> | ||
10 | <link rel="stylesheet" href="../../doc/docs.css"> | 15 | <link rel="stylesheet" href="../../doc/docs.css"> |
11 | </head> | 16 | </head> |
12 | <body> | 17 | <body> |
@@ -34,12 +39,12 @@ index 04646a9..9a39cc7 100644 | |||
34 | } | 39 | } |
35 | 40 | ||
36 | function onMouseDown(e) { | 41 | function onMouseDown(e) { |
37 | - var start = posFromMouse(e), last = start; | 42 | - var start = posFromMouse(e), last = start; |
38 | + var start = posFromMouse(e), last = start, target = e.target(); | 43 | + var start = posFromMouse(e), last = start, target = e.target(); |
39 | if (!start) return; | 44 | if (!start) return; |
40 | setCursor(start.line, start.ch, false); | 45 | setCursor(start.line, start.ch, false); |
41 | if (e.button() != 1) return; | 46 | if (e.button() != 1) return; |
42 | + if (target.parentNode == gutter) { | 47 | + if (target.parentNode == gutter) { |
43 | + if (options.onGutterClick) | 48 | + if (options.onGutterClick) |
44 | + options.onGutterClick(indexOf(gutter.childNodes, target) + showingFrom); | 49 | + options.onGutterClick(indexOf(gutter.childNodes, target) + showingFrom); |
45 | + return; | 50 | + return; |