28 changes: 20 additions & 8 deletions lib/util/search.js → addon/search/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,24 @@
// Ctrl-G.

(function() {
function searchOverlay(query) {
if (typeof query == "string") return {token: function(stream) {
if (stream.match(query)) return "searching";
stream.next();
stream.skipTo(query.charAt(0)) || stream.skipToEnd();
}};
return {token: function(stream) {
if (stream.match(query)) return "searching";
while (!stream.eol()) {
stream.next();
if (stream.match(query, false)) break;
}
}};
}

function SearchState() {
this.posFrom = this.posTo = this.query = null;
this.marked = [];
this.overlay = null;
}
function getSearchState(cm) {
return cm._searchState || (cm._searchState = new SearchState());
Expand Down Expand Up @@ -39,11 +54,9 @@
cm.operation(function() {
if (!query || state.query) return;
state.query = parseQuery(query);
if (cm.lineCount() < 2000) { // This is too expensive on big documents.
for (var cursor = getSearchCursor(cm, state.query); cursor.findNext();)
state.marked.push(cm.markText(cursor.from(), cursor.to(),
{className: "CodeMirror-searching"}));
}
cm.removeOverlay(state.overlay);
state.overlay = searchOverlay(query);
cm.addOverlay(state.overlay);
state.posFrom = state.posTo = cm.getCursor();
findNext(cm, rev);
});
Expand All @@ -63,8 +76,7 @@
var state = getSearchState(cm);
if (!state.query) return;
state.query = null;
for (var i = 0; i < state.marked.length; ++i) state.marked[i].clear();
state.marked.length = 0;
cm.removeOverlay(state.overlay);
});}

var replaceQueryDialog =
Expand Down
27 changes: 17 additions & 10 deletions lib/util/searchcursor.js → addon/search/searchcursor.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
var line = cm.getLine(pos.line), match = query.exec(line),
start = match && match.index;
}
if (match)
if (match && match[0])
return {from: {line: pos.line, ch: start},
to: {line: pos.line, ch: start + match[0].length},
match: match};
Expand All @@ -40,15 +40,21 @@
var fold = caseFold ? function(str){return str.toLowerCase();} : function(str){return str;};
var target = query.split("\n");
// Different methods for single-line and multi-line queries
if (target.length == 1)
this.matches = function(reverse, pos) {
var line = fold(cm.getLine(pos.line)), len = query.length, match;
if (reverse ? (pos.ch >= len && (match = line.lastIndexOf(query, pos.ch - len)) != -1)
: (match = line.indexOf(query, pos.ch)) != -1)
return {from: {line: pos.line, ch: match},
to: {line: pos.line, ch: match + len}};
};
else
if (target.length == 1) {
if (!query.length) {
// Empty string would match anything and never progress, so
// we define it to match nothing instead.
this.matches = function() {};
} else {
this.matches = function(reverse, pos) {
var line = fold(cm.getLine(pos.line)), len = query.length, match;
if (reverse ? (pos.ch >= len && (match = line.lastIndexOf(query, pos.ch - len)) != -1)
: (match = line.indexOf(query, pos.ch)) != -1)
return {from: {line: pos.line, ch: match},
to: {line: pos.line, ch: match + len}};
};
}
} else {
this.matches = function(reverse, pos) {
var ln = pos.line, idx = (reverse ? target.length - 1 : 0), match = target[idx], line = fold(cm.getLine(ln));
var offsetA = (reverse ? line.indexOf(match) + match.length : line.lastIndexOf(match));
Expand All @@ -70,6 +76,7 @@
return {from: reverse ? end : start, to: reverse ? start : end};
}
};
}
}
}

Expand Down
3 changes: 2 additions & 1 deletion bin/compress
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//
// bin/compress codemirror runmode javascript xml
//
// Will take lib/codemirror.js, lib/util/runmode.js,
// Will take lib/codemirror.js, addon/runmode/runmode.js,
// mode/javascript/javascript.js, and mode/xml/xml.js, run them though
// the online minifier at http://marijnhaverbeke.nl/uglifyjs, and spit
// out the result.
Expand Down Expand Up @@ -61,6 +61,7 @@ function walk(dir) {
}

walk("lib/");
walk("addon/");
walk("mode/");

if (!blob) help(false);
Expand Down
2 changes: 1 addition & 1 deletion demo/closetag.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<title>CodeMirror: Close-Tag Demo</title>
<link rel="stylesheet" href="../lib/codemirror.css">
<script src="../lib/codemirror.js"></script>
<script src="../lib/util/closetag.js"></script>
<script src="../addon/edit/closetag.js"></script>
<script src="../mode/xml/xml.js"></script>
<script src="../mode/javascript/javascript.js"></script>
<script src="../mode/css/css.js"></script>
Expand Down
104 changes: 104 additions & 0 deletions demo/collapserange.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>CodeMirror: Range Collapsing Demo</title>
<link rel="stylesheet" href="../lib/codemirror.css">
<script src="../lib/codemirror.js"></script>
<script src="../addon/fold/collapserange.js"></script>
<script src="../mode/javascript/javascript.js"></script>
<link rel="stylesheet" href="../doc/docs.css">

<style type="text/css">
.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}
.CodeMirror-collapserange { width: .6em; }
</style>
</head>
<body>
<h1>CodeMirror: Range Collapsing Demo</h1>

<form><textarea id="code" name="code">(function() {
CodeMirror.defineOption("collapseRange", false, function(cm, val, old) {
var wasOn = old && old != CodeMirror.Init;
if (val && !wasOn)
enableRangeCollapsing(cm);
else if (!val && wasOn)
disableRangeCollapsing(cm);
});

var gutterClass = "CodeMirror-collapserange";

function enableRangeCollapsing(cm) {
cm.on("gutterClick", gutterClick);
cm.setOption("gutters", (cm.getOption("gutters") || []).concat([gutterClass]));
}

function disableRangeCollapsing(cm) {
cm.rangeCollapseStart = null;
cm.off("gutterClick", gutterClick);
var gutters = cm.getOption("gutters");
for (var i = 0; i < gutters.length && gutters[i] != gutterClass; ++i) {}
cm.setOption("gutters", gutters.slice(0, i).concat(gutters.slice(i + 1)));
}

function gutterClick(cm, line, gutter) {
if (gutter != gutterClass) return;

var start = cm.rangeCollapseStart;
if (start) {
var old = cm.getLineNumber(start);
cm.setGutterMarker(start, gutterClass, null);
cm.rangeCollapseStart = null;
var from = Math.min(old, line), to = Math.max(old, line);
if (from != to) {
// Finish this fold
var fold = cm.markText({line: from + 1, ch: 0}, {line: to - 1}, {
collapsed: true,
inclusiveLeft: true,
inclusiveRight: true,
clearOnEnter: true
});
var topLine = cm.setGutterMarker(from, gutterClass, makeMarker(true, true, clear));
var botLine = cm.setGutterMarker(to, gutterClass, makeMarker(false, true, clear));
CodeMirror.on(fold, "clear", clear);

function clear() {
cm.setGutterMarker(topLine, gutterClass, null);
cm.setGutterMarker(botLine, gutterClass, null);
fold.clear();
}
return;
}
}

// Start a new fold
cm.rangeCollapseStart = cm.setGutterMarker(line, gutterClass, makeMarker(true, false));
}

function makeMarker(isTop, isFinished, handler) {
var node = document.createElement("div");
node.innerHTML = isTop ? "\u25bc" : "\u25b2";
if (!isFinished) node.style.color = "red";
node.style.fontSize = "85%";
node.style.cursor = "pointer";
if (handler) CodeMirror.on(node, "mousedown", handler);
return node;
}
})();
</textarea></form>

<script>
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
lineNumbers: true,
collapseRange: true,
mode: "javascript"
});
</script>

<p>Click on the right side of the gutter, then click again below,
the code between will collapse. Click on either arrow to expand.
To use, simply include the collapserange.js file and
set <code>collapseRange: true</code> in options. </p>

</body>
</html>
10 changes: 5 additions & 5 deletions demo/complete.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
<title>CodeMirror: Autocomplete Demo</title>
<link rel="stylesheet" href="../lib/codemirror.css">
<script src="../lib/codemirror.js"></script>
<script src="../lib/util/simple-hint.js"></script>
<link rel="stylesheet" href="../lib/util/simple-hint.css">
<script src="../lib/util/javascript-hint.js"></script>
<script src="../addon/hint/simple-hint.js"></script>
<link rel="stylesheet" href="../addon/hint/simple-hint.css">
<script src="../addon/hint/javascript-hint.js"></script>
<script src="../mode/javascript/javascript.js"></script>
<link rel="stylesheet" href="../doc/docs.css">
</head>
Expand Down Expand Up @@ -53,8 +53,8 @@ <h1>CodeMirror: Autocomplete demo</h1>
</textarea></form>

<p>Press <strong>ctrl-space</strong> to activate autocompletion. See
the code (<a href="../lib/util/simple-hint.js">here</a>
and <a href="../lib/util/javascript-hint.js">here</a>) to figure out
the code (<a href="../addon/hint/simple-hint.js">here</a>
and <a href="../addon/hint/javascript-hint.js">here</a>) to figure out
how it works.</p>

<script>
Expand Down
6 changes: 3 additions & 3 deletions demo/folding.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<title>CodeMirror: Code Folding Demo</title>
<link rel="stylesheet" href="../lib/codemirror.css">
<script src="../lib/codemirror.js"></script>
<script src="../lib/util/foldcode.js"></script>
<script src="../addon/fold/foldcode.js"></script>
<script src="../mode/javascript/javascript.js"></script>
<script src="../mode/xml/xml.js"></script>
<link rel="stylesheet" href="../doc/docs.css">
Expand All @@ -25,9 +25,9 @@
<h1>CodeMirror: Code Folding Demo</h1>

<p>Demonstration of code folding using the code
in <a href="../lib/util/foldcode.js"><code>foldcode.js</code></a>.
in <a href="../addon/fold/foldcode.js"><code>foldcode.js</code></a>.
Press ctrl-q or click on the gutter to fold a block, again
to unfold.</p>
to unfold.<br>Try the <a href="collapserange.html">Range Colapse demo</a> as well.</p>
<form>
<div style="max-width: 50em; margin-bottom: 1em">JavaScript:<br><textarea id="code" name="code"></textarea></div>
<div style="max-width: 50em">HTML:<br><textarea id="code-html" name="code-html"></textarea></div>
Expand Down
4 changes: 2 additions & 2 deletions demo/formatting.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<title>CodeMirror: Formatting Demo</title>
<link rel="stylesheet" href="../lib/codemirror.css">
<script src="../lib/codemirror.js"></script>
<script src="../lib/util/formatting.js"></script>
<script src="../addon/format/formatting.js"></script>
<script src="../mode/css/css.js"></script>
<script src="../mode/xml/xml.js"></script>
<script src="../mode/javascript/javascript.js"></script>
Expand All @@ -29,7 +29,7 @@ <h1>CodeMirror: Formatting demo</h1>
function test(c){ for (var i = 0; i < 10; i++){ process("a.b();c = null;", 300);}
}
</script>
<table><tr><td>test 1</td></tr><tr><td>test 2</td></tr></table>
<table><tr><td>test 1</td></tr><tr><td>test <strong>2</strong></td></tr></table>
<script> function test() { return 1;} </script>
<style> .test { font-size: medium; font-family: monospace; }
</style></textarea></form>
Expand Down
2 changes: 1 addition & 1 deletion demo/loadmode.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<title>CodeMirror: Lazy Mode Loading Demo</title>
<link rel="stylesheet" href="../lib/codemirror.css">
<script src="../lib/codemirror.js"></script>
<script src="../lib/util/loadmode.js"></script>
<script src="../addon/mode/loadmode.js"></script>
<link rel="stylesheet" href="../doc/docs.css">

<style type="text/css">
Expand Down
4 changes: 2 additions & 2 deletions demo/matchhighlighter.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<title>CodeMirror: Match Highlighter Demo</title>
<link rel="stylesheet" href="../lib/codemirror.css">
<script src="../lib/codemirror.js"></script>
<script src="../lib/util/searchcursor.js"></script>
<script src="../lib/util/match-highlighter.js"></script>
<script src="../addon/search/searchcursor.js"></script>
<script src="../addon/search/match-highlighter.js"></script>
<link rel="stylesheet" href="../doc/docs.css">

<style type="text/css">
Expand Down
6 changes: 3 additions & 3 deletions demo/multiplex.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<title>CodeMirror: Multiplexing Parser Demo</title>
<link rel="stylesheet" href="../lib/codemirror.css">
<script src="../lib/codemirror.js"></script>
<script src="../lib/util/multiplex.js"></script>
<script src="../addon/mode/multiplex.js"></script>
<script src="../mode/xml/xml.js"></script>
<link rel="stylesheet" href="../doc/docs.css">

