diff options
author | Eric Guzman | 2012-02-16 00:22:43 -0800 |
---|---|---|
committer | Eric Guzman | 2012-02-16 00:22:43 -0800 |
commit | 82b1a273219f0ae3d119e156c7acccdbe478f441 (patch) | |
tree | 74c45e5e3afc6706b2f7a7918807f72c54cdcfc5 /imports/codemirror/mode/diff/index.html | |
parent | af20ca9b11133dd5cefb9275dbe8fb101c3380d0 (diff) | |
parent | 966f0adaf1d4b7f2dd5a6e31643df58bff713884 (diff) | |
download | ninja-82b1a273219f0ae3d119e156c7acccdbe478f441.tar.gz |
Merge branch 'refs/heads/TreeComponents' into PresetsPanel
Diffstat (limited to 'imports/codemirror/mode/diff/index.html')
-rwxr-xr-x | imports/codemirror/mode/diff/index.html | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/imports/codemirror/mode/diff/index.html b/imports/codemirror/mode/diff/index.html new file mode 100755 index 00000000..2540236c --- /dev/null +++ b/imports/codemirror/mode/diff/index.html | |||
@@ -0,0 +1,99 @@ | |||
1 | <!doctype html> | ||
2 | <html> | ||
3 | <head> | ||
4 | <title>CodeMirror: 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="../../doc/docs.css"> | ||
11 | </head> | ||
12 | <body> | ||
13 | <h1>CodeMirror: 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> | ||