On changes to the content of the above editor, a (crude) script
28 | tries to auto-detect the language used, and switches the editor to
29 | either JavaScript or Scheme mode based on that.
The emacs keybindings are enabled by
36 | including keymap/emacs.js and setting
37 | the keyMap option to "emacs". Because
38 | CodeMirror's internal API is quite different from Emacs, they are only
39 | a loose approximation of actual emacs bindings, though.
40 |
41 |
Also note that a lot of browsers disallow certain keys from being
42 | captured. For example, Chrome blocks both Ctrl-W and Ctrl-N, with the
43 | result that idiomatic use of Emacs keys will constantly close your tab
44 | or open a new window.
Select a piece of code and click one of the links below to apply automatic formatting to the selected text or comment/uncomment the selected text. Note that the formatting behavior depends on the current block's mode.
38 |
Demonstration of a multiplexing mode, which, at certain
52 | boundary strings, switches to one or more inner modes. The out
53 | (HTML) mode does not get fed the content of the <<
54 | >> blocks. See
55 | the manual and
56 | the source for more
57 | information.
Demonstration of a mode that parses HTML, highlighting
53 | the Mustache templating
54 | directives inside of it by using the code
55 | in overlay.js. View
56 | source to see the 15 lines of code needed to accomplish this.
If this is a function, it will be called for each token with
42 | two arguments, the token's text and the token's style class (may
43 | be null for unstyled tokens). If it is a DOM node,
44 | the tokens will be converted to span elements as in
45 | an editor, and inserted into the node
46 | (through innerHTML).
The vim keybindings are enabled by
38 | including keymap/vim.js and setting
39 | the keyMap option to "vim". Because
40 | CodeMirror's internal API is quite different from Vim, they are only
41 | a loose approximation of actual vim bindings, though.
Tabs inside the editor are spans with the
40 | class cm-tab, and can be styled.
41 |
42 |
51 |
52 |
53 |
54 |
--------------------------------------------------------------------------------
/dist/example/codemirror/demo/xmlcomplete.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
Type '<' or space inside tag or
22 | press ctrl-space to activate autocompletion. See
23 | the code (here
24 | and here) to figure out how
25 | it works.
So you found a problem in CodeMirror. By all means, report it! Bug
25 | reports from users are the main drive behind improvements to
26 | CodeMirror. But first, please read over these points:
27 |
28 |
29 |
CodeMirror is maintained by volunteers. They don't owe you
30 | anything, so be polite. Reports with an indignant or belligerent
31 | tone tend to be moved to the bottom of the pile.
32 |
33 |
Include information about the browser in which the
34 | problem occurred. Even if you tested several browsers, and
35 | the problem occurred in all of them, mention this fact in the bug
36 | report. Also include browser version numbers and the operating
37 | system that you're on.
38 |
39 |
Mention which release of CodeMirror you're using. Preferably,
40 | try also with the current development snapshot, to ensure the
41 | problem has not already been fixed.
42 |
43 |
Mention very precisely what went wrong. "X is broken" is not a
44 | good bug report. What did you expect to happen? What happened
45 | instead? Describe the exact steps a maintainer has to take to make
46 | the problem occur. We can not fix something that we can not
47 | observe.
48 |
49 |
If the problem can not be reproduced in any of the demos
50 | included in the CodeMirror distribution, please provide an HTML
51 | document that demonstrates the problem. The best way to do this is
52 | to go to jsbin.com, enter
53 | it there, press save, and include the resulting link in your bug
54 | report.
';
9 | return dialog;
10 | }
11 |
12 | CodeMirror.defineExtension("openDialog", function(template, callback) {
13 | var dialog = dialogDiv(this, template);
14 | var closed = false, me = this;
15 | function close() {
16 | if (closed) return;
17 | closed = true;
18 | dialog.parentNode.removeChild(dialog);
19 | }
20 | var inp = dialog.getElementsByTagName("input")[0], button;
21 | if (inp) {
22 | CodeMirror.connect(inp, "keydown", function(e) {
23 | if (e.keyCode == 13 || e.keyCode == 27) {
24 | CodeMirror.e_stop(e);
25 | close();
26 | me.focus();
27 | if (e.keyCode == 13) callback(inp.value);
28 | }
29 | });
30 | inp.focus();
31 | CodeMirror.connect(inp, "blur", close);
32 | } else if (button = dialog.getElementsByTagName("button")[0]) {
33 | CodeMirror.connect(button, "click", function() {
34 | close();
35 | me.focus();
36 | });
37 | button.focus();
38 | CodeMirror.connect(button, "blur", close);
39 | }
40 | return close;
41 | });
42 |
43 | CodeMirror.defineExtension("openConfirm", function(template, callbacks) {
44 | var dialog = dialogDiv(this, template);
45 | var buttons = dialog.getElementsByTagName("button");
46 | var closed = false, me = this, blurring = 1;
47 | function close() {
48 | if (closed) return;
49 | closed = true;
50 | dialog.parentNode.removeChild(dialog);
51 | me.focus();
52 | }
53 | buttons[0].focus();
54 | for (var i = 0; i < buttons.length; ++i) {
55 | var b = buttons[i];
56 | (function(callback) {
57 | CodeMirror.connect(b, "click", function(e) {
58 | CodeMirror.e_preventDefault(e);
59 | close();
60 | if (callback) callback(me);
61 | });
62 | })(callbacks[i]);
63 | CodeMirror.connect(b, "blur", function() {
64 | --blurring;
65 | setTimeout(function() { if (blurring <= 0) close(); }, 200);
66 | });
67 | CodeMirror.connect(b, "focus", function() { ++blurring; });
68 | }
69 | });
70 | })();
--------------------------------------------------------------------------------
/dist/example/codemirror/lib/util/loadmode.js:
--------------------------------------------------------------------------------
1 | (function() {
2 | if (!CodeMirror.modeURL) CodeMirror.modeURL = "../mode/%N/%N.js";
3 |
4 | var loading = {};
5 | function splitCallback(cont, n) {
6 | var countDown = n;
7 | return function() { if (--countDown == 0) cont(); };
8 | }
9 | function ensureDeps(mode, cont) {
10 | var deps = CodeMirror.modes[mode].dependencies;
11 | if (!deps) return cont();
12 | var missing = [];
13 | for (var i = 0; i < deps.length; ++i) {
14 | if (!CodeMirror.modes.hasOwnProperty(deps[i]))
15 | missing.push(deps[i]);
16 | }
17 | if (!missing.length) return cont();
18 | var split = splitCallback(cont, missing.length);
19 | for (var i = 0; i < missing.length; ++i)
20 | CodeMirror.requireMode(missing[i], split);
21 | }
22 |
23 | CodeMirror.requireMode = function(mode, cont) {
24 | if (typeof mode != "string") mode = mode.name;
25 | if (CodeMirror.modes.hasOwnProperty(mode)) return ensureDeps(mode, cont);
26 | if (loading.hasOwnProperty(mode)) return loading[mode].push(cont);
27 |
28 | var script = document.createElement("script");
29 | script.src = CodeMirror.modeURL.replace(/%N/g, mode);
30 | var others = document.getElementsByTagName("script")[0];
31 | others.parentNode.insertBefore(script, others);
32 | var list = loading[mode] = [cont];
33 | var count = 0, poll = setInterval(function() {
34 | if (++count > 100) return clearInterval(poll);
35 | if (CodeMirror.modes.hasOwnProperty(mode)) {
36 | clearInterval(poll);
37 | loading[mode] = null;
38 | ensureDeps(mode, function() {
39 | for (var i = 0; i < list.length; ++i) list[i]();
40 | });
41 | }
42 | }, 200);
43 | };
44 |
45 | CodeMirror.autoLoadMode = function(instance, mode) {
46 | if (!CodeMirror.modes.hasOwnProperty(mode))
47 | CodeMirror.requireMode(mode, function() {
48 | instance.setOption("mode", instance.getOption("mode"));
49 | });
50 | };
51 | }());
52 |
--------------------------------------------------------------------------------
/dist/example/codemirror/lib/util/match-highlighter.js:
--------------------------------------------------------------------------------
1 | // Define match-highlighter commands. Depends on searchcursor.js
2 | // Use by attaching the following function call to the onCursorActivity event:
3 | //myCodeMirror.matchHighlight(minChars);
4 | // And including a special span.CodeMirror-matchhighlight css class (also optionally a separate one for .CodeMirror-focused -- see demo matchhighlighter.html)
5 |
6 | (function() {
7 | var DEFAULT_MIN_CHARS = 2;
8 |
9 | function MatchHighlightState() {
10 | this.marked = [];
11 | }
12 | function getMatchHighlightState(cm) {
13 | return cm._matchHighlightState || (cm._matchHighlightState = new MatchHighlightState());
14 | }
15 |
16 | function clearMarks(cm) {
17 | var state = getMatchHighlightState(cm);
18 | for (var i = 0; i < state.marked.length; ++i)
19 | state.marked[i].clear();
20 | state.marked = [];
21 | }
22 |
23 | function markDocument(cm, className, minChars) {
24 | clearMarks(cm);
25 | minChars = (typeof minChars !== 'undefined' ? minChars : DEFAULT_MIN_CHARS);
26 | if (cm.somethingSelected() && cm.getSelection().replace(/^\s+|\s+$/g, "").length >= minChars) {
27 | var state = getMatchHighlightState(cm);
28 | var query = cm.getSelection();
29 | cm.operation(function() {
30 | if (cm.lineCount() < 2000) { // This is too expensive on big documents.
31 | for (var cursor = cm.getSearchCursor(query); cursor.findNext();) {
32 | //Only apply matchhighlight to the matches other than the one actually selected
33 | if (!(cursor.from().line === cm.getCursor(true).line && cursor.from().ch === cm.getCursor(true).ch))
34 | state.marked.push(cm.markText(cursor.from(), cursor.to(), className));
35 | }
36 | }
37 | });
38 | }
39 | }
40 |
41 | CodeMirror.defineExtension("matchHighlight", function(className, minChars) {
42 | markDocument(this, className, minChars);
43 | });
44 | })();
45 |
--------------------------------------------------------------------------------
/dist/example/codemirror/lib/util/multiplex.js:
--------------------------------------------------------------------------------
1 | CodeMirror.multiplexingMode = function(outer /*, others */) {
2 | // Others should be {open, close, mode [, delimStyle]} objects
3 | var others = Array.prototype.slice.call(arguments, 1);
4 | var n_others = others.length;
5 |
6 | function indexOf(string, pattern, from) {
7 | if (typeof pattern == "string") return string.indexOf(pattern, from);
8 | var m = pattern.exec(from ? string.slice(from) : string);
9 | return m ? m.index + from : -1;
10 | }
11 |
12 | return {
13 | startState: function() {
14 | return {
15 | outer: CodeMirror.startState(outer),
16 | innerActive: null,
17 | inner: null
18 | };
19 | },
20 |
21 | copyState: function(state) {
22 | return {
23 | outer: CodeMirror.copyState(outer, state.outer),
24 | innerActive: state.innerActive,
25 | inner: state.innerActive && CodeMirror.copyState(state.innerActive.mode, state.inner)
26 | };
27 | },
28 |
29 | token: function(stream, state) {
30 | if (!state.innerActive) {
31 | var cutOff = Infinity, oldContent = stream.string;
32 | for (var i = 0; i < n_others; ++i) {
33 | var other = others[i];
34 | var found = indexOf(oldContent, other.open, stream.pos);
35 | if (found == stream.pos) {
36 | stream.match(other.open);
37 | state.innerActive = other;
38 | state.inner = CodeMirror.startState(other.mode, outer.indent ? outer.indent(state.outer, "") : 0);
39 | return other.delimStyle;
40 | } else if (found != -1 && found < cutOff) {
41 | cutOff = found;
42 | }
43 | }
44 | if (cutOff != Infinity) stream.string = oldContent.slice(0, cutOff);
45 | var outerToken = outer.token(stream, state.outer);
46 | if (cutOff != Infinity) stream.string = oldContent;
47 | return outerToken;
48 | } else {
49 | var curInner = state.innerActive, oldContent = stream.string;
50 | var found = indexOf(oldContent, curInner.close, stream.pos);
51 | if (found == stream.pos) {
52 | stream.match(curInner.close);
53 | state.innerActive = state.inner = null;
54 | return curInner.delimStyle;
55 | }
56 | if (found > -1) stream.string = oldContent.slice(0, found);
57 | var innerToken = curInner.mode.token(stream, state.inner);
58 | if (found > -1) stream.string = oldContent;
59 | var cur = stream.current(), found = cur.indexOf(curInner.close);
60 | if (found > -1) stream.backUp(cur.length - found);
61 | return innerToken;
62 | }
63 | },
64 |
65 | indent: function(state, textAfter) {
66 | var mode = state.innerActive ? state.innerActive.mode : outer;
67 | if (!mode.indent) return CodeMirror.Pass;
68 | return mode.indent(state.innerActive ? state.inner : state.outer, textAfter);
69 | },
70 |
71 | electricChars: outer.electricChars,
72 |
73 | innerMode: function(state) {
74 | return state.inner ? {state: state.inner, mode: state.innerActive.mode} : {state: state.outer, mode: outer};
75 | }
76 | };
77 | };
78 |
--------------------------------------------------------------------------------
/dist/example/codemirror/lib/util/overlay.js:
--------------------------------------------------------------------------------
1 | // Utility function that allows modes to be combined. The mode given
2 | // as the base argument takes care of most of the normal mode
3 | // functionality, but a second (typically simple) mode is used, which
4 | // can override the style of text. Both modes get to parse all of the
5 | // text, but when both assign a non-null style to a piece of code, the
6 | // overlay wins, unless the combine argument was true, in which case
7 | // the styles are combined.
8 |
9 | // overlayParser is the old, deprecated name
10 | CodeMirror.overlayMode = CodeMirror.overlayParser = function(base, overlay, combine) {
11 | return {
12 | startState: function() {
13 | return {
14 | base: CodeMirror.startState(base),
15 | overlay: CodeMirror.startState(overlay),
16 | basePos: 0, baseCur: null,
17 | overlayPos: 0, overlayCur: null
18 | };
19 | },
20 | copyState: function(state) {
21 | return {
22 | base: CodeMirror.copyState(base, state.base),
23 | overlay: CodeMirror.copyState(overlay, state.overlay),
24 | basePos: state.basePos, baseCur: null,
25 | overlayPos: state.overlayPos, overlayCur: null
26 | };
27 | },
28 |
29 | token: function(stream, state) {
30 | if (stream.start == state.basePos) {
31 | state.baseCur = base.token(stream, state.base);
32 | state.basePos = stream.pos;
33 | }
34 | if (stream.start == state.overlayPos) {
35 | stream.pos = stream.start;
36 | state.overlayCur = overlay.token(stream, state.overlay);
37 | state.overlayPos = stream.pos;
38 | }
39 | stream.pos = Math.min(state.basePos, state.overlayPos);
40 | if (stream.eol()) state.basePos = state.overlayPos = 0;
41 |
42 | if (state.overlayCur == null) return state.baseCur;
43 | if (state.baseCur != null && combine) return state.baseCur + " " + state.overlayCur;
44 | else return state.overlayCur;
45 | },
46 |
47 | indent: base.indent && function(state, textAfter) {
48 | return base.indent(state.base, textAfter);
49 | },
50 | electricChars: base.electricChars,
51 |
52 | innerMode: function(state) { return {state: state.base, mode: base}; },
53 |
54 | blankLine: function(state) {
55 | if (base.blankLine) base.blankLine(state.base);
56 | if (overlay.blankLine) overlay.blankLine(state.overlay);
57 | }
58 | };
59 | };
60 |
--------------------------------------------------------------------------------
/dist/example/codemirror/lib/util/runmode.js:
--------------------------------------------------------------------------------
1 | CodeMirror.runMode = function(string, modespec, callback, options) {
2 | function esc(str) {
3 | return str.replace(/[<&]/g, function(ch) { return ch == "<" ? "<" : "&"; });
4 | }
5 |
6 | var mode = CodeMirror.getMode(CodeMirror.defaults, modespec);
7 | var isNode = callback.nodeType == 1;
8 | var tabSize = (options && options.tabSize) || CodeMirror.defaults.tabSize;
9 | if (isNode) {
10 | var node = callback, accum = [], col = 0;
11 | callback = function(text, style) {
12 | if (text == "\n") {
13 | accum.push(" ");
14 | col = 0;
15 | return;
16 | }
17 | var escaped = "";
18 | // HTML-escape and replace tabs
19 | for (var pos = 0;;) {
20 | var idx = text.indexOf("\t", pos);
21 | if (idx == -1) {
22 | escaped += esc(text.slice(pos));
23 | col += text.length - pos;
24 | break;
25 | } else {
26 | col += idx - pos;
27 | escaped += esc(text.slice(pos, idx));
28 | var size = tabSize - col % tabSize;
29 | col += size;
30 | for (var i = 0; i < size; ++i) escaped += " ";
31 | pos = idx + 1;
32 | }
33 | }
34 |
35 | if (style)
36 | accum.push("" + escaped + "");
37 | else
38 | accum.push(escaped);
39 | };
40 | }
41 | var lines = CodeMirror.splitLines(string), state = CodeMirror.startState(mode);
42 | for (var i = 0, e = lines.length; i < e; ++i) {
43 | if (i) callback("\n");
44 | var stream = new CodeMirror.StringStream(lines[i]);
45 | while (!stream.eol()) {
46 | var style = mode.token(stream, state);
47 | callback(stream.current(), style, i, stream.start);
48 | stream.start = stream.pos;
49 | }
50 | }
51 | if (isNode)
52 | node.innerHTML = accum.join("");
53 | };
54 |
--------------------------------------------------------------------------------
/dist/example/codemirror/lib/util/simple-hint.css:
--------------------------------------------------------------------------------
1 | .CodeMirror-completions {
2 | position: absolute;
3 | z-index: 10;
4 | overflow: hidden;
5 | -webkit-box-shadow: 2px 3px 5px rgba(0,0,0,.2);
6 | -moz-box-shadow: 2px 3px 5px rgba(0,0,0,.2);
7 | box-shadow: 2px 3px 5px rgba(0,0,0,.2);
8 | }
9 | .CodeMirror-completions select {
10 | background: #fafafa;
11 | outline: none;
12 | border: none;
13 | padding: 0;
14 | margin: 0;
15 | font-family: monospace;
16 | }
17 |
--------------------------------------------------------------------------------
/dist/example/codemirror/mode/clojure/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CodeMirror: Clojure mode
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
CodeMirror: Clojure mode
14 |
60 |
63 |
64 |
MIME types defined:text/x-clojure.
65 |
66 |
67 |
68 |
--------------------------------------------------------------------------------
/dist/example/codemirror/mode/coffeescript/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License
2 |
3 | Copyright (c) 2011 Jeff Pickhardt
4 | Modified from the Python CodeMirror mode, Copyright (c) 2010 Timothy Farrell
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in
14 | all copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | THE SOFTWARE.
--------------------------------------------------------------------------------
/dist/example/codemirror/mode/css/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CodeMirror: CSS mode
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
Mode for html embedded scripts like JSP and ASP.NET. Depends on HtmlMixed which in turn depends on
45 | JavaScript, CSS and XML. Other dependancies include those of the scriping language chosen.
Loosely based on Franciszek
65 | Wawrzak's CodeMirror
66 | 1 mode. One configuration parameter is
67 | supported, specials, to which you can provide an
68 | array of strings to have those identifiers highlighted with
69 | the lua-special style.
32 |
33 |
34 |
--------------------------------------------------------------------------------
/dist/example/codemirror/mode/pascal/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2011 souceLair
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4 |
5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6 |
7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
8 |
--------------------------------------------------------------------------------
/dist/example/codemirror/mode/pascal/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CodeMirror: Pascal mode
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
CodeMirror: Pascal mode
14 |
15 |
38 |
39 |
46 |
47 |
MIME types defined:text/x-pascal.
48 |
49 |
50 |
--------------------------------------------------------------------------------
/dist/example/codemirror/mode/pascal/pascal.js:
--------------------------------------------------------------------------------
1 | CodeMirror.defineMode("pascal", function(config) {
2 | function words(str) {
3 | var obj = {}, words = str.split(" ");
4 | for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
5 | return obj;
6 | }
7 | var keywords = words("and array begin case const div do downto else end file for forward integer " +
8 | "boolean char function goto if in label mod nil not of or packed procedure " +
9 | "program record repeat set string then to type until var while with");
10 | var atoms = {"null": true};
11 |
12 | var isOperatorChar = /[+\-*&%=<>!?|\/]/;
13 |
14 | function tokenBase(stream, state) {
15 | var ch = stream.next();
16 | if (ch == "#" && state.startOfLine) {
17 | stream.skipToEnd();
18 | return "meta";
19 | }
20 | if (ch == '"' || ch == "'") {
21 | state.tokenize = tokenString(ch);
22 | return state.tokenize(stream, state);
23 | }
24 | if (ch == "(" && stream.eat("*")) {
25 | state.tokenize = tokenComment;
26 | return tokenComment(stream, state);
27 | }
28 | if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
29 | return null;
30 | }
31 | if (/\d/.test(ch)) {
32 | stream.eatWhile(/[\w\.]/);
33 | return "number";
34 | }
35 | if (ch == "/") {
36 | if (stream.eat("/")) {
37 | stream.skipToEnd();
38 | return "comment";
39 | }
40 | }
41 | if (isOperatorChar.test(ch)) {
42 | stream.eatWhile(isOperatorChar);
43 | return "operator";
44 | }
45 | stream.eatWhile(/[\w\$_]/);
46 | var cur = stream.current();
47 | if (keywords.propertyIsEnumerable(cur)) return "keyword";
48 | if (atoms.propertyIsEnumerable(cur)) return "atom";
49 | return "variable";
50 | }
51 |
52 | function tokenString(quote) {
53 | return function(stream, state) {
54 | var escaped = false, next, end = false;
55 | while ((next = stream.next()) != null) {
56 | if (next == quote && !escaped) {end = true; break;}
57 | escaped = !escaped && next == "\\";
58 | }
59 | if (end || !escaped) state.tokenize = null;
60 | return "string";
61 | };
62 | }
63 |
64 | function tokenComment(stream, state) {
65 | var maybeEnd = false, ch;
66 | while (ch = stream.next()) {
67 | if (ch == ")" && maybeEnd) {
68 | state.tokenize = null;
69 | break;
70 | }
71 | maybeEnd = (ch == "*");
72 | }
73 | return "comment";
74 | }
75 |
76 | // Interface
77 |
78 | return {
79 | startState: function(basecolumn) {
80 | return {tokenize: null};
81 | },
82 |
83 | token: function(stream, state) {
84 | if (stream.eatSpace()) return null;
85 | var style = (state.tokenize || tokenBase)(stream, state);
86 | if (style == "comment" || style == "meta") return style;
87 | return style;
88 | },
89 |
90 | electricChars: "{}"
91 | };
92 | });
93 |
94 | CodeMirror.defineMIME("text/x-pascal", "pascal");
95 |
--------------------------------------------------------------------------------
/dist/example/codemirror/mode/perl/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (C) 2011 by Sabaca under the MIT license.
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy
4 | of this software and associated documentation files (the "Software"), to deal
5 | in the Software without restriction, including without limitation the rights
6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | copies of the Software, and to permit persons to whom the Software is
8 | furnished to do so, subject to the following conditions:
9 |
10 | The above copyright notice and this permission notice shall be included in
11 | all copies or substantial portions of the Software.
12 |
13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 | THE SOFTWARE.
20 |
--------------------------------------------------------------------------------
/dist/example/codemirror/mode/perl/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CodeMirror: Perl mode
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/dist/example/codemirror/mode/properties/properties.js:
--------------------------------------------------------------------------------
1 | CodeMirror.defineMode("properties", function() {
2 | return {
3 | token: function(stream, state) {
4 | var sol = stream.sol() || state.afterSection;
5 | var eol = stream.eol();
6 |
7 | state.afterSection = false;
8 |
9 | if (sol) {
10 | if (state.nextMultiline) {
11 | state.inMultiline = true;
12 | state.nextMultiline = false;
13 | } else {
14 | state.position = "def";
15 | }
16 | }
17 |
18 | if (eol && ! state.nextMultiline) {
19 | state.inMultiline = false;
20 | state.position = "def";
21 | }
22 |
23 | if (sol) {
24 | while(stream.eatSpace());
25 | }
26 |
27 | var ch = stream.next();
28 |
29 | if (sol && (ch === "#" || ch === "!" || ch === ";")) {
30 | state.position = "comment";
31 | stream.skipToEnd();
32 | return "comment";
33 | } else if (sol && ch === "[") {
34 | state.afterSection = true;
35 | stream.skipTo("]"); stream.eat("]");
36 | return "header";
37 | } else if (ch === "=" || ch === ":") {
38 | state.position = "quote";
39 | return null;
40 | } else if (ch === "\\" && state.position === "quote") {
41 | if (stream.next() !== "u") { // u = Unicode sequence \u1234
42 | // Multiline value
43 | state.nextMultiline = true;
44 | }
45 | }
46 |
47 | return state.position;
48 | },
49 |
50 | startState: function() {
51 | return {
52 | position : "def", // Current position, "def", "quote" or "comment"
53 | nextMultiline : false, // Is the next line multiline value
54 | inMultiline : false, // Is the current line a multiline value
55 | afterSection : false // Did we just open a section
56 | };
57 | }
58 |
59 | };
60 | });
61 |
62 | CodeMirror.defineMIME("text/x-properties", "properties");
63 | CodeMirror.defineMIME("text/x-ini", "properties");
64 |
--------------------------------------------------------------------------------
/dist/example/codemirror/mode/python/LICENSE.txt:
--------------------------------------------------------------------------------
1 | The MIT License
2 |
3 | Copyright (c) 2010 Timothy Farrell
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
--------------------------------------------------------------------------------
/dist/example/codemirror/mode/r/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2011, Ubalo, Inc.
2 | All rights reserved.
3 |
4 | Redistribution and use in source and binary forms, with or without
5 | modification, are permitted provided that the following conditions are met:
6 | * Redistributions of source code must retain the above copyright
7 | notice, this list of conditions and the following disclaimer.
8 | * Redistributions in binary form must reproduce the above copyright
9 | notice, this list of conditions and the following disclaimer in the
10 | documentation and/or other materials provided with the distribution.
11 | * Neither the name of the Ubalo, Inc nor the names of its
12 | contributors may be used to endorse or promote products derived
13 | from this software without specific prior written permission.
14 |
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 | DISCLAIMED. IN NO EVENT SHALL UBALO, INC BE LIABLE FOR ANY
19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 |
--------------------------------------------------------------------------------
/dist/example/codemirror/mode/r/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CodeMirror: R mode
6 |
7 |
8 |
9 |
16 |
17 |
18 |
19 |
CodeMirror: R mode
20 |
63 |
66 |
67 |
MIME types defined:text/x-rsrc.
68 |
69 |
Development of the CodeMirror R mode was kindly sponsored
70 | by Ubalo, who hold
71 | the license.
53 |
54 |
55 |
--------------------------------------------------------------------------------
/dist/example/codemirror/mode/rpm/spec/spec.css:
--------------------------------------------------------------------------------
1 | .cm-s-default span.cm-preamble {color: #b26818; font-weight: bold;}
2 | .cm-s-default span.cm-macro {color: #b218b2;}
3 | .cm-s-default span.cm-section {color: green; font-weight: bold;}
4 | .cm-s-default span.cm-script {color: red;}
5 | .cm-s-default span.cm-issue {color: yellow;}
6 |
--------------------------------------------------------------------------------
/dist/example/codemirror/mode/rpm/spec/spec.js:
--------------------------------------------------------------------------------
1 | // Quick and dirty spec file highlighting
2 |
3 | CodeMirror.defineMode("spec", function(config, modeConfig) {
4 | var arch = /^(i386|i586|i686|x86_64|ppc64|ppc|ia64|s390x|s390|sparc64|sparcv9|sparc|noarch|alphaev6|alpha|hppa|mipsel)/;
5 |
6 | var preamble = /^(Name|Version|Release|License|Summary|Url|Group|Source|BuildArch|BuildRequires|BuildRoot|AutoReqProv|Provides|Requires(\(\w+\))?|Obsoletes|Conflicts|Recommends|Source\d*|Patch\d*|ExclusiveArch|NoSource|Supplements):/;
7 | var section = /^%(debug_package|package|description|prep|build|install|files|clean|changelog|preun|postun|pre|post|triggerin|triggerun|pretrans|posttrans|verifyscript|check|triggerpostun|triggerprein|trigger)/;
8 | var control_flow_complex = /^%(ifnarch|ifarch|if)/; // rpm control flow macros
9 | var control_flow_simple = /^%(else|endif)/; // rpm control flow macros
10 | var operators = /^(\!|\?|\<\=|\<|\>\=|\>|\=\=|\&\&|\|\|)/; // operators in control flow macros
11 |
12 | return {
13 | startState: function () {
14 | return {
15 | controlFlow: false,
16 | macroParameters: false,
17 | section: false
18 | };
19 | },
20 | token: function (stream, state) {
21 | var ch = stream.peek();
22 | if (ch == "#") { stream.skipToEnd(); return "comment"; }
23 |
24 | if (stream.sol()) {
25 | if (stream.match(preamble)) { return "preamble"; }
26 | if (stream.match(section)) { return "section"; }
27 | }
28 |
29 | if (stream.match(/^\$\w+/)) { return "def"; } // Variables like '$RPM_BUILD_ROOT'
30 | if (stream.match(/^\$\{\w+\}/)) { return "def"; } // Variables like '${RPM_BUILD_ROOT}'
31 |
32 | if (stream.match(control_flow_simple)) { return "keyword"; }
33 | if (stream.match(control_flow_complex)) {
34 | state.controlFlow = true;
35 | return "keyword";
36 | }
37 | if (state.controlFlow) {
38 | if (stream.match(operators)) { return "operator"; }
39 | if (stream.match(/^(\d+)/)) { return "number"; }
40 | if (stream.eol()) { state.controlFlow = false; }
41 | }
42 |
43 | if (stream.match(arch)) { return "number"; }
44 |
45 | // Macros like '%make_install' or '%attr(0775,root,root)'
46 | if (stream.match(/^%[\w]+/)) {
47 | if (stream.match(/^\(/)) { state.macroParameters = true; }
48 | return "macro";
49 | }
50 | if (state.macroParameters) {
51 | if (stream.match(/^\d+/)) { return "number";}
52 | if (stream.match(/^\)/)) {
53 | state.macroParameters = false;
54 | return "macro";
55 | }
56 | }
57 | if (stream.match(/^%\{\??[\w \-]+\}/)) { return "macro"; } // Macros like '%{defined fedora}'
58 |
59 | //TODO: Include bash script sub-parser (CodeMirror supports that)
60 | stream.next();
61 | return null;
62 | }
63 | };
64 | });
65 |
66 | CodeMirror.defineMIME("text/x-rpm-spec", "spec");
67 |
--------------------------------------------------------------------------------
/dist/example/codemirror/mode/ruby/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2011, Ubalo, Inc.
2 | All rights reserved.
3 |
4 | Redistribution and use in source and binary forms, with or without
5 | modification, are permitted provided that the following conditions are met:
6 | * Redistributions of source code must retain the above copyright
7 | notice, this list of conditions and the following disclaimer.
8 | * Redistributions in binary form must reproduce the above copyright
9 | notice, this list of conditions and the following disclaimer in the
10 | documentation and/or other materials provided with the distribution.
11 | * Neither the name of the Ubalo, Inc. nor the names of its
12 | contributors may be used to endorse or promote products derived
13 | from this software without specific prior written permission.
14 |
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 | DISCLAIMED. IN NO EVENT SHALL UBALO, INC BE LIABLE FOR ANY
19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 |
--------------------------------------------------------------------------------
/dist/example/codemirror/mode/rust/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CodeMirror: Rust mode
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
51 |
--------------------------------------------------------------------------------
/dist/example/codemirror/mode/sieve/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (C) 2012 Thomas Schmid
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy
4 | of this software and associated documentation files (the "Software"), to deal
5 | in the Software without restriction, including without limitation the rights
6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | copies of the Software, and to permit persons to whom the Software is
8 | furnished to do so, subject to the following conditions:
9 |
10 | The above copyright notice and this permission notice shall be included in
11 | all copies or substantial portions of the Software.
12 |
13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 | THE SOFTWARE.
20 |
21 | Please note that some subdirectories of the CodeMirror distribution
22 | include their own LICENSE files, and are released under different
23 | licences.
24 |
--------------------------------------------------------------------------------
/dist/example/codemirror/mode/sieve/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CodeMirror: Sieve (RFC5228) mode
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
72 |
73 |
81 |
82 |
83 |
84 |
--------------------------------------------------------------------------------
/dist/example/codemirror/mode/tiki/tiki.css:
--------------------------------------------------------------------------------
1 | .cm-tw-syntaxerror {
2 | color: #FFFFFF;
3 | background-color: #990000;
4 | }
5 |
6 | .cm-tw-deleted {
7 | text-decoration: line-through;
8 | }
9 |
10 | .cm-tw-header5 {
11 | font-weight: bold;
12 | }
13 | .cm-tw-listitem:first-child { /*Added first child to fix duplicate padding when highlighting*/
14 | padding-left: 10px;
15 | }
16 |
17 | .cm-tw-box {
18 | border-top-width: 0px ! important;
19 | border-style: solid;
20 | border-width: 1px;
21 | border-color: inherit;
22 | }
23 |
24 | .cm-tw-underline {
25 | text-decoration: underline;
26 | }
--------------------------------------------------------------------------------
/dist/example/codemirror/mode/vb/LICENSE.txt:
--------------------------------------------------------------------------------
1 | The MIT License
2 |
3 | Copyright (c) 2012 Codility Limited, 107 Cheapside, London EC2V 6DN, UK
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/dist/example/codemirror/mode/vb/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | CodeMirror: VB.NET mode
5 |
6 |
7 |
8 |
9 |
10 |
15 |
16 |
17 |
18 |
The XML mode supports two configuration parameters:
33 |
34 |
htmlMode (boolean)
35 |
This switches the mode to parse HTML instead of XML. This
36 | means attributes do not have to be quoted, and some elements
37 | (such as br) do not require a closing tag.
38 |
alignCDATA (boolean)
39 |
Setting this to true will force the opening tag of CDATA
40 | blocks to not be indented.
41 |
42 |
43 |
MIME types defined:application/xml, text/html.
44 |
45 |
46 |
--------------------------------------------------------------------------------
/dist/example/codemirror/mode/xquery/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (C) 2011 by MarkLogic Corporation
2 | Author: Mike Brevoort
3 |
4 | Permission is hereby granted, free of charge, to any person obtaining a copy
5 | of this software and associated documentation files (the "Software"), to deal
6 | in the Software without restriction, including without limitation the rights
7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | copies of the Software, and to permit persons to whom the Software is
9 | furnished to do so, subject to the following conditions:
10 |
11 | The above copyright notice and this permission notice shall be included in
12 | all copies or substantial portions of the Software.
13 |
14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | THE SOFTWARE.
--------------------------------------------------------------------------------
/dist/example/codemirror/mode/xquery/test/index.html:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |