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