codemirror-rails 2.2.1 → 2.3
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/README.md +8 -0
- data/codemirror-rails.gemspec +1 -1
- data/lib/codemirror/rails/version.rb +2 -2
- data/vendor/assets/javascripts/codemirror.js +842 -422
- data/vendor/assets/javascripts/codemirror/keymaps/emacs.js +2 -2
- data/vendor/assets/javascripts/codemirror/keymaps/vim.js +722 -32
- data/vendor/assets/javascripts/codemirror/modes/clike.js +31 -9
- data/vendor/assets/javascripts/codemirror/modes/clojure.js +14 -14
- data/vendor/assets/javascripts/codemirror/modes/coffeescript.js +59 -37
- data/vendor/assets/javascripts/codemirror/modes/css.js +1 -1
- data/vendor/assets/javascripts/codemirror/modes/diff.js +24 -5
- data/vendor/assets/javascripts/codemirror/modes/ecl.js +203 -0
- data/vendor/assets/javascripts/codemirror/modes/erlang.js +251 -0
- data/vendor/assets/javascripts/codemirror/modes/gfm.js +40 -4
- data/vendor/assets/javascripts/codemirror/modes/go.js +170 -0
- data/vendor/assets/javascripts/codemirror/modes/htmlembedded.js +1 -1
- data/vendor/assets/javascripts/codemirror/modes/htmlmixed.js +4 -2
- data/vendor/assets/javascripts/codemirror/modes/javascript.js +10 -9
- data/vendor/assets/javascripts/codemirror/modes/less.js +232 -0
- data/vendor/assets/javascripts/codemirror/modes/markdown.js +52 -49
- data/vendor/assets/javascripts/codemirror/modes/mysql.js +188 -0
- data/vendor/assets/javascripts/codemirror/modes/pascal.js +2 -46
- data/vendor/assets/javascripts/codemirror/modes/perl.js +1 -1
- data/vendor/assets/javascripts/codemirror/modes/php.js +55 -25
- data/vendor/assets/javascripts/codemirror/modes/pig.js +172 -0
- data/vendor/assets/javascripts/codemirror/modes/properties.js +63 -0
- data/vendor/assets/javascripts/codemirror/modes/python.js +37 -32
- data/vendor/assets/javascripts/codemirror/modes/rpm-spec.js +1 -1
- data/vendor/assets/javascripts/codemirror/modes/rst.js +1 -1
- data/vendor/assets/javascripts/codemirror/modes/ruby.js +14 -14
- data/vendor/assets/javascripts/codemirror/modes/rust.js +36 -15
- data/vendor/assets/javascripts/codemirror/modes/scheme.js +74 -46
- data/vendor/assets/javascripts/codemirror/modes/shell.js +103 -0
- data/vendor/assets/javascripts/codemirror/modes/smalltalk.js +16 -16
- data/vendor/assets/javascripts/codemirror/modes/smarty.js +148 -0
- data/vendor/assets/javascripts/codemirror/modes/stex.js +21 -6
- data/vendor/assets/javascripts/codemirror/modes/tiddlywiki.js +55 -45
- data/vendor/assets/javascripts/codemirror/modes/tiki.js +316 -0
- data/vendor/assets/javascripts/codemirror/modes/vbscript.js +26 -0
- data/vendor/assets/javascripts/codemirror/modes/verilog.js +194 -0
- data/vendor/assets/javascripts/codemirror/modes/xml.js +89 -16
- data/vendor/assets/javascripts/codemirror/modes/xmlpure.js +5 -0
- data/vendor/assets/javascripts/codemirror/modes/xquery.js +448 -0
- data/vendor/assets/javascripts/codemirror/utils/closetag.js +146 -0
- data/vendor/assets/javascripts/codemirror/utils/dialog.js +63 -0
- data/vendor/assets/javascripts/codemirror/utils/foldcode.js +196 -0
- data/vendor/assets/javascripts/codemirror/utils/formatting.js +297 -0
- data/vendor/assets/javascripts/codemirror/utils/javascript-hint.js +134 -0
- data/vendor/assets/javascripts/codemirror/utils/loadmode.js +51 -0
- data/vendor/assets/javascripts/codemirror/utils/match-highlighter.js +44 -0
- data/vendor/assets/javascripts/codemirror/utils/multiplex.js +72 -0
- data/vendor/assets/javascripts/codemirror/{overlay.js → utils/overlay.js} +3 -2
- data/vendor/assets/javascripts/codemirror/utils/pig-hint.js +123 -0
- data/vendor/assets/javascripts/codemirror/utils/runmode.js +49 -0
- data/vendor/assets/javascripts/codemirror/utils/search.js +118 -0
- data/vendor/assets/javascripts/codemirror/utils/searchcursor.js +117 -0
- data/vendor/assets/javascripts/codemirror/utils/simple-hint.js +72 -0
- data/vendor/assets/stylesheets/codemirror.css +69 -5
- data/vendor/assets/stylesheets/codemirror/modes/tiddlywiki.css +14 -21
- data/vendor/assets/stylesheets/codemirror/modes/tiki.css +26 -0
- data/vendor/assets/stylesheets/codemirror/themes/ambiance.css +81 -0
- data/vendor/assets/stylesheets/codemirror/themes/blackboard.css +25 -0
- data/vendor/assets/stylesheets/codemirror/themes/cobalt.css +1 -1
- data/vendor/assets/stylesheets/codemirror/themes/eclipse.css +1 -1
- data/vendor/assets/stylesheets/codemirror/themes/elegant.css +2 -2
- data/vendor/assets/stylesheets/codemirror/themes/erlang-dark.css +21 -0
- data/vendor/assets/stylesheets/codemirror/themes/lesser-dark.css +44 -0
- data/vendor/assets/stylesheets/codemirror/themes/monokai.css +1 -1
- data/vendor/assets/stylesheets/codemirror/themes/neat.css +3 -3
- data/vendor/assets/stylesheets/codemirror/themes/night.css +1 -1
- data/vendor/assets/stylesheets/codemirror/themes/rubyblue.css +2 -2
- data/vendor/assets/stylesheets/codemirror/themes/vibrant-ink.css +27 -0
- data/vendor/assets/stylesheets/codemirror/themes/xq-dark.css +46 -0
- data/vendor/assets/stylesheets/codemirror/utils/dialog.css +23 -0
- data/vendor/assets/stylesheets/codemirror/utils/simple-hint.css +16 -0
- metadata +41 -10
- data/vendor/assets/javascripts/codemirror/runmode.js +0 -27
- data/vendor/assets/stylesheets/codemirror/modes/clike.css +0 -7
- data/vendor/assets/stylesheets/codemirror/modes/markdown.css +0 -10
- data/vendor/assets/stylesheets/codemirror/modes/rst.css +0 -75
- data/vendor/assets/stylesheets/codemirror/themes/default.css +0 -19
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* MySQL Mode for CodeMirror 2 by MySQL-Tools
|
|
3
|
+
* @author James Thorne (partydroid)
|
|
4
|
+
* @link http://github.com/partydroid/MySQL-Tools
|
|
5
|
+
* @link http://mysqltools.org
|
|
6
|
+
* @version 02/Jan/2012
|
|
7
|
+
*/
|
|
8
|
+
CodeMirror.defineMode("mysql", function(config) {
|
|
9
|
+
var indentUnit = config.indentUnit;
|
|
10
|
+
var curPunc;
|
|
11
|
+
|
|
12
|
+
function wordRegexp(words) {
|
|
13
|
+
return new RegExp("^(?:" + words.join("|") + ")$", "i");
|
|
14
|
+
}
|
|
15
|
+
var ops = wordRegexp(["str", "lang", "langmatches", "datatype", "bound", "sameterm", "isiri", "isuri",
|
|
16
|
+
"isblank", "isliteral", "union", "a"]);
|
|
17
|
+
var keywords = wordRegexp([
|
|
18
|
+
('ACCESSIBLE'),('ALTER'),('AS'),('BEFORE'),('BINARY'),('BY'),('CASE'),('CHARACTER'),('COLUMN'),('CONTINUE'),('CROSS'),('CURRENT_TIMESTAMP'),('DATABASE'),('DAY_MICROSECOND'),('DEC'),('DEFAULT'),
|
|
19
|
+
('DESC'),('DISTINCT'),('DOUBLE'),('EACH'),('ENCLOSED'),('EXIT'),('FETCH'),('FLOAT8'),('FOREIGN'),('GRANT'),('HIGH_PRIORITY'),('HOUR_SECOND'),('IN'),('INNER'),('INSERT'),('INT2'),('INT8'),
|
|
20
|
+
('INTO'),('JOIN'),('KILL'),('LEFT'),('LINEAR'),('LOCALTIME'),('LONG'),('LOOP'),('MATCH'),('MEDIUMTEXT'),('MINUTE_SECOND'),('NATURAL'),('NULL'),('OPTIMIZE'),('OR'),('OUTER'),('PRIMARY'),
|
|
21
|
+
('RANGE'),('READ_WRITE'),('REGEXP'),('REPEAT'),('RESTRICT'),('RIGHT'),('SCHEMAS'),('SENSITIVE'),('SHOW'),('SPECIFIC'),('SQLSTATE'),('SQL_CALC_FOUND_ROWS'),('STARTING'),('TERMINATED'),
|
|
22
|
+
('TINYINT'),('TRAILING'),('UNDO'),('UNLOCK'),('USAGE'),('UTC_DATE'),('VALUES'),('VARCHARACTER'),('WHERE'),('WRITE'),('ZEROFILL'),('ALL'),('AND'),('ASENSITIVE'),('BIGINT'),('BOTH'),('CASCADE'),
|
|
23
|
+
('CHAR'),('COLLATE'),('CONSTRAINT'),('CREATE'),('CURRENT_TIME'),('CURSOR'),('DAY_HOUR'),('DAY_SECOND'),('DECLARE'),('DELETE'),('DETERMINISTIC'),('DIV'),('DUAL'),('ELSEIF'),('EXISTS'),('FALSE'),
|
|
24
|
+
('FLOAT4'),('FORCE'),('FULLTEXT'),('HAVING'),('HOUR_MINUTE'),('IGNORE'),('INFILE'),('INSENSITIVE'),('INT1'),('INT4'),('INTERVAL'),('ITERATE'),('KEYS'),('LEAVE'),('LIMIT'),('LOAD'),('LOCK'),
|
|
25
|
+
('LONGTEXT'),('MASTER_SSL_VERIFY_SERVER_CERT'),('MEDIUMINT'),('MINUTE_MICROSECOND'),('MODIFIES'),('NO_WRITE_TO_BINLOG'),('ON'),('OPTIONALLY'),('OUT'),('PRECISION'),('PURGE'),('READS'),
|
|
26
|
+
('REFERENCES'),('RENAME'),('REQUIRE'),('REVOKE'),('SCHEMA'),('SELECT'),('SET'),('SPATIAL'),('SQLEXCEPTION'),('SQL_BIG_RESULT'),('SSL'),('TABLE'),('TINYBLOB'),('TO'),('TRUE'),('UNIQUE'),
|
|
27
|
+
('UPDATE'),('USING'),('UTC_TIMESTAMP'),('VARCHAR'),('WHEN'),('WITH'),('YEAR_MONTH'),('ADD'),('ANALYZE'),('ASC'),('BETWEEN'),('BLOB'),('CALL'),('CHANGE'),('CHECK'),('CONDITION'),('CONVERT'),
|
|
28
|
+
('CURRENT_DATE'),('CURRENT_USER'),('DATABASES'),('DAY_MINUTE'),('DECIMAL'),('DELAYED'),('DESCRIBE'),('DISTINCTROW'),('DROP'),('ELSE'),('ESCAPED'),('EXPLAIN'),('FLOAT'),('FOR'),('FROM'),
|
|
29
|
+
('GROUP'),('HOUR_MICROSECOND'),('IF'),('INDEX'),('INOUT'),('INT'),('INT3'),('INTEGER'),('IS'),('KEY'),('LEADING'),('LIKE'),('LINES'),('LOCALTIMESTAMP'),('LONGBLOB'),('LOW_PRIORITY'),
|
|
30
|
+
('MEDIUMBLOB'),('MIDDLEINT'),('MOD'),('NOT'),('NUMERIC'),('OPTION'),('ORDER'),('OUTFILE'),('PROCEDURE'),('READ'),('REAL'),('RELEASE'),('REPLACE'),('RETURN'),('RLIKE'),('SECOND_MICROSECOND'),
|
|
31
|
+
('SEPARATOR'),('SMALLINT'),('SQL'),('SQLWARNING'),('SQL_SMALL_RESULT'),('STRAIGHT_JOIN'),('THEN'),('TINYTEXT'),('TRIGGER'),('UNION'),('UNSIGNED'),('USE'),('UTC_TIME'),('VARBINARY'),('VARYING'),
|
|
32
|
+
('WHILE'),('XOR'),('FULL'),('COLUMNS'),('MIN'),('MAX'),('STDEV'),('COUNT')
|
|
33
|
+
]);
|
|
34
|
+
var operatorChars = /[*+\-<>=&|]/;
|
|
35
|
+
|
|
36
|
+
function tokenBase(stream, state) {
|
|
37
|
+
var ch = stream.next();
|
|
38
|
+
curPunc = null;
|
|
39
|
+
if (ch == "$" || ch == "?") {
|
|
40
|
+
stream.match(/^[\w\d]*/);
|
|
41
|
+
return "variable-2";
|
|
42
|
+
}
|
|
43
|
+
else if (ch == "<" && !stream.match(/^[\s\u00a0=]/, false)) {
|
|
44
|
+
stream.match(/^[^\s\u00a0>]*>?/);
|
|
45
|
+
return "atom";
|
|
46
|
+
}
|
|
47
|
+
else if (ch == "\"" || ch == "'") {
|
|
48
|
+
state.tokenize = tokenLiteral(ch);
|
|
49
|
+
return state.tokenize(stream, state);
|
|
50
|
+
}
|
|
51
|
+
else if (ch == "`") {
|
|
52
|
+
state.tokenize = tokenOpLiteral(ch);
|
|
53
|
+
return state.tokenize(stream, state);
|
|
54
|
+
}
|
|
55
|
+
else if (/[{}\(\),\.;\[\]]/.test(ch)) {
|
|
56
|
+
curPunc = ch;
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
else if (ch == "-") {
|
|
60
|
+
ch2 = stream.next();
|
|
61
|
+
if(ch2=="-")
|
|
62
|
+
{
|
|
63
|
+
stream.skipToEnd();
|
|
64
|
+
return "comment";
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
}
|
|
68
|
+
else if (operatorChars.test(ch)) {
|
|
69
|
+
stream.eatWhile(operatorChars);
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
else if (ch == ":") {
|
|
73
|
+
stream.eatWhile(/[\w\d\._\-]/);
|
|
74
|
+
return "atom";
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
stream.eatWhile(/[_\w\d]/);
|
|
78
|
+
if (stream.eat(":")) {
|
|
79
|
+
stream.eatWhile(/[\w\d_\-]/);
|
|
80
|
+
return "atom";
|
|
81
|
+
}
|
|
82
|
+
var word = stream.current(), type;
|
|
83
|
+
if (ops.test(word))
|
|
84
|
+
return null;
|
|
85
|
+
else if (keywords.test(word))
|
|
86
|
+
return "keyword";
|
|
87
|
+
else
|
|
88
|
+
return "variable";
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function tokenLiteral(quote) {
|
|
93
|
+
return function(stream, state) {
|
|
94
|
+
var escaped = false, ch;
|
|
95
|
+
while ((ch = stream.next()) != null) {
|
|
96
|
+
if (ch == quote && !escaped) {
|
|
97
|
+
state.tokenize = tokenBase;
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
escaped = !escaped && ch == "\\";
|
|
101
|
+
}
|
|
102
|
+
return "string";
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function tokenOpLiteral(quote) {
|
|
107
|
+
return function(stream, state) {
|
|
108
|
+
var escaped = false, ch;
|
|
109
|
+
while ((ch = stream.next()) != null) {
|
|
110
|
+
if (ch == quote && !escaped) {
|
|
111
|
+
state.tokenize = tokenBase;
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
114
|
+
escaped = !escaped && ch == "\\";
|
|
115
|
+
}
|
|
116
|
+
return "variable-2";
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
function pushContext(state, type, col) {
|
|
122
|
+
state.context = {prev: state.context, indent: state.indent, col: col, type: type};
|
|
123
|
+
}
|
|
124
|
+
function popContext(state) {
|
|
125
|
+
state.indent = state.context.indent;
|
|
126
|
+
state.context = state.context.prev;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
return {
|
|
130
|
+
startState: function(base) {
|
|
131
|
+
return {tokenize: tokenBase,
|
|
132
|
+
context: null,
|
|
133
|
+
indent: 0,
|
|
134
|
+
col: 0};
|
|
135
|
+
},
|
|
136
|
+
|
|
137
|
+
token: function(stream, state) {
|
|
138
|
+
if (stream.sol()) {
|
|
139
|
+
if (state.context && state.context.align == null) state.context.align = false;
|
|
140
|
+
state.indent = stream.indentation();
|
|
141
|
+
}
|
|
142
|
+
if (stream.eatSpace()) return null;
|
|
143
|
+
var style = state.tokenize(stream, state);
|
|
144
|
+
|
|
145
|
+
if (style != "comment" && state.context && state.context.align == null && state.context.type != "pattern") {
|
|
146
|
+
state.context.align = true;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
if (curPunc == "(") pushContext(state, ")", stream.column());
|
|
150
|
+
else if (curPunc == "[") pushContext(state, "]", stream.column());
|
|
151
|
+
else if (curPunc == "{") pushContext(state, "}", stream.column());
|
|
152
|
+
else if (/[\]\}\)]/.test(curPunc)) {
|
|
153
|
+
while (state.context && state.context.type == "pattern") popContext(state);
|
|
154
|
+
if (state.context && curPunc == state.context.type) popContext(state);
|
|
155
|
+
}
|
|
156
|
+
else if (curPunc == "." && state.context && state.context.type == "pattern") popContext(state);
|
|
157
|
+
else if (/atom|string|variable/.test(style) && state.context) {
|
|
158
|
+
if (/[\}\]]/.test(state.context.type))
|
|
159
|
+
pushContext(state, "pattern", stream.column());
|
|
160
|
+
else if (state.context.type == "pattern" && !state.context.align) {
|
|
161
|
+
state.context.align = true;
|
|
162
|
+
state.context.col = stream.column();
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
return style;
|
|
167
|
+
},
|
|
168
|
+
|
|
169
|
+
indent: function(state, textAfter) {
|
|
170
|
+
var firstChar = textAfter && textAfter.charAt(0);
|
|
171
|
+
var context = state.context;
|
|
172
|
+
if (/[\]\}]/.test(firstChar))
|
|
173
|
+
while (context && context.type == "pattern") context = context.prev;
|
|
174
|
+
|
|
175
|
+
var closing = context && firstChar == context.type;
|
|
176
|
+
if (!context)
|
|
177
|
+
return 0;
|
|
178
|
+
else if (context.type == "pattern")
|
|
179
|
+
return context.col;
|
|
180
|
+
else if (context.align)
|
|
181
|
+
return context.col + (closing ? 0 : 1);
|
|
182
|
+
else
|
|
183
|
+
return context.indent + (closing ? 0 : indentUnit);
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
CodeMirror.defineMIME("text/x-mysql", "mysql");
|
|
@@ -7,11 +7,9 @@ CodeMirror.defineMode("pascal", function(config) {
|
|
|
7
7
|
var keywords = words("and array begin case const div do downto else end file for forward integer " +
|
|
8
8
|
"boolean char function goto if in label mod nil not of or packed procedure " +
|
|
9
9
|
"program record repeat set string then to type until var while with");
|
|
10
|
-
var blockKeywords = words("case do else for if switch while struct then of");
|
|
11
10
|
var atoms = {"null": true};
|
|
12
11
|
|
|
13
12
|
var isOperatorChar = /[+\-*&%=<>!?|\/]/;
|
|
14
|
-
var curPunc;
|
|
15
13
|
|
|
16
14
|
function tokenBase(stream, state) {
|
|
17
15
|
var ch = stream.next();
|
|
@@ -28,7 +26,6 @@ CodeMirror.defineMode("pascal", function(config) {
|
|
|
28
26
|
return tokenComment(stream, state);
|
|
29
27
|
}
|
|
30
28
|
if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
|
|
31
|
-
curPunc = ch;
|
|
32
29
|
return null
|
|
33
30
|
}
|
|
34
31
|
if (/\d/.test(ch)) {
|
|
@@ -47,10 +44,7 @@ CodeMirror.defineMode("pascal", function(config) {
|
|
|
47
44
|
}
|
|
48
45
|
stream.eatWhile(/[\w\$_]/);
|
|
49
46
|
var cur = stream.current();
|
|
50
|
-
if (keywords.propertyIsEnumerable(cur))
|
|
51
|
-
if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
|
|
52
|
-
return "keyword";
|
|
53
|
-
}
|
|
47
|
+
if (keywords.propertyIsEnumerable(cur)) return "keyword";
|
|
54
48
|
if (atoms.propertyIsEnumerable(cur)) return "atom";
|
|
55
49
|
return "word";
|
|
56
50
|
}
|
|
@@ -79,55 +73,17 @@ CodeMirror.defineMode("pascal", function(config) {
|
|
|
79
73
|
return "comment";
|
|
80
74
|
}
|
|
81
75
|
|
|
82
|
-
function Context(indented, column, type, align, prev) {
|
|
83
|
-
this.indented = indented;
|
|
84
|
-
this.column = column;
|
|
85
|
-
this.type = type;
|
|
86
|
-
this.align = align;
|
|
87
|
-
this.prev = prev;
|
|
88
|
-
}
|
|
89
|
-
function pushContext(state, col, type) {
|
|
90
|
-
return state.context = new Context(state.indented, col, type, null, state.context);
|
|
91
|
-
}
|
|
92
|
-
function popContext(state) {
|
|
93
|
-
var t = state.context.type;
|
|
94
|
-
if (t == ")" || t == "]" )
|
|
95
|
-
state.indented = state.context.indented;
|
|
96
|
-
return state.context = state.context.prev;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
76
|
// Interface
|
|
100
77
|
|
|
101
78
|
return {
|
|
102
79
|
startState: function(basecolumn) {
|
|
103
|
-
return {
|
|
104
|
-
tokenize: null,
|
|
105
|
-
context: new Context((basecolumn || 0) - config.indentUnit, 0, "top", false),
|
|
106
|
-
indented: 0,
|
|
107
|
-
startOfLine: true
|
|
108
|
-
};
|
|
80
|
+
return {tokenize: null};
|
|
109
81
|
},
|
|
110
82
|
|
|
111
83
|
token: function(stream, state) {
|
|
112
|
-
var ctx = state.context;
|
|
113
|
-
if (stream.sol()) {
|
|
114
|
-
if (ctx.align == null) ctx.align = false;
|
|
115
|
-
state.indented = stream.indentation();
|
|
116
|
-
state.startOfLine = true;
|
|
117
|
-
}
|
|
118
84
|
if (stream.eatSpace()) return null;
|
|
119
|
-
curPunc = null;
|
|
120
85
|
var style = (state.tokenize || tokenBase)(stream, state);
|
|
121
86
|
if (style == "comment" || style == "meta") return style;
|
|
122
|
-
if (ctx.align == null) ctx.align = true;
|
|
123
|
-
|
|
124
|
-
if ((curPunc == ";" || curPunc == ":") && ctx.type == "statement") popContext(state);
|
|
125
|
-
else if (curPunc == "[") pushContext(state, stream.column(), "]");
|
|
126
|
-
else if (curPunc == "(") pushContext(state, stream.column(), ")");
|
|
127
|
-
else if (curPunc == ctx.type) popContext(state);
|
|
128
|
-
else if ( ctx.type == "top" || (ctx.type == "statement" && curPunc == "newstatement"))
|
|
129
|
-
pushContext(state, stream.column(), "statement");
|
|
130
|
-
state.startOfLine = false;
|
|
131
87
|
return style;
|
|
132
88
|
},
|
|
133
89
|
|
|
@@ -324,7 +324,7 @@ CodeMirror.defineMode("perl",function(config,parserConfig){
|
|
|
324
324
|
hex :1, // - convert a string to a hexadecimal number
|
|
325
325
|
'import' :1, // - patch a module's namespace into your own
|
|
326
326
|
index :1, // - find a substring within a string
|
|
327
|
-
int :1, // - get the integer portion of a number
|
|
327
|
+
'int' :1, // - get the integer portion of a number
|
|
328
328
|
ioctl :1, // - system-dependent device control system call
|
|
329
329
|
'join' :1, // - join a list into a string using a separator
|
|
330
330
|
keys :1, // - retrieve list of indices from a hash
|
|
@@ -13,11 +13,12 @@
|
|
|
13
13
|
}
|
|
14
14
|
var phpConfig = {
|
|
15
15
|
name: "clike",
|
|
16
|
-
keywords: keywords("abstract and array as break case catch
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"new or private protected public static switch throw try use var while xor
|
|
20
|
-
"die echo empty exit eval include include_once isset list require require_once
|
|
16
|
+
keywords: keywords("abstract and array as break case catch class clone const continue declare default " +
|
|
17
|
+
"do else elseif enddeclare endfor endforeach endif endswitch endwhile extends final " +
|
|
18
|
+
"for foreach function global goto if implements interface instanceof namespace " +
|
|
19
|
+
"new or private protected public static switch throw trait try use var while xor " +
|
|
20
|
+
"die echo empty exit eval include include_once isset list require require_once return " +
|
|
21
|
+
"print unset __halt_compiler self static parent"),
|
|
21
22
|
blockKeywords: keywords("catch do else elseif for foreach if switch try while"),
|
|
22
23
|
atoms: keywords("true false null TRUE FALSE NULL"),
|
|
23
24
|
multiLineStrings: true,
|
|
@@ -35,8 +36,15 @@
|
|
|
35
36
|
return false;
|
|
36
37
|
},
|
|
37
38
|
"#": function(stream, state) {
|
|
38
|
-
stream.
|
|
39
|
+
while (!stream.eol() && !stream.match("?>", false)) stream.next();
|
|
39
40
|
return "comment";
|
|
41
|
+
},
|
|
42
|
+
"/": function(stream, state) {
|
|
43
|
+
if (stream.eat("/")) {
|
|
44
|
+
while (!stream.eol() && !stream.match("?>", false)) stream.next();
|
|
45
|
+
return "comment";
|
|
46
|
+
}
|
|
47
|
+
return false;
|
|
40
48
|
}
|
|
41
49
|
}
|
|
42
50
|
};
|
|
@@ -48,38 +56,57 @@
|
|
|
48
56
|
var phpMode = CodeMirror.getMode(config, phpConfig);
|
|
49
57
|
|
|
50
58
|
function dispatch(stream, state) { // TODO open PHP inside text/css
|
|
59
|
+
var isPHP = state.mode == "php";
|
|
60
|
+
if (stream.sol() && state.pending != '"') state.pending = null;
|
|
51
61
|
if (state.curMode == htmlMode) {
|
|
52
|
-
|
|
53
|
-
if (style == "meta" && /^<\?/.test(stream.current())) {
|
|
62
|
+
if (stream.match(/^<\?\w*/)) {
|
|
54
63
|
state.curMode = phpMode;
|
|
55
64
|
state.curState = state.php;
|
|
56
|
-
state.curClose =
|
|
57
|
-
|
|
65
|
+
state.curClose = "?>";
|
|
66
|
+
state.mode = "php";
|
|
67
|
+
return "meta";
|
|
58
68
|
}
|
|
59
|
-
|
|
69
|
+
if (state.pending == '"') {
|
|
70
|
+
while (!stream.eol() && stream.next() != '"') {}
|
|
71
|
+
var style = "string";
|
|
72
|
+
} else if (state.pending && stream.pos < state.pending.end) {
|
|
73
|
+
stream.pos = state.pending.end;
|
|
74
|
+
var style = state.pending.style;
|
|
75
|
+
} else {
|
|
76
|
+
var style = htmlMode.token(stream, state.curState);
|
|
77
|
+
}
|
|
78
|
+
state.pending = null;
|
|
79
|
+
var cur = stream.current(), openPHP = cur.search(/<\?/);
|
|
80
|
+
if (openPHP != -1) {
|
|
81
|
+
if (style == "string" && /\"$/.test(cur) && !/\?>/.test(cur)) state.pending = '"';
|
|
82
|
+
else state.pending = {end: stream.pos, style: style};
|
|
83
|
+
stream.backUp(cur.length - openPHP);
|
|
84
|
+
} else if (style == "tag" && stream.current() == ">" && state.curState.context) {
|
|
60
85
|
if (/^script$/i.test(state.curState.context.tagName)) {
|
|
61
86
|
state.curMode = jsMode;
|
|
62
87
|
state.curState = jsMode.startState(htmlMode.indent(state.curState, ""));
|
|
63
88
|
state.curClose = /^<\/\s*script\s*>/i;
|
|
64
|
-
|
|
89
|
+
state.mode = "javascript";
|
|
65
90
|
}
|
|
66
91
|
else if (/^style$/i.test(state.curState.context.tagName)) {
|
|
67
92
|
state.curMode = cssMode;
|
|
68
93
|
state.curState = cssMode.startState(htmlMode.indent(state.curState, ""));
|
|
69
|
-
state.curClose =
|
|
70
|
-
state.mode =
|
|
94
|
+
state.curClose = /^<\/\s*style\s*>/i;
|
|
95
|
+
state.mode = "css";
|
|
71
96
|
}
|
|
72
97
|
}
|
|
73
98
|
return style;
|
|
74
|
-
}
|
|
75
|
-
|
|
99
|
+
} else if ((!isPHP || state.php.tokenize == null) &&
|
|
100
|
+
stream.match(state.curClose, isPHP)) {
|
|
76
101
|
state.curMode = htmlMode;
|
|
77
102
|
state.curState = state.html;
|
|
78
103
|
state.curClose = null;
|
|
79
|
-
|
|
80
|
-
|
|
104
|
+
state.mode = "html";
|
|
105
|
+
if (isPHP) return "meta";
|
|
106
|
+
else return dispatch(stream, state);
|
|
107
|
+
} else {
|
|
108
|
+
return state.curMode.token(stream, state.curState);
|
|
81
109
|
}
|
|
82
|
-
else return state.curMode.token(stream, state.curState);
|
|
83
110
|
}
|
|
84
111
|
|
|
85
112
|
return {
|
|
@@ -87,10 +114,11 @@
|
|
|
87
114
|
var html = htmlMode.startState();
|
|
88
115
|
return {html: html,
|
|
89
116
|
php: phpMode.startState(),
|
|
90
|
-
curMode:
|
|
91
|
-
curState:
|
|
92
|
-
curClose:
|
|
93
|
-
|
|
117
|
+
curMode: parserConfig.startOpen ? phpMode : htmlMode,
|
|
118
|
+
curState: parserConfig.startOpen ? phpMode.startState() : html,
|
|
119
|
+
curClose: parserConfig.startOpen ? /^\?>/ : null,
|
|
120
|
+
mode: parserConfig.startOpen ? "php" : "html",
|
|
121
|
+
pending: null}
|
|
94
122
|
},
|
|
95
123
|
|
|
96
124
|
copyState: function(state) {
|
|
@@ -99,7 +127,9 @@
|
|
|
99
127
|
if (state.curState == html) cur = htmlNew;
|
|
100
128
|
else if (state.curState == php) cur = phpNew;
|
|
101
129
|
else cur = CodeMirror.copyState(state.curMode, state.curState);
|
|
102
|
-
return {html: htmlNew, php: phpNew, curMode: state.curMode, curState: cur,
|
|
130
|
+
return {html: htmlNew, php: phpNew, curMode: state.curMode, curState: cur,
|
|
131
|
+
curClose: state.curClose, mode: state.mode,
|
|
132
|
+
pending: state.pending};
|
|
103
133
|
},
|
|
104
134
|
|
|
105
135
|
token: dispatch,
|
|
@@ -113,7 +143,7 @@
|
|
|
113
143
|
|
|
114
144
|
electricChars: "/{}:"
|
|
115
145
|
}
|
|
116
|
-
});
|
|
146
|
+
}, "xml", "clike", "javascript", "css");
|
|
117
147
|
CodeMirror.defineMIME("application/x-httpd-php", "php");
|
|
118
148
|
CodeMirror.defineMIME("application/x-httpd-php-open", {name: "php", startOpen: true});
|
|
119
149
|
CodeMirror.defineMIME("text/x-php", phpConfig);
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Pig Latin Mode for CodeMirror 2
|
|
3
|
+
* @author Prasanth Jayachandran
|
|
4
|
+
* @link https://github.com/prasanthj/pig-codemirror-2
|
|
5
|
+
* This implementation is adapted from PL/SQL mode in CodeMirror 2.
|
|
6
|
+
*/
|
|
7
|
+
CodeMirror.defineMode("pig", function(config, parserConfig) {
|
|
8
|
+
var indentUnit = config.indentUnit,
|
|
9
|
+
keywords = parserConfig.keywords,
|
|
10
|
+
builtins = parserConfig.builtins,
|
|
11
|
+
types = parserConfig.types,
|
|
12
|
+
multiLineStrings = parserConfig.multiLineStrings;
|
|
13
|
+
|
|
14
|
+
var isOperatorChar = /[*+\-%<>=&?:\/!|]/;
|
|
15
|
+
|
|
16
|
+
function chain(stream, state, f) {
|
|
17
|
+
state.tokenize = f;
|
|
18
|
+
return f(stream, state);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
var type;
|
|
22
|
+
function ret(tp, style) {
|
|
23
|
+
type = tp;
|
|
24
|
+
return style;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function tokenComment(stream, state) {
|
|
28
|
+
var isEnd = false;
|
|
29
|
+
var ch;
|
|
30
|
+
while(ch = stream.next()) {
|
|
31
|
+
if(ch == "/" && isEnd) {
|
|
32
|
+
state.tokenize = tokenBase;
|
|
33
|
+
break;
|
|
34
|
+
}
|
|
35
|
+
isEnd = (ch == "*");
|
|
36
|
+
}
|
|
37
|
+
return ret("comment", "comment");
|
|
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) {
|
|
45
|
+
end = true; break;
|
|
46
|
+
}
|
|
47
|
+
escaped = !escaped && next == "\\";
|
|
48
|
+
}
|
|
49
|
+
if (end || !(escaped || multiLineStrings))
|
|
50
|
+
state.tokenize = tokenBase;
|
|
51
|
+
return ret("string", "error");
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function tokenBase(stream, state) {
|
|
56
|
+
var ch = stream.next();
|
|
57
|
+
|
|
58
|
+
// is a start of string?
|
|
59
|
+
if (ch == '"' || ch == "'")
|
|
60
|
+
return chain(stream, state, tokenString(ch));
|
|
61
|
+
// is it one of the special chars
|
|
62
|
+
else if(/[\[\]{}\(\),;\.]/.test(ch))
|
|
63
|
+
return ret(ch);
|
|
64
|
+
// is it a number?
|
|
65
|
+
else if(/\d/.test(ch)) {
|
|
66
|
+
stream.eatWhile(/[\w\.]/);
|
|
67
|
+
return ret("number", "number");
|
|
68
|
+
}
|
|
69
|
+
// multi line comment or operator
|
|
70
|
+
else if (ch == "/") {
|
|
71
|
+
if (stream.eat("*")) {
|
|
72
|
+
return chain(stream, state, tokenComment);
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
stream.eatWhile(isOperatorChar);
|
|
76
|
+
return ret("operator", "operator");
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
// single line comment or operator
|
|
80
|
+
else if (ch=="-") {
|
|
81
|
+
if(stream.eat("-")){
|
|
82
|
+
stream.skipToEnd();
|
|
83
|
+
return ret("comment", "comment");
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
stream.eatWhile(isOperatorChar);
|
|
87
|
+
return ret("operator", "operator");
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
// is it an operator
|
|
91
|
+
else if (isOperatorChar.test(ch)) {
|
|
92
|
+
stream.eatWhile(isOperatorChar);
|
|
93
|
+
return ret("operator", "operator");
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
// get the while word
|
|
97
|
+
stream.eatWhile(/[\w\$_]/);
|
|
98
|
+
// is it one of the listed keywords?
|
|
99
|
+
if (keywords && keywords.propertyIsEnumerable(stream.current().toUpperCase())) {
|
|
100
|
+
if (stream.eat(")") || stream.eat(".")) {
|
|
101
|
+
//keywords can be used as variables like flatten(group), group.$0 etc..
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
return ("keyword", "keyword");
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
// is it one of the builtin functions?
|
|
108
|
+
if (builtins && builtins.propertyIsEnumerable(stream.current().toUpperCase()))
|
|
109
|
+
{
|
|
110
|
+
return ("keyword", "variable-2")
|
|
111
|
+
}
|
|
112
|
+
// is it one of the listed types?
|
|
113
|
+
if (types && types.propertyIsEnumerable(stream.current().toUpperCase()))
|
|
114
|
+
return ("keyword", "variable-3")
|
|
115
|
+
// default is a 'word'
|
|
116
|
+
return ret("word", "pig-word");
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// Interface
|
|
121
|
+
return {
|
|
122
|
+
startState: function(basecolumn) {
|
|
123
|
+
return {
|
|
124
|
+
tokenize: tokenBase,
|
|
125
|
+
startOfLine: true
|
|
126
|
+
};
|
|
127
|
+
},
|
|
128
|
+
|
|
129
|
+
token: function(stream, state) {
|
|
130
|
+
if(stream.eatSpace()) return null;
|
|
131
|
+
var style = state.tokenize(stream, state);
|
|
132
|
+
return style;
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
(function() {
|
|
138
|
+
function keywords(str) {
|
|
139
|
+
var obj = {}, words = str.split(" ");
|
|
140
|
+
for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
|
|
141
|
+
return obj;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// builtin funcs taken from trunk revision 1303237
|
|
145
|
+
var pBuiltins = "ABS ACOS ARITY ASIN ATAN AVG BAGSIZE BINSTORAGE BLOOM BUILDBLOOM CBRT CEIL "
|
|
146
|
+
+ "CONCAT COR COS COSH COUNT COUNT_STAR COV CONSTANTSIZE CUBEDIMENSIONS DIFF DISTINCT DOUBLEABS "
|
|
147
|
+
+ "DOUBLEAVG DOUBLEBASE DOUBLEMAX DOUBLEMIN DOUBLEROUND DOUBLESUM EXP FLOOR FLOATABS FLOATAVG "
|
|
148
|
+
+ "FLOATMAX FLOATMIN FLOATROUND FLOATSUM GENERICINVOKER INDEXOF INTABS INTAVG INTMAX INTMIN "
|
|
149
|
+
+ "INTSUM INVOKEFORDOUBLE INVOKEFORFLOAT INVOKEFORINT INVOKEFORLONG INVOKEFORSTRING INVOKER "
|
|
150
|
+
+ "ISEMPTY JSONLOADER JSONMETADATA JSONSTORAGE LAST_INDEX_OF LCFIRST LOG LOG10 LOWER LONGABS "
|
|
151
|
+
+ "LONGAVG LONGMAX LONGMIN LONGSUM MAX MIN MAPSIZE MONITOREDUDF NONDETERMINISTIC OUTPUTSCHEMA "
|
|
152
|
+
+ "PIGSTORAGE PIGSTREAMING RANDOM REGEX_EXTRACT REGEX_EXTRACT_ALL REPLACE ROUND SIN SINH SIZE "
|
|
153
|
+
+ "SQRT STRSPLIT SUBSTRING SUM STRINGCONCAT STRINGMAX STRINGMIN STRINGSIZE TAN TANH TOBAG "
|
|
154
|
+
+ "TOKENIZE TOMAP TOP TOTUPLE TRIM TEXTLOADER TUPLESIZE UCFIRST UPPER UTF8STORAGECONVERTER ";
|
|
155
|
+
|
|
156
|
+
// taken from QueryLexer.g
|
|
157
|
+
var pKeywords = "VOID IMPORT RETURNS DEFINE LOAD FILTER FOREACH ORDER CUBE DISTINCT COGROUP "
|
|
158
|
+
+ "JOIN CROSS UNION SPLIT INTO IF OTHERWISE ALL AS BY USING INNER OUTER ONSCHEMA PARALLEL "
|
|
159
|
+
+ "PARTITION GROUP AND OR NOT GENERATE FLATTEN ASC DESC IS STREAM THROUGH STORE MAPREDUCE "
|
|
160
|
+
+ "SHIP CACHE INPUT OUTPUT STDERROR STDIN STDOUT LIMIT SAMPLE LEFT RIGHT FULL EQ GT LT GTE LTE "
|
|
161
|
+
+ "NEQ MATCHES TRUE FALSE ";
|
|
162
|
+
|
|
163
|
+
// data types
|
|
164
|
+
var pTypes = "BOOLEAN INT LONG FLOAT DOUBLE CHARARRAY BYTEARRAY BAG TUPLE MAP "
|
|
165
|
+
|
|
166
|
+
CodeMirror.defineMIME("text/x-pig", {
|
|
167
|
+
name: "pig",
|
|
168
|
+
builtins: keywords(pBuiltins),
|
|
169
|
+
keywords: keywords(pKeywords),
|
|
170
|
+
types: keywords(pTypes)
|
|
171
|
+
});
|
|
172
|
+
}());
|