Expand Down Expand Up @@ -52,8 +52,8 @@ <h1><< this is not <html >></h1>
boundary strings, switches to one or more inner modes. The out
(HTML) mode does not get fed the content of the <code>&lt;&lt;
>></code> blocks. See
the <a href="../doc/manual.html#util_multiplex">manual</a> and
the <a href="../lib/util/multiplex.js">source</a> for more
the <a href="../doc/manual.html#addon_multiplex">manual</a> and
the <a href="../addon/mode/multiplex.js">source</a> for more
information.</p>

</body>
Expand Down
4 changes: 2 additions & 2 deletions demo/mustache.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<title>CodeMirror: Overlay Parser Demo</title>
<link rel="stylesheet" href="../lib/codemirror.css">
<script src="../lib/codemirror.js"></script>
<script src="../lib/util/overlay.js"></script>
<script src="../addon/mode/overlay.js"></script>
<script src="../mode/xml/xml.js"></script>
<link rel="stylesheet" href="../doc/docs.css">

Expand Down Expand Up @@ -52,7 +52,7 @@ <h1>{{title}}</h1>
<p>Demonstration of a mode that parses HTML, highlighting
the <a href="http://mustache.github.com/">Mustache</a> templating
directives inside of it by using the code
in <a href="../lib/util/overlay.js"><code>overlay.js</code></a>. View
in <a href="../addon/mode/overlay.js"><code>overlay.js</code></a>. View
source to see the 15 lines of code needed to accomplish this.</p>

</body>
Expand Down
4 changes: 2 additions & 2 deletions demo/runmode.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<title>CodeMirror: Mode Runner Demo</title>
<link rel="stylesheet" href="../lib/codemirror.css">
<script src="../lib/codemirror.js"></script>
<script src="../lib/util/runmode.js"></script>
<script src="../addon/runmode/runmode.js"></script>
<script src="../mode/xml/xml.js"></script>
<link rel="stylesheet" href="../doc/docs.css">
</head>
Expand All @@ -30,7 +30,7 @@ <h1>CodeMirror: Mode Runner Demo</h1>

<p>Running a CodeMirror mode outside of the editor.
The <code>CodeMirror.runMode</code> function, defined
in <code><a href="../lib/util/runmode.js">lib/runmode.js</a></code> takes the following arguments:</p>
in <code><a href="../addon/runmode/runmode.js">lib/runmode.js</a></code> takes the following arguments:</p>

<dl>
<dt><code>text (string)</code></dt>
Expand Down
16 changes: 8 additions & 8 deletions demo/search.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
<link rel="stylesheet" href="../lib/codemirror.css">
<script src="../lib/codemirror.js"></script>
<script src="../mode/xml/xml.js"></script>
<script src="../lib/util/dialog.js"></script>
<link rel="stylesheet" href="../lib/util/dialog.css">
<script src="../lib/util/searchcursor.js"></script>
<script src="../lib/util/search.js"></script>
<script src="../addon/dialog/dialog.js"></script>
<link rel="stylesheet" href="../addon/dialog/dialog.css">
<script src="../addon/search/searchcursor.js"></script>
<script src="../addon/search/search.js"></script>
<link rel="stylesheet" href="../doc/docs.css">

<style type="text/css">
Expand Down Expand Up @@ -76,10 +76,10 @@ <h1>CodeMirror: Search/Replace Demo</h1>
<dt>Shift-Ctrl-R / Shift-Cmd-Option-F</dt><dd>Replace all</dd>
</dl>
<p>Searching is enabled by
including <a href="../lib/util/search.js">lib/util/search.js</a>
and <a href="../lib/util/searchcursor.js">lib/util/searchcursor.js</a>.
including <a href="../addon/search/search.js">addon/search/search.js</a>
and <a href="../addon/search/searchcursor.js">addon/search/searchcursor.js</a>.
For good-looking input dialogs, you also want to include
<a href="../lib/util/dialog.js">lib/util/dialog.js</a>
and <a href="../lib/util/dialog.css">lib/util/dialog.css</a>.</p>
<a href="../addon/dialog/dialog.js">addon/dialog/dialog.js</a>
and <a href="../addon/dialog/dialog.css">addon/dialog/dialog.css</a>.</p>
</body>
</html>
6 changes: 3 additions & 3 deletions demo/vim.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
<title>CodeMirror: Vim bindings demo</title>
<link rel="stylesheet" href="../lib/codemirror.css">
<script src="../lib/codemirror.js"></script>
<script src="../lib/util/dialog.js"></script>
<script src="../lib/util/searchcursor.js"></script>
<script src="../addon/dialog/dialog.js"></script>
<script src="../addon/search/searchcursor.js"></script>
<script src="../mode/clike/clike.js"></script>
<script src="../keymap/vim.js"></script>
<link rel="stylesheet" href="../doc/docs.css">
<link rel="stylesheet" href="../lib/util/dialog.css">
<link rel="stylesheet" href="../addon/dialog/dialog.css">

<style type="text/css">
.CodeMirror {border-top: 1px solid #eee; border-bottom: 1px solid #eee;}
Expand Down
17 changes: 8 additions & 9 deletions demo/xmlcomplete.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
<title>CodeMirror: XML Autocomplete Demo</title>
<link rel="stylesheet" href="../lib/codemirror.css">
<script src="../lib/codemirror.js"></script>
<script src="../lib/util/simple-hint.js"></script>
<link rel="stylesheet" href="../lib/util/simple-hint.css">
<script src="../lib/util/closetag.js"></script>
<script src="../lib/util/xml-hint.js"></script>
<script src="../addon/hint/simple-hint.js"></script>
<link rel="stylesheet" href="../addon/hint/simple-hint.css">
<script src="../addon/edit/closetag.js"></script>
<script src="../addon/hint/xml-hint.js"></script>
<script src="../mode/xml/xml.js"></script>
<link rel="stylesheet" href="../doc/docs.css">
<style type="text/css">
Expand All @@ -23,8 +23,8 @@ <h1>CodeMirror: XML Autocomplete demo</h1>

<p>Type '&lt;' or space inside tag or
press <strong>ctrl-space</strong> to activate autocompletion. See
the code (<a href="../lib/util/simple-hint.js">here</a>
and <a href="../lib/util/xml-hint.js">here</a>) to figure out how
the code (<a href="../addon/hint/simple-hint.js">here</a>
and <a href="../addon/hint/xml-hint.js">here</a>) to figure out how
it works.</p>

<script>
Expand Down Expand Up @@ -62,12 +62,11 @@ <h1>CodeMirror: XML Autocomplete demo</h1>
mode: 'text/html',
lineNumbers: true,
extraKeys: {
"'>'": function(cm) { cm.closeTag(cm, '>'); },
"'/'": function(cm) { cm.closeTag(cm, '/'); },
"' '": function(cm) { CodeMirror.xmlHint(cm, ' '); },
"'<'": function(cm) { CodeMirror.xmlHint(cm, '<'); },
"Ctrl-Space": function(cm) { CodeMirror.xmlHint(cm, ''); }
}
},
autoCloseTags: true
});
</script>
</body>
Expand Down
52 changes: 32 additions & 20 deletions doc/compress.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,10 @@ <h1><span class="logo-braces">{ }</span> <a href="http://codemirror.net/">CodeMi
<input type="hidden" id="download" name="download" value="codemirror-compressed.js"/>
<p>Version: <select id="version" onchange="setVersion(this);" style="padding: 1px">
<option value="http://codemirror.net/">HEAD</option>
<option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=v3.01;f=">3.01</option>
<option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=v3.0;f=">3.0</option>
<option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=v3.0rc2;f=">3.0rc2</option>
<option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=v3.0rc1;f=">3.0rc1</option>
<option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=v3.0beta2;f=">3.0beta2</option>
<option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=v3.0beta1;f=">3.0beta1</option>
<option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=v2.38;f=">2.38</option>
<option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=v2.37;f=">2.37</option>
<option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=v2.36;f=">2.36</option>
<option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=v2.35;f=">2.35</option>
<option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=v2.34;f=">2.34</option>
Expand Down Expand Up @@ -67,11 +66,13 @@ <h1><span class="logo-braces">{ }</span> <a href="http://codemirror.net/">CodeMi
<option value="http://codemirror.net/lib/codemirror.js" selected>codemirror.js</option>
</optgroup>
<optgroup label="Modes">
<option value="http://codemirror.net/mode/apl/apl.js">apl.js</option>
<option value="http://codemirror.net/mode/clike/clike.js">clike.js</option>
<option value="http://codemirror.net/mode/clojure/clojure.js">clojure.js</option>
<option value="http://codemirror.net/mode/coffeescript/coffeescript.js">coffeescript.js</option>
<option value="http://codemirror.net/mode/commonlisp/commonlisp.js">commonlisp.js</option>
<option value="http://codemirror.net/mode/css/css.js">css.js</option>
<option value="http://codemirror.net/mode/d/d.js">d.js</option>
<option value="http://codemirror.net/mode/diff/diff.js">diff.js</option>
<option value="http://codemirror.net/mode/ecl/ecl.js">ecl.js</option>
<option value="http://codemirror.net/mode/erlang/erlang.js">erlang.js</option>
Expand Down Expand Up @@ -104,11 +105,14 @@ <h1><span class="logo-braces">{ }</span> <a href="http://codemirror.net/">CodeMi
<option value="http://codemirror.net/mode/rst/rst.js">rst.js</option>
<option value="http://codemirror.net/mode/ruby/ruby.js">ruby.js</option>
<option value="http://codemirror.net/mode/rust/rust.js">rust.js</option>
<option value="http://codemirror.net/mode/sass/sass.js">sass.js</option>
<option value="http://codemirror.net/mode/scala/scala.js">scala.js</option>
<option value="http://codemirror.net/mode/scheme/scheme.js">scheme.js</option>
<option value="http://codemirror.net/mode/shell/shell.js">shell.js</option>
<option value="http://codemirror.net/mode/sieve/sieve.js">sieve.js</option>
<option value="http://codemirror.net/mode/smalltalk/smalltalk.js">smalltalk.js</option>
<option value="http://codemirror.net/mode/smarty/smarty.js">smarty.js</option>
<option value="http://codemirror.net/mode/sql/sql.js">sql.js</option>
<option value="http://codemirror.net/mode/sparql/sparql.js">sparql.js</option>
<option value="http://codemirror.net/mode/stex/stex.js">stex.js</option>
<option value="http://codemirror.net/mode/tiddlywiki/tiddlywiki.js">tiddlywiki.js</option>
Expand All @@ -122,22 +126,30 @@ <h1><span class="logo-braces">{ }</span> <a href="http://codemirror.net/">CodeMi
<option value="http://codemirror.net/mode/yaml/yaml.js">yaml.js</option>
<option value="http://codemirror.net/mode/z80/z80.js">z80.js</option>
</optgroup>
<optgroup label="Utilities and add-ons">
<option value="http://codemirror.net/lib/util/overlay.js">overlay.js</option>
<option value="http://codemirror.net/lib/util/multiplex.js">multiplex.js</option>
<option value="http://codemirror.net/lib/util/runmode.js">runmode.js</option>
<option value="http://codemirror.net/lib/util/simple-hint.js">simple-hint.js</option>
<option value="http://codemirror.net/lib/util/javascript-hint.js">javascript-hint.js</option>
<option value="http://codemirror.net/lib/util/xml-hint.js">xml-hint.js</option>
<option value="http://codemirror.net/lib/util/foldcode.js">foldcode.js</option>
<option value="http://codemirror.net/lib/util/dialog.js">dialog.js</option>
<option value="http://codemirror.net/lib/util/search.js">search.js</option>
<option value="http://codemirror.net/lib/util/searchcursor.js">searchcursor.js</option>
<option value="http://codemirror.net/lib/util/matchbrackets.js">matchbrackets.js</option>
<option value="http://codemirror.net/lib/util/formatting.js">formatting.js</option>
<option value="http://codemirror.net/lib/util/match-highlighter.js">match-highlighter.js</option>
<option value="http://codemirror.net/lib/util/closetag.js">closetag.js</option>
<option value="http://codemirror.net/lib/util/loadmode.js">loadmode.js</option>
<optgroup label="Add-ons">
<option value="http://codemirror.net/addon/dialog/dialog.js">dialog.js</option>
<option value="http://codemirror.net/addon/edit/closetag.js">closetag.js</option>
<option value="http://codemirror.net/addon/edit/continuecomment.js">continuecomment.js</option>
<option value="http://codemirror.net/addon/edit/continuelist.js">continuelist.js</option>
<option value="http://codemirror.net/addon/edit/matchbrackets.js">matchbrackets.js</option>
<option value="http://codemirror.net/addon/fold/foldcode.js">foldcode.js</option>
<option value="http://codemirror.net/addon/fold/collapserange.js">collapserange.js</option>
<option value="http://codemirror.net/addon/format/formatting.js">formatting.js</option>
<option value="http://codemirror.net/addon/hint/simple-hint.js">simple-hint.js</option>
<option value="http://codemirror.net/addon/hint/javascript-hint.js">javascript-hint.js</option>
<option value="http://codemirror.net/addon/hint/xml-hint.js">xml-hint.js</option>
<option value="http://codemirror.net/addon/hint/pig-hint.js">pig-hint.js</option>
<option value="http://codemirror.net/addon/hint/python-hint.js">python-hint.js</option>
<option value="http://codemirror.net/addon/mode/loadmode.js">loadmode.js</option>
<option value="http://codemirror.net/addon/mode/overlay.js">overlay.js</option>
<option value="http://codemirror.net/addon/mode/multiplex.js">multiplex.js</option>
<option value="http://codemirror.net/addon/runmode/colorize.js">colorize.js</option>
<option value="http://codemirror.net/addon/runmode/runmode.js">runmode.js</option>
<option value="http://codemirror.net/addon/runmode/runmode-standalone.js">runmode-standalone.js</option>
<option value="http://codemirror.net/addon/runmode/runmode.node.js">runmode.node.js</option>
<option value="http://codemirror.net/addon/search/search.js">search.js</option>
<option value="http://codemirror.net/addon/search/searchcursor.js">searchcursor.js</option>
<option value="http://codemirror.net/addon/search/match-highlighter.js">match-highlighter.js</option>
</optgroup>
<optgroup label="Keymaps">
<option value="http://codemirror.net/keymap/emacs.js">emacs.js</option>
Expand Down
154 changes: 109 additions & 45 deletions doc/manual.html

