codemirror-rails 0.1.1 → 0.1.2

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.
Files changed (28) hide show
  1. data/codemirror-rails-0.0.0.gem +0 -0
  2. data/codemirror-rails-0.1.gem +0 -0
  3. data/lib/codemirror/rails/version.rb +2 -2
  4. data/vendor/assets/javascripts/codemirror.js +122 -63
  5. data/vendor/assets/javascripts/codemirror/modes/clike.js +221 -0
  6. data/vendor/assets/javascripts/codemirror/modes/css.js +124 -0
  7. data/vendor/assets/javascripts/codemirror/modes/diff.js +13 -0
  8. data/vendor/assets/javascripts/codemirror/modes/haskell.js +242 -0
  9. data/vendor/assets/javascripts/codemirror/modes/htmlmixed.js +79 -0
  10. data/vendor/assets/javascripts/codemirror/modes/javascript.js +348 -0
  11. data/vendor/assets/javascripts/codemirror/modes/lua.js +138 -0
  12. data/vendor/assets/javascripts/codemirror/modes/php.js +111 -0
  13. data/vendor/assets/javascripts/codemirror/modes/plsql.js +217 -0
  14. data/vendor/assets/javascripts/codemirror/modes/python.js +321 -0
  15. data/vendor/assets/javascripts/codemirror/modes/rst.js +333 -0
  16. data/vendor/assets/javascripts/codemirror/modes/scheme.js +181 -0
  17. data/vendor/assets/javascripts/codemirror/modes/smalltalk.js +122 -0
  18. data/vendor/assets/javascripts/codemirror/modes/stex.js +167 -0
  19. data/vendor/assets/javascripts/codemirror/modes/xml.js +227 -0
  20. data/vendor/assets/javascripts/codemirror/modes/yaml.js +95 -0
  21. data/vendor/assets/javascripts/codemirror/overlay.js +51 -0
  22. data/vendor/assets/javascripts/codemirror/runmode.js +27 -0
  23. data/vendor/assets/stylesheets/codemirror.css +3 -0
  24. data/vendor/assets/stylesheets/codemirror/modes/clike.css +7 -0
  25. data/vendor/assets/stylesheets/codemirror/modes/diff.css +3 -0
  26. data/vendor/assets/stylesheets/codemirror/modes/rst.css +75 -0
  27. metadata +25 -3
  28. data/codemirror-rails-0.1.1.gem +0 -0
