aboutsummaryrefslogtreecommitdiff
path: root/imports/codemirror/mode/diff/index.html
diff options
context:
space:
mode:
authorValerio Virgillito2012-02-14 11:07:21 -0800
committerValerio Virgillito2012-02-14 11:07:21 -0800
commitf060190a3bffd9a16718f2ce0499699103d46372 (patch)
treea308fe7eacec2156c8212dff0892a3de925d5f9a /imports/codemirror/mode/diff/index.html
parentf766cc203f30ea43ae8b83cf4b65d45cc4435ee9 (diff)
parent33bc9d62b8e6694500bf14d5b18187bd99a520a3 (diff)
downloadninja-f060190a3bffd9a16718f2ce0499699103d46372.tar.gz
Merge branch 'FileIO' of https://github.com/joseeight/ninja-internal into integration
Diffstat (limited to 'imports/codemirror/mode/diff/index.html')
-rwxr-xr-ximports/codemirror/mode/diff/index.html99
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">
15diff --git a/index.html b/index.html
16index 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>
29diff --git a/lib/codemirror.js b/lib/codemirror.js
30index 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>