Large diffs are not rendered by default.

87 changes: 87 additions & 0 deletions doc/modes.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8"/>
<title>CodeMirror: Mode list</title>
<link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Droid+Sans|Droid+Sans:bold"/>
<link rel="stylesheet" type="text/css" href="docs.css"/>
</head>
<body>

<h1><span class="logo-braces">{ }</span> <a href="http://codemirror.net/">CodeMirror</a></h1>

<div class="grey">
<img src="baboon.png" class="logo" alt="logo"/>
<pre>
/* Full list of
modes */
</pre>
</div>

<p>Every mode in the distribution. The list on the front-page leaves
out some of the more obscure ones.</p>

<div style="-webkit-columns: 50px 3; -moz-columns: 50px 3; columns: 50px 3;">
<ul>
<li><a href="../mode/apl/index.html">APL</a></li>
<li><a href="../mode/asterisk/index.html">Asterisk dialplan</a></li>
<li><a href="../mode/clike/index.html">C, C++, C#</a></li>
<li><a href="../mode/clojure/index.html">Clojure</a></li>
<li><a href="../mode/coffeescript/index.html">CoffeeScript</a></li>
<li><a href="../mode/commonlisp/index.html">Common Lisp</a></li>
<li><a href="../mode/css/index.html">CSS</a></li>
<li><a href="../mode/d/index.html">D</a></li>
<li><a href="../mode/diff/index.html">diff</a></li>
<li><a href="../mode/ecl/index.html">ECL</a></li>
<li><a href="../mode/erlang/index.html">Erlang</a></li>
<li><a href="../mode/go/index.html">Go</a></li>
<li><a href="../mode/groovy/index.html">Groovy</a></li>
<li><a href="../mode/haskell/index.html">Haskell</a></li>
<li><a href="../mode/haxe/index.html">Haxe</a></li>
<li><a href="../mode/htmlembedded/index.html">HTML embedded scripts</a></li>
<li><a href="../mode/htmlmixed/index.html">HTML mixed-mode</a></li>
<li><a href="../mode/http/index.html">HTTP</a></li>
<li><a href="../mode/clike/index.html">Java</a></li>
<li><a href="../mode/javascript/index.html">JavaScript</a></li>
<li><a href="../mode/jinja2/index.html">Jinja2</a></li>
<li><a href="../mode/less/index.html">LESS</a></li>
<li><a href="../mode/lua/index.html">Lua</a></li>
<li><a href="../mode/markdown/index.html">Markdown</a> (<a href="../mode/gfm/index.html">GitHub-flavour</a>)</li>
<li><a href="../mode/ntriples/index.html">NTriples</a></li>
<li><a href="../mode/ocaml/index.html">OCaml</a></li>
<li><a href="../mode/pascal/index.html">Pascal</a></li>
<li><a href="../mode/perl/index.html">Perl</a></li>
<li><a href="../mode/php/index.html">PHP</a></li>
<li><a href="../mode/pig/index.html">Pig Latin</a></li>
<li><a href="../mode/properties/index.html">Properties files</a></li>
<li><a href="../mode/python/index.html">Python</a></li>
<li><a href="../mode/r/index.html">R</a></li>
<li>RPM <a href="../mode/rpm/spec/index.html">spec</a> and <a href="../mode/rpm/changes/index.html">changelog</a></li>
<li><a href="../mode/rst/index.html">reStructuredText</a></li>
<li><a href="../mode/ruby/index.html">Ruby</a></li>
<li><a href="../mode/rust/index.html">Rust</a></li>
<li><a href="../mode/sass/index.html">Sass</a></li>
<li><a href="../mode/clike/scala.html">Scala</a></li>
<li><a href="../mode/scheme/index.html">Scheme</a></li>
<li><a href="../mode/shell/index.html">Shell</a></li>
<li><a href="../mode/sieve/index.html">Sieve</a></li>
<li><a href="../mode/smalltalk/index.html">Smalltalk</a></li>
<li><a href="../mode/smarty/index.html">Smarty</a></li>
<li><a href="../mode/sql/index.html">SQL</a> (several dialects)</li>
<li><a href="../mode/sparql/index.html">SPARQL</a></li>
<li><a href="../mode/stex/index.html">sTeX, LaTeX</a></li>
<li><a href="../mode/tiddlywiki/index.html">Tiddlywiki</a></li>
<li><a href="../mode/tiki/index.html">Tiki wiki</a></li>
<li><a href="../mode/vb/index.html">VB.NET</a></li>
<li><a href="../mode/vbscript/index.html">VBScript</a></li>
<li><a href="../mode/velocity/index.html">Velocity</a></li>
<li><a href="../mode/verilog/index.html">Verilog</a></li>
<li><a href="../mode/xml/index.html">XML/HTML</a></li>
<li><a href="../mode/xquery/index.html">XQuery</a></li>
<li><a href="../mode/yaml/index.html">YAML</a></li>
<li><a href="../mode/z80/index.html">Z80</a></li>
</ul>
</div>

</body>
</html>
47 changes: 44 additions & 3 deletions doc/oldrelease.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,47 @@ <h1><span class="logo-braces">{ }</span> <a href="http://codemirror.net/">CodeMi
</pre>
</div>

<p class="rel">23-07-2012: <a href="http://codemirror.net/codemirror-2.32.zip">Version 2.32</a>:</p>

<p class="rel-note">Emergency fix for a bug where an editor with
line wrapping on IE will break when there is <em>no</em>
scrollbar.</p>

<p class="rel">20-07-2012: <a href="http://codemirror.net/codemirror-2.31.zip">Version 2.31</a>:</p>

<ul class="rel-note">
<li>New modes: <a href="../mode/ocaml/index.html">OCaml</a>, <a href="../mode/haxe/index.html">Haxe</a>, and <a href="../mode/vb/index.html">VB.NET</a>.</li>
<li>Several fixes to the new scrolling model.</li>
<li>Add a <a href="manual.html#setSize"><code>setSize</code></a> method for programmatic resizing.</li>
<li>Add <a href="manual.html#getHistory"><code>getHistory</code></a> and <a href="manual.html#setHistory"><code>setHistory</code></a> methods.</li>
<li>Allow custom line separator string in <a href="manual.html#getValue"><code>getValue</code></a> and <a href="manual.html#getRange"><code>getRange</code></a>.</li>
<li>Support double- and triple-click drag, double-clicking whitespace.</li>
<li>And more... <a href="https://github.com/marijnh/CodeMirror/compare/v2.3...v2.31">(all patches)</a></li>
</ul>

<p class="rel">22-06-2012: <a href="http://codemirror.net/codemirror-2.3.zip">Version 2.3</a>:</p>

<ul class="rel-note">
<li><strong>New scrollbar implementation</strong>. Should flicker less. Changes DOM structure of the editor.</li>
<li>New theme: <a href="../demo/theme.html?vibrant-ink">vibrant-ink</a>.</li>
<li>Many extensions to the VIM keymap (including text objects).</li>
<li>Add <a href="../demo/multiplex.html">mode-multiplexing</a> utility script.</li>
<li>Fix bug where right-click paste works in read-only mode.</li>
<li>Add a <a href="manual.html#getScrollInfo"><code>getScrollInfo</code></a> method.</li>
<li>Lots of other <a href="https://github.com/marijnh/CodeMirror/compare/v2.25...v2.3">fixes</a>.</li>
</ul>

<p class="rel">23-05-2012: <a href="http://codemirror.net/codemirror-2.25.zip">Version 2.25</a>:</p>

<ul class="rel-note">
<li>New mode: <a href="../mode/erlang/index.html">Erlang</a>.</li>
<li><strong>Remove xmlpure mode</strong> (use <a href="../mode/xml/index.html">xml.js</a>).</li>
<li>Fix line-wrapping in Opera.</li>
<li>Fix X Windows middle-click paste in Chrome.</li>
<li>Fix bug that broke pasting of huge documents.</li>
<li>Fix backspace and tab key repeat in Opera.</li>
</ul>

<p class="rel">23-04-2012: <a href="http://codemirror.net/codemirror-2.24.zip">Version 2.24</a>:</p>

<ul class="rel-note">
Expand Down Expand Up @@ -68,8 +109,8 @@ <h1><span class="logo-braces">{ }</span> <a href="http://codemirror.net/">CodeMi
<li>Add <a href="manual.html#option_autoClearEmptyLines"><code>autoClearEmptyLines</code></a> option.</li>
<li>Properly use tab stops when rendering tabs.</li>
<li>Make PHP mode more robust.</li>
<li>Support indentation blocks in <a href="manual.html#util_foldcode">code folder</a>.</li>
<li>Add a script for <a href="manual.html#util_match-highlighter">highlighting instances of the selection</a>.</li>
<li>Support indentation blocks in <a href="manual.html#addon_foldcode">code folder</a>.</li>
<li>Add a script for <a href="manual.html#addon_match-highlighter">highlighting instances of the selection</a>.</li>
<li>New <a href="../mode/properties/index.html">.properties</a> mode.</li>
<li>Fix many bugs.</li>
</ul>
Expand Down Expand Up @@ -125,7 +166,7 @@ <h1><span class="logo-braces">{ }</span> <a href="http://codemirror.net/">CodeMi
and <a href="../theme/rubyblue.css">Rubyblue</a> themes.</li>
<li>Add <a href="manual.html#setBookmark"><code>setBookmark</code></a> method.</li>
<li>Move some of the demo code into reusable components
under <a href="../lib/util/"><code>lib/util</code></a>.</li>
under <a href="../addon/"><code>lib/util</code></a>.</li>
<li>Make screen-coord-finding code faster and more reliable.</li>
<li>Fix drag-and-drop in Firefox.</li>
<li>Improve support for IME.</li>
Expand Down
8 changes: 8 additions & 0 deletions doc/realworld.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@ <h1><span class="logo-braces">{ }</span> <a href="http://codemirror.net/">CodeMi

<ul>
<li><a href="http://brackets.io">Adobe Brackets</a> (code editor)</li>
<li><a href="http://amber-lang.net/">Amber</a> (JavaScript-based Smalltalk system)</li>
<li><a href="http://bluegriffon.org/">BlueGriffon</a> (HTML editor)</li>
<li><a href="http://cargocollective.com/">Cargo Collective</a> (creative publishing platform)</li>
<li><a href="http://www.codebugapp.com/">Codebug</a> (PHP Xdebug front-end)</li>
<li><a href="http://code.google.com/p/codemirror2-gwt/">CodeMirror2-GWT</a> (Google Web Toolkit wrapper)</li>
<li><a href="http://codepen.io">Codepen</a> (gallery of animations)</li>
<li><a href="http://sasstwo.codeschool.com/levels/1/challenges/1">Code School</a> (online tech learning environment)</li>
<li><a href="http://codev.it/">Codev</a> (collaborative IDE)</li>
<li><a href="http://ot.substance.io/demo/">Collaborative CodeMirror demo</a> (CodeMirror + operational transforms)</li>
<li><a href="http://www.ckwnc.com/">CKWNC</a> (UML editor)</li>
Expand Down Expand Up @@ -55,6 +57,8 @@ <h1><span class="logo-braces">{ }</span> <a href="http://codemirror.net/">CodeMi
<li><a href="http://kl1p.com/cmtest/1">kl1p</a> (paste service)</li>
<li><a href="http://www.chris-granger.com/2012/04/12/light-table---a-new-ide-concept/">Light Table</a> (experimental IDE)</li>
<li><a href="http://www.mergely.com/">Mergely</a> (interactive diffing)</li>
<li><a href="http://www.iunbug.com/mihtool">MIHTool</a> (iOS web-app debugging tool)</li>
<li><a href="https://www.my2ndgeneration.com/">My2ndGeneration</a> (social coding)</li>
<li><a href="https://notex.ch">NoTex</a> (rST authoring)</li>
<li><a href="http://clrhome.org/asm/">ORG</a> (z80 assembly IDE)</li>
<li><a href="https://github.com/mamacdon/orion-codemirror">Orion-CodeMirror integration</a> (running CodeMirror modes in Orion)</li>
Expand All @@ -63,12 +67,16 @@ <h1><span class="logo-braces">{ }</span> <a href="http://codemirror.net/">CodeMi
<li><a href="http://ql.io/">ql.io</a> (http API query helper)</li>
<li><a href="http://qyapp.com">QiYun web app platform</a></li>
<li><a href="http://ariya.ofilabs.com/2011/09/hybrid-webnative-desktop-codemirror.html">Qt+Webkit integration</a> (building a desktop CodeMirror app)</li>
<li><a href="http://rascalmicro.com/docs/basic-tutorial-getting-started.html">Rascal</a> (tiny computer)</li>
<li><a href="https://www.realtime.io/">RealTime.io</a> (Internet-of-Things infrastructure)</li>
<li><a href="http://www.sketchpatch.net/labs/livecodelabIntro.html">sketchPatch Livecodelab</a></li>
<li><a href="http://www.skulpt.org/">Skulpt</a> (in-browser Python environment)</li>
<li><a href="http://www.solidshops.com/">SolidShops</a> (hosted e-commerce platform)</li>
<li><a href="http://sqlfiddle.com">SQLFiddle</a> (SQL playground)</li>
<li><a href="https://thefiletree.com">The File Tree</a> (collab editor)</li>
<li><a href="http://www.toolsverse.com/products/data-explorer/">Toolsverse Data Explorer</a> (database management)</li>
<li><a href="http://enjalot.com/tributary/2636296/sinwaves.js">Tributary</a> (augmented editing)</li>
<li><a href="http://blog.englard.net/post/39608000629/codeintumblr">Tumblr code highlighting shim</a></li>
<li><a href="http://turbopy.com/">TurboPY</a> (web publishing framework)</li>
<li><a href="http://webglplayground.net/">WebGL playground</a></li>
<li><a href="http://www.wescheme.org/">WeScheme</a> (learning tool)</li>
Expand Down
8 changes: 4 additions & 4 deletions doc/upgrade_v3.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
<link rel="stylesheet" type="text/css" href="docs.css"/>
<script src="../lib/codemirror.js"></script>
<link rel="stylesheet" href="../lib/codemirror.css">
<script src="../lib/util/runmode.js"></script>
<script src="../lib/util/colorize.js"></script>
<script src="../addon/runmode/runmode.js"></script>
<script src="../addon/runmode/colorize.js"></script>
<script src="../mode/javascript/javascript.js"></script>
<script src="../mode/xml/xml.js"></script>
<script src="../mode/css/css.js"></script>
Expand Down Expand Up @@ -174,9 +174,9 @@ <h2 id=positions>Position properties</h2>

<h2 id=matchbrackets>Bracket matching no longer in core</h2>

<p>The <a href="manual.html#util_matchbrackets"><code>matchBrackets</code></a>
<p>The <a href="manual.html#addon_matchbrackets"><code>matchBrackets</code></a>
option is no longer defined in the core editor.
Load <code>lib/util/matchbrackets.js</code> to enable it.</p>
Load <code>addon/edit/matchbrackets.js</code> to enable it.</p>

<h2 id=modes>Mode management</h2>

Expand Down
97 changes: 41 additions & 56 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,55 +40,49 @@ <h2 style="margin-top: 0">Supported modes:</h2>
<li><a href="mode/coffeescript/index.html">CoffeeScript</a></li>
<li><a href="mode/commonlisp/index.html">Common Lisp</a></li>
<li><a href="mode/css/index.html">CSS</a></li>
<li><a href="mode/d/index.html">D</a></li>
<li><a href="mode/diff/index.html">diff</a></li>
<li><a href="mode/ecl/index.html">ECL</a></li>
<li><a href="mode/erlang/index.html">Erlang</a></li>
<li><a href="mode/go/index.html">Go</a></li>
<li><a href="mode/groovy/index.html">Groovy</a></li>
<li><a href="mode/haskell/index.html">Haskell</a></li>
<li><a href="mode/haxe/index.html">Haxe</a></li>
<li><a href="mode/htmlembedded/index.html">HTML embedded scripts</a></li>
<li><a href="mode/htmlmixed/index.html">HTML mixed-mode</a></li>
<li><a href="mode/http/index.html">HTTP</a></li>
<li><a href="mode/clike/index.html">Java</a></li>
<li><a href="mode/javascript/index.html">JavaScript</a></li>
<li><a href="mode/jinja2/index.html">Jinja2</a></li>
<li><a href="mode/less/index.html">LESS</a></li>
<li><a href="mode/lua/index.html">Lua</a></li>
<li><a href="mode/markdown/index.html">Markdown</a> (<a href="mode/gfm/index.html">GitHub-flavour</a>)</li>
<li><a href="mode/mysql/index.html">MySQL</a></li>
<li><a href="mode/ntriples/index.html">NTriples</a></li>
<li><a href="mode/ocaml/index.html">OCaml</a></li>
<li><a href="mode/pascal/index.html">Pascal</a></li>
<li><a href="mode/perl/index.html">Perl</a></li>
<li><a href="mode/php/index.html">PHP</a></li>
<li><a href="mode/pig/index.html">Pig Latin</a></li>
<li><a href="mode/plsql/index.html">PL/SQL</a></li>
<li><a href="mode/properties/index.html">Properties files</a></li>
<li><a href="mode/python/index.html">Python</a></li>
<li><a href="mode/r/index.html">R</a></li>
<li>RPM <a href="mode/rpm/spec/index.html">spec</a> and <a href="mode/rpm/changes/index.html">changelog</a></li>
<li><a href="mode/rst/index.html">reStructuredText</a></li>
<li><a href="mode/ruby/index.html">Ruby</a></li>
<li><a href="mode/rust/index.html">Rust</a></li>
<li><a href="mode/sass/index.html">Sass</a></li>
<li><a href="mode/clike/scala.html">Scala</a></li>
<li><a href="mode/scheme/index.html">Scheme</a></li>
<li><a href="mode/shell/index.html">Shell</a></li>
<li><a href="mode/sieve/index.html">Sieve</a></li>
<li><a href="mode/smalltalk/index.html">Smalltalk</a></li>
<li><a href="mode/smarty/index.html">Smarty</a></li>
<li><a href="mode/sql/index.html">SQL</a> (several dialects)</li>
<li><a href="mode/sparql/index.html">SPARQL</a></li>
<li><a href="mode/stex/index.html">sTeX, LaTeX</a></li>
<li><a href="mode/tiddlywiki/index.html">Tiddlywiki</a></li>
<li><a href="mode/tiki/index.html">Tiki wiki</a></li>
<li><a href="mode/vb/index.html">VB.NET</a></li>
<li><a href="mode/vbscript/index.html">VBScript</a></li>
<li><a href="mode/velocity/index.html">Velocity</a></li>
<li><a href="mode/verilog/index.html">Verilog</a></li>
<li><a href="mode/xml/index.html">XML/HTML</a></li>
<li><a href="mode/xquery/index.html">XQuery</a></li>
<li><a href="mode/yaml/index.html">YAML</a></li>
<li><a href="mode/z80/index.html">Z80</a></li>
<li><a href="doc/modes.html">Full list...</a></li>
</ul>

</div><div class="left2 blk">
Expand Down Expand Up @@ -133,17 +127,14 @@ <h2>Real-world uses:</h2>
<li><a href="http://eloquentjavascript.net/chapter1.html">Eloquent JavaScript</a> (book)</li>
<li><a href="http://media.chikuyonok.ru/codemirror2/">Zen Coding</a> (fast XML editing)</li>
<li><a href="http://paperjs.org/">Paper.js</a> (graphics scripting)</li>
<li><a href="http://tour.golang.org">Go language tour</a></li>
<li><a href="http://codev.it/">Codev</a> (collaborative IDE)</li>
<li><a href="http://enjalot.com/tributary/2636296/sinwaves.js">Tributary</a> (augmented editing)</li>
<li><a href="http://prose.io/">Prose.io</a> (github content editor)</li>
<li><a href="http://www.wescheme.org/">WeScheme</a> (learning tool)</li>
<li><a href="http://webglplayground.net/">WebGL playground</a></li>
<li><a href="http://ql.io/">ql.io</a> (http API query helper)</li>
<li><a href="http://elm-lang.org/Examples.elm">Elm language examples</a></li>
<li><a href="https://thefiletree.com">The File Tree</a> (collab editor)</li>
<li><a href="http://www.jshint.com/">JSHint</a> (JS linter)</li>
<li><a href="http://kl1p.com/cmtest/1">kl1p</a> (paste service)</li>
<li><a href="http://sqlfiddle.com">SQLFiddle</a> (SQL playground)</li>
<li><a href="http://try.haxe.org">Try Haxe</a> (Haxe Playground) </li>
<li><a href="http://cssdeck.com/">CSSDeck</a> (CSS showcase)</li>
Expand Down Expand Up @@ -292,7 +283,42 @@ <h2>Reading material</h2>

<h2 id=releases>Releases</h2>

<p class="rel">20-11-2012: <a href="http://codemirror.net/codemirror-3.0.zip">Version 3.0</a>:</p>
<p class="rel">21-01-2013: <a href="http://codemirror.net/codemirror-3.01.zip">Version 3.01</a>:</p>

<ul class="rel-note">
<li>Move all add-ons into an organized directory structure
under <a href="addon/"><code>/addon</code></a>. <strong>You might have to adjust your
paths.</strong></li>
<li>New
modes: <a href="mode/d/index.html">D</a>, <a href="mode/sass/index.html">Sass</a>, <a href="mode/apl/index.html">APL</a>, <a href="mode/sql/index.html">SQL</a>
(configurable), and <a href="mode/asterisk/index.html">Asterisk</a>.</li>
<li>Several bugfixes in right-to-left text support.</li>
<li>Add <a href="doc/manual.html#option_rtlMoveVisually"><code>rtlMoveVisually</code></a> option.</li>
<li>Improvements to vim keymap.</li>
<li>Add built-in (lightweight) <a href="doc/manual.html#addOverlay">overlay mode</a> support.</li>
<li>Support <code>showIfHidden</code> option for <a href="doc/manual.html#addLineWidget">line widgets</a>.</li>
<li>Add simple <a href="doc/manual.html#addon_python-hint">Python hinter</a>.</li>
<li>Bring back the <a href="doc/manual.html#option_fixedGutter"><code>fixedGutter</code></a> option.</li>
<li>Full <a href="https://github.com/marijnh/CodeMirror/compare/v3.0...v3.01">list of patches</a>.</li>
</ul>

<p class="rel">21-01-2013: <a href="http://codemirror.net/codemirror-2.38.zip">Version 2.38</a>:</p>

<p class="rel-note">Integrate some bugfixes, enhancements to the vim keymap, and new
modes
(<a href="mode/d/index.html">D</a>, <a href="mode/sass/index.html">Sass</a>, <a href="mode/apl/index.html">APL</a>)
from the v3 branch.</p>

<p class="rel">20-12-2012: <a href="http://codemirror.net/codemirror-2.37.zip">Version 2.37</a>:</p>

<ul class="rel-note">
<li>New mode: <a href="mode/sql/index.html">SQL</a> (will replace <a href="mode/plsql/index.html">plsql</a> and <a href="mode/mysql/index.html">mysql</a> modes).</li>
<li>Further work on the new VIM mode.</li>
<li>Fix Cmd/Ctrl keys on recent Operas on OS X.</li>
<li>Full <a href="https://github.com/marijnh/CodeMirror/compare/v2.36...v2.37">list of patches</a>.</li>
</ul>

<p class="rel">10-12-2012: <a href="http://codemirror.net/codemirror-3.0.zip">Version 3.0</a>:</p>

<p class="rel-note"><strong>New major version</strong>. Only
partially backwards-compatible. See
Expand Down Expand Up @@ -329,7 +355,7 @@ <h2 id=releases>Releases</h2>
<li>Add <a href="doc/manual.html#defaultTextHeight"><code>defaultTextHeight</code></a> method.</li>
<li>Various extensions to the vim keymap.</li>
<li>Make <a href="mode/php/index.html">PHP mode</a> build on <a href="mode/htmlmixed/index.html">mixed HTML mode</a>.</li>
<li>Add <a href="doc/manual.html#util_continuecomment">comment-continuing</a> add-on.</li>
<li>Add <a href="doc/manual.html#addon_continuecomment">comment-continuing</a> add-on.</li>
<li>Full <a href="https://github.com/marijnh/CodeMirror/compare/v2.35...v2.36">list of patches</a>.</li>
</ul>

Expand Down Expand Up @@ -414,47 +440,6 @@ <h2 id=releases>Releases</h2>
<li><a href="https://github.com/marijnh/CodeMirror/compare/v2.32...v2.33">Full list</a> of patches.</li>
</ul>

