liquid_cms 0.2.1.1 → 0.2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.rdoc +7 -0
- data/README.rdoc +15 -1
- data/TODO.rdoc +0 -2
- data/app/controllers/cms/assets_controller.rb +20 -6
- data/app/controllers/cms/components_controller.rb +11 -3
- data/app/controllers/cms/pages_controller.rb +15 -4
- data/app/helpers/cms/common_helper.rb +31 -31
- data/app/liquid/cms_paperclip_extension.rb +75 -3
- data/app/models/cms/asset.rb +1 -1
- data/app/models/cms/component.rb +3 -3
- data/app/views/cms/assets/_form.html.erb +1 -1
- data/app/views/cms/assets/update.js.rjs +1 -0
- data/app/views/cms/components/update.js.rjs +1 -0
- data/app/views/cms/pages/_form.html.erb +1 -1
- data/app/views/cms/pages/update.js.rjs +1 -0
- data/app/views/layouts/cms.html.erb +4 -3
- data/generators/liquid_cms/liquid_cms_generator.rb +1 -0
- data/generators/liquid_cms/templates/config/locales/cms/en.yml +4 -0
- data/generators/liquid_cms/templates/migration_rev2.rb +13 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/LICENSE +16 -20
- data/generators/liquid_cms/templates/public/cms/codemirror/lib/codemirror.css +68 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/lib/codemirror.js +2197 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/lib/overlay.js +51 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/lib/runmode.js +27 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/clike/clike.js +247 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/clike/index.html +102 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/clojure/clojure.js +207 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/clojure/index.html +85 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/coffeescript/LICENSE +22 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/coffeescript/coffeescript.js +325 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/coffeescript/index.html +722 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/css/css.js +124 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/css/index.html +56 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/diff/diff.css +3 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/diff/diff.js +13 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/diff/index.html +99 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/haskell/haskell.js +242 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/haskell/index.html +60 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/htmlmixed/htmlmixed.js +79 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/htmlmixed/index.html +52 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/javascript/index.html +78 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/javascript/javascript.js +352 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/jinja2/index.html +38 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/jinja2/jinja2.js +42 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/lua/index.html +72 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/lua/lua.js +140 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/markdown/index.html +340 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/markdown/markdown.css +10 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/markdown/markdown.js +230 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/ntriples/index.html +33 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/ntriples/ntriples.js +172 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/pascal/LICENSE +7 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/pascal/index.html +49 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/pascal/pascal.js +138 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/php/index.html +49 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/php/php.js +116 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/plsql/index.html +63 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/plsql/plsql.js +217 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/python/LICENSE.txt +21 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/python/index.html +123 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/python/python.js +320 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/r/LICENSE +24 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/r/index.html +74 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/r/r.js +141 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/rst/index.html +526 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/rst/rst.css +75 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/rst/rst.js +333 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/ruby/LICENSE +24 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/ruby/index.html +172 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/ruby/ruby.js +195 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/scheme/index.html +65 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/scheme/scheme.js +202 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/smalltalk/index.html +56 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/smalltalk/smalltalk.js +122 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/sparql/index.html +41 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/sparql/sparql.js +143 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/stex/index.html +96 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/stex/stex.js +167 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/velocity/index.html +103 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/velocity/velocity.js +146 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/xml/index.html +42 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/xml/xml.js +231 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/xmlpure/index.html +60 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/xmlpure/xmlpure.js +481 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/yaml/index.html +68 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/yaml/yaml.js +95 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/theme/cobalt.css +17 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/theme/default.css +19 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/theme/eclipse.css +24 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/theme/elegant.css +9 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/theme/neat.css +8 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/theme/night.css +20 -0
- data/generators/liquid_cms/templates/public/cms/javascripts/cms.js +1 -1
- data/generators/liquid_cms/templates/public/cms/javascripts/codemirror_custom.js +96 -0
- data/generators/liquid_cms/templates/public/cms/stylesheets/codemirror_changes.css +26 -0
- data/generators/liquid_cms/templates/public/cms/stylesheets/liquid.css +7 -0
- data/generators/liquid_cms/templates/public/cms/stylesheets/simple_form.css +0 -8
- data/lib/liquid_cms/version.rb +1 -1
- data/liquid_cms.gemspec +0 -1
- data/test/functional/assets_controller_test.rb +35 -20
- data/test/functional/components_controller_test.rb +15 -5
- data/test/functional/pages_controller_test.rb +19 -6
- data/test/rails_app/config/environment.rb +1 -1
- data/test/rails_app/config/locales/cms/en.yml +19 -4
- data/test/rails_app/db/migrate/20110511161859_create_liquid_cms_upgrade_rev2.rb +13 -0
- data/test/unit/asset_test.rb +1 -1
- metadata +100 -58
- data/generators/liquid_cms/templates/public/cms/codemirror/css/csscolors.css +0 -55
- data/generators/liquid_cms/templates/public/cms/codemirror/css/docs.css +0 -158
- data/generators/liquid_cms/templates/public/cms/codemirror/css/font.js +0 -15
- data/generators/liquid_cms/templates/public/cms/codemirror/css/jscolors.css +0 -59
- data/generators/liquid_cms/templates/public/cms/codemirror/css/sparqlcolors.css +0 -43
- data/generators/liquid_cms/templates/public/cms/codemirror/css/xmlcolors.css +0 -55
- data/generators/liquid_cms/templates/public/cms/codemirror/js/codemirror.js +0 -582
- data/generators/liquid_cms/templates/public/cms/codemirror/js/editor.js +0 -1671
- data/generators/liquid_cms/templates/public/cms/codemirror/js/highlight.js +0 -68
- data/generators/liquid_cms/templates/public/cms/codemirror/js/mirrorframe.js +0 -81
- data/generators/liquid_cms/templates/public/cms/codemirror/js/parsecss.js +0 -161
- data/generators/liquid_cms/templates/public/cms/codemirror/js/parsedummy.js +0 -32
- data/generators/liquid_cms/templates/public/cms/codemirror/js/parsehtmlmixed.js +0 -93
- data/generators/liquid_cms/templates/public/cms/codemirror/js/parsejavascript.js +0 -359
- data/generators/liquid_cms/templates/public/cms/codemirror/js/parsesparql.js +0 -162
- data/generators/liquid_cms/templates/public/cms/codemirror/js/parsexml.js +0 -291
- data/generators/liquid_cms/templates/public/cms/codemirror/js/select.js +0 -699
- data/generators/liquid_cms/templates/public/cms/codemirror/js/stringstream.js +0 -159
- data/generators/liquid_cms/templates/public/cms/codemirror/js/tokenize.js +0 -57
- data/generators/liquid_cms/templates/public/cms/codemirror/js/tokenizejavascript.js +0 -174
- data/generators/liquid_cms/templates/public/cms/codemirror/js/undo.js +0 -413
- data/generators/liquid_cms/templates/public/cms/codemirror/js/unittests.js +0 -44
- data/generators/liquid_cms/templates/public/cms/codemirror/js/util.js +0 -133
|
@@ -0,0 +1,51 @@
|
|
|
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
|
+
CodeMirror.overlayParser = function(base, overlay, combine) {
|
|
10
|
+
return {
|
|
11
|
+
startState: function() {
|
|
12
|
+
return {
|
|
13
|
+
base: CodeMirror.startState(base),
|
|
14
|
+
overlay: CodeMirror.startState(overlay),
|
|
15
|
+
basePos: 0, baseCur: null,
|
|
16
|
+
overlayPos: 0, overlayCur: null
|
|
17
|
+
};
|
|
18
|
+
},
|
|
19
|
+
copyState: function(state) {
|
|
20
|
+
return {
|
|
21
|
+
base: CodeMirror.copyState(base, state.base),
|
|
22
|
+
overlay: CodeMirror.copyState(overlay, state.overlay),
|
|
23
|
+
basePos: state.basePos, baseCur: null,
|
|
24
|
+
overlayPos: state.overlayPos, overlayCur: null
|
|
25
|
+
};
|
|
26
|
+
},
|
|
27
|
+
|
|
28
|
+
token: function(stream, state) {
|
|
29
|
+
if (stream.start == state.basePos) {
|
|
30
|
+
state.baseCur = base.token(stream, state.base);
|
|
31
|
+
state.basePos = stream.pos;
|
|
32
|
+
}
|
|
33
|
+
if (stream.start == state.overlayPos) {
|
|
34
|
+
stream.pos = stream.start;
|
|
35
|
+
state.overlayCur = overlay.token(stream, state.overlay);
|
|
36
|
+
state.overlayPos = stream.pos;
|
|
37
|
+
}
|
|
38
|
+
stream.pos = Math.min(state.basePos, state.overlayPos);
|
|
39
|
+
if (stream.eol()) state.basePos = state.overlayPos = 0;
|
|
40
|
+
|
|
41
|
+
if (state.overlayCur == null) return state.baseCur;
|
|
42
|
+
if (state.baseCur != null && combine) return state.baseCur + " " + state.overlayCur;
|
|
43
|
+
else return state.overlayCur;
|
|
44
|
+
},
|
|
45
|
+
|
|
46
|
+
indent: function(state, textAfter) {
|
|
47
|
+
return base.indent(state.base, textAfter);
|
|
48
|
+
},
|
|
49
|
+
electricChars: base.electricChars
|
|
50
|
+
};
|
|
51
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
CodeMirror.runMode = function(string, modespec, callback) {
|
|
2
|
+
var mode = CodeMirror.getMode({indentUnit: 2}, modespec);
|
|
3
|
+
var isNode = callback.nodeType == 1;
|
|
4
|
+
if (isNode) {
|
|
5
|
+
var node = callback, accum = [];
|
|
6
|
+
callback = function(string, style) {
|
|
7
|
+
if (string == "\n")
|
|
8
|
+
accum.push("<br>");
|
|
9
|
+
else if (style)
|
|
10
|
+
accum.push("<span class=\"cm-" + CodeMirror.htmlEscape(style) + "\">" + CodeMirror.htmlEscape(string) + "</span>");
|
|
11
|
+
else
|
|
12
|
+
accum.push(CodeMirror.htmlEscape(string));
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
var lines = CodeMirror.splitLines(string), state = CodeMirror.startState(mode);
|
|
16
|
+
for (var i = 0, e = lines.length; i < e; ++i) {
|
|
17
|
+
if (i) callback("\n");
|
|
18
|
+
var stream = new CodeMirror.StringStream(lines[i]);
|
|
19
|
+
while (!stream.eol()) {
|
|
20
|
+
var style = mode.token(stream, state);
|
|
21
|
+
callback(stream.current(), style);
|
|
22
|
+
stream.start = stream.pos;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
if (isNode)
|
|
26
|
+
node.innerHTML = accum.join("");
|
|
27
|
+
};
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
CodeMirror.defineMode("clike", function(config, parserConfig) {
|
|
2
|
+
var indentUnit = config.indentUnit,
|
|
3
|
+
keywords = parserConfig.keywords || {},
|
|
4
|
+
blockKeywords = parserConfig.blockKeywords || {},
|
|
5
|
+
atoms = parserConfig.atoms || {},
|
|
6
|
+
hooks = parserConfig.hooks || {},
|
|
7
|
+
multiLineStrings = parserConfig.multiLineStrings;
|
|
8
|
+
var isOperatorChar = /[+\-*&%=<>!?|\/]/;
|
|
9
|
+
|
|
10
|
+
var curPunc;
|
|
11
|
+
|
|
12
|
+
function tokenBase(stream, state) {
|
|
13
|
+
var ch = stream.next();
|
|
14
|
+
if (hooks[ch]) {
|
|
15
|
+
var result = hooks[ch](stream, state);
|
|
16
|
+
if (result !== false) return result;
|
|
17
|
+
}
|
|
18
|
+
if (ch == '"' || ch == "'") {
|
|
19
|
+
state.tokenize = tokenString(ch);
|
|
20
|
+
return state.tokenize(stream, state);
|
|
21
|
+
}
|
|
22
|
+
if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
|
|
23
|
+
curPunc = ch;
|
|
24
|
+
return null
|
|
25
|
+
}
|
|
26
|
+
if (/\d/.test(ch)) {
|
|
27
|
+
stream.eatWhile(/[\w\.]/);
|
|
28
|
+
return "number";
|
|
29
|
+
}
|
|
30
|
+
if (ch == "/") {
|
|
31
|
+
if (stream.eat("*")) {
|
|
32
|
+
state.tokenize = tokenComment;
|
|
33
|
+
return tokenComment(stream, state);
|
|
34
|
+
}
|
|
35
|
+
if (stream.eat("/")) {
|
|
36
|
+
stream.skipToEnd();
|
|
37
|
+
return "comment";
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
if (isOperatorChar.test(ch)) {
|
|
41
|
+
stream.eatWhile(isOperatorChar);
|
|
42
|
+
return "operator";
|
|
43
|
+
}
|
|
44
|
+
stream.eatWhile(/[\w\$_]/);
|
|
45
|
+
var cur = stream.current();
|
|
46
|
+
if (keywords.propertyIsEnumerable(cur)) {
|
|
47
|
+
if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
|
|
48
|
+
return "keyword";
|
|
49
|
+
}
|
|
50
|
+
if (atoms.propertyIsEnumerable(cur)) return "atom";
|
|
51
|
+
return "word";
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function tokenString(quote) {
|
|
55
|
+
return function(stream, state) {
|
|
56
|
+
var escaped = false, next, end = false;
|
|
57
|
+
while ((next = stream.next()) != null) {
|
|
58
|
+
if (next == quote && !escaped) {end = true; break;}
|
|
59
|
+
escaped = !escaped && next == "\\";
|
|
60
|
+
}
|
|
61
|
+
if (end || !(escaped || multiLineStrings))
|
|
62
|
+
state.tokenize = tokenBase;
|
|
63
|
+
return "string";
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function tokenComment(stream, state) {
|
|
68
|
+
var maybeEnd = false, ch;
|
|
69
|
+
while (ch = stream.next()) {
|
|
70
|
+
if (ch == "/" && maybeEnd) {
|
|
71
|
+
state.tokenize = tokenBase;
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
maybeEnd = (ch == "*");
|
|
75
|
+
}
|
|
76
|
+
return "comment";
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function Context(indented, column, type, align, prev) {
|
|
80
|
+
this.indented = indented;
|
|
81
|
+
this.column = column;
|
|
82
|
+
this.type = type;
|
|
83
|
+
this.align = align;
|
|
84
|
+
this.prev = prev;
|
|
85
|
+
}
|
|
86
|
+
function pushContext(state, col, type) {
|
|
87
|
+
return state.context = new Context(state.indented, col, type, null, state.context);
|
|
88
|
+
}
|
|
89
|
+
function popContext(state) {
|
|
90
|
+
var t = state.context.type;
|
|
91
|
+
if (t == ")" || t == "]" || t == "}")
|
|
92
|
+
state.indented = state.context.indented;
|
|
93
|
+
return state.context = state.context.prev;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Interface
|
|
97
|
+
|
|
98
|
+
return {
|
|
99
|
+
startState: function(basecolumn) {
|
|
100
|
+
return {
|
|
101
|
+
tokenize: null,
|
|
102
|
+
context: new Context((basecolumn || 0) - indentUnit, 0, "top", false),
|
|
103
|
+
indented: 0,
|
|
104
|
+
startOfLine: true
|
|
105
|
+
};
|
|
106
|
+
},
|
|
107
|
+
|
|
108
|
+
token: function(stream, state) {
|
|
109
|
+
var ctx = state.context;
|
|
110
|
+
if (stream.sol()) {
|
|
111
|
+
if (ctx.align == null) ctx.align = false;
|
|
112
|
+
state.indented = stream.indentation();
|
|
113
|
+
state.startOfLine = true;
|
|
114
|
+
}
|
|
115
|
+
if (stream.eatSpace()) return null;
|
|
116
|
+
curPunc = null;
|
|
117
|
+
var style = (state.tokenize || tokenBase)(stream, state);
|
|
118
|
+
if (style == "comment" || style == "meta") return style;
|
|
119
|
+
if (ctx.align == null) ctx.align = true;
|
|
120
|
+
|
|
121
|
+
if ((curPunc == ";" || curPunc == ":") && ctx.type == "statement") popContext(state);
|
|
122
|
+
else if (curPunc == "{") pushContext(state, stream.column(), "}");
|
|
123
|
+
else if (curPunc == "[") pushContext(state, stream.column(), "]");
|
|
124
|
+
else if (curPunc == "(") pushContext(state, stream.column(), ")");
|
|
125
|
+
else if (curPunc == "}") {
|
|
126
|
+
while (ctx.type == "statement") ctx = popContext(state);
|
|
127
|
+
if (ctx.type == "}") ctx = popContext(state);
|
|
128
|
+
while (ctx.type == "statement") ctx = popContext(state);
|
|
129
|
+
}
|
|
130
|
+
else if (curPunc == ctx.type) popContext(state);
|
|
131
|
+
else if (ctx.type == "}" || ctx.type == "top" || (ctx.type == "statement" && curPunc == "newstatement"))
|
|
132
|
+
pushContext(state, stream.column(), "statement");
|
|
133
|
+
state.startOfLine = false;
|
|
134
|
+
return style;
|
|
135
|
+
},
|
|
136
|
+
|
|
137
|
+
indent: function(state, textAfter) {
|
|
138
|
+
if (state.tokenize != tokenBase && state.tokenize != null) return 0;
|
|
139
|
+
var firstChar = textAfter && textAfter.charAt(0), ctx = state.context, closing = firstChar == ctx.type;
|
|
140
|
+
if (ctx.type == "statement") return ctx.indented + (firstChar == "{" ? 0 : indentUnit);
|
|
141
|
+
else if (ctx.align) return ctx.column + (closing ? 0 : 1);
|
|
142
|
+
else return ctx.indented + (closing ? 0 : indentUnit);
|
|
143
|
+
},
|
|
144
|
+
|
|
145
|
+
electricChars: "{}"
|
|
146
|
+
};
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
(function() {
|
|
150
|
+
function words(str) {
|
|
151
|
+
var obj = {}, words = str.split(" ");
|
|
152
|
+
for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
|
|
153
|
+
return obj;
|
|
154
|
+
}
|
|
155
|
+
var cKeywords = "auto if break int case long char register continue return default short do sizeof " +
|
|
156
|
+
"double static else struct entry switch extern typedef float union for unsigned " +
|
|
157
|
+
"goto while enum void const signed volatile";
|
|
158
|
+
|
|
159
|
+
function cppHook(stream, state) {
|
|
160
|
+
if (!state.startOfLine) return false;
|
|
161
|
+
stream.skipToEnd();
|
|
162
|
+
return "meta";
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// C#-style strings where "" escapes a quote.
|
|
166
|
+
function tokenAtString(stream, state) {
|
|
167
|
+
var next;
|
|
168
|
+
while ((next = stream.next()) != null) {
|
|
169
|
+
if (next == '"' && !stream.eat('"')) {
|
|
170
|
+
state.tokenize = null;
|
|
171
|
+
break;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
return "string";
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
CodeMirror.defineMIME("text/x-csrc", {
|
|
178
|
+
name: "clike",
|
|
179
|
+
keywords: words(cKeywords),
|
|
180
|
+
blockKeywords: words("case do else for if switch while struct"),
|
|
181
|
+
atoms: words("null"),
|
|
182
|
+
hooks: {"#": cppHook}
|
|
183
|
+
});
|
|
184
|
+
CodeMirror.defineMIME("text/x-c++src", {
|
|
185
|
+
name: "clike",
|
|
186
|
+
keywords: words(cKeywords + " asm dynamic_cast namespace reinterpret_cast try bool explicit new " +
|
|
187
|
+
"static_cast typeid catch operator template typename class friend private " +
|
|
188
|
+
"this using const_cast inline public throw virtual delete mutable protected " +
|
|
189
|
+
"wchar_t"),
|
|
190
|
+
blockKeywords: words("catch class do else finally for if struct switch try while"),
|
|
191
|
+
atoms: words("true false null"),
|
|
192
|
+
hooks: {"#": cppHook}
|
|
193
|
+
});
|
|
194
|
+
CodeMirror.defineMIME("text/x-java", {
|
|
195
|
+
name: "clike",
|
|
196
|
+
keywords: words("abstract assert boolean break byte case catch char class const continue default " +
|
|
197
|
+
"do double else enum extends final finally float for goto if implements import " +
|
|
198
|
+
"instanceof int interface long native new package private protected public " +
|
|
199
|
+
"return short static strictfp super switch synchronized this throw throws transient " +
|
|
200
|
+
"try void volatile while"),
|
|
201
|
+
blockKeywords: words("catch class do else finally for if switch try while"),
|
|
202
|
+
atoms: words("true false null"),
|
|
203
|
+
hooks: {
|
|
204
|
+
"@": function(stream, state) {
|
|
205
|
+
stream.eatWhile(/[\w\$_]/);
|
|
206
|
+
return "meta";
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
CodeMirror.defineMIME("text/x-csharp", {
|
|
211
|
+
name: "clike",
|
|
212
|
+
keywords: words("abstract as base bool break byte case catch char checked class const continue decimal" +
|
|
213
|
+
" default delegate do double else enum event explicit extern finally fixed float for" +
|
|
214
|
+
" foreach goto if implicit in int interface internal is lock long namespace new object" +
|
|
215
|
+
" operator out override params private protected public readonly ref return sbyte sealed short" +
|
|
216
|
+
" sizeof stackalloc static string struct switch this throw try typeof uint ulong unchecked" +
|
|
217
|
+
" unsafe ushort using virtual void volatile while add alias ascending descending dynamic from get" +
|
|
218
|
+
" global group into join let orderby partial remove select set value var yield"),
|
|
219
|
+
blockKeywords: words("catch class do else finally for foreach if struct switch try while"),
|
|
220
|
+
atoms: words("true false null"),
|
|
221
|
+
hooks: {
|
|
222
|
+
"@": function(stream, state) {
|
|
223
|
+
if (stream.eat('"')) {
|
|
224
|
+
state.tokenize = tokenAtString;
|
|
225
|
+
return tokenAtString(stream, state);
|
|
226
|
+
}
|
|
227
|
+
stream.eatWhile(/[\w\$_]/);
|
|
228
|
+
return "meta";
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
CodeMirror.defineMIME("text/x-groovy", {
|
|
233
|
+
name: "clike",
|
|
234
|
+
keywords: words("abstract as assert boolean break byte case catch char class const continue def default " +
|
|
235
|
+
"do double else enum extends final finally float for goto if implements import " +
|
|
236
|
+
"in instanceof int interface long native new package property private protected public " +
|
|
237
|
+
"return short static strictfp super switch synchronized this throw throws transient " +
|
|
238
|
+
"try void volatile while"),
|
|
239
|
+
atoms: words("true false null"),
|
|
240
|
+
hooks: {
|
|
241
|
+
"@": function(stream, state) {
|
|
242
|
+
stream.eatWhile(/[\w\$_]/);
|
|
243
|
+
return "meta";
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
});
|
|
247
|
+
}());
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title>CodeMirror 2: C-like mode</title>
|
|
5
|
+
<link rel="stylesheet" href="../../lib/codemirror.css">
|
|
6
|
+
<script src="../../lib/codemirror.js"></script>
|
|
7
|
+
<script src="clike.js"></script>
|
|
8
|
+
<link rel="stylesheet" href="../../theme/default.css">
|
|
9
|
+
<link rel="stylesheet" href="../../css/docs.css">
|
|
10
|
+
<style>.CodeMirror {border: 2px inset #dee;}</style>
|
|
11
|
+
</head>
|
|
12
|
+
<body>
|
|
13
|
+
<h1>CodeMirror 2: C-like mode</h1>
|
|
14
|
+
|
|
15
|
+
<form><textarea id="code" name="code">
|
|
16
|
+
/* C demo code */
|
|
17
|
+
|
|
18
|
+
#include <zmq.h>
|
|
19
|
+
#include <pthread.h>
|
|
20
|
+
#include <semaphore.h>
|
|
21
|
+
#include <time.h>
|
|
22
|
+
#include <stdio.h>
|
|
23
|
+
#include <fcntl.h>
|
|
24
|
+
#include <malloc.h>
|
|
25
|
+
|
|
26
|
+
typedef struct {
|
|
27
|
+
void* arg_socket;
|
|
28
|
+
zmq_msg_t* arg_msg;
|
|
29
|
+
char* arg_string;
|
|
30
|
+
unsigned long arg_len;
|
|
31
|
+
int arg_int, arg_command;
|
|
32
|
+
|
|
33
|
+
int signal_fd;
|
|
34
|
+
int pad;
|
|
35
|
+
void* context;
|
|
36
|
+
sem_t sem;
|
|
37
|
+
} acl_zmq_context;
|
|
38
|
+
|
|
39
|
+
#define p(X) (context->arg_##X)
|
|
40
|
+
|
|
41
|
+
void* zmq_thread(void* context_pointer) {
|
|
42
|
+
acl_zmq_context* context = (acl_zmq_context*)context_pointer;
|
|
43
|
+
char ok = 'K', err = 'X';
|
|
44
|
+
int res;
|
|
45
|
+
|
|
46
|
+
while (1) {
|
|
47
|
+
while ((res = sem_wait(&context->sem)) == EINTR);
|
|
48
|
+
if (res) {write(context->signal_fd, &err, 1); goto cleanup;}
|
|
49
|
+
switch(p(command)) {
|
|
50
|
+
case 0: goto cleanup;
|
|
51
|
+
case 1: p(socket) = zmq_socket(context->context, p(int)); break;
|
|
52
|
+
case 2: p(int) = zmq_close(p(socket)); break;
|
|
53
|
+
case 3: p(int) = zmq_bind(p(socket), p(string)); break;
|
|
54
|
+
case 4: p(int) = zmq_connect(p(socket), p(string)); break;
|
|
55
|
+
case 5: p(int) = zmq_getsockopt(p(socket), p(int), (void*)p(string), &p(len)); break;
|
|
56
|
+
case 6: p(int) = zmq_setsockopt(p(socket), p(int), (void*)p(string), p(len)); break;
|
|
57
|
+
case 7: p(int) = zmq_send(p(socket), p(msg), p(int)); break;
|
|
58
|
+
case 8: p(int) = zmq_recv(p(socket), p(msg), p(int)); break;
|
|
59
|
+
case 9: p(int) = zmq_poll(p(socket), p(int), p(len)); break;
|
|
60
|
+
}
|
|
61
|
+
p(command) = errno;
|
|
62
|
+
write(context->signal_fd, &ok, 1);
|
|
63
|
+
}
|
|
64
|
+
cleanup:
|
|
65
|
+
close(context->signal_fd);
|
|
66
|
+
free(context_pointer);
|
|
67
|
+
return 0;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
void* zmq_thread_init(void* zmq_context, int signal_fd) {
|
|
71
|
+
acl_zmq_context* context = malloc(sizeof(acl_zmq_context));
|
|
72
|
+
pthread_t thread;
|
|
73
|
+
|
|
74
|
+
context->context = zmq_context;
|
|
75
|
+
context->signal_fd = signal_fd;
|
|
76
|
+
sem_init(&context->sem, 1, 0);
|
|
77
|
+
pthread_create(&thread, 0, &zmq_thread, context);
|
|
78
|
+
pthread_detach(thread);
|
|
79
|
+
return context;
|
|
80
|
+
}
|
|
81
|
+
</textarea></form>
|
|
82
|
+
|
|
83
|
+
<script>
|
|
84
|
+
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
|
85
|
+
lineNumbers: true,
|
|
86
|
+
matchBrackets: true,
|
|
87
|
+
mode: "text/x-csrc"
|
|
88
|
+
});
|
|
89
|
+
</script>
|
|
90
|
+
|
|
91
|
+
<p>Simple mode that tries to handle C-like languages as well as it
|
|
92
|
+
can. Takes two configuration parameters: <code>keywords</code>, an
|
|
93
|
+
object whose property names are the keywords in the language,
|
|
94
|
+
and <code>useCPP</code>, which determines whether C preprocessor
|
|
95
|
+
directives are recognized.</p>
|
|
96
|
+
|
|
97
|
+
<p><strong>MIME types defined:</strong> <code>text/x-csrc</code>
|
|
98
|
+
(C code), <code>text/x-c++src</code> (C++
|
|
99
|
+
code), <code>text/x-java</code> (Java
|
|
100
|
+
code), <code>text/x-groovy</code> (Groovy code).</p>
|
|
101
|
+
</body>
|
|
102
|
+
</html>
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Author: Hans Engel
|
|
3
|
+
* Branched from CodeMirror's Scheme mode (by Koh Zi Han, based on implementation by Koh Zi Chun)
|
|
4
|
+
*/
|
|
5
|
+
CodeMirror.defineMode("clojure", function (config, mode) {
|
|
6
|
+
var BUILTIN = "builtin", COMMENT = "comment", STRING = "string", TAG = "tag",
|
|
7
|
+
ATOM = "atom", NUMBER = "number", BRACKET = "bracket", KEYWORD="keyword";
|
|
8
|
+
var INDENT_WORD_SKIP = 2, KEYWORDS_SKIP = 1;
|
|
9
|
+
|
|
10
|
+
function makeKeywords(str) {
|
|
11
|
+
var obj = {}, words = str.split(" ");
|
|
12
|
+
for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
|
|
13
|
+
return obj;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
var atoms = makeKeywords("true false nil");
|
|
17
|
+
|
|
18
|
+
var keywords = makeKeywords(
|
|
19
|
+
// Control structures
|
|
20
|
+
"defn defn- def def- defonce defmulti defmethod defmacro defstruct deftype defprotocol defrecord deftest slice defalias defhinted defmacro- defn-memo defnk defnk defonce- defunbound defunbound- defvar defvar- let letfn do case cond condp for loop recur when when-not when-let when-first if if-let if-not . .. -> ->> doto and or dosync doseq dotimes dorun doall load import unimport ns in-ns refer try catch finally throw with-open with-local-vars binding gen-class gen-and-load-class gen-and-save-class handler-case handle" +
|
|
21
|
+
|
|
22
|
+
// Built-ins
|
|
23
|
+
"* *1 *2 *3 *agent* *allow-unresolved-vars* *assert *clojure-version* *command-line-args* *compile-files* *compile-path* *e *err* *file* *flush-on-newline* *in* *macro-meta* *math-context* *ns* *out* *print-dup* *print-length* *print-level* *print-meta* *print-readably* *read-eval* *source-path* *use-context-classloader* *warn-on-reflection* + - / < <= = == > >= accessor aclone agent agent-errors aget alength alias all-ns alter alter-meta! alter-var-root amap ancestors and apply areduce array-map aset aset-boolean aset-byte aset-char aset-double aset-float aset-int aset-long aset-short assert assoc assoc! assoc-in associative? atom await await-for await1 bases bean bigdec bigint binding bit-and bit-and-not bit-clear bit-flip bit-not bit-or bit-set bit-shift-left bit-shift-right bit-test bit-xor boolean boolean-array booleans bound-fn bound-fn* butlast byte byte-array bytes case cast char char-array char-escape-string char-name-string char? chars chunk chunk-append chunk-buffer chunk-cons chunk-first chunk-next chunk-rest chunked-seq? class class? clear-agent-errors clojure-version coll? comment commute comp comparator compare compare-and-set! compile complement concat cond condp conj conj! cons constantly construct-proxy contains? count counted? create-ns create-struct cycle dec decimal? declare definline defmacro defmethod defmulti defn defn- defonce defstruct delay delay? deliver deref derive descendants destructure disj disj! dissoc dissoc! distinct distinct? doall doc dorun doseq dosync dotimes doto double double-array doubles drop drop-last drop-while empty empty? ensure enumeration-seq eval even? every? extend extend-protocol extend-type extends? extenders false? ffirst file-seq filter find find-doc find-ns find-var first float float-array float? floats flush fn fn? fnext for force format future future-call future-cancel future-cancelled? future-done? future? gen-class gen-interface gensym get get-in get-method get-proxy-class get-thread-bindings get-validator hash hash-map hash-set identical? identity if-let if-not ifn? import in-ns inc init-proxy instance? int int-array integer? interleave intern interpose into into-array ints io! isa? iterate iterator-seq juxt key keys keyword keyword? last lazy-cat lazy-seq let letfn line-seq list list* list? load load-file load-reader load-string loaded-libs locking long long-array longs loop macroexpand macroexpand-1 make-array make-hierarchy map map? mapcat max max-key memfn memoize merge merge-with meta method-sig methods min min-key mod name namespace neg? newline next nfirst nil? nnext not not-any? not-empty not-every? not= ns ns-aliases ns-imports ns-interns ns-map ns-name ns-publics ns-refers ns-resolve ns-unalias ns-unmap nth nthnext num number? odd? or parents partial partition pcalls peek persistent! pmap pop pop! pop-thread-bindings pos? pr pr-str prefer-method prefers primitives-classnames print print-ctor print-doc print-dup print-method print-namespace-doc print-simple print-special-doc print-str printf println println-str prn prn-str promise proxy proxy-call-with-super proxy-mappings proxy-name proxy-super push-thread-bindings pvalues quot rand rand-int range ratio? rational? rationalize re-find re-groups re-matcher re-matches re-pattern re-seq read read-line read-string reify reduce ref ref-history-count ref-max-history ref-min-history ref-set refer refer-clojure release-pending-sends rem remove remove-method remove-ns repeat repeatedly replace replicate require reset! reset-meta! resolve rest resultset-seq reverse reversible? rseq rsubseq satisfies? second select-keys send send-off seq seq? seque sequence sequential? set set-validator! set? short short-array shorts shutdown-agents slurp some sort sort-by sorted-map sorted-map-by sorted-set sorted-set-by sorted? special-form-anchor special-symbol? split-at split-with str stream? string? struct struct-map subs subseq subvec supers swap! symbol symbol? sync syntax-symbol-anchor take take-last take-nth take-while test the-ns time to-array to-array-2d trampoline transient tree-seq true? type unchecked-add unchecked-dec unchecked-divide unchecked-inc unchecked-multiply unchecked-negate unchecked-remainder unchecked-subtract underive unquote unquote-splicing update-in update-proxy use val vals var-get var-set var? vary-meta vec vector vector? when when-first when-let when-not while with-bindings with-bindings* with-in-str with-loading-context with-local-vars with-meta with-open with-out-str with-precision xml-seq");
|
|
24
|
+
|
|
25
|
+
var indentKeys = makeKeywords(
|
|
26
|
+
// Built-ins
|
|
27
|
+
"ns fn def defn defmethod bound-fn if if-not case condp when while when-not when-first do future comment doto locking proxy with-open with-precision reify deftype defrecord defprotocol extend extend-protocol extend-type try catch" +
|
|
28
|
+
|
|
29
|
+
// Binding forms
|
|
30
|
+
"let letfn binding loop for doseq dotimes when-let if-let" +
|
|
31
|
+
|
|
32
|
+
// Data structures
|
|
33
|
+
"defstruct struct-map assoc" +
|
|
34
|
+
|
|
35
|
+
// clojure.test
|
|
36
|
+
"testing deftest" +
|
|
37
|
+
|
|
38
|
+
// contrib
|
|
39
|
+
"handler-case handle dotrace deftrace");
|
|
40
|
+
|
|
41
|
+
var tests = {
|
|
42
|
+
digit: /\d/,
|
|
43
|
+
digit_or_colon: /[\d:]/,
|
|
44
|
+
hex: /[0-9a-fA-F]/,
|
|
45
|
+
sign: /[+-]/,
|
|
46
|
+
exponent: /[eE]/,
|
|
47
|
+
keyword_char: /[^\s\(\[\;\)\]]/,
|
|
48
|
+
basic: /[\w\$_\-]/,
|
|
49
|
+
lang_keyword: /[\w*+!\-_?:\/]/
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
function stateStack(indent, type, prev) { // represents a state stack object
|
|
53
|
+
this.indent = indent;
|
|
54
|
+
this.type = type;
|
|
55
|
+
this.prev = prev;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function pushStack(state, indent, type) {
|
|
59
|
+
state.indentStack = new stateStack(indent, type, state.indentStack);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function popStack(state) {
|
|
63
|
+
state.indentStack = state.indentStack.prev;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function isNumber(ch, stream){
|
|
67
|
+
// hex
|
|
68
|
+
if ( ch === '0' && 'x' == stream.peek().toLowerCase() ) {
|
|
69
|
+
stream.eat('x');
|
|
70
|
+
stream.eatWhile(tests.hex);
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// leading sign
|
|
75
|
+
if ( ch == '+' || ch == '-' ) {
|
|
76
|
+
stream.eat(tests.sign);
|
|
77
|
+
ch = stream.next();
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if ( tests.digit.test(ch) ) {
|
|
81
|
+
stream.eat(ch);
|
|
82
|
+
stream.eatWhile(tests.digit);
|
|
83
|
+
|
|
84
|
+
if ( '.' == stream.peek() ) {
|
|
85
|
+
stream.eat('.');
|
|
86
|
+
stream.eatWhile(tests.digit);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if ( 'e' == stream.peek().toLowerCase() ) {
|
|
90
|
+
stream.eat(tests.exponent);
|
|
91
|
+
stream.eat(tests.sign);
|
|
92
|
+
stream.eatWhile(tests.digit);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return {
|
|
102
|
+
startState: function () {
|
|
103
|
+
return {
|
|
104
|
+
indentStack: null,
|
|
105
|
+
indentation: 0,
|
|
106
|
+
mode: false,
|
|
107
|
+
};
|
|
108
|
+
},
|
|
109
|
+
|
|
110
|
+
token: function (stream, state) {
|
|
111
|
+
if (state.indentStack == null && stream.sol()) {
|
|
112
|
+
// update indentation, but only if indentStack is empty
|
|
113
|
+
state.indentation = stream.indentation();
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// skip spaces
|
|
117
|
+
if (stream.eatSpace()) {
|
|
118
|
+
return null;
|
|
119
|
+
}
|
|
120
|
+
var returnType = null;
|
|
121
|
+
|
|
122
|
+
switch(state.mode){
|
|
123
|
+
case "string": // multi-line string parsing mode
|
|
124
|
+
var next, escaped = false;
|
|
125
|
+
while ((next = stream.next()) != null) {
|
|
126
|
+
if (next == "\"" && !escaped) {
|
|
127
|
+
|
|
128
|
+
state.mode = false;
|
|
129
|
+
break;
|
|
130
|
+
}
|
|
131
|
+
escaped = !escaped && next == "\\";
|
|
132
|
+
}
|
|
133
|
+
returnType = STRING; // continue on in string mode
|
|
134
|
+
break;
|
|
135
|
+
default: // default parsing mode
|
|
136
|
+
var ch = stream.next();
|
|
137
|
+
|
|
138
|
+
if (ch == "\"") {
|
|
139
|
+
state.mode = "string";
|
|
140
|
+
returnType = STRING;
|
|
141
|
+
} else if (ch == "'" && !( tests.digit_or_colon.test(stream.peek()) )) {
|
|
142
|
+
returnType = ATOM;
|
|
143
|
+
} else if (ch == ";") { // comment
|
|
144
|
+
stream.skipToEnd(); // rest of the line is a comment
|
|
145
|
+
returnType = COMMENT;
|
|
146
|
+
} else if (isNumber(ch,stream)){
|
|
147
|
+
returnType = NUMBER;
|
|
148
|
+
} else if (ch == "(" || ch == "[") {
|
|
149
|
+
var keyWord = ''; var indentTemp = stream.column();
|
|
150
|
+
/**
|
|
151
|
+
Either
|
|
152
|
+
(indent-word ..
|
|
153
|
+
(non-indent-word ..
|
|
154
|
+
(;something else, bracket, etc.
|
|
155
|
+
*/
|
|
156
|
+
|
|
157
|
+
while ((letter = stream.eat(tests.keyword_char)) != null) {
|
|
158
|
+
keyWord += letter;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
if (keyWord.length > 0 && indentKeys.propertyIsEnumerable(keyWord)) { // indent-word
|
|
162
|
+
|
|
163
|
+
pushStack(state, indentTemp + INDENT_WORD_SKIP, ch);
|
|
164
|
+
} else { // non-indent word
|
|
165
|
+
// we continue eating the spaces
|
|
166
|
+
stream.eatSpace();
|
|
167
|
+
if (stream.eol() || stream.peek() == ";") {
|
|
168
|
+
// nothing significant after
|
|
169
|
+
// we restart indentation 1 space after
|
|
170
|
+
pushStack(state, indentTemp + 1, ch);
|
|
171
|
+
} else {
|
|
172
|
+
pushStack(state, indentTemp + stream.current().length, ch); // else we match
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
stream.backUp(stream.current().length - 1); // undo all the eating
|
|
176
|
+
|
|
177
|
+
returnType = BRACKET;
|
|
178
|
+
} else if (ch == ")" || ch == "]") {
|
|
179
|
+
returnType = BRACKET;
|
|
180
|
+
if (state.indentStack != null && state.indentStack.type == (ch == ")" ? "(" : "[")) {
|
|
181
|
+
popStack(state);
|
|
182
|
+
}
|
|
183
|
+
} else if ( ch == ":" ) {
|
|
184
|
+
stream.eatWhile(tests.lang_keyword);
|
|
185
|
+
return TAG;
|
|
186
|
+
} else {
|
|
187
|
+
stream.eatWhile(tests.basic);
|
|
188
|
+
|
|
189
|
+
if (keywords && keywords.propertyIsEnumerable(stream.current())) {
|
|
190
|
+
returnType = BUILTIN;
|
|
191
|
+
} else if ( atoms && atoms.propertyIsEnumerable(stream.current()) ) {
|
|
192
|
+
returnType = ATOM;
|
|
193
|
+
} else returnType = null;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
return returnType;
|
|
198
|
+
},
|
|
199
|
+
|
|
200
|
+
indent: function (state, textAfter) {
|
|
201
|
+
if (state.indentStack == null) return state.indentation;
|
|
202
|
+
return state.indentStack.indent;
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
CodeMirror.defineMIME("text/x-clojure", "clojure");
|