Subversion-Projekte lars-tiefland.ci

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
776 lars 1
<!doctype html>
2
<title>CodeMirror: Diff mode</title>
3
<meta charset="utf-8" />
4
<link rel=stylesheet href="../../doc/docs.css">
5
<link rel="stylesheet" href="../../lib/codemirror.css">
6
<script src="../../lib/codemirror.js"></script>
7
<script src="diff.js"></script>
8
<style>
9
    .CodeMirror {
10
        border-top: 1px solid #ddd;
11
        border-bottom: 1px solid #ddd;
12
    }
13
 
14
    span.cm-meta {
15
        color: #a0b !important;
16
    }
17
 
18
    span.cm-error {
19
        background-color: black;
20
        opacity: 0.4;
21
    }
22
 
23
    span.cm-error.cm-string {
24
        background-color: red;
25
    }
26
 
27
    span.cm-error.cm-tag {
28
        background-color: #2b2;
29
    }
30
</style>
31
<div id=nav>
32
    <a href="http://codemirror.net">
33
        <h1>CodeMirror</h1>
34
        <img id=logo src="../../doc/logo.png">
35
    </a>
36
    <ul>
37
        <li>
38
            <a href="../../index.html">Home</a>
39
            <li>
40
                <a href="../../doc/manual.html">Manual</a>
41
                <li>
42
                    <a href="https://github.com/codemirror/codemirror">Code</a>
43
    </ul>
44
    <ul>
45
        <li>
46
            <a href="../index.html">Language modes</a>
47
            <li>
48
                <a class=active href="#">Diff</a>
49
    </ul>
50
</div>
51
<article>
52
    <h2>Diff mode</h2>
53
    <form>
54
        <textarea id="code" name="code"> diff --git a/index.html b/index.html index c1d9156..7764744 100644 --- a/index.html +++ b/index.html @@ -95,7 +95,8 @@ StringStream.prototype = {
55
            <script>
56
                var editor = CodeMirror.fromTextArea(document.getElementById("code"),
57
                {
58
                    lineNumbers: true,
59
                    -autoMatchBrackets: true + autoMatchBrackets: true,
60
                    +onGutterClick: function(x)
61
                    {
62
                        console.log(x);
63
                    }
64
                });
65
            </script>
66
            </body> diff --git a/lib/codemirror.js b/lib/codemirror.js index 04646a9..9a39cc7 100644 --- a/lib/codemirror.js +++ b/lib/codemirror.js @@ -399,10 +399,16 @@ var CodeMirror = (function() { } function onMouseDown(e) { - var start = posFromMouse(e),
67
            last = start; + var start = posFromMouse(e), last = start, target = e.target(); if (!start) return; setCursor(start.line, start.ch, false); if (e.button() != 1) return; + if (target.parentNode == gutter) { + if (options.onGutterClick) + options.onGutterClick(indexOf(gutter.childNodes,
68
            target) + showingFrom); + return; + } + if (!focused) onFocus(); e.stop(); @@ -808,7 +814,7 @@ var CodeMirror = (function() { for (var i = showingFrom; i
69
            < showingTo; ++i) { var marker=l ines[i].gutterMarker; if (marker) html.push(
70
                '<div class="' + marker.style + '">' + htmlEscape(marker.text) + '</div>'); - else html.push( "<div>" + (options.lineNumbers ? i + 1 : "\u00a0") + "</div>"); + else html.push( "<div>" + (options.lineNumbers ? i + options.firstLineNumber : "\u00a0") +
71
                "</div>"); } gutter.style.display="none" ; // TODO test whether this actually helps gutter.innerHTML=h tml.join( ""); @@ -1371,10 +1377,8 @@ var CodeMirror=( function() { if (option=="parser" ) setParser(value); else if (option==="lineNumbers" )
72
                setLineNumbers(value); else if (option==="gutter" ) setGutter(value); - else if (option==="readOnly" ) options.readOnly=v alue; - else if (option==="indentUnit" ) {options.indentUnit=i ndentUnit=v alue; setParser(options.parser);} - else if
73
                (/^(?:enterMode|tabMode|indentWithTabs|readOnly|autoMatchBrackets|undoDepth)$/.test(option)) options[option]=v alue; - else throw new Error( "Can't set option " + option); + else if (option==="indentUnit" ) {options.indentUnit=v alue; setParser(options.parser);}
74
                + else options[option]=v alue; }, cursorCoords: cursorCoords, undo: operation(undo), @@ -1402,7 +1406,8 @@ var CodeMirror=( function() { replaceRange: operation(replaceRange), operation: function(f){return operation(f)();}, - refresh: function(){updateDisplay([{from:
75
                0, to: lines.length}]);} + refresh: function(){updateDisplay([{from: 0, to: lines.length}]);}, + getInputField: function(){return input;} }; return instance; } @@ -1420,6 +1425,7 @@ var CodeMirror=( function() { readOnly: false, onChange:
76
                null, onCursorActivity: null, + onGutterClick: null, autoMatchBrackets: false, workTime: 200, workDelay: 300, </textarea>
77
    </form>
78
    <script>
79
        var editor = CodeMirror.fromTextArea(document.getElementById("code"),
80
        {});
81
    </script>
82
    <p>
83
        <strong>MIME types defined:</strong> <code>text/x-diff</code>.</p>
84
</article>