<p class="rel">23-07-2012: <a href="http://codemirror.net/codemirror-2.32.zip">Version 2.32</a>:</p>

<p class="rel-note">Emergency fix for a bug where an editor with
line wrapping on IE will break when there is <em>no</em>
scrollbar.</p>

<p class="rel">20-07-2012: <a href="http://codemirror.net/codemirror-2.31.zip">Version 2.31</a>:</p>

<ul class="rel-note">
<li>New modes: <a href="mode/ocaml/index.html">OCaml</a>, <a href="mode/haxe/index.html">Haxe</a>, and <a href="mode/vb/index.html">VB.NET</a>.</li>
<li>Several fixes to the new scrolling model.</li>
<li>Add a <a href="doc/manual.html#setSize"><code>setSize</code></a> method for programmatic resizing.</li>
<li>Add <a href="doc/manual.html#getHistory"><code>getHistory</code></a> and <a href="doc/manual.html#setHistory"><code>setHistory</code></a> methods.</li>
<li>Allow custom line separator string in <a href="doc/manual.html#getValue"><code>getValue</code></a> and <a href="doc/manual.html#getRange"><code>getRange</code></a>.</li>
<li>Support double- and triple-click drag, double-clicking whitespace.</li>
<li>And more... <a href="https://github.com/marijnh/CodeMirror/compare/v2.3...v2.31">(all patches)</a></li>
</ul>

<p class="rel">22-06-2012: <a href="http://codemirror.net/codemirror-2.3.zip">Version 2.3</a>:</p>

<ul class="rel-note">
<li><strong>New scrollbar implementation</strong>. Should flicker less. Changes DOM structure of the editor.</li>
<li>New theme: <a href="demo/theme.html?vibrant-ink">vibrant-ink</a>.</li>
<li>Many extensions to the VIM keymap (including text objects).</li>
<li>Add <a href="demo/multiplex.html">mode-multiplexing</a> utility script.</li>
<li>Fix bug where right-click paste works in read-only mode.</li>
<li>Add a <a href="doc/manual.html#getScrollInfo"><code>getScrollInfo</code></a> method.</li>
<li>Lots of other <a href="https://github.com/marijnh/CodeMirror/compare/v2.25...v2.3">fixes</a>.</li>
</ul>

<p class="rel">23-05-2012: <a href="http://codemirror.net/codemirror-2.25.zip">Version 2.25</a>:</p>

<ul class="rel-note">
<li>New mode: <a href="mode/erlang/index.html">Erlang</a>.</li>
<li><strong>Remove xmlpure mode</strong> (use <a href="mode/xml/index.html">xml.js</a>).</li>
<li>Fix line-wrapping in Opera.</li>
<li>Fix X Windows middle-click paste in Chrome.</li>
<li>Fix bug that broke pasting of huge documents.</li>
<li>Fix backspace and tab key repeat in Opera.</li>
</ul>

<p><a href="doc/oldrelease.html">Older releases...</a></p>

</div></div>
Expand Down
345 changes: 279 additions & 66 deletions keymap/vim.js

Large diffs are not rendered by default.

19 changes: 10 additions & 9 deletions lib/codemirror.css
Original file line number Diff line number Diff line change
Expand Up @@ -39,26 +39,26 @@

/* CURSOR */

