1
0
Fork 0
forked from forgejo/forgejo

Update CodeMirror to version 5.49.0 (#8381)

* Update CodeMirror to version 5.49.0

* Update CodeMirror versions in librejs and VERSIONS
This commit is contained in:
oscar.lofwenhamn 2019-10-15 10:40:42 +02:00 committed by Lauris BH
parent 6fa14ac3c8
commit 1e9b330525
352 changed files with 14625 additions and 2451 deletions

View file

@ -6,10 +6,11 @@
<link rel="stylesheet" href="../../lib/codemirror.css">
<script src="../../lib/codemirror.js"></script>
<script src="../../addon/edit/matchbrackets.js"></script>
<script src="julia.js"></script>
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
<style>.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
<div id=nav>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>

View file

@ -1,5 +1,5 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE
// Distributed under an MIT license: https://codemirror.net/LICENSE
(function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS
@ -11,51 +11,70 @@
})(function(CodeMirror) {
"use strict";
CodeMirror.defineMode("julia", function(_conf, parserConf) {
var ERRORCLASS = 'error';
CodeMirror.defineMode("julia", function(config, parserConf) {
function wordRegexp(words, end) {
if (typeof end === 'undefined') { end = "\\b"; }
if (typeof end === "undefined") { end = "\\b"; }
return new RegExp("^((" + words.join(")|(") + "))" + end);
}
var octChar = "\\\\[0-7]{1,3}";
var hexChar = "\\\\x[A-Fa-f0-9]{1,2}";
var specialChar = "\\\\[abfnrtv0%?'\"\\\\]";
var singleChar = "([^\\u0027\\u005C\\uD800-\\uDFFF]|[\\uD800-\\uDFFF][\\uDC00-\\uDFFF])";
var operators = parserConf.operators || /^\.?[|&^\\%*+\-<>!=\/]=?|\?|~|:|\$|\.[<>]|<<=?|>>>?=?|\.[<>=]=|->?|\/\/|\bin\b(?!\()|[\u2208\u2209](?!\()/;
var delimiters = parserConf.delimiters || /^[;,()[\]{}]/;
var identifiers = parserConf.identifiers || /^[_A-Za-z\u00A1-\uFFFF][\w\u00A1-\uFFFF]*!*/;
var charsList = [octChar, hexChar, specialChar, singleChar];
var blockOpeners = ["begin", "function", "type", "immutable", "let", "macro", "for", "while", "quote", "if", "else", "elseif", "try", "finally", "catch", "do"];
var blockClosers = ["end", "else", "elseif", "catch", "finally"];
var keywordList = ['if', 'else', 'elseif', 'while', 'for', 'begin', 'let', 'end', 'do', 'try', 'catch', 'finally', 'return', 'break', 'continue', 'global', 'local', 'const', 'export', 'import', 'importall', 'using', 'function', 'macro', 'module', 'baremodule', 'type', 'immutable', 'quote', 'typealias', 'abstract', 'bitstype'];
var builtinList = ['true', 'false', 'nothing', 'NaN', 'Inf'];
var sChar = "\\\\[abefnrtv0%?'\"\\\\]";
var uChar = "([^\\u0027\\u005C\\uD800-\\uDFFF]|[\\uD800-\\uDFFF][\\uDC00-\\uDFFF])";
var operators = parserConf.operators || wordRegexp([
"[<>]:", "[<>=]=", "<<=?", ">>>?=?", "=>", "->", "\\/\\/",
"[\\\\%*+\\-<>!=\\/^|&\\u00F7\\u22BB]=?", "\\?", "\\$", "~", ":",
"\\u00D7", "\\u2208", "\\u2209", "\\u220B", "\\u220C", "\\u2218",
"\\u221A", "\\u221B", "\\u2229", "\\u222A", "\\u2260", "\\u2264",
"\\u2265", "\\u2286", "\\u2288", "\\u228A", "\\u22C5",
"\\b(in|isa)\\b(?!\.?\\()"], "");
var delimiters = parserConf.delimiters || /^[;,()[\]{}]/;
var identifiers = parserConf.identifiers ||
/^[_A-Za-z\u00A1-\u2217\u2219-\uFFFF][\w\u00A1-\u2217\u2219-\uFFFF]*!*/;
var chars = wordRegexp([octChar, hexChar, sChar, uChar], "'");
var openersList = ["begin", "function", "type", "struct", "immutable", "let",
"macro", "for", "while", "quote", "if", "else", "elseif", "try",
"finally", "catch", "do"];
var closersList = ["end", "else", "elseif", "catch", "finally"];
var keywordsList = ["if", "else", "elseif", "while", "for", "begin", "let",
"end", "do", "try", "catch", "finally", "return", "break", "continue",
"global", "local", "const", "export", "import", "importall", "using",
"function", "where", "macro", "module", "baremodule", "struct", "type",
"mutable", "immutable", "quote", "typealias", "abstract", "primitive",
"bitstype"];
var builtinsList = ["true", "false", "nothing", "NaN", "Inf"];
CodeMirror.registerHelper("hintWords", "julia", keywordsList.concat(builtinsList));
var openers = wordRegexp(openersList);
var closers = wordRegexp(closersList);
var keywords = wordRegexp(keywordsList);
var builtins = wordRegexp(builtinsList);
//var stringPrefixes = new RegExp("^[br]?('|\")")
var stringPrefixes = /^(`|"{3}|([brv]?"))/;
var chars = wordRegexp(charsList, "'");
var keywords = wordRegexp(keywordList);
var builtins = wordRegexp(builtinList);
var openers = wordRegexp(blockOpeners);
var closers = wordRegexp(blockClosers);
var macro = /^@[_A-Za-z][\w]*/;
var symbol = /^:[_A-Za-z\u00A1-\uFFFF][\w\u00A1-\uFFFF]*!*/;
var typeAnnotation = /^::[^,;"{()=$\s]+({[^}]*}+)*/;
var stringPrefixes = /^(`|([_A-Za-z\u00A1-\uFFFF]*"("")?))/;
function inArray(state) {
var ch = currentScope(state);
if (ch == '[') {
return true;
}
return false;
return (state.nestedArrays > 0);
}
function currentScope(state) {
if (state.scopes.length == 0) {
function inGenerator(state) {
return (state.nestedGenerators > 0);
}
function currentScope(state, n) {
if (typeof(n) === "undefined") { n = 0; }
if (state.scopes.length <= n) {
return null;
}
return state.scopes[state.scopes.length - 1];
return state.scopes[state.scopes.length - (n + 1)];
}
// tokenizers
@ -72,14 +91,17 @@ CodeMirror.defineMode("julia", function(_conf, parserConf) {
leavingExpr = false;
}
state.leavingExpr = false;
if (leavingExpr) {
if (stream.match(/^'+/)) {
return 'operator';
return "operator";
}
}
if (stream.match(/^\.{2,3}/)) {
return 'operator';
if (stream.match(/\.{4,}/)) {
return "error";
} else if (stream.match(/\.{1,3}/)) {
return "operator";
}
if (stream.eatSpace()) {
@ -91,98 +113,97 @@ CodeMirror.defineMode("julia", function(_conf, parserConf) {
// Handle single line comments
if (ch === '#') {
stream.skipToEnd();
return 'comment';
return "comment";
}
if (ch === '[') {
state.scopes.push('[');
state.nestedArrays++;
}
if (ch === '(') {
state.scopes.push('(');
state.nestedGenerators++;
}
var scope = currentScope(state);
if (scope == '[' && ch === ']') {
if (inArray(state) && ch === ']') {
if (currentScope(state) === "if") { state.scopes.pop(); }
while (currentScope(state) === "for") { state.scopes.pop(); }
state.scopes.pop();
state.nestedArrays--;
state.leavingExpr = true;
}
if (scope == '(' && ch === ')') {
if (inGenerator(state) && ch === ')') {
if (currentScope(state) === "if") { state.scopes.pop(); }
while (currentScope(state) === "for") { state.scopes.pop(); }
state.scopes.pop();
state.nestedGenerators--;
state.leavingExpr = true;
}
var match;
if (!inArray(state) && (match=stream.match(openers, false))) {
state.scopes.push(match);
}
if (!inArray(state) && stream.match(closers, false)) {
state.scopes.pop();
}
if (inArray(state)) {
if (state.lastToken == 'end' && stream.match(/^:/)) {
return 'operator';
if (state.lastToken == "end" && stream.match(/^:/)) {
return "operator";
}
if (stream.match(/^end/)) {
return 'number';
return "number";
}
}
if (stream.match(/^=>/)) {
return 'operator';
var match;
if (match = stream.match(openers, false)) {
state.scopes.push(match[0]);
}
if (stream.match(closers, false)) {
state.scopes.pop();
}
// Handle type annotations
if (stream.match(/^::(?![:\$])/)) {
state.tokenize = tokenAnnotation;
return state.tokenize(stream, state);
}
// Handle symbols
if (!leavingExpr && stream.match(symbol) ||
stream.match(/:([<>]:|<<=?|>>>?=?|->|\/\/|\.{2,3}|[\.\\%*+\-<>!\/^|&]=?|[~\?\$])/)) {
return "builtin";
}
// Handle parametric types
//if (stream.match(/^{[^}]*}(?=\()/)) {
// return "builtin";
//}
// Handle operators and Delimiters
if (stream.match(operators)) {
return "operator";
}
// Handle Number Literals
if (stream.match(/^[0-9\.]/, false)) {
if (stream.match(/^\.?\d/, false)) {
var imMatcher = RegExp(/^im\b/);
var numberLiteral = false;
// Floats
if (stream.match(/^\d*\.(?!\.)\d*([Eef][\+\-]?\d+)?/i)) { numberLiteral = true; }
if (stream.match(/^\d+\.(?!\.)\d*/)) { numberLiteral = true; }
if (stream.match(/^\.\d+/)) { numberLiteral = true; }
if (stream.match(/^0x\.[0-9a-f]+p[\+\-]?\d+/i)) { numberLiteral = true; }
if (stream.match(/^(?:(?:\d[_\d]*)?\.(?!\.)(?:\d[_\d]*)?|\d[_\d]*\.(?!\.)(?:\d[_\d]*))?([Eef][\+\-]?[_\d]+)?/i)) { numberLiteral = true; }
if (stream.match(/^0x\.[0-9a-f_]+p[\+\-]?[_\d]+/i)) { numberLiteral = true; }
// Integers
if (stream.match(/^0x[0-9a-f]+/i)) { numberLiteral = true; } // Hex
if (stream.match(/^0b[01]+/i)) { numberLiteral = true; } // Binary
if (stream.match(/^0o[0-7]+/i)) { numberLiteral = true; } // Octal
if (stream.match(/^[1-9]\d*(e[\+\-]?\d+)?/)) { numberLiteral = true; } // Decimal
if (stream.match(/^0x[0-9a-f_]+/i)) { numberLiteral = true; } // Hex
if (stream.match(/^0b[01_]+/i)) { numberLiteral = true; } // Binary
if (stream.match(/^0o[0-7_]+/i)) { numberLiteral = true; } // Octal
if (stream.match(/^[1-9][_\d]*(e[\+\-]?\d+)?/)) { numberLiteral = true; } // Decimal
// Zero by itself with no other piece of number.
if (stream.match(/^0(?![\dx])/i)) { numberLiteral = true; }
if (numberLiteral) {
// Integer literals may be "long"
stream.match(imMatcher);
state.leavingExpr = true;
return 'number';
return "number";
}
}
if (stream.match(/^<:/)) {
return 'operator';
}
if (stream.match(typeAnnotation)) {
return 'builtin';
}
// Handle symbols
if (!leavingExpr && stream.match(symbol) || stream.match(/:\./)) {
return 'builtin';
}
// Handle parametric types
if (stream.match(/^{[^}]*}(?=\()/)) {
return 'builtin';
}
// Handle operators and Delimiters
if (stream.match(operators)) {
return 'operator';
}
// Handle Chars
if (stream.match(/^'/)) {
state.tokenize = tokenChar;
@ -196,7 +217,7 @@ CodeMirror.defineMode("julia", function(_conf, parserConf) {
}
if (stream.match(macro)) {
return 'meta';
return "meta";
}
if (stream.match(delimiters)) {
@ -204,41 +225,40 @@ CodeMirror.defineMode("julia", function(_conf, parserConf) {
}
if (stream.match(keywords)) {
return 'keyword';
return "keyword";
}
if (stream.match(builtins)) {
return 'builtin';
return "builtin";
}
var isDefinition = state.isDefinition ||
state.lastToken == 'function' ||
state.lastToken == 'macro' ||
state.lastToken == 'type' ||
state.lastToken == 'immutable';
var isDefinition = state.isDefinition || state.lastToken == "function" ||
state.lastToken == "macro" || state.lastToken == "type" ||
state.lastToken == "struct" || state.lastToken == "immutable";
if (stream.match(identifiers)) {
if (isDefinition) {
if (stream.peek() === '.') {
state.isDefinition = true;
return 'variable';
return "variable";
}
state.isDefinition = false;
return 'def';
return "def";
}
if (stream.match(/^({[^}]*})*\(/, false)) {
return callOrDef(stream, state);
state.tokenize = tokenCallOrDef;
return state.tokenize(stream, state);
}
state.leavingExpr = true;
return 'variable';
return "variable";
}
// Handle non-detected items
stream.next();
return ERRORCLASS;
return "error";
}
function callOrDef(stream, state) {
function tokenCallOrDef(stream, state) {
var match = stream.match(/^(\(\s*)/);
if (match) {
if (state.firstParenPos < 0)
@ -250,13 +270,14 @@ CodeMirror.defineMode("julia", function(_conf, parserConf) {
state.scopes.pop();
state.charsAdvanced += 1;
if (state.scopes.length <= state.firstParenPos) {
var isDefinition = stream.match(/^\s*?=(?!=)/, false);
var isDefinition = stream.match(/^(\s*where\s+[^\s=]+)*\s*?=(?!=)/, false);
stream.backUp(state.charsAdvanced);
state.firstParenPos = -1;
state.charsAdvanced = 0;
state.tokenize = tokenBase;
if (isDefinition)
return 'def';
return 'builtin';
return "def";
return "builtin";
}
}
// Unfortunately javascript does not support multiline strings, so we have
@ -268,25 +289,41 @@ CodeMirror.defineMode("julia", function(_conf, parserConf) {
state.scopes.pop();
state.firstParenPos = -1;
state.charsAdvanced = 0;
return 'builtin';
state.tokenize = tokenBase;
return "builtin";
}
state.charsAdvanced += stream.match(/^([^()]*)/)[1].length;
return callOrDef(stream, state);
return state.tokenize(stream, state);
}
function tokenAnnotation(stream, state) {
stream.match(/.*?(?=,|;|{|}|\(|\)|=|$|\s)/);
if (stream.match(/^{/)) {
state.nestedParameters++;
} else if (stream.match(/^}/) && state.nestedParameters > 0) {
state.nestedParameters--;
}
if (state.nestedParameters > 0) {
stream.match(/.*?(?={|})/) || stream.next();
} else if (state.nestedParameters == 0) {
state.tokenize = tokenBase;
}
return "builtin";
}
function tokenComment(stream, state) {
if (stream.match(/^#=/)) {
state.weakScopes++;
state.nestedComments++;
}
if (!stream.match(/.*?(?=(#=|=#))/)) {
stream.skipToEnd();
}
if (stream.match(/^=#/)) {
state.weakScopes--;
if (state.weakScopes == 0)
state.nestedComments--;
if (state.nestedComments == 0)
state.tokenize = tokenBase;
}
return 'comment';
return "comment";
}
function tokenChar(stream, state) {
@ -309,35 +346,32 @@ CodeMirror.defineMode("julia", function(_conf, parserConf) {
if (isChar) {
state.leavingExpr = true;
state.tokenize = tokenBase;
return 'string';
return "string";
}
if (!stream.match(/^[^']+(?=')/)) { stream.skipToEnd(); }
if (stream.match(/^'/)) { state.tokenize = tokenBase; }
return ERRORCLASS;
return "error";
}
function tokenStringFactory(delimiter) {
while ('bruv'.indexOf(delimiter.charAt(0).toLowerCase()) >= 0) {
delimiter = delimiter.substr(1);
if (delimiter.substr(-3) === '"""') {
delimiter = '"""';
} else if (delimiter.substr(-1) === '"') {
delimiter = '"';
}
var OUTCLASS = 'string';
function tokenString(stream, state) {
while (!stream.eol()) {
stream.eatWhile(/[^"\\]/);
if (stream.eat('\\')) {
stream.next();
} else if (stream.match(delimiter)) {
state.tokenize = tokenBase;
state.leavingExpr = true;
return OUTCLASS;
} else {
stream.eat(/["]/);
}
if (stream.eat('\\')) {
stream.next();
} else if (stream.match(delimiter)) {
state.tokenize = tokenBase;
state.leavingExpr = true;
return "string";
} else {
stream.eat(/[`"]/);
}
return OUTCLASS;
stream.eatWhile(/[^\\`"]/);
return "string";
}
tokenString.isString = true;
return tokenString;
}
@ -346,10 +380,13 @@ CodeMirror.defineMode("julia", function(_conf, parserConf) {
return {
tokenize: tokenBase,
scopes: [],
weakScopes: 0,
lastToken: null,
leavingExpr: false,
isDefinition: false,
nestedArrays: 0,
nestedComments: 0,
nestedGenerators: 0,
nestedParameters: 0,
charsAdvanced: 0,
firstParenPos: -1
};
@ -363,24 +400,24 @@ CodeMirror.defineMode("julia", function(_conf, parserConf) {
state.lastToken = current;
}
// Handle '.' connected identifiers
if (current === '.') {
style = stream.match(identifiers, false) || stream.match(macro, false) ||
stream.match(/\(/, false) ? 'operator' : ERRORCLASS;
}
return style;
},
indent: function(state, textAfter) {
var delta = 0;
if (textAfter == "]" || textAfter == ")" || textAfter == "end" || textAfter == "else" || textAfter == "elseif" || textAfter == "catch" || textAfter == "finally") {
if ( textAfter === ']' || textAfter === ')' || textAfter === "end" ||
textAfter === "else" || textAfter === "catch" || textAfter === "elseif" ||
textAfter === "finally" ) {
delta = -1;
}
return (state.scopes.length + delta) * _conf.indentUnit;
return (state.scopes.length + delta) * config.indentUnit;
},
electricInput: /(end|else(if)?|catch|finally)$/,
electricInput: /\b(end|else|catch|finally)\b/,
blockCommentStart: "#=",
blockCommentEnd: "=#",
lineComment: "#",
closeBrackets: "()[]{}\"\"",
fold: "indent"
};
return external;