Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 13 additions & 65 deletions editor/js/extra/codemirror/blackboard.css
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,84 +1,32 @@
/* Port of TextMate's Blackboard theme */

.cm-s-blackboard.CodeMirror { background: #1D1D1D; color: #F8F8F8; } /* #111 */
.cm-s-blackboard .CodeMirror-selected { background: #253B76; } /* */
.cm-s-blackboard .CodeMirror-gutters { background: #0C1021; border-right: 0; } /* */
.cm-s-blackboard .CodeMirror-linenumber { color: #717175; }
.cm-s-blackboard .CodeMirror-cursor { border-left: 1px solid #A7A7A7 !important; }
.cm-s-blackboard .CodeMirror-activeline { background: #303030 !important; }
.cm-s-blackboard.CodeMirror { background: #0C1021; color: #F8F8F8; }
.cm-s-blackboard div.CodeMirror-selected { background: #253B76; }
.cm-s-blackboard .CodeMirror-line::selection, .cm-s-blackboard .CodeMirror-line > span::selection, .cm-s-blackboard .CodeMirror-line > span > span::selection { background: rgba(37, 59, 118, .99); }
.cm-s-blackboard .CodeMirror-line::-moz-selection, .cm-s-blackboard .CodeMirror-line > span::-moz-selection, .cm-s-blackboard .CodeMirror-line > span > span::-moz-selection { background: rgba(37, 59, 118, .99); }
.cm-s-blackboard .CodeMirror-gutters { background: #0C1021; border-right: 0; }
.cm-s-blackboard .CodeMirror-guttermarker { color: #FBDE2D; }
.cm-s-blackboard .CodeMirror-guttermarker-subtle { color: #888; }
.cm-s-blackboard .CodeMirror-linenumber { color: #888; }
.cm-s-blackboard .CodeMirror-cursor { border-left: 1px solid #A7A7A7; }

.cm-s-blackboard .cm-keyword { color: #FBDE2D; }
.cm-s-blackboard .cm-atom { color: #D8FA3C; }
.cm-s-blackboard .cm-number { color: #D8FA3C; }
.cm-s-blackboard .cm-def { color: #8DA6CE; }
.cm-s-blackboard .cm-variable { color: #FF6400; }
.cm-s-blackboard .cm-operator { color: #FBDE2D;}
.cm-s-blackboard .cm-operator { color: #FBDE2D; }
.cm-s-blackboard .cm-comment { color: #AEAEAE; }
.cm-s-blackboard .cm-string { color: #61CE3C; }
.cm-s-blackboard .cm-string-2 { color: #61CE3C; }
.cm-s-blackboard .cm-meta { color: #D8FA3C; }
.cm-s-blackboard .cm-error { background: #9D1E15; color: #F8F8F8; }
.cm-s-blackboard .cm-builtin { color: #8DA6CE; }
.cm-s-blackboard .cm-tag { color: #8DA6CE; }
.cm-s-blackboard .cm-attribute { color: #8DA6CE; }
.cm-s-blackboard .cm-header { color: #FF6400; }
.cm-s-blackboard .cm-hr { color: #AEAEAE; }
.cm-s-blackboard .cm-link { color: #8DA6CE; }
.cm-s-blackboard .cm-error { background: #9D1E15; color: #F8F8F8; }


/* TAMAT */

.CodeMirror {
/*font-family: Source Code !important;*/
color: #AAA !important;
font-size: 15px;
height: 100% !important;
}

.CodeMirror-scroll {
height: 100%;
background-color: transparent;
}

/*
.cm-s-blackboard .CodeMirror-gutter { background-color: #1a1a1a !important; z-index: 0; }
.cm-s-blackboard .CodeMirror-linenumber { color: #444; }
.cm-s-blackboard .cm-comment { color: #64614e !important; }
.cm-s-blackboard .cm-keyword { color: #be275e !important; }
.cm-s-blackboard .cm-string { color: #FF88FF !important; }
.cm-s-blackboard .cm-def { color: #AAFFAA !important; }
.cm-s-blackboard .cm-variable { color: #AAAAFF !important; }
.cm-s-blackboard .cm-property { color: #AAAAAA !important; }
.cm-s-blackboard .cm-variable-2 { color: #B99 !important; }
*/

/* smooth */
.cm-s-blackboard .CodeMirror-gutter { background-color: #303030 !important; z-index: 0; }
.cm-s-blackboard .CodeMirror-linenumber { color: #717175; }
.cm-s-blackboard .cm-comment { color: #7bad7c !important; }
.cm-s-blackboard .cm-keyword { color: #fed6af !important; }
.cm-s-blackboard .cm-string { color: #d68686 !important; }
.cm-s-blackboard .cm-def { color: #ffb5ff !important; }
.cm-s-blackboard .cm-variable { color: #bed6ff !important; }
.cm-s-blackboard .cm-property { color: #d8d8d8 !important; }
.cm-s-blackboard .cm-variable-2 { color: #B99 !important; }
.cm-s-blackboard .cm-number { color: #ffb5ff !important; }



.CodeMirror-hints {
background-color: black;
color: #AAA;
border-radius: 0;
border: 0;
}

span.CodeMirror-matchhighlight { background: rgba(50,50,80,0.5); border-radius: 2px; outline: 1px solid #889; }

.CodeMirror pre {
/*z-index: auto !important;*/
}

.CodeMirror-activeline-background {
background-color: inherit;
}
.cm-s-blackboard .CodeMirror-activeline-background { background: #3C3636; }
.cm-s-blackboard .CodeMirror-matchingbracket { outline:1px solid grey;color:white !important; }
102 changes: 55 additions & 47 deletions editor/js/extra/codemirror/clike.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,19 @@
})(function(CodeMirror) {
"use strict";

function Context(indented, column, type, align, prev) {
function Context(indented, column, type, info, align, prev) {
this.indented = indented;
this.column = column;
this.type = type;
this.info = info;
this.align = align;
this.prev = prev;
}
function isStatement(type) {
return type == "statement" || type == "switchstatement" || type == "namespace";
}
function pushContext(state, col, type) {
function pushContext(state, col, type, info) {
var indent = state.indented;
if (state.context && isStatement(state.context.type) && !isStatement(type))
if (state.context && state.context.type == "statement" && type != "statement")
indent = state.context.indented;
return state.context = new Context(indent, col, type, null, state.context);
return state.context = new Context(indent, col, type, info, null, state.context);
}
function popContext(state) {
var t = state.context.type;
Expand All @@ -34,15 +32,16 @@ function popContext(state) {
return state.context = state.context.prev;
}

function typeBefore(stream, state) {
if (state.prevToken == "variable" || state.prevToken == "variable-3") return true;
if (/\S(?:[^- ]>|[*\]])\s*$|\*$/.test(stream.string.slice(0, stream.start))) return true;
function typeBefore(stream, state, pos) {
if (state.prevToken == "variable" || state.prevToken == "type") return true;
if (/\S(?:[^- ]>|[*\]])\s*$|\*$/.test(stream.string.slice(0, pos))) return true;
if (state.typeAtEndOfLine && stream.column() == stream.indentation()) return true;
}

function isTopScope(context) {
for (;;) {
if (!context || context.type == "top") return true;
if (context.type == "}" && context.prev.type != "namespace") return false;
if (context.type == "}" && context.prev.info != "namespace") return false;
context = context.prev;
}
}
Expand All @@ -66,7 +65,7 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
numberStart = parserConfig.numberStart || /[\d\.]/,
number = parserConfig.number || /^(?:0x[a-f\d]+|0b[01]+|(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?)(u|ll?|l|f)?/i,
isOperatorChar = parserConfig.isOperatorChar || /[+\-*&%=<>!?|\/]/,
endStatement = parserConfig.endStatement || /^[;:,]$/;
isIdentifierChar = parserConfig.isIdentifierChar || /[\w\$_\xa1-\uffff]/;

var curPunc, isDefKeyword;

Expand Down Expand Up @@ -103,17 +102,17 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
while (!stream.match(/^\/[\/*]/, false) && stream.eat(isOperatorChar)) {}
return "operator";
}
stream.eatWhile(/[\w\$_\xa1-\uffff]/);
stream.eatWhile(isIdentifierChar);
if (namespaceSeparator) while (stream.match(namespaceSeparator))
stream.eatWhile(/[\w\$_\xa1-\uffff]/);
stream.eatWhile(isIdentifierChar);

var cur = stream.current();
if (contains(keywords, cur)) {
if (contains(blockKeywords, cur)) curPunc = "newstatement";
if (contains(defKeywords, cur)) isDefKeyword = true;
return "keyword";
}
if (contains(types, cur)) return "variable-3";
if (contains(types, cur)) return "type";
if (contains(builtin, cur)) {
if (contains(blockKeywords, cur)) curPunc = "newstatement";
return "builtin";
Expand Down Expand Up @@ -147,13 +146,18 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
return "comment";
}

function maybeEOL(stream, state) {
if (parserConfig.typeFirstDefinitions && stream.eol() && isTopScope(state.context))
state.typeAtEndOfLine = typeBefore(stream, state, stream.pos)
}

// Interface

return {
startState: function(basecolumn) {
return {
tokenize: null,
context: new Context((basecolumn || 0) - indentUnit, 0, "top", false),
context: new Context((basecolumn || 0) - indentUnit, 0, "top", null, false),
indented: 0,
startOfLine: true,
prevToken: null
Expand All @@ -167,36 +171,32 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
state.indented = stream.indentation();
state.startOfLine = true;
}
if (stream.eatSpace()) return null;
if (stream.eatSpace()) { maybeEOL(stream, state); return null; }
curPunc = isDefKeyword = null;
var style = (state.tokenize || tokenBase)(stream, state);
if (style == "comment" || style == "meta") return style;
if (ctx.align == null) ctx.align = true;

if (endStatement.test(curPunc)) while (isStatement(state.context.type)) popContext(state);
if (curPunc == ";" || curPunc == ":" || (curPunc == "," && stream.match(/^\s*(?:\/\/.*)?$/, false)))
while (state.context.type == "statement") popContext(state);
else if (curPunc == "{") pushContext(state, stream.column(), "}");
else if (curPunc == "[") pushContext(state, stream.column(), "]");
else if (curPunc == "(") pushContext(state, stream.column(), ")");
else if (curPunc == "}") {
while (isStatement(ctx.type)) ctx = popContext(state);
while (ctx.type == "statement") ctx = popContext(state);
if (ctx.type == "}") ctx = popContext(state);
while (isStatement(ctx.type)) ctx = popContext(state);
while (ctx.type == "statement") ctx = popContext(state);
}
else if (curPunc == ctx.type) popContext(state);
else if (indentStatements &&
(((ctx.type == "}" || ctx.type == "top") && curPunc != ";") ||
(isStatement(ctx.type) && curPunc == "newstatement"))) {
var type = "statement";
if (curPunc == "newstatement" && indentSwitch && stream.current() == "switch")
type = "switchstatement";
else if (style == "keyword" && stream.current() == "namespace")
type = "namespace";
pushContext(state, stream.column(), type);
(ctx.type == "statement" && curPunc == "newstatement"))) {
pushContext(state, stream.column(), "statement", stream.current());
}

if (style == "variable" &&
((state.prevToken == "def" ||
(parserConfig.typeFirstDefinitions && typeBefore(stream, state) &&
(parserConfig.typeFirstDefinitions && typeBefore(stream, state, stream.start) &&
isTopScope(state.context) && stream.match(/^\s*\(/, false)))))
style = "def";

Expand All @@ -209,24 +209,28 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {

state.startOfLine = false;
state.prevToken = isDefKeyword ? "def" : style || curPunc;
maybeEOL(stream, state);
return style;
},

indent: function(state, textAfter) {
if (state.tokenize != tokenBase && state.tokenize != null) return CodeMirror.Pass;
if (state.tokenize != tokenBase && state.tokenize != null || state.typeAtEndOfLine) return CodeMirror.Pass;
var ctx = state.context, firstChar = textAfter && textAfter.charAt(0);
if (isStatement(ctx.type) && firstChar == "}") ctx = ctx.prev;
if (ctx.type == "statement" && firstChar == "}") ctx = ctx.prev;
if (parserConfig.dontIndentStatements)
while (ctx.type == "statement" && parserConfig.dontIndentStatements.test(ctx.info))
ctx = ctx.prev
if (hooks.indent) {
var hook = hooks.indent(state, ctx, textAfter);
if (typeof hook == "number") return hook
}
var closing = firstChar == ctx.type;
var switchBlock = ctx.prev && ctx.prev.type == "switchstatement";
var switchBlock = ctx.prev && ctx.prev.info == "switch";
if (parserConfig.allmanIndentation && /[{(]/.test(firstChar)) {
while (ctx.type != "top" && ctx.type != "}") ctx = ctx.prev
return ctx.indented
}
if (isStatement(ctx.type))
if (ctx.type == "statement")
return ctx.indented + (firstChar == "{" ? 0 : statementIndentUnit);
if (ctx.align && (!dontAlignCalls || ctx.type != ")"))
return ctx.column + (closing ? 0 : 1);
Expand Down Expand Up @@ -277,7 +281,7 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
}

function pointerHook(_stream, state) {
if (state.prevToken == "variable-3") return "variable-3";
if (state.prevToken == "type") return "type";
return false;
}

Expand Down Expand Up @@ -311,7 +315,7 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
}

function cppLooksLikeConstructor(word) {
var lastTwo = /(\w+)::(\w+)$/.exec(word);
var lastTwo = /(\w+)::~?(\w+)$/.exec(word);
return lastTwo && lastTwo[1] == lastTwo[2];
}

Expand Down Expand Up @@ -386,6 +390,8 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
defKeywords: words("class namespace struct enum union"),
typeFirstDefinitions: true,
atoms: words("true false null"),
dontIndentStatements: /^template$/,
isIdentifierChar: /[\w\$_~\xa1-\uffff]/,
hooks: {
"#": cppHook,
"*": pointerHook,
Expand Down Expand Up @@ -421,16 +427,19 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
"do else enum extends final finally float for goto if implements import " +
"instanceof interface native new package private protected public " +
"return static strictfp super switch synchronized this throw throws transient " +
"try volatile while"),
"try volatile while @interface"),
types: words("byte short int long float double boolean char void Boolean Byte Character Double Float " +
"Integer Long Number Object Short String StringBuffer StringBuilder Void"),
blockKeywords: words("catch class do else finally for if switch try while"),
defKeywords: words("class interface package enum"),
defKeywords: words("class interface package enum @interface"),
typeFirstDefinitions: true,
atoms: words("true false null"),
endStatement: /^[;:]$/,
number: /^(?:0x[a-f\d_]+|0b[01_]+|(?:[\d_]+\.?\d*|\.\d+)(?:e[-+]?[\d_]+)?)(u|ll?|l|f)?/i,
hooks: {
"@": function(stream) {
// Don't match the @interface keyword.
if (stream.match('interface', false)) return false;

stream.eatWhile(/[\w\$_]/);
return "meta";
}
Expand Down Expand Up @@ -486,14 +495,11 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
/* scala */
"abstract case catch class def do else extends final finally for forSome if " +
"implicit import lazy match new null object override package private protected return " +
"sealed super this throw trait try type val var while with yield _ : = => <- <: " +
"<% >: # @ " +
"sealed super this throw trait try type val var while with yield _ " +

/* package scala */
"assert assume require print println printf readLine readBoolean readByte readShort " +
"readChar readInt readLong readFloat readDouble " +

":: #:: "
"readChar readInt readLong readFloat readDouble"
),
types: words(
"AnyVal App Application Array BufferedIterator BigDecimal BigInt Char Console Either " +
Expand All @@ -509,11 +515,12 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
"StringBuffer System Thread ThreadGroup ThreadLocal Throwable Triple Void"
),
multiLineStrings: true,
blockKeywords: words("catch class do else finally for forSome if match switch try while"),
defKeywords: words("class def object package trait type val var"),
blockKeywords: words("catch class enum do else finally for forSome if match switch try while"),
defKeywords: words("class enum def object package trait type val var"),
atoms: words("true false null"),
indentStatements: false,
indentSwitch: false,
isOperatorChar: /[+\-*&%=<>!?|\/#:@]/,
hooks: {
"@": function(stream) {
stream.eatWhile(/[\w\$_]/);
Expand All @@ -531,7 +538,7 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
"=": function(stream, state) {
var cx = state.context
if (cx.type == "}" && cx.align && stream.eat(">")) {
state.context = new Context(cx.indented, cx.column, cx.type, null, cx.prev)
state.context = new Context(cx.indented, cx.column, cx.type, cx.info, null, cx.prev)
return "operator"
} else {
return false
Expand Down Expand Up @@ -570,7 +577,7 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
"file import where by get set abstract enum open inner override private public internal " +
"protected catch finally out final vararg reified dynamic companion constructor init " +
"sealed field property receiver param sparam lateinit data inline noinline tailrec " +
"external annotation crossinline const operator infix"
"external annotation crossinline const operator infix suspend"
),
types: words(
/* package java.lang */
Expand All @@ -582,6 +589,7 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
intendSwitch: false,
indentStatements: false,
multiLineStrings: true,
number: /^(?:0x[a-f\d_]+|0b[01_]+|(?:[\d_]+\.?\d*|\.\d+)(?:e[-+]?[\d_]+)?)(u|ll?|l|f)?/i,
blockKeywords: words("catch class do else finally for if where try while enum"),
defKeywords: words("class val var object package interface fun"),
atoms: words("true false null this"),
Expand Down Expand Up @@ -766,7 +774,7 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
return "atom";
},
token: function(_stream, state, style) {
if ((style == "variable" || style == "variable-3") &&
if ((style == "variable" || style == "type") &&
state.prevToken == ".") {
return "variable-2";
}
Expand Down
Loading