.CodeMirror pre.CodeMirror-cursor {
.CodeMirror div.CodeMirror-cursor {
border-left: 1px solid black;
}
/* Shown when moving in bi-directional text */
.CodeMirror pre.CodeMirror-secondarycursor {
.CodeMirror div.CodeMirror-secondarycursor {
border-left: 1px solid silver;
}
.cm-keymap-fat-cursor pre.CodeMirror-cursor {
.CodeMirror.cm-keymap-fat-cursor div.CodeMirror-cursor {
width: auto;
border: 0;
background: transparent;
background: rgba(0, 200, 0, .4);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#6600c800, endColorstr=#4c00c800);
}
/* Kludge to turn off filter in ie9+, which also accepts rgba */
.cm-keymap-fat-cursor pre.CodeMirror-cursor:not(#nonsense_id) {
.CodeMirror.cm-keymap-fat-cursor div.CodeMirror-cursor:not(#nonsense_id) {
filter: progid:DXImageTransform.Microsoft.gradient(enabled=false);
}
/* Can style cursor different in overwrite (non-insert) mode */
.CodeMirror pre.CodeMirror-cursor.CodeMirror-overwrite {}
.CodeMirror div.CodeMirror-cursor.CodeMirror-overwrite {}

/* DEFAULT THEME */

Expand Down Expand Up @@ -196,6 +196,7 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
.CodeMirror-linewidget {
position: relative;
z-index: 2;
overflow: auto;
}

.CodeMirror-wrap .CodeMirror-scroll {
Expand All @@ -210,20 +211,20 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
}
.CodeMirror-measure pre { position: static; }

.CodeMirror pre.CodeMirror-cursor {
.CodeMirror div.CodeMirror-cursor {
position: absolute;
visibility: hidden;
border-right: none;
width: 0;
}
.CodeMirror-focused pre.CodeMirror-cursor {
.CodeMirror-focused div.CodeMirror-cursor {
visibility: visible;
}

.CodeMirror-selected { background: #d9d9d9; }
.CodeMirror-focused .CodeMirror-selected { background: #d7d4f0; }

.CodeMirror-searching {
.cm-searching {
background: #ffa;
background: rgba(255, 255, 0, .4);
}
Expand All @@ -233,7 +234,7 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}

@media print {
/* Hide the cursor when printing */
.CodeMirror pre.CodeMirror-cursor {
.CodeMirror div.CodeMirror-cursor {
visibility: hidden;
}
}
516 changes: 369 additions & 147 deletions lib/codemirror.js

Large diffs are not rendered by default.

160 changes: 160 additions & 0 deletions mode/apl/apl.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
CodeMirror.defineMode("apl", function() {
var builtInOps = {
".": "innerProduct",
"\\": "scan",
"/": "reduce",
"⌿": "reduce1Axis",
"⍀": "scan1Axis",
"¨": "each",
"⍣": "power"
};
var builtInFuncs = {
"+": ["conjugate", "add"],
"−": ["negate", "subtract"],
"×": ["signOf", "multiply"],
"÷": ["reciprocal", "divide"],
"⌈": ["ceiling", "greaterOf"],
"⌊": ["floor", "lesserOf"],
"∣": ["absolute", "residue"],
"⍳": ["indexGenerate", "indexOf"],
"?": ["roll", "deal"],
"⋆": ["exponentiate", "toThePowerOf"],
"⍟": ["naturalLog", "logToTheBase"],
"○": ["piTimes", "circularFuncs"],
"!": ["factorial", "binomial"],
"⌹": ["matrixInverse", "matrixDivide"],
"<": [null, "lessThan"],
"≤": [null, "lessThanOrEqual"],
"=": [null, "equals"],
">": [null, "greaterThan"],
"≥": [null, "greaterThanOrEqual"],
"≠": [null, "notEqual"],
"≡": ["depth", "match"],
"≢": [null, "notMatch"],
"∈": ["enlist", "membership"],
"⍷": [null, "find"],
"∪": ["unique", "union"],
"∩": [null, "intersection"],
"∼": ["not", "without"],
"∨": [null, "or"],
"∧": [null, "and"],
"⍱": [null, "nor"],
"⍲": [null, "nand"],
"⍴": ["shapeOf", "reshape"],
",": ["ravel", "catenate"],
"⍪": [null, "firstAxisCatenate"],
"⌽": ["reverse", "rotate"],
"⊖": ["axis1Reverse", "axis1Rotate"],
"⍉": ["transpose", null],
"↑": ["first", "take"],
"↓": [null, "drop"],
"⊂": ["enclose", "partitionWithAxis"],
"⊃": ["diclose", "pick"],
"⌷": [null, "index"],
"⍋": ["gradeUp", null],
"⍒": ["gradeDown", null],
"⊤": ["encode", null],
"⊥": ["decode", null],
"⍕": ["format", "formatByExample"],
"⍎": ["execute", null],
"⊣": ["stop", "left"],
"⊢": ["pass", "right"]
};

var isOperator = /[\.\/¨]/;
var isNiladic = //;
var isFunction = /[\+×÷\?!<=>,]/;
var isArrow = //;
var isComment = /[#].*$/;

var stringEater = function(type) {
var prev;
prev = false;
return function(c) {
prev = c;
if (c === type) {
return prev === "\\";
}
return true;
};
};
return {
startState: function() {
return {
prev: false,
func: false,
op: false,
string: false,
escape: false
};
},
token: function(stream, state) {
var ch, funcName, word;
if (stream.eatSpace()) {
return null;
}
ch = stream.next();
if (ch === '"' || ch === "'") {
stream.eatWhile(stringEater(ch));
stream.next();
state.prev = true;
return "string";
}
if (/[\[{\(]/.test(ch)) {
state.prev = false;
return null;
}
if (/[\]}\)]/.test(ch)) {
state.prev = true;
return null;
}
if (isNiladic.test(ch)) {
state.prev = false;
return "niladic";
}
if (/[¯\d]/.test(ch)) {
if (state.func) {
state.func = false;
state.prev = false;
} else {
state.prev = true;
}
stream.eatWhile(/[\w\.]/);
return "number";
}
if (isOperator.test(ch)) {
return "operator apl-" + builtInOps[ch];
}
if (isArrow.test(ch)) {
return "apl-arrow";
}
if (isFunction.test(ch)) {
funcName = "apl-";
if (builtInFuncs[ch] != null) {
if (state.prev) {
funcName += builtInFuncs[ch][1];
} else {
funcName += builtInFuncs[ch][0];
}
}
state.func = true;
state.prev = false;
return "function " + funcName;
}
if (isComment.test(ch)) {
stream.skipToEnd();
return "comment";
}
if (ch === "∘" && stream.peek() === ".") {
stream.next();
return "function jot-dot";
}
stream.eatWhile(/[\w\$_]/);
word = stream.current();
state.prev = true;
return "keyword";
}
};
});

CodeMirror.defineMIME("text/apl", "apl");
61 changes: 61 additions & 0 deletions mode/apl/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>CodeMirror: APL mode</title>
<link rel="stylesheet" href="../../doc/docs.css">
<link rel="stylesheet" href="../../lib/codemirror.css">
<script src="../../lib/codemirror.js"></script>
<script src="../../addon/edit/matchbrackets.js"></script>
<script src="./apl.js"></script>
<style>
.CodeMirror { border: 2px inset #dee; }
</style>
</head>
<body>
<h1>CodeMirror: APL mode</h1>

<form><textarea id="code" name="code">
⍝ Conway's game of life

⍝ This example was inspired by the impressive demo at
⍝ http://www.youtube.com/watch?v=a9xAKttWgP4

⍝ Create a matrix:
⍝ 0 1 1
⍝ 1 1 0
⍝ 0 1 0
creature ← (3 3 ⍴ ⍳ 9) ∈ 1 2 3 4 7 ⍝ Original creature from demo
creature ← (3 3 ⍴ ⍳ 9) ∈ 1 3 6 7 8 ⍝ Glider

⍝ Place the creature on a larger board, near the centre
board ← ¯1 ⊖ ¯2 ⌽ 5 7 ↑ creature

⍝ A function to move from one generation to the next
life ← {∨/ 1 ⍵ ∧ 3 4 = ⊂+/ +⌿ 1 0 ¯1 ∘.⊖ 1 0 ¯1 ⌽¨ ⊂⍵}

⍝ Compute n-th generation and format it as a
⍝ character matrix
gen ← {' #'[(life ⍣ ⍵) board]}

⍝ Show first three generations
(gen 1) (gen 2) (gen 3)
</textarea></form>

<script>
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
lineNumbers: true,
matchBrackets: true,
mode: "text/apl"
});
</script>

<p>Simple mode that tries to handle APL as well as it can.</p>
<p>It attempts to label functions/operators based upon
monadic/dyadic usage (but this is far from fully fleshed out).
This means there are meaningful classnames so hover states can
have popups etc.</p>

<p><strong>MIME types defined:</strong> <code>text/apl</code> (APL code)</p>
</body>
</html>
183 changes: 183 additions & 0 deletions mode/asterisk/asterisk.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
/*
* =====================================================================================
*
* Filename: mode/asterisk/asterisk.js
*
* Description: CodeMirror mode for Asterisk dialplan
*
* Created: 05/17/2012 09:20:25 PM
* Revision: none
*
* Author: Stas Kobzar (stas@modulis.ca),
* Company: Modulis.ca Inc.
*
* =====================================================================================
*/

CodeMirror.defineMode("asterisk", function() {
var atoms = ["exten", "same", "include","ignorepat","switch"],
dpcmd = ["#include","#exec"],
apps = [
"addqueuemember","adsiprog","aelsub","agentlogin","agentmonitoroutgoing","agi",
"alarmreceiver","amd","answer","authenticate","background","backgrounddetect",
"bridge","busy","callcompletioncancel","callcompletionrequest","celgenuserevent",
"changemonitor","chanisavail","channelredirect","chanspy","clearhash","confbridge",
"congestion","continuewhile","controlplayback","dahdiacceptr2call","dahdibarge",
"dahdiras","dahdiscan","dahdisendcallreroutingfacility","dahdisendkeypadfacility",
"datetime","dbdel","dbdeltree","deadagi","dial","dictate","directory","disa",
"dumpchan","eagi","echo","endwhile","exec","execif","execiftime","exitwhile","extenspy",
"externalivr","festival","flash","followme","forkcdr","getcpeid","gosub","gosubif",
"goto","gotoif","gotoiftime","hangup","iax2provision","ices","importvar","incomplete",
"ivrdemo","jabberjoin","jabberleave","jabbersend","jabbersendgroup","jabberstatus",
"jack","log","macro","macroexclusive","macroexit","macroif","mailboxexists","meetme",
"meetmeadmin","meetmechanneladmin","meetmecount","milliwatt","minivmaccmess","minivmdelete",
"minivmgreet","minivmmwi","minivmnotify","minivmrecord","mixmonitor","monitor","morsecode",
"mp3player","mset","musiconhold","nbscat","nocdr","noop","odbc","odbc","odbcfinish",
"originate","ospauth","ospfinish","osplookup","ospnext","page","park","parkandannounce",
"parkedcall","pausemonitor","pausequeuemember","pickup","pickupchan","playback","playtones",
"privacymanager","proceeding","progress","queue","queuelog","raiseexception","read","readexten",
"readfile","receivefax","receivefax","receivefax","record","removequeuemember",
"resetcdr","retrydial","return","ringing","sayalpha","saycountedadj","saycountednoun",
"saycountpl","saydigits","saynumber","sayphonetic","sayunixtime","senddtmf","sendfax",
"sendfax","sendfax","sendimage","sendtext","sendurl","set","setamaflags",
"setcallerpres","setmusiconhold","sipaddheader","sipdtmfmode","sipremoveheader","skel",
"slastation","slatrunk","sms","softhangup","speechactivategrammar","speechbackground",
"speechcreate","speechdeactivategrammar","speechdestroy","speechloadgrammar","speechprocessingsound",
"speechstart","speechunloadgrammar","stackpop","startmusiconhold","stopmixmonitor","stopmonitor",
"stopmusiconhold","stopplaytones","system","testclient","testserver","transfer","tryexec",
"trysystem","unpausemonitor","unpausequeuemember","userevent","verbose","vmauthenticate",
"vmsayname","voicemail","voicemailmain","wait","waitexten","waitfornoise","waitforring",
"waitforsilence","waitmusiconhold","waituntil","while","zapateller"
];

function basicToken(stream,state){
var cur = '';
var ch = '';
ch = stream.next();
// comment
if(ch == ";") {
stream.skipToEnd();
return "comment";
}
// context
if(ch == '[') {
stream.skipTo(']');
stream.eat(']');
return "header";
}
// string
if(ch == '"') {
stream.skipTo('"');
return "string";
}
if(ch == "'") {
stream.skipTo("'");
return "string-2";
}
// dialplan commands
if(ch == '#') {
stream.eatWhile(/\w/);
cur = stream.current();
if(dpcmd.indexOf(cur) !== -1) {
stream.skipToEnd();
return "strong";
}
}
// application args
if(ch == '$'){
var ch1 = stream.peek();
if(ch1 == '{'){
stream.skipTo('}');
stream.eat('}');
return "variable-3";
}
}
// extension
stream.eatWhile(/\w/);
cur = stream.current();
if(atoms.indexOf(cur) !== -1) {
state.extenStart = true;
switch(cur) {
case 'same': state.extenSame = true; break;
case 'include':
case 'switch':
case 'ignorepat':
state.extenInclude = true;break;
default:break;
}
return "atom";
}
}

return {
startState: function() {
return {
extenStart: false,
extenSame: false,
extenInclude: false,
extenExten: false,
extenPriority: false,
extenApplication: false
};
},
token: function(stream, state) {

var cur = '';
var ch = '';
if(stream.eatSpace()) return null;
// extension started
if(state.extenStart){
stream.eatWhile(/[^\s]/);
cur = stream.current();
if(/^=>?$/.test(cur)){
state.extenExten = true;
state.extenStart = false;
return "strong";
} else {
state.extenStart = false;
stream.skipToEnd();
return "error";
}
} else if(state.extenExten) {
// set exten and priority
state.extenExten = false;
state.extenPriority = true;
stream.eatWhile(/[^,]/);
if(state.extenInclude) {
stream.skipToEnd();
state.extenPriority = false;
state.extenInclude = false;
}
if(state.extenSame) {
state.extenPriority = false;
state.extenSame = false;
state.extenApplication = true;
}
return "tag";
} else if(state.extenPriority) {
state.extenPriority = false;
state.extenApplication = true;
ch = stream.next(); // get comma
if(state.extenSame) return null;
stream.eatWhile(/[^,]/);
return "number";
} else if(state.extenApplication) {
stream.eatWhile(/,/);
cur = stream.current();
if(cur === ',') return null;
stream.eatWhile(/\w/);
cur = stream.current().toLowerCase();
state.extenApplication = false;
if(apps.indexOf(cur) !== -1){
return "def strong";
}
} else{
return basicToken(stream,state);
}

return null;
}
};
});

CodeMirror.defineMIME("text/x-asterisk", "asterisk");
142 changes: 142 additions & 0 deletions mode/asterisk/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>CodeMirror: Asterisk dialplan mode</title>
<link rel="stylesheet" href="../../lib/codemirror.css">
<script src="../../lib/codemirror.js"></script>
<script src="asterisk.js"></script>
<style>
.CodeMirror {border: 1px solid #999;}
.cm-s-default span.cm-arrow { color: red; }
</style>
<link rel="stylesheet" href="../../doc/docs.css">
</head>
<body>
<h1>CodeMirror: Asterisk dialplan mode</h1>
<form><textarea id="code" name="code">
; extensions.conf - the Asterisk dial plan
;

[general]
;
; If static is set to no, or omitted, then the pbx_config will rewrite
; this file when extensions are modified. Remember that all comments
; made in the file will be lost when that happens.
static=yes

#include "/etc/asterisk/additional_general.conf

[iaxprovider]
switch => IAX2/user:[key]@myserver/mycontext

[dynamic]
#exec /usr/bin/dynamic-peers.pl

[trunkint]
;
; International long distance through trunk
;
exten => _9011.,1,Macro(dundi-e164,${EXTEN:4})
exten => _9011.,n,Dial(${GLOBAL(TRUNK)}/${FILTER(0-9,${EXTEN:${GLOBAL(TRUNKMSD)}})})

[local]
;
; Master context for local, toll-free, and iaxtel calls only
;
ignorepat => 9
include => default

[demo]
include => stdexten
;
; We start with what to do when a call first comes in.
;
exten => s,1,Wait(1) ; Wait a second, just for fun
same => n,Answer ; Answer the line
same => n,Set(TIMEOUT(digit)=5) ; Set Digit Timeout to 5 seconds
same => n,Set(TIMEOUT(response)=10) ; Set Response Timeout to 10 seconds
same => n(restart),BackGround(demo-congrats) ; Play a congratulatory message
same => n(instruct),BackGround(demo-instruct) ; Play some instructions
same => n,WaitExten ; Wait for an extension to be dialed.

exten => 2,1,BackGround(demo-moreinfo) ; Give some more information.
exten => 2,n,Goto(s,instruct)

exten => 3,1,Set(LANGUAGE()=fr) ; Set language to french
exten => 3,n,Goto(s,restart) ; Start with the congratulations

exten => 1000,1,Goto(default,s,1)
;
; We also create an example user, 1234, who is on the console and has
; voicemail, etc.
;
exten => 1234,1,Playback(transfer,skip) ; "Please hold while..."
; (but skip if channel is not up)
exten => 1234,n,Gosub(${EXTEN},stdexten(${GLOBAL(CONSOLE)}))
exten => 1234,n,Goto(default,s,1) ; exited Voicemail

exten => 1235,1,Voicemail(1234,u) ; Right to voicemail

exten => 1236,1,Dial(Console/dsp) ; Ring forever
exten => 1236,n,Voicemail(1234,b) ; Unless busy

;
; # for when they're done with the demo
;
exten => #,1,Playback(demo-thanks) ; "Thanks for trying the demo"
exten => #,n,Hangup ; Hang them up.

;
; A timeout and "invalid extension rule"
;
exten => t,1,Goto(#,1) ; If they take too long, give up
exten => i,1,Playback(invalid) ; "That's not valid, try again"

;
; Create an extension, 500, for dialing the
; Asterisk demo.
;
exten => 500,1,Playback(demo-abouttotry); Let them know what's going on
exten => 500,n,Dial(IAX2/guest@pbx.digium.com/s@default) ; Call the Asterisk demo
exten => 500,n,Playback(demo-nogo) ; Couldn't connect to the demo site
exten => 500,n,Goto(s,6) ; Return to the start over message.

;
; Create an extension, 600, for evaluating echo latency.
;
exten => 600,1,Playback(demo-echotest) ; Let them know what's going on
exten => 600,n,Echo ; Do the echo test
exten => 600,n,Playback(demo-echodone) ; Let them know it's over
exten => 600,n,Goto(s,6) ; Start over

;
; You can use the Macro Page to intercom a individual user
exten => 76245,1,Macro(page,SIP/Grandstream1)
; or if your peernames are the same as extensions
exten => _7XXX,1,Macro(page,SIP/${EXTEN})
;
;
; System Wide Page at extension 7999
;
exten => 7999,1,Set(TIMEOUT(absolute)=60)
exten => 7999,2,Page(Local/Grandstream1@page&Local/Xlite1@page&Local/1234@page/n,d)

; Give voicemail at extension 8500
;
exten => 8500,1,VoicemailMain
exten => 8500,n,Goto(s,6)

</textarea></form>
<script>
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
mode: "text/x-asterisk",
matchBrackets: true,
lineNumber: true
});
</script>

<p><strong>MIME types defined:</strong> <code>text/x-asterisk</code>.</p>

</body>
</html>
2 changes: 2 additions & 0 deletions mode/clike/clike.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
CodeMirror.defineMode("clike", function(config, parserConfig) {
var indentUnit = config.indentUnit,
statementIndentUnit = parserConfig.statementIndentUnit || indentUnit,
dontAlignCalls = parserConfig.dontAlignCalls,
keywords = parserConfig.keywords || {},
builtin = parserConfig.builtin || {},
blockKeywords = parserConfig.blockKeywords || {},
Expand Down Expand Up @@ -149,6 +150,7 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
if (ctx.type == "statement" && firstChar == "}") ctx = ctx.prev;
var closing = firstChar == ctx.type;
if (ctx.type == "statement") return ctx.indented + (firstChar == "{" ? 0 : statementIndentUnit);
else if (dontAlignCalls && ctx.type == ")" && !closing) return ctx.indented + statementIndentUnit;
else if (ctx.align) return ctx.column + (closing ? 0 : 1);
else return ctx.indented + (closing ? 0 : indentUnit);
},
Expand Down
2 changes: 1 addition & 1 deletion mode/clike/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<title>CodeMirror: C-like mode</title>
<link rel="stylesheet" href="../../lib/codemirror.css">
<script src="../../lib/codemirror.js"></script>
<script src="../../lib/util/matchbrackets.js"></script>
<script src="../../addon/edit/matchbrackets.js"></script>
<script src="clike.js"></script>
<link rel="stylesheet" href="../../doc/docs.css">
<style>.CodeMirror {border: 2px inset #dee;}</style>
Expand Down
2 changes: 1 addition & 1 deletion mode/clike/scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<link rel="stylesheet" href="../../lib/codemirror.css">
<link rel="stylesheet" href="../../theme/ambiance.css">
<script src="../../lib/codemirror.js"></script>
<script src="../../lib/util/matchbrackets.js"></script>
<script src="../../addon/edit/matchbrackets.js"></script>
<script src="clike.js"></script>
<link rel="stylesheet" href="../../doc/docs.css">
<style>
Expand Down
6 changes: 3 additions & 3 deletions mode/clojure/clojure.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ CodeMirror.defineMode("clojure", function () {
returnType = COMMENT;
} else if (isNumber(ch,stream)){
returnType = NUMBER;
} else if (ch == "(" || ch == "[") {
} else if (ch == "(" || ch == "[" || ch == "{" ) {
var keyWord = '', indentTemp = stream.column(), letter;
/**
Either
Expand Down Expand Up @@ -172,9 +172,9 @@ CodeMirror.defineMode("clojure", function () {
stream.backUp(stream.current().length - 1); // undo all the eating

returnType = BRACKET;
} else if (ch == ")" || ch == "]") {
} else if (ch == ")" || ch == "]" || ch == "}") {
returnType = BRACKET;
if (state.indentStack != null && state.indentStack.type == (ch == ")" ? "(" : "[")) {
if (state.indentStack != null && state.indentStack.type == (ch == ")" ? "(" : (ch == "]" ? "[" :"{"))) {
popStack(state);
}
} else if ( ch == ":" ) {
Expand Down
4 changes: 2 additions & 2 deletions mode/css/css.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,14 +222,14 @@ CodeMirror.defineMode("css", function(config) {
stream.eatWhile(/[\w.%]/);
return ret("number", "unit");
} else if (stream.match(/^[^-]+-/)) {
return ret("meta", type);
return ret("meta", "meta");
}
}
else if (/[,+>*\/]/.test(ch)) {
return ret(null, "select-op");
}
else if (ch == "." && stream.match(/^-?[_a-z][_a-z0-9-]*/i)) {
return ret("qualifier", type);
return ret("qualifier", "qualifier");
}
else if (ch == ":") {
return ret("operator", ch);
Expand Down
547 changes: 76 additions & 471 deletions mode/css/test.js

Large diffs are not rendered by default.

205 changes: 205 additions & 0 deletions mode/d/d.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,205 @@
CodeMirror.defineMode("d", function(config, parserConfig) {
var indentUnit = config.indentUnit,
statementIndentUnit = parserConfig.statementIndentUnit || indentUnit,
keywords = parserConfig.keywords || {},
builtin = parserConfig.builtin || {},
blockKeywords = parserConfig.blockKeywords || {},
atoms = parserConfig.atoms || {},
hooks = parserConfig.hooks || {},
multiLineStrings = parserConfig.multiLineStrings;
var isOperatorChar = /[+\-*&%=<>!?|\/]/;

var curPunc;

function tokenBase(stream, state) {
var ch = stream.next();
if (hooks[ch]) {
var result = hooks[ch](stream, state);
if (result !== false) return result;
}
if (ch == '"' || ch == "'" || ch == "`") {
state.tokenize = tokenString(ch);
return state.tokenize(stream, state);
}
if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
curPunc = ch;
return null;
}
if (/\d/.test(ch)) {
stream.eatWhile(/[\w\.]/);
return "number";
}
if (ch == "/") {
if (stream.eat("+")) {
state.tokenize = tokenComment;
return tokenNestedComment(stream, state);
}
if (stream.eat("*")) {
state.tokenize = tokenComment;
return tokenComment(stream, state);
}
if (stream.eat("/")) {
stream.skipToEnd();
return "comment";
}
}
if (isOperatorChar.test(ch)) {
stream.eatWhile(isOperatorChar);
return "operator";
}
stream.eatWhile(/[\w\$_]/);
var cur = stream.current();
if (keywords.propertyIsEnumerable(cur)) {
if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
return "keyword";
}
if (builtin.propertyIsEnumerable(cur)) {
if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
return "builtin";
}
if (atoms.propertyIsEnumerable(cur)) return "atom";
return "variable";
}

function tokenString(quote) {
return function(stream, state) {
var escaped = false, next, end = false;
while ((next = stream.next()) != null) {
if (next == quote && !escaped) {end = true; break;}
escaped = !escaped && next == "\\";
}
if (end || !(escaped || multiLineStrings))
state.tokenize = null;
return "string";
};
}

function tokenComment(stream, state) {
var maybeEnd = false, ch;
while (ch = stream.next()) {
if (ch == "/" && maybeEnd) {
state.tokenize = null;
break;
}
maybeEnd = (ch == "*");
}
return "comment";
}

function tokenNestedComment(stream, state) {
var maybeEnd = false, ch;
while (ch = stream.next()) {
if (ch == "/" && maybeEnd) {
state.tokenize = null;
break;
}
maybeEnd = (ch == "+");
}
return "comment";
}

function Context(indented, column, type, align, prev) {
this.indented = indented;
this.column = column;
this.type = type;
this.align = align;
this.prev = prev;
}
function pushContext(state, col, type) {
var indent = state.indented;
if (state.context && state.context.type == "statement")
indent = state.context.indented;
return state.context = new Context(indent, col, type, null, state.context);
}
function popContext(state) {
var t = state.context.type;
if (t == ")" || t == "]" || t == "}")
state.indented = state.context.indented;
return state.context = state.context.prev;
}

// Interface

return {
startState: function(basecolumn) {
return {
tokenize: null,
context: new Context((basecolumn || 0) - indentUnit, 0, "top", false),
indented: 0,
startOfLine: true
};
},

token: function(stream, state) {
var ctx = state.context;
if (stream.sol()) {
if (ctx.align == null) ctx.align = false;
state.indented = stream.indentation();
state.startOfLine = true;
}
if (stream.eatSpace()) return null;
curPunc = null;
var style = (state.tokenize || tokenBase)(stream, state);
if (style == "comment" || style == "meta") return style;
if (ctx.align == null) ctx.align = true;

if ((curPunc == ";" || curPunc == ":" || curPunc == ",") && ctx.type == "statement") popContext(state);
else if (curPunc == "{") pushContext(state, stream.column(), "}");
else if (curPunc == "[") pushContext(state, stream.column(), "]");
else if (curPunc == "(") pushContext(state, stream.column(), ")");
else if (curPunc == "}") {
while (ctx.type == "statement") ctx = popContext(state);
if (ctx.type == "}") ctx = popContext(state);
while (ctx.type == "statement") ctx = popContext(state);
}
else if (curPunc == ctx.type) popContext(state);
else if (((ctx.type == "}" || ctx.type == "top") && curPunc != ';') || (ctx.type == "statement" && curPunc == "newstatement"))
pushContext(state, stream.column(), "statement");
state.startOfLine = false;
return style;
},

indent: function(state, textAfter) {
if (state.tokenize != tokenBase && state.tokenize != null) return CodeMirror.Pass;
var ctx = state.context, firstChar = textAfter && textAfter.charAt(0);
if (ctx.type == "statement" && firstChar == "}") ctx = ctx.prev;
var closing = firstChar == ctx.type;
if (ctx.type == "statement") return ctx.indented + (firstChar == "{" ? 0 : statementIndentUnit);
else if (ctx.align) return ctx.column + (closing ? 0 : 1);
else return ctx.indented + (closing ? 0 : indentUnit);
},

electricChars: "{}"
};
});

(function() {
function words(str) {
var obj = {}, words = str.split(" ");
for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
return obj;
}

var blockKeywords = "body catch class do else enum for foreach foreach_reverse if in interface mixin " +
"out scope struct switch try union unittest version while with";

CodeMirror.defineMIME("text/x-d", {
name: "d",
keywords: words("abstract alias align asm assert auto break case cast cdouble cent cfloat const continue " +
"debug default delegate delete deprecated export extern final finally function goto immutable " +
"import inout invariant is lazy macro module new nothrow override package pragma private " +
"protected public pure ref return shared short static super synchronized template this " +
"throw typedef typeid typeof volatile __FILE__ __LINE__ __gshared __traits __vector __parameters " +
blockKeywords),
blockKeywords: words(blockKeywords),
builtin: words("bool byte char creal dchar double float idouble ifloat int ireal long real short ubyte " +
"ucent uint ulong ushort wchar wstring void size_t sizediff_t"),
atoms: words("exit failure success true false null"),
hooks: {
"@": function(stream, _state) {
stream.eatWhile(/[\w\$_]/);
return "meta";
}
}
});
}());
262 changes: 262 additions & 0 deletions mode/d/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,262 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>CodeMirror: D mode</title>
<link rel="stylesheet" href="../../lib/codemirror.css">
<script src="../../lib/codemirror.js"></script>
<script src="../../addon/edit/matchbrackets.js"></script>
<script src="d.js"></script>
<link rel="stylesheet" href="../../doc/docs.css">
<style>.CodeMirror {border: 2px inset #dee;}</style>
</head>
<body>
<h1>CodeMirror: D mode</h1>

<form><textarea id="code" name="code">
/* D demo code // copied from phobos/sd/metastrings.d */
// Written in the D programming language.

/**
Templates with which to do compile-time manipulation of strings.

Macros:
WIKI = Phobos/StdMetastrings

Copyright: Copyright Digital Mars 2007 - 2009.
License: <a href="http://www.boost.org/LICENSE_1_0.txt">Boost License 1.0</a>.
Authors: $(WEB digitalmars.com, Walter Bright),
Don Clugston
Source: $(PHOBOSSRC std/_metastrings.d)
*/
/*
Copyright Digital Mars 2007 - 2009.
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt)
*/
module std.metastrings;

/**
Formats constants into a string at compile time. Analogous to $(XREF
string,format).

Parameters:

A = tuple of constants, which can be strings, characters, or integral
values.

Formats:
* The formats supported are %s for strings, and %%
* for the % character.
Example:
---
import std.metastrings;
import std.stdio;

void main()
{
string s = Format!("Arg %s = %s", "foo", 27);
writefln(s); // "Arg foo = 27"
}
* ---
*/

template Format(A...)
{
static if (A.length == 0)
enum Format = "";
else static if (is(typeof(A[0]) : const(char)[]))
enum Format = FormatString!(A[0], A[1..$]);
else
enum Format = toStringNow!(A[0]) ~ Format!(A[1..$]);
}

template FormatString(const(char)[] F, A...)
{
static if (F.length == 0)
enum FormatString = Format!(A);
else static if (F.length == 1)
enum FormatString = F[0] ~ Format!(A);
else static if (F[0..2] == "%s")
enum FormatString
= toStringNow!(A[0]) ~ FormatString!(F[2..$],A[1..$]);
else static if (F[0..2] == "%%")
enum FormatString = "%" ~ FormatString!(F[2..$],A);
else
{
static assert(F[0] != '%', "unrecognized format %" ~ F[1]);
enum FormatString = F[0] ~ FormatString!(F[1..$],A);
}
}

unittest
{
auto s = Format!("hel%slo", "world", -138, 'c', true);
assert(s == "helworldlo-138ctrue", "[" ~ s ~ "]");
}

/**
* Convert constant argument to a string.
*/

template toStringNow(ulong v)
{
static if (v < 10)
enum toStringNow = "" ~ cast(char)(v + '0');
else
enum toStringNow = toStringNow!(v / 10) ~ toStringNow!(v % 10);
}

unittest
{
static assert(toStringNow!(1uL << 62) == "4611686018427387904");
}

/// ditto
template toStringNow(long v)
{
static if (v < 0)
enum toStringNow = "-" ~ toStringNow!(cast(ulong) -v);
else
enum toStringNow = toStringNow!(cast(ulong) v);
}

unittest
{
static assert(toStringNow!(0x100000000) == "4294967296");
static assert(toStringNow!(-138L) == "-138");
}

/// ditto
template toStringNow(uint U)
{
enum toStringNow = toStringNow!(cast(ulong)U);
}

/// ditto
template toStringNow(int I)
{
enum toStringNow = toStringNow!(cast(long)I);
}

/// ditto
template toStringNow(bool B)
{
enum toStringNow = B ? "true" : "false";
}

/// ditto
template toStringNow(string S)
{
enum toStringNow = S;
}

/// ditto
template toStringNow(char C)
{
enum toStringNow = "" ~ C;
}


/********
* Parse unsigned integer literal from the start of string s.
* returns:
* .value = the integer literal as a string,
* .rest = the string following the integer literal
* Otherwise:
* .value = null,
* .rest = s
*/

template parseUinteger(const(char)[] s)
{
static if (s.length == 0)
{
enum value = "";
enum rest = "";
}
else static if (s[0] >= '0' && s[0] <= '9')
{
enum value = s[0] ~ parseUinteger!(s[1..$]).value;
enum rest = parseUinteger!(s[1..$]).rest;
}
else
{
enum value = "";
enum rest = s;
}
}

/********
Parse integer literal optionally preceded by $(D '-') from the start
of string $(D s).

Returns:
.value = the integer literal as a string,
.rest = the string following the integer literal

Otherwise:
.value = null,
.rest = s
*/

template parseInteger(const(char)[] s)
{
static if (s.length == 0)
{
enum value = "";
enum rest = "";
}
else static if (s[0] >= '0' && s[0] <= '9')
{
enum value = s[0] ~ parseUinteger!(s[1..$]).value;
enum rest = parseUinteger!(s[1..$]).rest;
}
else static if (s.length >= 2 &&
s[0] == '-' && s[1] >= '0' && s[1] <= '9')
{
enum value = s[0..2] ~ parseUinteger!(s[2..$]).value;
enum rest = parseUinteger!(s[2..$]).rest;
}
else
{
enum value = "";
enum rest = s;
}
}

unittest
{
assert(parseUinteger!("1234abc").value == "1234");
assert(parseUinteger!("1234abc").rest == "abc");
assert(parseInteger!("-1234abc").value == "-1234");
assert(parseInteger!("-1234abc").rest == "abc");
}

/**
Deprecated aliases held for backward compatibility.
*/
deprecated alias toStringNow ToString;
/// Ditto
deprecated alias parseUinteger ParseUinteger;
/// Ditto
deprecated alias parseUinteger ParseInteger;

</textarea></form>

<script>
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
lineNumbers: true,
matchBrackets: true,
indentUnit: 4,
mode: "text/x-d"
});
</script>

<p>Simple mode that handle D-Syntax (<a href="http://www.dlang.org">DLang Homepage</a>).</p>

<p><strong>MIME types defined:</strong> <code>text/x-d</code>
.</p>
</body>
</html>
2 changes: 1 addition & 1 deletion mode/erlang/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<title>CodeMirror: Erlang mode</title>
<link rel="stylesheet" href="../../lib/codemirror.css">
<script src="../../lib/codemirror.js"></script>
<script src="../../lib/util/matchbrackets.js"></script>
<script src="../../addon/edit/matchbrackets.js"></script>
<script src="erlang.js"></script>
<link rel="stylesheet" href="../../theme/erlang-dark.css">
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
Expand Down
3 changes: 2 additions & 1 deletion mode/gfm/gfm.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,10 @@ CodeMirror.defineMode("gfm", function(config) {
return "link";
}
}
if (stream.match(/^((?:[a-z][\w-]+:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»]))/i)) {
if (stream.match(/^((?:[a-z][\w-]+:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\([^\s()<>]*\))+(?:\([^\s()<>]*\)|[^\s`!()\[\]{};:'".,<>?«»]))/i)) {
// URLs
// Taken from http://daringfireball.net/2010/07/improved_regex_for_matching_urls
// And then (issue #1160) simplified to make it not crash the Chrome Regexp engine
return "link";
}
stream.next();
Expand Down
3 changes: 1 addition & 2 deletions mode/gfm/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<title>CodeMirror: GFM mode</title>
<link rel="stylesheet" href="../../lib/codemirror.css">
<script src="../../lib/codemirror.js"></script>
<script src="../../lib/util/overlay.js"></script>
<script src="../../addon/mode/overlay.js"></script>
<script src="../xml/xml.js"></script>
<script src="../markdown/markdown.js"></script>
<script src="gfm.js"></script>
Expand All @@ -16,7 +16,6 @@
<script src="../htmlmixed/htmlmixed.js"></script>
<script src="../clike/clike.js"></script>

<link rel="stylesheet" href="../markdown/markdown.css">
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
<link rel="stylesheet" href="../../doc/docs.css">
</head>
Expand Down
309 changes: 84 additions & 225 deletions mode/gfm/test.js
Original file line number Diff line number Diff line change
@@ -1,225 +1,84 @@
// Initiate ModeTest and set defaults
var MT = ModeTest;
MT.modeName = 'gfm';
MT.modeOptions = {};

// Emphasis characters within a word
MT.testMode(
'emInWordAsterisk',
'foo*bar*hello',
[
null, 'foo',
'em', '*bar*',
null, 'hello'
]
);
MT.testMode(
'emInWordUnderscore',
'foo_bar_hello',
[
null, 'foo_bar_hello'
]
);
MT.testMode(
'emStrongUnderscore',
'___foo___ bar',
[
'strong', '__',
'emstrong', '_foo__',
'em', '_',
null, ' bar'
]
);

// Fenced code blocks
MT.testMode(
'fencedCodeBlocks',
'```\nfoo\n\n```\nbar',
[
'comment', '```',
'comment', 'foo',
'comment', '```',
null, 'bar'
]
);
// Fenced code block mode switching
MT.testMode(
'fencedCodeBlockModeSwitching',
'```javascript\nfoo\n\n```\nbar',
[
'comment', '```javascript',
'variable', 'foo',
'comment', '```',
null, 'bar'
]
);

// SHA
MT.testMode(
'SHA',
'foo be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2 bar',
[
null, 'foo ',
'link', 'be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2',
null, ' bar'
]
);
// GitHub highlights hashes 7-40 chars in length
MT.testMode(
'shortSHA',
'foo be6a8cc bar',
[
null, 'foo ',
'link', 'be6a8cc',
null, ' bar'
]
);
// Invalid SHAs
//
// GitHub does not highlight hashes shorter than 7 chars
MT.testMode(
'tooShortSHA',
'foo be6a8c bar',
[
null, 'foo be6a8c bar'
]
);
// GitHub does not highlight hashes longer than 40 chars
MT.testMode(
'longSHA',
'foo be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd22 bar',
[
null, 'foo be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd22 bar'
]
);
MT.testMode(
'badSHA',
'foo be6a8cc1c1ecfe9489fb51e4869af15a13fc2cg2 bar',
[
null, 'foo be6a8cc1c1ecfe9489fb51e4869af15a13fc2cg2 bar'
]
);
// User@SHA
MT.testMode(
'userSHA',
'foo bar@be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2 hello',
[
null, 'foo ',
'link', 'bar@be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2',
null, ' hello'
]
);
// User/Project@SHA
MT.testMode(
'userProjectSHA',
'foo bar/hello@be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2 world',
[
null, 'foo ',
'link', 'bar/hello@be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2',
null, ' world'
]
);

// #Num
MT.testMode(
'num',
'foo #1 bar',
[
null, 'foo ',
'link', '#1',
null, ' bar'
]
);
// bad #Num
MT.testMode(
'badNum',
'foo #1bar hello',
[
null, 'foo #1bar hello'
]
);
// User#Num
MT.testMode(
'userNum',
'foo bar#1 hello',
[
null, 'foo ',
'link', 'bar#1',
null, ' hello'
]
);
// User/Project#Num
MT.testMode(
'userProjectNum',
'foo bar/hello#1 world',
[
null, 'foo ',
'link', 'bar/hello#1',
null, ' world'
]
);

// Vanilla links
MT.testMode(
'vanillaLink',
'foo http://www.example.com/ bar',
[
null, 'foo ',
'link', 'http://www.example.com/',
null, ' bar'
]
);
MT.testMode(
'vanillaLinkPunctuation',
'foo http://www.example.com/. bar',
[
null, 'foo ',
'link', 'http://www.example.com/',
null, '. bar'
]
);
MT.testMode(
'vanillaLinkExtension',
'foo http://www.example.com/index.html bar',
[
null, 'foo ',
'link', 'http://www.example.com/index.html',
null, ' bar'
]
);
// Not a link
MT.testMode(
'notALink',
'```css\nfoo {color:black;}\n```http://www.example.com/',
[
'comment', '```css',
'tag', 'foo',
null, ' {',
'property', 'color',
'operator', ':',
'keyword', 'black',
null, ';}',
'comment', '```',
'link', 'http://www.example.com/'
]
);
// Not a link
MT.testMode(
'notALink',
'``foo `bar` http://www.example.com/`` hello',
[
'comment', '``foo `bar` http://www.example.com/``',
null, ' hello'
]
);
// Not a link
MT.testMode(
'notALink',
'`foo\nhttp://www.example.com/\n`foo\n\nhttp://www.example.com/',
[
'comment', '`foo',
'link', 'http://www.example.com/',
'comment', '`foo',
'link', 'http://www.example.com/'
]
);
(function() {
var mode = CodeMirror.getMode({tabSize: 4}, "gfm");
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }

MT("emInWordAsterisk",
"foo[em *bar*]hello");

MT("emInWordUnderscore",
"foo_bar_hello");

MT("emStrongUnderscore",
"[strong __][emstrong _foo__][em _] bar");

MT("fencedCodeBlocks",
"[comment ```]",
"[comment foo]",
"",
"[comment ```]",
"bar");

MT("fencedCodeBlockModeSwitching",
"[comment ```javascript]",
"[variable foo]",
"",
"[comment ```]",
"bar");

MT("SHA",
"foo [link be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2] bar");

MT("shortSHA",
"foo [link be6a8cc] bar");

MT("tooShortSHA",
"foo be6a8c bar");

MT("longSHA",
"foo be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd22 bar");

MT("badSHA",
"foo be6a8cc1c1ecfe9489fb51e4869af15a13fc2cg2 bar");

MT("userSHA",
"foo [link bar@be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2] hello");

MT("userProjectSHA",
"foo [link bar/hello@be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2] world");

MT("num",
"foo [link #1] bar");

MT("badNum",
"foo #1bar hello");

MT("userNum",
"foo [link bar#1] hello");

MT("userProjectNum",
"foo [link bar/hello#1] world");

MT("vanillaLink",
"foo [link http://www.example.com/] bar");

MT("vanillaLinkPunctuation",
"foo [link http://www.example.com/]. bar");

MT("vanillaLinkExtension",
"foo [link http://www.example.com/index.html] bar");

MT("notALink",
"[comment ```css]",
"[tag foo] {[property color][operator :][keyword black];}",
"[comment ```][link http://www.example.com/]");

MT("notALink",
"[comment ``foo `bar` http://www.example.com/``] hello");

MT("notALink",
"[comment `foo]",
"[link http://www.example.com/]",
"[comment `foo]",
"",
"[link http://www.example.com/]");
})();
2 changes: 1 addition & 1 deletion mode/go/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<link rel="stylesheet" href="../../lib/codemirror.css">
<link rel="stylesheet" href="../../theme/elegant.css">
<script src="../../lib/codemirror.js"></script>
<script src="../../lib/util/matchbrackets.js"></script>
<script src="../../addon/edit/matchbrackets.js"></script>
<script src="go.js"></script>
<link rel="stylesheet" href="../../doc/docs.css">
<style>.CodeMirror {border:1px solid #999; background:#ffc}</style>
Expand Down
2 changes: 1 addition & 1 deletion mode/groovy/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<title>CodeMirror: Groovy mode</title>
<link rel="stylesheet" href="../../lib/codemirror.css">
<script src="../../lib/codemirror.js"></script>
<script src="../../lib/util/matchbrackets.js"></script>
<script src="../../addon/edit/matchbrackets.js"></script>
<script src="groovy.js"></script>
<link rel="stylesheet" href="../../doc/docs.css">
<style>.CodeMirror {border-top: 1px solid #500; border-bottom: 1px solid #500;}</style>
Expand Down
2 changes: 1 addition & 1 deletion mode/haskell/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<title>CodeMirror: Haskell mode</title>
<link rel="stylesheet" href="../../lib/codemirror.css">
<script src="../../lib/codemirror.js"></script>
<script src="../../lib/util/matchbrackets.js"></script>
<script src="../../addon/edit/matchbrackets.js"></script>
<script src="haskell.js"></script>
<link rel="stylesheet" href="../../theme/elegant.css">
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
Expand Down
4 changes: 2 additions & 2 deletions mode/javascript/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<title>CodeMirror: JavaScript mode</title>
<link rel="stylesheet" href="../../lib/codemirror.css">
<script src="../../lib/codemirror.js"></script>
<script src="../../lib/util/matchbrackets.js"></script>
<script src="../../lib/util/continuecomment.js"></script>
<script src="../../addon/edit/matchbrackets.js"></script>
<script src="../../addon/edit/continuecomment.js"></script>
<script src="javascript.js"></script>
<link rel="stylesheet" href="../../doc/docs.css">
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
Expand Down
15 changes: 13 additions & 2 deletions mode/javascript/javascript.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,12 +196,19 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
return true;
}
function register(varname) {
function inList(list) {
for (var v = list; v; v = v.next)
if (v.name == varname) return true;
return false;
}
var state = cx.state;
if (state.context) {
cx.marked = "def";
for (var v = state.localVars; v; v = v.next)
if (v.name == varname) return;
if (inList(state.localVars)) return;
state.localVars = {name: varname, next: state.localVars};
} else {
if (inList(state.globalVars)) return;
state.globalVars = {name: varname, next: state.globalVars};
}
}

Expand Down Expand Up @@ -364,6 +371,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
cc: [],
lexical: new JSLexical((basecolumn || 0) - indentUnit, 0, "block", false),
localVars: parserConfig.localVars,
globalVars: parserConfig.globalVars,
context: parserConfig.localVars && {vars: parserConfig.localVars},
indented: 0
};
Expand Down Expand Up @@ -406,6 +414,9 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
});

CodeMirror.defineMIME("text/javascript", "javascript");
CodeMirror.defineMIME("text/ecmascript", "javascript");
CodeMirror.defineMIME("application/javascript", "javascript");
CodeMirror.defineMIME("application/ecmascript", "javascript");
CodeMirror.defineMIME("application/json", {name: "javascript", json: true});
CodeMirror.defineMIME("text/typescript", { name: "javascript", typescript: true });
CodeMirror.defineMIME("application/typescript", { name: "javascript", typescript: true });
2 changes: 1 addition & 1 deletion mode/less/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<title>CodeMirror: LESS mode</title>
<link rel="stylesheet" href="../../lib/codemirror.css">
<script src="../../lib/codemirror.js"></script>
<script src="../../lib/util/matchbrackets.js"></script>
<script src="../../addon/edit/matchbrackets.js"></script>
<script src="less.js"></script>
<style>.CodeMirror {background: #f8f8f8; border: 1px solid #ddd; font-size:12px; height: 400px}</style>
<link rel="stylesheet" href="../../doc/docs.css">
Expand Down
Loading