@@ -0,0 +1,122 @@
1
+ CodeMirror.defineMode("smalltalk", function(config, parserConfig) {
2
+ var keywords = {"true": 1, "false": 1, nil: 1, self: 1, "super": 1, thisContext: 1};
3
+ var indentUnit = config.indentUnit;
4
+
5
+ function chain(stream, state, f) {
6
+ state.tokenize = f;
7
+ return f(stream, state);
8
+ }
9
+
10
+ var type;
11
+ function ret(tp, style) {
12
+ type = tp;
13
+ return style;
14
+ }
15
+
16
+ function tokenBase(stream, state) {
17
+ var ch = stream.next();
18
+ if (ch == '"')
19
+ return chain(stream, state, tokenComment(ch));
20
+ else if (ch == "'")
21
+ return chain(stream, state, tokenString(ch));
22
+ else if (ch == "#") {
23
+ stream.eatWhile(/[\w\$_]/);
24
+ return ret("string", "string");
25
+ }
26
+ else if (/\d/.test(ch)) {
27
+ stream.eatWhile(/[\w\.]/)
28
+ return ret("number", "number");
29
+ }
30
+ else if (/[\[\]()]/.test(ch)) {
31
+ return ret(ch, null);
32
+ }
33
+ else {
34
+ stream.eatWhile(/[\w\$_]/);
35
+ if (keywords && keywords.propertyIsEnumerable(stream.current())) return ret("keyword", "keyword");
36
+ return ret("word", "variable");
37
+ }
38
+ }
39
+
40
+ function tokenString(quote) {
41
+ return function(stream, state) {
42
+ var escaped = false, next, end = false;
43
+ while ((next = stream.next()) != null) {
44
+ if (next == quote && !escaped) {end = true; break;}
45
+ escaped = !escaped && next == "\\";
46
+ }
47
+ if (end || !(escaped))
48
+ state.tokenize = tokenBase;
49
+ return ret("string", "string");
50
+ };
51
+ }
52
+
53
+ function tokenComment(quote) {
54
+ return function(stream, state) {
55
+ var next, end = false;
56
+ while ((next = stream.next()) != null) {
57
+ if (next == quote) {end = true; break;}
58
+ }
59
+ if (end)
60
+ state.tokenize = tokenBase;
61
+ return ret("comment", "comment");
62
+ };
63
+ }
64
+
65
+ function Context(indented, column, type, align, prev) {
66
+ this.indented = indented;
67
+ this.column = column;
68
+ this.type = type;
69
+ this.align = align;
70
+ this.prev = prev;
71
+ }
72
+
73
+ function pushContext(state, col, type) {
74
+ return state.context = new Context(state.indented, col, type, null, state.context);
75
+ }
76
+ function popContext(state) {
77
+ return state.context = state.context.prev;
78
+ }
79
+
80
+ // Interface
81
+
82
+ return {
83
+ startState: function(basecolumn) {
84
+ return {
85
+ tokenize: tokenBase,
86
+ context: new Context((basecolumn || 0) - indentUnit, 0, "top", false),
87
+ indented: 0,
88
+ startOfLine: true
89
+ };
90
+ },
91
+
92
+ token: function(stream, state) {
93
+ var ctx = state.context;
94
+ if (stream.sol()) {
95
+ if (ctx.align == null) ctx.align = false;
96
+ state.indented = stream.indentation();
97
+ state.startOfLine = true;
98
+ }
99
+ if (stream.eatSpace()) return null;
100
+ var style = state.tokenize(stream, state);
101
+ if (type == "comment") return style;
102
+ if (ctx.align == null) ctx.align = true;
103
+
104
+ if (type == "[") pushContext(state, stream.column(), "]");
105
+ else if (type == "(") pushContext(state, stream.column(), ")");
106
+ else if (type == ctx.type) popContext(state);
107
+ state.startOfLine = false;
108
+ return style;
109
+ },
110
+
111
+ indent: function(state, textAfter) {
112
+ if (state.tokenize != tokenBase) return 0;
113
+ var firstChar = textAfter && textAfter.charAt(0), ctx = state.context, closing = firstChar == ctx.type;
114
+ if (ctx.align) return ctx.column + (closing ? 0 : 1);
115
+ else return ctx.indented + (closing ? 0 : indentUnit);
116
+ },
117
+
118
+ electricChars: "]"
119
+ };
120
+ });
121
+
122
+ CodeMirror.defineMIME("text/x-stsrc", {name: "smalltalk"});
@@ -0,0 +1,167 @@
1
+ /*
2
+ * Author: Constantin Jucovschi (c.jucovschi@jacobs-university.de)
3
+ * Licence: MIT
4
+ */
5
+
6
+ CodeMirror.defineMode("stex", function(cmCfg, modeCfg)
7
+ {
8
+ function pushCommand(state, command) {
9
+ state.cmdState.push(command);
10
+ }
11
+
12
+ function peekCommand(state) {
13
+ if (state.cmdState.length>0)
14
+ return state.cmdState[state.cmdState.length-1];
15
+ else
16
+ return null;
17
+ }
18
+
19
+ function popCommand(state) {
20
+ if (state.cmdState.length>0) {
21
+ var plug = state.cmdState.pop();
22
+ plug.closeBracket();
23
+ }
24
+ }
25
+
26
+ function applyMostPowerful(state) {
27
+ var context = state.cmdState;
28
+ for (var i = context.length - 1; i >= 0; i--) {
29
+ var plug = context[i];
30
+ if (plug.name=="DEFAULT")
31
+ continue;
32
+ return plug.styleIdentifier();
33
+ }
34
+ return null;
35
+ }
36
+
37
+ function addPluginPattern(pluginName, cmdStyle, brackets, styles) {
38
+ return function () {
39
+ this.name=pluginName;
40
+ this.bracketNo = 0;
41
+ this.style=cmdStyle;
42
+ this.styles = styles;
43
+ this.brackets = brackets;
44
+
45
+ this.styleIdentifier = function(content) {
46
+ if (this.bracketNo<=this.styles.length)
47
+ return this.styles[this.bracketNo-1];
48
+ else
49
+ return null;
50
+ };
51
+ this.openBracket = function(content) {
52
+ this.bracketNo++;
53
+ return "bracket";
54
+ };
55
+ this.closeBracket = function(content) {
56
+ };
57
+ }
58
+ }
59
+
60
+ var plugins = new Array();
61
+
62
+ plugins["importmodule"] = addPluginPattern("importmodule", "tag", "{[", ["string", "builtin"]);
63
+ plugins["documentclass"] = addPluginPattern("documentclass", "tag", "{[", ["", "atom"]);
64
+ plugins["usepackage"] = addPluginPattern("documentclass", "tag", "[", ["atom"]);
65
+ plugins["begin"] = addPluginPattern("documentclass", "tag", "[", ["atom"]);
66
+ plugins["end"] = addPluginPattern("documentclass", "tag", "[", ["atom"]);
67
+
68
+ plugins["DEFAULT"] = function () {
69
+ this.name="DEFAULT";
70
+ this.style="tag";
71
+
72
+ this.styleIdentifier = function(content) {
73
+ };
74
+ this.openBracket = function(content) {
75
+ };
76
+ this.closeBracket = function(content) {
77
+ };
78
+ };
79
+
80
+ function setState(state, f) {
81
+ state.f = f;
82
+ }
83
+
84
+ function normal(source, state) {
85
+ if (source.match(/^\\[a-z]+/)) {
86
+ var cmdName = source.current();
87
+ cmdName = cmdName.substr(1, cmdName.length-1);
88
+ var plug = plugins[cmdName];
89
+ if (typeof(plug) == 'undefined') {
90
+ plug = plugins["DEFAULT"];
91
+ }
92
+ plug = new plug();
93
+ pushCommand(state, plug);
94
+ setState(state, beginParams);
95
+ return plug.style;
96
+ }
97
+
98
+ var ch = source.next();
99
+ if (ch == "%") {
100
+ setState(state, inCComment);
101
+ return "comment";
102
+ }
103
+ else if (ch=='}' || ch==']') {
104
+ plug = peekCommand(state);
105
+ if (plug) {
106
+ plug.closeBracket(ch);
107
+ setState(state, beginParams);
108
+ } else
109
+ return "error";
110
+ return "bracket";
111
+ } else if (ch=='{' || ch=='[') {
112
+ plug = plugins["DEFAULT"];
113
+ plug = new plug();
114
+ pushCommand(state, plug);
115
+ return "bracket";
116
+ }
117
+ else if (/\d/.test(ch)) {
118
+ source.eatWhile(/[\w.%]/);
119
+ return "atom";
120
+ }
121
+ else {
122
+ source.eatWhile(/[\w-_]/);
123
+ return applyMostPowerful(state);
124
+ }
125
+ }
126
+
127
+ function inCComment(source, state) {
128
+ source.skipToEnd();
129
+ setState(state, normal);
130
+ return "comment";
131
+ }
132
+
133
+ function beginParams(source, state) {
134
+ var ch = source.peek();
135
+ if (ch == '{' || ch == '[') {
136
+ var lastPlug = peekCommand(state);
137
+ var style = lastPlug.openBracket(ch);
138
+ source.eat(ch);
139
+ setState(state, normal);
140
+ return "bracket";
141
+ }
142
+ if (/[ \t\r]/.test(ch)) {
143
+ source.eat(ch);
144
+ return null;
145
+ }
146
+ setState(state, normal);
147
+ lastPlug = peekCommand(state);
148
+ if (lastPlug) {
149
+ popCommand(state);
150
+ }
151
+ return normal(source, state);
152
+ }
153
+
154
+ return {
155
+ startState: function() { return { f:normal, cmdState:[] }; },
156
+ copyState: function(s) { return { f: s.f, cmdState: s.cmdState.slice(0, s.cmdState.length) }; },
157
+
158
+ token: function(stream, state) {
159
+ var t = state.f(stream, state);
160
+ var w = stream.current();
161
+ return t;
162
+ }
163
+ };
164
+ });
165
+
166
+
167
+ CodeMirror.defineMIME("text/x-stex", "stex");
@@ -0,0 +1,227 @@
1
+ CodeMirror.defineMode("xml", function(config, parserConfig) {
2
+ var indentUnit = config.indentUnit;
3
+ var Kludges = parserConfig.htmlMode ? {
4
+ autoSelfClosers: {"br": true, "img": true, "hr": true, "link": true, "input": true,
5
+ "meta": true, "col": true, "frame": true, "base": true, "area": true},
6
+ doNotIndent: {"pre": true, "!cdata": true},
7
+ allowUnquoted: true
8
+ } : {autoSelfClosers: {}, doNotIndent: {"!cdata": true}, allowUnquoted: false};
9
+ var alignCDATA = parserConfig.alignCDATA;
10
+
11
+ // Return variables for tokenizers
12
+ var tagName, type;
13
+
14
+ function inText(stream, state) {
15
+ function chain(parser) {
16
+ state.tokenize = parser;
17
+ return parser(stream, state);
18
+ }
19
+
20
+ var ch = stream.next();
21
+ if (ch == "<") {
22
+ if (stream.eat("!")) {
23
+ if (stream.eat("[")) {
24
+ if (stream.match("CDATA[")) return chain(inBlock("atom", "]]>"));
25
+ else return null;
26
+ }
27
+ else if (stream.match("--")) return chain(inBlock("comment", "-->"));
28
+ else if (stream.match("DOCTYPE")) {
29
+ stream.eatWhile(/[\w\._\-]/);
30
+ return chain(inBlock("meta", ">"));
31
+ }
32
+ else return null;
33
+ }
34
+ else if (stream.eat("?")) {
35
+ stream.eatWhile(/[\w\._\-]/);
36
+ state.tokenize = inBlock("meta", "?>");
37
+ return "meta";
38
+ }
39
+ else {
40
+ type = stream.eat("/") ? "closeTag" : "openTag";
41
+ stream.eatSpace();
42
+ tagName = "";
43
+ var c;
44
+ while ((c = stream.eat(/[^\s\u00a0=<>\"\'\/?]/))) tagName += c;
45
+ state.tokenize = inTag;
46
+ return "tag";
47
+ }
48
+ }
49
+ else if (ch == "&") {
50
+ stream.eatWhile(/[^;]/);
51
+ stream.eat(";");
52
+ return "atom";
53
+ }
54
+ else {
55
+ stream.eatWhile(/[^&<]/);
56
+ return null;
57
+ }
58
+ }
59
+
60
+ function inTag(stream, state) {
61
+ var ch = stream.next();
62
+ if (ch == ">" || (ch == "/" && stream.eat(">"))) {
63
+ state.tokenize = inText;
64
+ type = ch == ">" ? "endTag" : "selfcloseTag";
65
+ return "tag";
66
+ }
67
+ else if (ch == "=") {
68
+ type = "equals";
69
+ return null;
70
+ }
71
+ else if (/[\'\"]/.test(ch)) {
72
+ state.tokenize = inAttribute(ch);
73
+ return state.tokenize(stream, state);
74
+ }
75
+ else {
76
+ stream.eatWhile(/[^\s\u00a0=<>\"\'\/?]/);
77
+ return "word";
78
+ }
79
+ }
80
+
81
+ function inAttribute(quote) {
82
+ return function(stream, state) {
83
+ while (!stream.eol()) {
84
+ if (stream.next() == quote) {
85
+ state.tokenize = inTag;
86
+ break;
87
+ }
88
+ }
89
+ return "string";
90
+ };
91
+ }
92
+
93
+ function inBlock(style, terminator) {
94
+ return function(stream, state) {
95
+ while (!stream.eol()) {
96
+ if (stream.match(terminator)) {
97
+ state.tokenize = inText;
98
+ break;
99
+ }
100
+ stream.next();
101
+ }
102
+ return style;
103
+ };
104
+ }
105
+
106
+ var curState, setStyle;
107
+ function pass() {
108
+ for (var i = arguments.length - 1; i >= 0; i--) curState.cc.push(arguments[i]);
109
+ }
110
+ function cont() {
111
+ pass.apply(null, arguments);
112
+ return true;
113
+ }
114
+
115
+ function pushContext(tagName, startOfLine) {
116
+ var noIndent = Kludges.doNotIndent.hasOwnProperty(tagName) || (curState.context && curState.context.noIndent);
117
+ curState.context = {
118
+ prev: curState.context,
119
+ tagName: tagName,
120
+ indent: curState.indented,
121
+ startOfLine: startOfLine,
122
+ noIndent: noIndent
123
+ };
124
+ }
125
+ function popContext() {
126
+ if (curState.context) curState.context = curState.context.prev;
127
+ }
128
+
129
+ function element(type) {
130
+ if (type == "openTag") {curState.tagName = tagName; return cont(attributes, endtag(curState.startOfLine));}
131
+ else if (type == "closeTag") {
132
+ var err = false;
133
+ if (curState.context) {
134
+ err = curState.context.tagName != tagName;
135
+ popContext();
136
+ } else {
137
+ err = true;
138
+ }
139
+ if (err) setStyle = "error";
140
+ return cont(endclosetag(err));
141
+ }
142
+ else if (type == "string") {
143
+ if (!curState.context || curState.context.name != "!cdata") pushContext("!cdata");
144
+ if (curState.tokenize == inText) popContext();
145
+ return cont();
146
+ }
147
+ else return cont();
148
+ }
149
+ function endtag(startOfLine) {
150
+ return function(type) {
151
+ if (type == "selfcloseTag" ||
152
+ (type == "endTag" && Kludges.autoSelfClosers.hasOwnProperty(curState.tagName.toLowerCase())))
153
+ return cont();
154
+ if (type == "endTag") {pushContext(curState.tagName, startOfLine); return cont();}
155
+ return cont();
156
+ };
157
+ }
158
+ function endclosetag(err) {
159
+ return function(type) {
160
+ if (err) setStyle = "error";
161
+ if (type == "endTag") return cont();
162
+ return pass();
163
+ }
164
+ }
165
+
166
+ function attributes(type) {
167
+ if (type == "word") {setStyle = "attribute"; return cont(attributes);}
168
+ if (type == "equals") return cont(attvalue, attributes);
169
+ return pass();
170
+ }
171
+ function attvalue(type) {
172
+ if (type == "word" && Kludges.allowUnquoted) {setStyle = "string"; return cont();}
173
+ if (type == "string") return cont();
174
+ return pass();
175
+ }
176
+
177
+ return {
178
+ startState: function() {
179
+ return {tokenize: inText, cc: [], indented: 0, startOfLine: true, tagName: null, context: null};
180
+ },
181
+
182
+ token: function(stream, state) {
183
+ if (stream.sol()) {
184
+ state.startOfLine = true;
185
+ state.indented = stream.indentation();
186
+ }
187
+ if (stream.eatSpace()) return null;
188
+
189
+ setStyle = type = tagName = null;
190
+ var style = state.tokenize(stream, state);
191
+ if ((style || type) && style != "comment") {
192
+ curState = state;
193
+ while (true) {
194
+ var comb = state.cc.pop() || element;
195
+ if (comb(type || style)) break;
196
+ }
197
+ }
198
+ state.startOfLine = false;
199
+ return setStyle || style;
200
+ },
201
+
202
+ indent: function(state, textAfter) {
203
+ var context = state.context;
204
+ if (context && context.noIndent) return 0;
205
+ if (alignCDATA && /<!\[CDATA\[/.test(textAfter)) return 0;
206
+ if (context && /^<\//.test(textAfter))
207
+ context = context.prev;
208
+ while (context && !context.startOfLine)
209
+ context = context.prev;
210
+ if (context) return context.indent + indentUnit;
211
+ else return 0;
212
+ },
213
+
214
+ compareStates: function(a, b) {
215
+ if (a.indented != b.indented || a.tagName != b.tagName) return false;
216
+ for (var ca = a.context, cb = b.context; ; ca = ca.prev, cb = cb.prev) {
217
+ if (!ca || !cb) return ca == cb;
218
+ if (ca.tagName != cb.tagName) return false;
219
+ }
220
+ },
221
+
222
+ electricChars: "/"
223
+ };
224
+ });
225
+
226
+ CodeMirror.defineMIME("application/xml", "xml");
227
+ CodeMirror.defineMIME("text/html", {name: "xml", htmlMode: true});