fine tuning codemirror styles

This commit is contained in:
Raymond Hill 2018-03-01 11:26:24 -05:00
parent 273c80564a
commit 8680bbc086
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
2 changed files with 22 additions and 15 deletions

View File

@ -8,3 +8,7 @@
height: 100%; height: 100%;
width: 100%; width: 100%;
} }
.cm-s-default .cm-comment {color: #777;}
.cm-staticext {color: #008;}
.cm-staticnet.cm-block {color: #800;}
.cm-staticnet.cm-allow {color: #060;}

View File

@ -24,26 +24,29 @@
'use strict'; 'use strict';
CodeMirror.defineMode("ubo-static-filtering", function() { CodeMirror.defineMode("ubo-static-filtering", function() {
var reNotSpace = /\S/;
var reComment = /^(?:!|#[^#@]|#@[^#])/;
var reExt = /^[^#]*#(?:#[^#]|##[^#]|@#)/;
var reNetAllow = /^@@/;
return { return {
token: function(stream) { token: function(stream) {
if ( stream.sol() === false ) { var style = null;
return null; var pos = stream.string.search(reNotSpace);
} if ( pos !== -1 ) {
stream.eatSpace(); var s = stream.string.slice(pos);
var c = stream.next(); if ( reComment.test(s) ) {
if ( c === '!' ) { style = 'comment';
stream.skipToEnd(); } else if ( reExt.test(s) ) {
return 'comment'; style = 'staticext';
} } else if ( reNetAllow.test(s) ) {
if ( c === '#' ) { style = 'staticnet allow';
c = stream.next(); } else {
if ( c !== '#' && c !== '@' ) { style = 'staticnet block';
stream.skipToEnd();
return 'comment';
} }
} }
stream.skipToEnd(); stream.skipToEnd();
return null; return style;
} }
}; };
}); });