codemirror-rails 4.12 → 4.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/codemirror/rails/version.rb +2 -2
- data/vendor/assets/javascripts/codemirror.js +45 -22
- data/vendor/assets/javascripts/codemirror/addons/edit/closebrackets.js +6 -4
- data/vendor/assets/javascripts/codemirror/addons/edit/closetag.js +1 -1
- data/vendor/assets/javascripts/codemirror/addons/fold/foldgutter.js +12 -4
- data/vendor/assets/javascripts/codemirror/addons/hint/show-hint.js +14 -9
- data/vendor/assets/javascripts/codemirror/addons/hint/sql-hint.js +94 -51
- data/vendor/assets/javascripts/codemirror/addons/lint/lint.js +2 -1
- data/vendor/assets/javascripts/codemirror/addons/merge/merge.js +211 -123
- data/vendor/assets/javascripts/codemirror/addons/scroll/annotatescrollbar.js +36 -12
- data/vendor/assets/javascripts/codemirror/addons/search/matchesonscrollbar.js +9 -4
- data/vendor/assets/javascripts/codemirror/addons/selection/selection-pointer.js +3 -0
- data/vendor/assets/javascripts/codemirror/addons/tern/tern.js +31 -4
- data/vendor/assets/javascripts/codemirror/keymaps/vim.js +46 -7
- data/vendor/assets/javascripts/codemirror/modes/clike.js +5 -1
- data/vendor/assets/javascripts/codemirror/modes/css.js +104 -55
- data/vendor/assets/javascripts/codemirror/modes/cypher.js +1 -1
- data/vendor/assets/javascripts/codemirror/modes/forth.js +180 -0
- data/vendor/assets/javascripts/codemirror/modes/go.js +1 -0
- data/vendor/assets/javascripts/codemirror/modes/idl.js +1 -1
- data/vendor/assets/javascripts/codemirror/modes/javascript.js +1 -1
- data/vendor/assets/javascripts/codemirror/modes/sql.js +1 -1
- data/vendor/assets/javascripts/codemirror/modes/stylus.js +444 -0
- data/vendor/assets/javascripts/codemirror/modes/verilog.js +192 -19
- data/vendor/assets/stylesheets/codemirror/themes/colorforth.css +33 -0
- metadata +4 -1
@@ -17,7 +17,8 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) {
|
|
17
17
|
statementIndentUnit = parserConfig.statementIndentUnit || indentUnit,
|
18
18
|
dontAlignCalls = parserConfig.dontAlignCalls,
|
19
19
|
noIndentKeywords = parserConfig.noIndentKeywords || [],
|
20
|
-
multiLineStrings = parserConfig.multiLineStrings
|
20
|
+
multiLineStrings = parserConfig.multiLineStrings,
|
21
|
+
hooks = parserConfig.hooks || {};
|
21
22
|
|
22
23
|
function words(str) {
|
23
24
|
var obj = {}, words = str.split(" ");
|
@@ -107,7 +108,11 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) {
|
|
107
108
|
var statementKeywords = words("always always_comb always_ff always_latch assert assign assume else export for foreach forever if import initial repeat while");
|
108
109
|
|
109
110
|
function tokenBase(stream, state) {
|
110
|
-
var ch = stream.peek();
|
111
|
+
var ch = stream.peek(), style;
|
112
|
+
if (hooks[ch] && (style = hooks[ch](stream, state)) != false) return style;
|
113
|
+
if (hooks.tokenBase && (style = hooks.tokenBase(stream, state)) != false)
|
114
|
+
return style;
|
115
|
+
|
111
116
|
if (/[,;:\.]/.test(ch)) {
|
112
117
|
curPunc = stream.next();
|
113
118
|
return null;
|
@@ -280,12 +285,14 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) {
|
|
280
285
|
electricInput: buildElectricInputRegEx(),
|
281
286
|
|
282
287
|
startState: function(basecolumn) {
|
283
|
-
|
288
|
+
var state = {
|
284
289
|
tokenize: null,
|
285
290
|
context: new Context((basecolumn || 0) - indentUnit, 0, "top", false),
|
286
291
|
indented: 0,
|
287
292
|
startOfLine: true
|
288
293
|
};
|
294
|
+
if (hooks.startState) hooks.startState(state);
|
295
|
+
return state;
|
289
296
|
},
|
290
297
|
|
291
298
|
token: function(stream, state) {
|
@@ -295,6 +302,7 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) {
|
|
295
302
|
state.indented = stream.indentation();
|
296
303
|
state.startOfLine = true;
|
297
304
|
}
|
305
|
+
if (hooks.token) hooks.token(stream, state);
|
298
306
|
if (stream.eatSpace()) return null;
|
299
307
|
curPunc = null;
|
300
308
|
curKeyword = null;
|
@@ -304,17 +312,19 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) {
|
|
304
312
|
|
305
313
|
if (curPunc == ctx.type) {
|
306
314
|
popContext(state);
|
307
|
-
}
|
308
|
-
else if ((curPunc == ";" && ctx.type == "statement") ||
|
315
|
+
} else if ((curPunc == ";" && ctx.type == "statement") ||
|
309
316
|
(ctx.type && isClosing(curKeyword, ctx.type))) {
|
310
317
|
ctx = popContext(state);
|
311
318
|
while (ctx && ctx.type == "statement") ctx = popContext(state);
|
312
|
-
}
|
313
|
-
|
314
|
-
else if (curPunc == "[") {
|
315
|
-
|
316
|
-
else if (
|
317
|
-
|
319
|
+
} else if (curPunc == "{") {
|
320
|
+
pushContext(state, stream.column(), "}");
|
321
|
+
} else if (curPunc == "[") {
|
322
|
+
pushContext(state, stream.column(), "]");
|
323
|
+
} else if (curPunc == "(") {
|
324
|
+
pushContext(state, stream.column(), ")");
|
325
|
+
} else if (ctx && ctx.type == "endcase" && curPunc == ":") {
|
326
|
+
pushContext(state, stream.column(), "statement");
|
327
|
+
} else if (curPunc == "newstatement") {
|
318
328
|
pushContext(state, stream.column(), "statement");
|
319
329
|
} else if (curPunc == "newblock") {
|
320
330
|
if (curKeyword == "function" && ctx && (ctx.type == "statement" || ctx.type == "endgroup")) {
|
@@ -335,13 +345,16 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) {
|
|
335
345
|
|
336
346
|
indent: function(state, textAfter) {
|
337
347
|
if (state.tokenize != tokenBase && state.tokenize != null) return CodeMirror.Pass;
|
348
|
+
if (hooks.indent) {
|
349
|
+
var fromHook = hooks.indent(state);
|
350
|
+
if (fromHook >= 0) return fromHook;
|
351
|
+
}
|
338
352
|
var ctx = state.context, firstChar = textAfter && textAfter.charAt(0);
|
339
353
|
if (ctx.type == "statement" && firstChar == "}") ctx = ctx.prev;
|
340
354
|
var closing = false;
|
341
355
|
var possibleClosing = textAfter.match(closingBracketOrWord);
|
342
|
-
if (possibleClosing)
|
356
|
+
if (possibleClosing)
|
343
357
|
closing = isClosing(possibleClosing[0], ctx.type);
|
344
|
-
}
|
345
358
|
if (ctx.type == "statement") return ctx.indented + (firstChar == "{" ? 0 : statementIndentUnit);
|
346
359
|
else if (closingBracket.test(ctx.type) && ctx.align && !dontAlignCalls) return ctx.column + (closing ? 0 : 1);
|
347
360
|
else if (ctx.type == ")" && !closing) return ctx.indented + statementIndentUnit;
|
@@ -354,11 +367,171 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) {
|
|
354
367
|
};
|
355
368
|
});
|
356
369
|
|
357
|
-
CodeMirror.defineMIME("text/x-verilog", {
|
358
|
-
|
359
|
-
});
|
360
|
-
|
361
|
-
|
362
|
-
|
370
|
+
CodeMirror.defineMIME("text/x-verilog", {
|
371
|
+
name: "verilog"
|
372
|
+
});
|
373
|
+
|
374
|
+
CodeMirror.defineMIME("text/x-systemverilog", {
|
375
|
+
name: "verilog"
|
376
|
+
});
|
377
|
+
|
378
|
+
// SVXVerilog mode
|
379
|
+
|
380
|
+
var svxchScopePrefixes = {
|
381
|
+
">": "property", "->": "property", "-": "hr", "|": "link", "?$": "qualifier", "?*": "qualifier",
|
382
|
+
"@-": "variable-3", "@": "variable-3", "?": "qualifier"
|
383
|
+
};
|
363
384
|
|
385
|
+
function svxGenIndent(stream, state) {
|
386
|
+
var svxindentUnit = 2;
|
387
|
+
var rtnIndent = -1, indentUnitRq = 0, curIndent = stream.indentation();
|
388
|
+
switch (state.svxCurCtlFlowChar) {
|
389
|
+
case "\\":
|
390
|
+
curIndent = 0;
|
391
|
+
break;
|
392
|
+
case "|":
|
393
|
+
if (state.svxPrevPrevCtlFlowChar == "@") {
|
394
|
+
indentUnitRq = -2; //-2 new pipe rq after cur pipe
|
395
|
+
break;
|
396
|
+
}
|
397
|
+
if (svxchScopePrefixes[state.svxPrevCtlFlowChar])
|
398
|
+
indentUnitRq = 1; // +1 new scope
|
399
|
+
break;
|
400
|
+
case "M": // m4
|
401
|
+
if (state.svxPrevPrevCtlFlowChar == "@") {
|
402
|
+
indentUnitRq = -2; //-2 new inst rq after pipe
|
403
|
+
break;
|
404
|
+
}
|
405
|
+
if (svxchScopePrefixes[state.svxPrevCtlFlowChar])
|
406
|
+
indentUnitRq = 1; // +1 new scope
|
407
|
+
break;
|
408
|
+
case "@":
|
409
|
+
if (state.svxPrevCtlFlowChar == "S")
|
410
|
+
indentUnitRq = -1; // new pipe stage after stmts
|
411
|
+
if (state.svxPrevCtlFlowChar == "|")
|
412
|
+
indentUnitRq = 1; // 1st pipe stage
|
413
|
+
break;
|
414
|
+
case "S":
|
415
|
+
if (state.svxPrevCtlFlowChar == "@")
|
416
|
+
indentUnitRq = 1; // flow in pipe stage
|
417
|
+
if (svxchScopePrefixes[state.svxPrevCtlFlowChar])
|
418
|
+
indentUnitRq = 1; // +1 new scope
|
419
|
+
break;
|
420
|
+
}
|
421
|
+
var statementIndentUnit = svxindentUnit;
|
422
|
+
rtnIndent = curIndent + (indentUnitRq*statementIndentUnit);
|
423
|
+
return rtnIndent >= 0 ? rtnIndent : curIndent;
|
424
|
+
}
|
425
|
+
|
426
|
+
CodeMirror.defineMIME("text/x-svx", {
|
427
|
+
name: "verilog",
|
428
|
+
hooks: {
|
429
|
+
"\\": function(stream, state) {
|
430
|
+
var vxIndent = 0, style = false;
|
431
|
+
var curPunc = stream.string;
|
432
|
+
if ((stream.sol()) && (/\\SV/.test(stream.string))) {
|
433
|
+
curPunc = (/\\SVX_version/.test(stream.string))
|
434
|
+
? "\\SVX_version" : stream.string;
|
435
|
+
stream.skipToEnd();
|
436
|
+
if (curPunc == "\\SV" && state.vxCodeActive) {state.vxCodeActive = false;};
|
437
|
+
if ((/\\SVX/.test(curPunc) && !state.vxCodeActive)
|
438
|
+
|| (curPunc=="\\SVX_version" && state.vxCodeActive)) {state.vxCodeActive = true;};
|
439
|
+
style = "keyword";
|
440
|
+
state.svxCurCtlFlowChar = state.svxPrevPrevCtlFlowChar
|
441
|
+
= state.svxPrevCtlFlowChar = "";
|
442
|
+
if (state.vxCodeActive == true) {
|
443
|
+
state.svxCurCtlFlowChar = "\\";
|
444
|
+
vxIndent = svxGenIndent(stream, state);
|
445
|
+
}
|
446
|
+
state.vxIndentRq = vxIndent;
|
447
|
+
}
|
448
|
+
return style;
|
449
|
+
},
|
450
|
+
tokenBase: function(stream, state) {
|
451
|
+
var vxIndent = 0, style = false;
|
452
|
+
var svxisOperatorChar = /[\[\]=:]/;
|
453
|
+
var svxkpScopePrefixs = {
|
454
|
+
"**":"variable-2", "*":"variable-2", "$$":"variable", "$":"variable",
|
455
|
+
"^^":"attribute", "^":"attribute"};
|
456
|
+
var ch = stream.peek();
|
457
|
+
var vxCurCtlFlowCharValueAtStart = state.svxCurCtlFlowChar;
|
458
|
+
if (state.vxCodeActive == true) {
|
459
|
+
if (/[\[\]{}\(\);\:]/.test(ch)) {
|
460
|
+
// bypass nesting and 1 char punc
|
461
|
+
style = "meta";
|
462
|
+
stream.next();
|
463
|
+
} else if (ch == "/") {
|
464
|
+
stream.next();
|
465
|
+
if (stream.eat("/")) {
|
466
|
+
stream.skipToEnd();
|
467
|
+
style = "comment";
|
468
|
+
state.svxCurCtlFlowChar = "S";
|
469
|
+
} else {
|
470
|
+
stream.backUp(1);
|
471
|
+
}
|
472
|
+
} else if (ch == "@") {
|
473
|
+
// pipeline stage
|
474
|
+
style = svxchScopePrefixes[ch];
|
475
|
+
state.svxCurCtlFlowChar = "@";
|
476
|
+
stream.next();
|
477
|
+
stream.eatWhile(/[\w\$_]/);
|
478
|
+
} else if (stream.match(/\b[mM]4+/, true)) { // match: function(pattern, consume, caseInsensitive)
|
479
|
+
// m4 pre proc
|
480
|
+
stream.skipTo("(");
|
481
|
+
style = "def";
|
482
|
+
state.svxCurCtlFlowChar = "M";
|
483
|
+
} else if (ch == "!" && stream.sol()) {
|
484
|
+
// v stmt in svx region
|
485
|
+
// state.svxCurCtlFlowChar = "S";
|
486
|
+
style = "comment";
|
487
|
+
stream.next();
|
488
|
+
} else if (svxisOperatorChar.test(ch)) {
|
489
|
+
// operators
|
490
|
+
stream.eatWhile(svxisOperatorChar);
|
491
|
+
style = "operator";
|
492
|
+
} else if (ch == "#") {
|
493
|
+
// phy hier
|
494
|
+
state.svxCurCtlFlowChar = (state.svxCurCtlFlowChar == "")
|
495
|
+
? ch : state.svxCurCtlFlowChar;
|
496
|
+
stream.next();
|
497
|
+
stream.eatWhile(/[+-]\d/);
|
498
|
+
style = "tag";
|
499
|
+
} else if (svxkpScopePrefixs.propertyIsEnumerable(ch)) {
|
500
|
+
// special SVX operators
|
501
|
+
style = svxkpScopePrefixs[ch];
|
502
|
+
state.svxCurCtlFlowChar = state.svxCurCtlFlowChar == "" ? "S" : state.svxCurCtlFlowChar; // stmt
|
503
|
+
stream.next();
|
504
|
+
stream.match(/[a-zA-Z_0-9]+/);
|
505
|
+
} else if (style = svxchScopePrefixes[ch] || false) {
|
506
|
+
// special SVX operators
|
507
|
+
state.svxCurCtlFlowChar = state.svxCurCtlFlowChar == "" ? ch : state.svxCurCtlFlowChar;
|
508
|
+
stream.next();
|
509
|
+
stream.match(/[a-zA-Z_0-9]+/);
|
510
|
+
}
|
511
|
+
if (state.svxCurCtlFlowChar != vxCurCtlFlowCharValueAtStart) { // flow change
|
512
|
+
vxIndent = svxGenIndent(stream, state);
|
513
|
+
state.vxIndentRq = vxIndent;
|
514
|
+
}
|
515
|
+
}
|
516
|
+
return style;
|
517
|
+
},
|
518
|
+
token: function(stream, state) {
|
519
|
+
if (state.vxCodeActive == true && stream.sol() && state.svxCurCtlFlowChar != "") {
|
520
|
+
state.svxPrevPrevCtlFlowChar = state.svxPrevCtlFlowChar;
|
521
|
+
state.svxPrevCtlFlowChar = state.svxCurCtlFlowChar;
|
522
|
+
state.svxCurCtlFlowChar = "";
|
523
|
+
}
|
524
|
+
},
|
525
|
+
indent: function(state) {
|
526
|
+
return (state.vxCodeActive == true) ? state.vxIndentRq : -1;
|
527
|
+
},
|
528
|
+
startState: function(state) {
|
529
|
+
state.svxCurCtlFlowChar = "";
|
530
|
+
state.svxPrevCtlFlowChar = "";
|
531
|
+
state.svxPrevPrevCtlFlowChar = "";
|
532
|
+
state.vxCodeActive = true;
|
533
|
+
state.vxIndentRq = 0;
|
534
|
+
}
|
535
|
+
}
|
536
|
+
});
|
364
537
|
});
|
@@ -0,0 +1,33 @@
|
|
1
|
+
.cm-s-colorforth.CodeMirror { background: #000000; color: #f8f8f8; }
|
2
|
+
.cm-s-colorforth .CodeMirror-gutters { background: #0a001f; border-right: 1px solid #aaa; }
|
3
|
+
.cm-s-colorforth .CodeMirror-guttermarker { color: #FFBD40; }
|
4
|
+
.cm-s-colorforth .CodeMirror-guttermarker-subtle { color: #78846f; }
|
5
|
+
.cm-s-colorforth .CodeMirror-linenumber { color: #bababa; }
|
6
|
+
.cm-s-colorforth .CodeMirror-cursor { border-left: 1px solid white !important; }
|
7
|
+
|
8
|
+
.cm-s-colorforth span.cm-comment { color: #ededed; }
|
9
|
+
.cm-s-colorforth span.cm-def { color: #ff1c1c; font-weight:bold; }
|
10
|
+
.cm-s-colorforth span.cm-keyword { color: #ffd900; }
|
11
|
+
.cm-s-colorforth span.cm-builtin { color: #00d95a; }
|
12
|
+
.cm-s-colorforth span.cm-variable { color: #73ff00; }
|
13
|
+
.cm-s-colorforth span.cm-string { color: #007bff; }
|
14
|
+
.cm-s-colorforth span.cm-number { color: #00c4ff; }
|
15
|
+
.cm-s-colorforth span.cm-atom { color: #606060; }
|
16
|
+
|
17
|
+
.cm-s-colorforth span.cm-variable-2 { color: #EEE; }
|
18
|
+
.cm-s-colorforth span.cm-variable-3 { color: #DDD; }
|
19
|
+
.cm-s-colorforth span.cm-property {}
|
20
|
+
.cm-s-colorforth span.cm-operator {}
|
21
|
+
|
22
|
+
.cm-s-colorforth span.cm-meta { color: yellow; }
|
23
|
+
.cm-s-colorforth span.cm-qualifier { color: #FFF700; }
|
24
|
+
.cm-s-colorforth span.cm-bracket { color: #cc7; }
|
25
|
+
.cm-s-colorforth span.cm-tag { color: #FFBD40; }
|
26
|
+
.cm-s-colorforth span.cm-attribute { color: #FFF700; }
|
27
|
+
.cm-s-colorforth span.cm-error { color: #f00; }
|
28
|
+
|
29
|
+
.cm-s-colorforth .CodeMirror-selected { background: #333d53 !important; }
|
30
|
+
|
31
|
+
.cm-s-colorforth span.cm-compilation { background: rgba(255, 255, 255, 0.12); }
|
32
|
+
|
33
|
+
.cm-s-colorforth .CodeMirror-activeline-background {background: #253540 !important;}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: codemirror-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '4.
|
4
|
+
version: '4.13'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathan Fixler
|
@@ -287,6 +287,7 @@ files:
|
|
287
287
|
- vendor/assets/javascripts/codemirror/modes/ecl.js
|
288
288
|
- vendor/assets/javascripts/codemirror/modes/eiffel.js
|
289
289
|
- vendor/assets/javascripts/codemirror/modes/erlang.js
|
290
|
+
- vendor/assets/javascripts/codemirror/modes/forth.js
|
290
291
|
- vendor/assets/javascripts/codemirror/modes/fortran.js
|
291
292
|
- vendor/assets/javascripts/codemirror/modes/gas.js
|
292
293
|
- vendor/assets/javascripts/codemirror/modes/gfm.js
|
@@ -342,6 +343,7 @@ files:
|
|
342
343
|
- vendor/assets/javascripts/codemirror/modes/spreadsheet.js
|
343
344
|
- vendor/assets/javascripts/codemirror/modes/sql.js
|
344
345
|
- vendor/assets/javascripts/codemirror/modes/stex.js
|
346
|
+
- vendor/assets/javascripts/codemirror/modes/stylus.js
|
345
347
|
- vendor/assets/javascripts/codemirror/modes/tcl.js
|
346
348
|
- vendor/assets/javascripts/codemirror/modes/textile.js
|
347
349
|
- vendor/assets/javascripts/codemirror/modes/tiddlywiki.js
|
@@ -377,6 +379,7 @@ files:
|
|
377
379
|
- vendor/assets/stylesheets/codemirror/themes/base16-light.css
|
378
380
|
- vendor/assets/stylesheets/codemirror/themes/blackboard.css
|
379
381
|
- vendor/assets/stylesheets/codemirror/themes/cobalt.css
|
382
|
+
- vendor/assets/stylesheets/codemirror/themes/colorforth.css
|
380
383
|
- vendor/assets/stylesheets/codemirror/themes/eclipse.css
|
381
384
|
- vendor/assets/stylesheets/codemirror/themes/elegant.css
|
382
385
|
- vendor/assets/stylesheets/codemirror/themes/erlang-dark.css
|