diff options
author | Valerio Virgillito | 2012-02-15 17:04:39 -0800 |
---|---|---|
committer | Valerio Virgillito | 2012-02-15 17:04:39 -0800 |
commit | fe71cb9aa1700199c0089166ad54fc56eb760644 (patch) | |
tree | b0c7c24b1f45a079e1c09312ca716e3d35aecad4 /js/codemirror/mode/diff | |
parent | 747616980cad14f0b65fbcc7f497ed9680a39d29 (diff) | |
parent | d366c0bd1af6471511217ed574083e15059519b5 (diff) | |
download | ninja-fe71cb9aa1700199c0089166ad54fc56eb760644.tar.gz |
Merge branch 'refs/heads/master' into components
Diffstat (limited to 'js/codemirror/mode/diff')
-rw-r--r-- | js/codemirror/mode/diff/diff.css | 3 | ||||
-rw-r--r-- | js/codemirror/mode/diff/diff.js | 13 | ||||
-rw-r--r-- | js/codemirror/mode/diff/index.html | 99 |
3 files changed, 0 insertions, 115 deletions
diff --git a/js/codemirror/mode/diff/diff.css b/js/codemirror/mode/diff/diff.css deleted file mode 100644 index 16f8d335..00000000 --- a/js/codemirror/mode/diff/diff.css +++ /dev/null | |||
@@ -1,3 +0,0 @@ | |||
1 | .cm-s-default span.cm-rangeinfo {color: #a0b;} | ||
2 | .cm-s-default span.cm-minus {color: #a22;} | ||
3 | .cm-s-default span.cm-plus {color: #2b2;} | ||
diff --git a/js/codemirror/mode/diff/diff.js b/js/codemirror/mode/diff/diff.js deleted file mode 100644 index 725bb2c7..00000000 --- a/js/codemirror/mode/diff/diff.js +++ /dev/null | |||
@@ -1,13 +0,0 @@ | |||
1 | CodeMirror.defineMode("diff", function() { | ||
2 | return { | ||
3 | token: function(stream) { | ||
4 | var ch = stream.next(); | ||
5 | stream.skipToEnd(); | ||
6 | if (ch == "+") return "plus"; | ||
7 | if (ch == "-") return "minus"; | ||
8 | if (ch == "@") return "rangeinfo"; | ||
9 | } | ||
10 | }; | ||
11 | }); | ||
12 | |||
13 | CodeMirror.defineMIME("text/x-diff", "diff"); | ||
diff --git a/js/codemirror/mode/diff/index.html b/js/codemirror/mode/diff/index.html deleted file mode 100644 index 2748f2fa..00000000 --- a/js/codemirror/mode/diff/index.html +++ /dev/null | |||
@@ -1,99 +0,0 @@ | |||
1 | <!doctype html> | ||
2 | <html> | ||
3 | <head> | ||
4 | <title>CodeMirror 2: Diff mode</title> | ||
5 | <link rel="stylesheet" href="../../lib/codemirror.css"> | ||
6 | <script src="../../lib/codemirror.js"></script> | ||
7 | <script src="diff.js"></script> | ||
8 | <link rel="stylesheet" href="diff.css"> | ||
9 | <style>.CodeMirror {border-top: 1px solid #ddd; border-bottom: 1px solid #ddd;}</style> | ||
10 | <link rel="stylesheet" href="../../css/docs.css"> | ||
11 | </head> | ||
12 | <body> | ||
13 | <h1>CodeMirror 2: Diff mode</h1> | ||
14 | <form><textarea id="code" name="code"> | ||
15 | diff --git a/index.html b/index.html | ||
16 | index c1d9156..7764744 100644 | ||
17 | --- a/index.html | ||
18 | +++ b/index.html | ||
19 | @@ -95,7 +95,8 @@ StringStream.prototype = { | ||
20 | <script> | ||
21 | var editor = CodeMirror.fromTextArea(document.getElementById("code"), { | ||
22 | lineNumbers: true, | ||
23 | - autoMatchBrackets: true | ||
24 | + autoMatchBrackets: true, | ||
25 | + onGutterClick: function(x){console.log(x);} | ||
26 | }); | ||
27 | </script> | ||
28 | </body> | ||
29 | diff --git a/lib/codemirror.js b/lib/codemirror.js | ||
30 | index 04646a9..9a39cc7 100644 | ||
31 | --- a/lib/codemirror.js | ||
32 | +++ b/lib/codemirror.js | ||
33 | @@ -399,10 +399,16 @@ var CodeMirror = (function() { | ||
34 | } | ||
35 | |||
36 | function onMouseDown(e) { | ||
37 | - var start = posFromMouse(e), last = start; | ||
38 | + var start = posFromMouse(e), last = start, target = e.target(); | ||
39 | if (!start) return; | ||
40 | setCursor(start.line, start.ch, false); | ||
41 | if (e.button() != 1) return; | ||
42 | + if (target.parentNode == gutter) { | ||
43 | + if (options.onGutterClick) | ||
44 | + options.onGutterClick(indexOf(gutter.childNodes, target) + showingFrom); | ||
45 | + return; | ||
46 | + } | ||
47 | + | ||
48 | if (!focused) onFocus(); | ||
49 | |||
50 | e.stop(); | ||
51 | @@ -808,7 +814,7 @@ var CodeMirror = (function() { | ||
52 | for (var i = showingFrom; i < showingTo; ++i) { | ||
53 | var marker = lines[i].gutterMarker; | ||
54 | if (marker) html.push('<div class="' + marker.style + '">' + htmlEscape(marker.text) + '</div>'); | ||
55 | - else html.push("<div>" + (options.lineNumbers ? i + 1 : "\u00a0") + "</div>"); | ||
56 | + else html.push("<div>" + (options.lineNumbers ? i + options.firstLineNumber : "\u00a0") + "</div>"); | ||
57 | } | ||
58 | gutter.style.display = "none"; // TODO test whether this actually helps | ||
59 | gutter.innerHTML = html.join(""); | ||
60 | @@ -1371,10 +1377,8 @@ var CodeMirror = (function() { | ||
61 | if (option == "parser") setParser(value); | ||
62 | else if (option === "lineNumbers") setLineNumbers(value); | ||
63 | else if (option === "gutter") setGutter(value); | ||
64 | - else if (option === "readOnly") options.readOnly = value; | ||
65 | - else if (option === "indentUnit") {options.indentUnit = indentUnit = value; setParser(options.parser);} | ||
66 | - else if (/^(?:enterMode|tabMode|indentWithTabs|readOnly|autoMatchBrackets|undoDepth)$/.test(option)) options[option] = value; | ||
67 | - else throw new Error("Can't set option " + option); | ||
68 | + else if (option === "indentUnit") {options.indentUnit = value; setParser(options.parser);} | ||
69 | + else options[option] = value; | ||
70 | }, | ||
71 | cursorCoords: cursorCoords, | ||
72 | undo: operation(undo), | ||
73 | @@ -1402,7 +1406,8 @@ var CodeMirror = (function() { | ||
74 | replaceRange: operation(replaceRange), | ||
75 | |||
76 | operation: function(f){return operation(f)();}, | ||
77 | - refresh: function(){updateDisplay([{from: 0, to: lines.length}]);} | ||
78 | + refresh: function(){updateDisplay([{from: 0, to: lines.length}]);}, | ||
79 | + getInputField: function(){return input;} | ||
80 | }; | ||
81 | return instance; | ||
82 | } | ||
83 | @@ -1420,6 +1425,7 @@ var CodeMirror = (function() { | ||
84 | readOnly: false, | ||
85 | onChange: null, | ||
86 | onCursorActivity: null, | ||
87 | + onGutterClick: null, | ||
88 | autoMatchBrackets: false, | ||
89 | workTime: 200, | ||
90 | workDelay: 300, | ||
91 | </textarea></form> | ||
92 | <script> | ||
93 | var editor = CodeMirror.fromTextArea(document.getElementById("code"), {}); | ||
94 | </script> | ||
95 | |||
96 | <p><strong>MIME types defined:</strong> <code>text/x-diff</code>.</p> | ||
97 | |||
98 | </body> | ||
99 | </html> | ||