codemirror-rails 2.24 → 2.32
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/.gitignore +1 -0
- data/Rakefile +19 -0
- data/codemirror-rails.gemspec +6 -1
- data/lib/codemirror/rails/version.rb +2 -2
- data/test/dummy/README.rdoc +261 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/assets/javascripts/application.js +15 -0
- data/test/dummy/app/assets/stylesheets/application.css +13 -0
- data/test/dummy/app/controllers/application_controller.rb +3 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/mailers/.gitkeep +0 -0
- data/test/dummy/app/models/.gitkeep +0 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +56 -0
- data/test/dummy/config/boot.rb +10 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +37 -0
- data/test/dummy/config/environments/production.rb +67 -0
- data/test/dummy/config/environments/test.rb +37 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/inflections.rb +15 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +7 -0
- data/test/dummy/config/initializers/session_store.rb +8 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +5 -0
- data/test/dummy/config/routes.rb +58 -0
- data/test/dummy/lib/assets/.gitkeep +0 -0
- data/test/dummy/log/.gitkeep +0 -0
- data/test/dummy/public/404.html +26 -0
- data/test/dummy/public/422.html +26 -0
- data/test/dummy/public/500.html +25 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/script/rails +6 -0
- data/test/integration/codemirror_rails_integration_test.rb +13 -0
- data/test/test_helper.rb +13 -0
- data/vendor/assets/javascripts/codemirror.js +381 -197
- data/vendor/assets/javascripts/codemirror/keymaps/emacs.js +1 -1
- data/vendor/assets/javascripts/codemirror/keymaps/vim.js +649 -94
- data/vendor/assets/javascripts/codemirror/modes/clike.js +53 -7
- data/vendor/assets/javascripts/codemirror/modes/coffeescript.js +12 -7
- data/vendor/assets/javascripts/codemirror/modes/diff.js +24 -5
- data/vendor/assets/javascripts/codemirror/modes/ecl.js +2 -2
- data/vendor/assets/javascripts/codemirror/modes/erlang.js +463 -0
- data/vendor/assets/javascripts/codemirror/modes/gfm.js +38 -2
- data/vendor/assets/javascripts/codemirror/modes/go.js +1 -1
- data/vendor/assets/javascripts/codemirror/modes/groovy.js +1 -1
- data/vendor/assets/javascripts/codemirror/modes/haxe.js +432 -0
- data/vendor/assets/javascripts/codemirror/modes/javascript.js +1 -1
- data/vendor/assets/javascripts/codemirror/modes/less.js +93 -93
- data/vendor/assets/javascripts/codemirror/modes/markdown.js +29 -6
- data/vendor/assets/javascripts/codemirror/modes/mysql.js +6 -8
- data/vendor/assets/javascripts/codemirror/modes/ocaml.js +114 -0
- data/vendor/assets/javascripts/codemirror/modes/pascal.js +1 -1
- data/vendor/assets/javascripts/codemirror/modes/pig.js +2 -2
- data/vendor/assets/javascripts/codemirror/modes/plsql.js +2 -2
- data/vendor/assets/javascripts/codemirror/modes/python.js +13 -16
- data/vendor/assets/javascripts/codemirror/modes/ruby.js +3 -8
- data/vendor/assets/javascripts/codemirror/modes/scheme.js +74 -46
- data/vendor/assets/javascripts/codemirror/modes/shell.js +22 -7
- data/vendor/assets/javascripts/codemirror/modes/stex.js +7 -5
- data/vendor/assets/javascripts/codemirror/modes/tiddlywiki.js +14 -14
- data/vendor/assets/javascripts/codemirror/modes/vb.js +260 -0
- data/vendor/assets/javascripts/codemirror/modes/verilog.js +1 -1
- data/vendor/assets/javascripts/codemirror/modes/xml.js +2 -1
- data/vendor/assets/javascripts/codemirror/modes/xquery.js +3 -3
- data/vendor/assets/javascripts/codemirror/utils/closetag.js +24 -34
- data/vendor/assets/javascripts/codemirror/utils/dialog.js +5 -1
- data/vendor/assets/javascripts/codemirror/utils/foldcode.js +10 -5
- data/vendor/assets/javascripts/codemirror/utils/formatting.js +8 -3
- data/vendor/assets/javascripts/codemirror/utils/loadmode.js +2 -1
- data/vendor/assets/javascripts/codemirror/utils/match-highlighter.js +1 -1
- data/vendor/assets/javascripts/codemirror/utils/multiplex.js +81 -0
- data/vendor/assets/javascripts/codemirror/utils/overlay.js +2 -1
- data/vendor/assets/javascripts/codemirror/utils/pig-hint.js +123 -0
- data/vendor/assets/javascripts/codemirror/utils/search.js +16 -12
- data/vendor/assets/javascripts/codemirror/utils/searchcursor.js +1 -1
- data/vendor/assets/javascripts/codemirror/utils/simple-hint.js +4 -0
- data/vendor/assets/javascripts/codemirror/utils/xml-hint.js +137 -0
- data/vendor/assets/stylesheets/codemirror.css +59 -4
- data/vendor/assets/stylesheets/codemirror/modes/tiddlywiki.css +14 -21
- data/vendor/assets/stylesheets/codemirror/themes/ambiance.css +1 -2
- data/vendor/assets/stylesheets/codemirror/themes/erlang-dark.css +21 -0
- data/vendor/assets/stylesheets/codemirror/themes/lesser-dark.css +2 -3
- data/vendor/assets/stylesheets/codemirror/themes/night.css +1 -1
- data/vendor/assets/stylesheets/codemirror/themes/vibrant-ink.css +27 -0
- data/vendor/assets/stylesheets/codemirror/utils/dialog.css +4 -0
- metadata +98 -5
- data/vendor/assets/javascripts/codemirror/modes/rpm-spec.css +0 -5
|
@@ -46,7 +46,7 @@ CodeMirror.defineMode("pascal", function(config) {
|
|
|
46
46
|
var cur = stream.current();
|
|
47
47
|
if (keywords.propertyIsEnumerable(cur)) return "keyword";
|
|
48
48
|
if (atoms.propertyIsEnumerable(cur)) return "atom";
|
|
49
|
-
return "
|
|
49
|
+
return "variable";
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
function tokenString(quote) {
|
|
@@ -112,8 +112,8 @@ CodeMirror.defineMode("pig", function(config, parserConfig) {
|
|
|
112
112
|
// is it one of the listed types?
|
|
113
113
|
if (types && types.propertyIsEnumerable(stream.current().toUpperCase()))
|
|
114
114
|
return ("keyword", "variable-3")
|
|
115
|
-
// default is a '
|
|
116
|
-
return ret("
|
|
115
|
+
// default is a 'variable'
|
|
116
|
+
return ret("variable", "pig-word");
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
119
|
|
|
@@ -72,8 +72,8 @@ CodeMirror.defineMode("plsql", function(config, parserConfig) {
|
|
|
72
72
|
if (types && types.propertyIsEnumerable(stream.current().toLowerCase())) return ret("keyword", "variable-2");
|
|
73
73
|
// is it one of the listed sqlplus keywords?
|
|
74
74
|
if (sqlplus && sqlplus.propertyIsEnumerable(stream.current().toLowerCase())) return ret("keyword", "variable-3");
|
|
75
|
-
// default: just a "
|
|
76
|
-
return ret("word", "
|
|
75
|
+
// default: just a "variable"
|
|
76
|
+
return ret("word", "variable");
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
|
|
@@ -249,26 +249,23 @@ CodeMirror.defineMode("python", function(conf, parserConf) {
|
|
|
249
249
|
|
|
250
250
|
// Handle '.' connected identifiers
|
|
251
251
|
if (current === '.') {
|
|
252
|
-
style =
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
return ERRORCLASS;
|
|
252
|
+
style = stream.match(identifiers, false) ? null : ERRORCLASS;
|
|
253
|
+
if (style === null && state.lastToken === 'meta') {
|
|
254
|
+
// Apply 'meta' style to '.' connected identifiers when
|
|
255
|
+
// appropriate.
|
|
256
|
+
style = 'meta';
|
|
258
257
|
}
|
|
258
|
+
return style;
|
|
259
259
|
}
|
|
260
260
|
|
|
261
261
|
// Handle decorators
|
|
262
262
|
if (current === '@') {
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
} else {
|
|
270
|
-
return ERRORCLASS;
|
|
271
|
-
}
|
|
263
|
+
return stream.match(identifiers, false) ? 'meta' : ERRORCLASS;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
if ((style === 'variable' || style === 'builtin')
|
|
267
|
+
&& state.lastToken === 'meta') {
|
|
268
|
+
style = 'meta';
|
|
272
269
|
}
|
|
273
270
|
|
|
274
271
|
// Handle scope changes.
|
|
@@ -317,7 +314,7 @@ CodeMirror.defineMode("python", function(conf, parserConf) {
|
|
|
317
314
|
token: function(stream, state) {
|
|
318
315
|
var style = tokenLexer(stream, state);
|
|
319
316
|
|
|
320
|
-
state.lastToken =
|
|
317
|
+
state.lastToken = style;
|
|
321
318
|
|
|
322
319
|
if (stream.eol() && stream.lambda) {
|
|
323
320
|
state.lambda = false;
|
|
@@ -30,7 +30,7 @@ CodeMirror.defineMode("ruby", function(config, parserConfig) {
|
|
|
30
30
|
return "comment";
|
|
31
31
|
}
|
|
32
32
|
if (stream.eatSpace()) return null;
|
|
33
|
-
var ch = stream.next();
|
|
33
|
+
var ch = stream.next(), m;
|
|
34
34
|
if (ch == "`" || ch == "'" || ch == '"' ||
|
|
35
35
|
(ch == "/" && !stream.eol() && stream.peek() != " ")) {
|
|
36
36
|
return chain(readQuoted(ch, "string", ch == '"' || ch == "`"), stream, state);
|
|
@@ -46,13 +46,8 @@ CodeMirror.defineMode("ruby", function(config, parserConfig) {
|
|
|
46
46
|
} else if (ch == "#") {
|
|
47
47
|
stream.skipToEnd();
|
|
48
48
|
return "comment";
|
|
49
|
-
} else if (ch == "<" && stream.
|
|
50
|
-
|
|
51
|
-
stream.eat(/[\'\"\`]/);
|
|
52
|
-
var match = stream.match(/^\w+/);
|
|
53
|
-
stream.eat(/[\'\"\`]/);
|
|
54
|
-
if (match) return chain(readHereDoc(match[0]), stream, state);
|
|
55
|
-
return null;
|
|
49
|
+
} else if (ch == "<" && (m = stream.match(/^<-?[\`\"\']?([a-zA-Z_?]\w*)[\`\"\']?(?:;|$)/))) {
|
|
50
|
+
return chain(readHereDoc(m[1]), stream, state);
|
|
56
51
|
} else if (ch == "0") {
|
|
57
52
|
if (stream.eat("x")) stream.eatWhile(/[\da-fA-F]/);
|
|
58
53
|
else if (stream.eat("b")) stream.eatWhile(/[01]/);
|
|
@@ -5,7 +5,7 @@ CodeMirror.defineMode("scheme", function (config, mode) {
|
|
|
5
5
|
var BUILTIN = "builtin", COMMENT = "comment", STRING = "string",
|
|
6
6
|
ATOM = "atom", NUMBER = "number", BRACKET = "bracket", KEYWORD="keyword";
|
|
7
7
|
var INDENT_WORD_SKIP = 2, KEYWORDS_SKIP = 1;
|
|
8
|
-
|
|
8
|
+
|
|
9
9
|
function makeKeywords(str) {
|
|
10
10
|
var obj = {}, words = str.split(" ");
|
|
11
11
|
for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
|
|
@@ -14,7 +14,6 @@ CodeMirror.defineMode("scheme", function (config, mode) {
|
|
|
14
14
|
|
|
15
15
|
var keywords = makeKeywords("λ case-lambda call/cc class define-class exit-handler field import inherit init-field interface let*-values let-values let/ec mixin opt-lambda override protect provide public rename require require-for-syntax syntax syntax-case syntax-error unit/sig unless when with-syntax and begin call-with-current-continuation call-with-input-file call-with-output-file case cond define define-syntax delay do dynamic-wind else for-each if lambda let let* let-syntax letrec letrec-syntax map or syntax-rules abs acos angle append apply asin assoc assq assv atan boolean? caar cadr call-with-input-file call-with-output-file call-with-values car cdddar cddddr cdr ceiling char->integer char-alphabetic? char-ci<=? char-ci<? char-ci=? char-ci>=? char-ci>? char-downcase char-lower-case? char-numeric? char-ready? char-upcase char-upper-case? char-whitespace? char<=? char<? char=? char>=? char>? char? close-input-port close-output-port complex? cons cos current-input-port current-output-port denominator display eof-object? eq? equal? eqv? eval even? exact->inexact exact? exp expt #f floor force gcd imag-part inexact->exact inexact? input-port? integer->char integer? interaction-environment lcm length list list->string list->vector list-ref list-tail list? load log magnitude make-polar make-rectangular make-string make-vector max member memq memv min modulo negative? newline not null-environment null? number->string number? numerator odd? open-input-file open-output-file output-port? pair? peek-char port? positive? procedure? quasiquote quote quotient rational? rationalize read read-char real-part real? remainder reverse round scheme-report-environment set! set-car! set-cdr! sin sqrt string string->list string->number string->symbol string-append string-ci<=? string-ci<? string-ci=? string-ci>=? string-ci>? string-copy string-fill! string-length string-ref string-set! string<=? string<? string=? string>=? string>? string? substring symbol->string symbol? #t tan transcript-off transcript-on truncate values vector vector->list vector-fill! vector-length vector-ref vector-set! with-input-from-file with-output-to-file write write-char zero?");
|
|
16
16
|
var indentKeys = makeKeywords("define let letrec let* lambda");
|
|
17
|
-
|
|
18
17
|
|
|
19
18
|
function stateStack(indent, type, prev) { // represents a state stack object
|
|
20
19
|
this.indent = indent;
|
|
@@ -29,21 +28,29 @@ CodeMirror.defineMode("scheme", function (config, mode) {
|
|
|
29
28
|
function popStack(state) {
|
|
30
29
|
state.indentStack = state.indentStack.prev;
|
|
31
30
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
function
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
31
|
+
|
|
32
|
+
var binaryMatcher = new RegExp(/^(?:[-+]i|[-+][01]+#*(?:\/[01]+#*)?i|[-+]?[01]+#*(?:\/[01]+#*)?@[-+]?[01]+#*(?:\/[01]+#*)?|[-+]?[01]+#*(?:\/[01]+#*)?[-+](?:[01]+#*(?:\/[01]+#*)?)?i|[-+]?[01]+#*(?:\/[01]+#*)?)(?=[()\s;"]|$)/i);
|
|
33
|
+
var octalMatcher = new RegExp(/^(?:[-+]i|[-+][0-7]+#*(?:\/[0-7]+#*)?i|[-+]?[0-7]+#*(?:\/[0-7]+#*)?@[-+]?[0-7]+#*(?:\/[0-7]+#*)?|[-+]?[0-7]+#*(?:\/[0-7]+#*)?[-+](?:[0-7]+#*(?:\/[0-7]+#*)?)?i|[-+]?[0-7]+#*(?:\/[0-7]+#*)?)(?=[()\s;"]|$)/i);
|
|
34
|
+
var hexMatcher = new RegExp(/^(?:[-+]i|[-+][\da-f]+#*(?:\/[\da-f]+#*)?i|[-+]?[\da-f]+#*(?:\/[\da-f]+#*)?@[-+]?[\da-f]+#*(?:\/[\da-f]+#*)?|[-+]?[\da-f]+#*(?:\/[\da-f]+#*)?[-+](?:[\da-f]+#*(?:\/[\da-f]+#*)?)?i|[-+]?[\da-f]+#*(?:\/[\da-f]+#*)?)(?=[()\s;"]|$)/i);
|
|
35
|
+
var decimalMatcher = new RegExp(/^(?:[-+]i|[-+](?:(?:(?:\d+#+\.?#*|\d+\.\d*#*|\.\d+#*|\d+)(?:[esfdl][-+]?\d+)?)|\d+#*\/\d+#*)i|[-+]?(?:(?:(?:\d+#+\.?#*|\d+\.\d*#*|\.\d+#*|\d+)(?:[esfdl][-+]?\d+)?)|\d+#*\/\d+#*)@[-+]?(?:(?:(?:\d+#+\.?#*|\d+\.\d*#*|\.\d+#*|\d+)(?:[esfdl][-+]?\d+)?)|\d+#*\/\d+#*)|[-+]?(?:(?:(?:\d+#+\.?#*|\d+\.\d*#*|\.\d+#*|\d+)(?:[esfdl][-+]?\d+)?)|\d+#*\/\d+#*)[-+](?:(?:(?:\d+#+\.?#*|\d+\.\d*#*|\.\d+#*|\d+)(?:[esfdl][-+]?\d+)?)|\d+#*\/\d+#*)?i|(?:(?:(?:\d+#+\.?#*|\d+\.\d*#*|\.\d+#*|\d+)(?:[esfdl][-+]?\d+)?)|\d+#*\/\d+#*))(?=[()\s;"]|$)/i);
|
|
36
|
+
|
|
37
|
+
function isBinaryNumber (stream) {
|
|
38
|
+
return stream.match(binaryMatcher);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function isOctalNumber (stream) {
|
|
42
|
+
return stream.match(octalMatcher);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function isDecimalNumber (stream, backup) {
|
|
46
|
+
if (backup === true) {
|
|
47
|
+
stream.backUp(1);
|
|
45
48
|
}
|
|
46
|
-
return
|
|
49
|
+
return stream.match(decimalMatcher);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function isHexNumber (stream) {
|
|
53
|
+
return stream.match(hexMatcher);
|
|
47
54
|
}
|
|
48
55
|
|
|
49
56
|
return {
|
|
@@ -67,13 +74,13 @@ CodeMirror.defineMode("scheme", function (config, mode) {
|
|
|
67
74
|
return null;
|
|
68
75
|
}
|
|
69
76
|
var returnType = null;
|
|
70
|
-
|
|
77
|
+
|
|
71
78
|
switch(state.mode){
|
|
72
79
|
case "string": // multi-line string parsing mode
|
|
73
80
|
var next, escaped = false;
|
|
74
81
|
while ((next = stream.next()) != null) {
|
|
75
82
|
if (next == "\"" && !escaped) {
|
|
76
|
-
|
|
83
|
+
|
|
77
84
|
state.mode = false;
|
|
78
85
|
break;
|
|
79
86
|
}
|
|
@@ -85,7 +92,7 @@ CodeMirror.defineMode("scheme", function (config, mode) {
|
|
|
85
92
|
var next, maybeEnd = false;
|
|
86
93
|
while ((next = stream.next()) != null) {
|
|
87
94
|
if (next == "#" && maybeEnd) {
|
|
88
|
-
|
|
95
|
+
|
|
89
96
|
state.mode = false;
|
|
90
97
|
break;
|
|
91
98
|
}
|
|
@@ -106,52 +113,73 @@ CodeMirror.defineMode("scheme", function (config, mode) {
|
|
|
106
113
|
}
|
|
107
114
|
default: // default parsing mode
|
|
108
115
|
var ch = stream.next();
|
|
109
|
-
|
|
116
|
+
|
|
110
117
|
if (ch == "\"") {
|
|
111
118
|
state.mode = "string";
|
|
112
119
|
returnType = STRING;
|
|
113
|
-
|
|
120
|
+
|
|
114
121
|
} else if (ch == "'") {
|
|
115
122
|
returnType = ATOM;
|
|
116
123
|
} else if (ch == '#') {
|
|
117
|
-
if (stream.eat("|")) {
|
|
124
|
+
if (stream.eat("|")) { // Multi-line comment
|
|
118
125
|
state.mode = "comment"; // toggle to comment mode
|
|
119
126
|
returnType = COMMENT;
|
|
120
|
-
} else if (stream.eat(/[tf]/)) {
|
|
127
|
+
} else if (stream.eat(/[tf]/i)) { // #t/#f (atom)
|
|
121
128
|
returnType = ATOM;
|
|
122
|
-
} else if (stream.eat(';')) {
|
|
129
|
+
} else if (stream.eat(';')) { // S-Expr comment
|
|
123
130
|
state.mode = "s-expr-comment";
|
|
124
131
|
returnType = COMMENT;
|
|
132
|
+
} else {
|
|
133
|
+
var numTest = null, hasExactness = false, hasRadix = true;
|
|
134
|
+
if (stream.eat(/[ei]/i)) {
|
|
135
|
+
hasExactness = true;
|
|
136
|
+
} else {
|
|
137
|
+
stream.backUp(1); // must be radix specifier
|
|
138
|
+
}
|
|
139
|
+
if (stream.match(/^#b/i)) {
|
|
140
|
+
numTest = isBinaryNumber;
|
|
141
|
+
} else if (stream.match(/^#o/i)) {
|
|
142
|
+
numTest = isOctalNumber;
|
|
143
|
+
} else if (stream.match(/^#x/i)) {
|
|
144
|
+
numTest = isHexNumber;
|
|
145
|
+
} else if (stream.match(/^#d/i)) {
|
|
146
|
+
numTest = isDecimalNumber;
|
|
147
|
+
} else if (stream.match(/^[-+0-9.]/, false)) {
|
|
148
|
+
hasRadix = false;
|
|
149
|
+
numTest = isDecimalNumber;
|
|
150
|
+
// re-consume the intial # if all matches failed
|
|
151
|
+
} else if (!hasExactness) {
|
|
152
|
+
stream.eat('#');
|
|
153
|
+
}
|
|
154
|
+
if (numTest != null) {
|
|
155
|
+
if (hasRadix && !hasExactness) {
|
|
156
|
+
// consume optional exactness after radix
|
|
157
|
+
stream.match(/^#[ei]/i);
|
|
158
|
+
}
|
|
159
|
+
if (numTest(stream))
|
|
160
|
+
returnType = NUMBER;
|
|
161
|
+
}
|
|
125
162
|
}
|
|
126
|
-
|
|
163
|
+
} else if (/^[-+0-9.]/.test(ch) && isDecimalNumber(stream, true)) { // match non-prefixed number, must be decimal
|
|
164
|
+
returnType = NUMBER;
|
|
127
165
|
} else if (ch == ";") { // comment
|
|
128
166
|
stream.skipToEnd(); // rest of the line is a comment
|
|
129
167
|
returnType = COMMENT;
|
|
130
|
-
} else if (ch == "-"){
|
|
131
|
-
|
|
132
|
-
if(!isNaN(parseInt(stream.peek()))){
|
|
133
|
-
stream.eatWhile(/[\/0-9]/);
|
|
134
|
-
returnType = NUMBER;
|
|
135
|
-
}else{
|
|
136
|
-
returnType = null;
|
|
137
|
-
}
|
|
138
|
-
} else if (isNumber(ch,stream)){
|
|
139
|
-
returnType = NUMBER;
|
|
140
168
|
} else if (ch == "(" || ch == "[") {
|
|
141
169
|
var keyWord = ''; var indentTemp = stream.column();
|
|
142
170
|
/**
|
|
143
|
-
Either
|
|
171
|
+
Either
|
|
144
172
|
(indent-word ..
|
|
145
173
|
(non-indent-word ..
|
|
146
174
|
(;something else, bracket, etc.
|
|
147
175
|
*/
|
|
148
|
-
|
|
176
|
+
|
|
149
177
|
while ((letter = stream.eat(/[^\s\(\[\;\)\]]/)) != null) {
|
|
150
178
|
keyWord += letter;
|
|
151
179
|
}
|
|
152
|
-
|
|
180
|
+
|
|
153
181
|
if (keyWord.length > 0 && indentKeys.propertyIsEnumerable(keyWord)) { // indent-word
|
|
154
|
-
|
|
182
|
+
|
|
155
183
|
pushStack(state, indentTemp + INDENT_WORD_SKIP, ch);
|
|
156
184
|
} else { // non-indent word
|
|
157
185
|
// we continue eating the spaces
|
|
@@ -165,15 +193,15 @@ CodeMirror.defineMode("scheme", function (config, mode) {
|
|
|
165
193
|
}
|
|
166
194
|
}
|
|
167
195
|
stream.backUp(stream.current().length - 1); // undo all the eating
|
|
168
|
-
|
|
196
|
+
|
|
169
197
|
if(typeof state.sExprComment == "number") state.sExprComment++;
|
|
170
|
-
|
|
198
|
+
|
|
171
199
|
returnType = BRACKET;
|
|
172
200
|
} else if (ch == ")" || ch == "]") {
|
|
173
201
|
returnType = BRACKET;
|
|
174
202
|
if (state.indentStack != null && state.indentStack.type == (ch == ")" ? "(" : "[")) {
|
|
175
203
|
popStack(state);
|
|
176
|
-
|
|
204
|
+
|
|
177
205
|
if(typeof state.sExprComment == "number"){
|
|
178
206
|
if(--state.sExprComment == 0){
|
|
179
207
|
returnType = COMMENT; // final closing bracket
|
|
@@ -182,11 +210,11 @@ CodeMirror.defineMode("scheme", function (config, mode) {
|
|
|
182
210
|
}
|
|
183
211
|
}
|
|
184
212
|
} else {
|
|
185
|
-
stream.eatWhile(/[\w\$_
|
|
186
|
-
|
|
213
|
+
stream.eatWhile(/[\w\$_\-!$%&*+\.\/:<=>?@\^~]/);
|
|
214
|
+
|
|
187
215
|
if (keywords && keywords.propertyIsEnumerable(stream.current())) {
|
|
188
216
|
returnType = BUILTIN;
|
|
189
|
-
}else returnType =
|
|
217
|
+
} else returnType = "variable";
|
|
190
218
|
}
|
|
191
219
|
}
|
|
192
220
|
return (typeof state.sExprComment == "number") ? COMMENT : returnType;
|
|
@@ -199,4 +227,4 @@ CodeMirror.defineMode("scheme", function (config, mode) {
|
|
|
199
227
|
};
|
|
200
228
|
});
|
|
201
229
|
|
|
202
|
-
CodeMirror.defineMIME("text/x-scheme", "scheme");
|
|
230
|
+
CodeMirror.defineMIME("text/x-scheme", "scheme");
|
|
@@ -1,8 +1,26 @@
|
|
|
1
1
|
CodeMirror.defineMode('shell', function(config) {
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
var words = {};
|
|
4
|
+
function define(style, string) {
|
|
5
|
+
var split = string.split(' ');
|
|
6
|
+
for(var i = 0; i < split.length; i++) {
|
|
7
|
+
words[split[i]] = style;
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
// Atoms
|
|
12
|
+
define('atom', 'true false');
|
|
13
|
+
|
|
14
|
+
// Keywords
|
|
15
|
+
define('keyword', 'if then do else elif while until for in esac fi fin ' +
|
|
16
|
+
'fil done exit set unset export function');
|
|
17
|
+
|
|
18
|
+
// Commands
|
|
19
|
+
define('builtin', 'ab awk bash beep cat cc cd chown chmod chroot clear cp ' +
|
|
20
|
+
'curl cut diff echo find gawk gcc get git grep kill killall ln ls make ' +
|
|
21
|
+
'mkdir openssl mv nc node npm ping ps restart rm rmdir sed service sh ' +
|
|
22
|
+
'shopt shred source sort sleep ssh start stop su sudo tee telnet top ' +
|
|
23
|
+
'touch vi vim wall wc wget who write yes zsh');
|
|
6
24
|
|
|
7
25
|
function tokenBase(stream, state) {
|
|
8
26
|
|
|
@@ -42,10 +60,7 @@ CodeMirror.defineMode('shell', function(config) {
|
|
|
42
60
|
stream.eatWhile(/\w/);
|
|
43
61
|
var cur = stream.current();
|
|
44
62
|
if (stream.peek() === '=' && /\w+/.test(cur)) return 'def';
|
|
45
|
-
|
|
46
|
-
if (commands.indexOf(cur) !== -1) return 'builtin';
|
|
47
|
-
if (keywords.indexOf(cur) !== -1) return 'keyword';
|
|
48
|
-
return 'word';
|
|
63
|
+
return words[cur] || null;
|
|
49
64
|
}
|
|
50
65
|
|
|
51
66
|
function tokenString(quote) {
|
|
@@ -85,10 +85,12 @@ CodeMirror.defineMode("stex", function(cmCfg, modeCfg)
|
|
|
85
85
|
if (source.match(/^\\[a-zA-Z@]+/)) {
|
|
86
86
|
var cmdName = source.current();
|
|
87
87
|
cmdName = cmdName.substr(1, cmdName.length-1);
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
88
|
+
var plug;
|
|
89
|
+
if (plugins.hasOwnProperty(cmdName)) {
|
|
90
|
+
plug = plugins[cmdName];
|
|
91
|
+
} else {
|
|
92
|
+
plug = plugins["DEFAULT"];
|
|
93
|
+
}
|
|
92
94
|
plug = new plug();
|
|
93
95
|
pushCommand(state, plug);
|
|
94
96
|
setState(state, beginParams);
|
|
@@ -176,5 +178,5 @@ CodeMirror.defineMode("stex", function(cmCfg, modeCfg)
|
|
|
176
178
|
};
|
|
177
179
|
});
|
|
178
180
|
|
|
179
|
-
|
|
180
181
|
CodeMirror.defineMIME("text/x-stex", "stex");
|
|
182
|
+
CodeMirror.defineMIME("text/x-latex", "stex");
|
|
@@ -107,10 +107,10 @@ CodeMirror.defineMode("tiddlywiki", function (config, parserConfig) {
|
|
|
107
107
|
return ret('quote', 'quote');
|
|
108
108
|
}
|
|
109
109
|
if (stream.match(reWikiCommentStart) || stream.match(reWikiCommentStop)) {
|
|
110
|
-
return ret('code', '
|
|
110
|
+
return ret('code', 'comment');
|
|
111
111
|
}
|
|
112
112
|
if (stream.match(reJsCodeStart) || stream.match(reJsCodeStop) || stream.match(reXmlCodeStart) || stream.match(reXmlCodeStop)) {
|
|
113
|
-
return ret('code', '
|
|
113
|
+
return ret('code', 'comment');
|
|
114
114
|
}
|
|
115
115
|
if (stream.match(reHR)) {
|
|
116
116
|
return ret('hr', 'hr');
|
|
@@ -125,26 +125,26 @@ CodeMirror.defineMode("tiddlywiki", function (config, parserConfig) {
|
|
|
125
125
|
}
|
|
126
126
|
if (ch == "*") { // tw list
|
|
127
127
|
stream.eatWhile('*');
|
|
128
|
-
return ret("list", "
|
|
128
|
+
return ret("list", "comment");
|
|
129
129
|
}
|
|
130
130
|
if (ch == "#") { // tw numbered list
|
|
131
131
|
stream.eatWhile('#');
|
|
132
|
-
return ret("list", "
|
|
132
|
+
return ret("list", "comment");
|
|
133
133
|
}
|
|
134
134
|
if (ch == ";") { // definition list, term
|
|
135
135
|
stream.eatWhile(';');
|
|
136
|
-
return ret("list", "
|
|
136
|
+
return ret("list", "comment");
|
|
137
137
|
}
|
|
138
138
|
if (ch == ":") { // definition list, description
|
|
139
139
|
stream.eatWhile(':');
|
|
140
|
-
return ret("list", "
|
|
140
|
+
return ret("list", "comment");
|
|
141
141
|
}
|
|
142
142
|
if (ch == ">") { // single line quote
|
|
143
143
|
stream.eatWhile(">");
|
|
144
144
|
return ret("quote", "quote");
|
|
145
145
|
}
|
|
146
146
|
if (ch == '|') {
|
|
147
|
-
return ret('table', '
|
|
147
|
+
return ret('table', 'header');
|
|
148
148
|
}
|
|
149
149
|
}
|
|
150
150
|
|
|
@@ -155,7 +155,7 @@ CodeMirror.defineMode("tiddlywiki", function (config, parserConfig) {
|
|
|
155
155
|
// rudimentary html:// file:// link matching. TW knows much more ...
|
|
156
156
|
if (/[hf]/i.test(ch)) {
|
|
157
157
|
if (/[ti]/i.test(stream.peek()) && stream.match(/\b(ttps?|tp|ile):\/\/[\-A-Z0-9+&@#\/%?=~_|$!:,.;]*[A-Z0-9+&@#\/%=~_|$]/i)) {
|
|
158
|
-
return ret("link
|
|
158
|
+
return ret("link", "link");
|
|
159
159
|
}
|
|
160
160
|
}
|
|
161
161
|
// just a little string indicator, don't want to have the whole string covered
|
|
@@ -173,7 +173,7 @@ CodeMirror.defineMode("tiddlywiki", function (config, parserConfig) {
|
|
|
173
173
|
}
|
|
174
174
|
if (ch == "@") { // check for space link. TODO fix @@...@@ highlighting
|
|
175
175
|
stream.eatWhile(isSpaceName);
|
|
176
|
-
return ret("link
|
|
176
|
+
return ret("link", "link");
|
|
177
177
|
}
|
|
178
178
|
if (/\d/.test(ch)) { // numbers
|
|
179
179
|
stream.eatWhile(/\d/);
|
|
@@ -266,21 +266,21 @@ CodeMirror.defineMode("tiddlywiki", function (config, parserConfig) {
|
|
|
266
266
|
var ch, sb = state.block;
|
|
267
267
|
|
|
268
268
|
if (sb && stream.current()) {
|
|
269
|
-
return ret("code", "
|
|
269
|
+
return ret("code", "comment");
|
|
270
270
|
}
|
|
271
271
|
|
|
272
272
|
if (!sb && stream.match(reUntilCodeStop)) {
|
|
273
273
|
state.tokenize = jsTokenBase;
|
|
274
|
-
return ret("code", "
|
|
274
|
+
return ret("code", "comment");
|
|
275
275
|
}
|
|
276
276
|
|
|
277
277
|
if (sb && stream.sol() && stream.match(reCodeBlockStop)) {
|
|
278
278
|
state.tokenize = jsTokenBase;
|
|
279
|
-
return ret("code", "
|
|
279
|
+
return ret("code", "comment");
|
|
280
280
|
}
|
|
281
281
|
|
|
282
282
|
ch = stream.next();
|
|
283
|
-
return (sb) ? ret("code", "
|
|
283
|
+
return (sb) ? ret("code", "comment") : ret("code", "comment");
|
|
284
284
|
}
|
|
285
285
|
|
|
286
286
|
// tw em / italic
|
|
@@ -324,7 +324,7 @@ CodeMirror.defineMode("tiddlywiki", function (config, parserConfig) {
|
|
|
324
324
|
}
|
|
325
325
|
maybeEnd = (ch == "-");
|
|
326
326
|
}
|
|
327
|
-
return ret("text", "
|
|
327
|
+
return ret("text", "strikethrough");
|
|
328
328
|
}
|
|
329
329
|
|
|
330
330
|
// macro
|