From f739dbfe879036505f442c79f1d09ea41359c554 Mon Sep 17 00:00:00 2001 From: zadam Date: Tue, 6 Apr 2021 22:16:34 +0200 Subject: [PATCH] ckeditor 5.60.0 --- .../codemirror/addon/edit/matchbrackets.js | 30 +- libraries/codemirror/addon/lint/lint.css | 24 +- libraries/codemirror/addon/lint/lint.js | 16 +- libraries/codemirror/addon/mode/simple.js | 3 +- .../addon/search/match-highlighter.js | 2 +- libraries/codemirror/codemirror.css | 1 + libraries/codemirror/codemirror.js | 93 ++- libraries/codemirror/mode/asn.1/asn.1.js | 2 +- libraries/codemirror/mode/clike/clike.js | 18 +- libraries/codemirror/mode/clike/scala.html | 767 ------------------ libraries/codemirror/mode/clojure/clojure.js | 4 +- libraries/codemirror/mode/crystal/crystal.js | 8 +- libraries/codemirror/mode/css/css.js | 15 +- libraries/codemirror/mode/css/gss.html | 104 --- libraries/codemirror/mode/css/less.html | 152 ---- libraries/codemirror/mode/css/scss.html | 158 ---- libraries/codemirror/mode/cypher/cypher.js | 4 +- libraries/codemirror/mode/dtd/dtd.js | 4 +- libraries/codemirror/mode/ebnf/ebnf.js | 14 +- libraries/codemirror/mode/erlang/erlang.js | 4 +- libraries/codemirror/mode/factor/factor.js | 2 +- libraries/codemirror/mode/gas/gas.js | 4 +- libraries/codemirror/mode/haml/haml.js | 2 +- .../codemirror/mode/htmlmixed/htmlmixed.js | 3 +- libraries/codemirror/mode/idl/idl.js | 2 +- .../codemirror/mode/javascript/javascript.js | 29 +- .../codemirror/mode/javascript/json-ld.html | 72 -- .../mode/javascript/typescript.html | 62 -- libraries/codemirror/mode/julia/julia.js | 63 +- libraries/codemirror/mode/lua/lua.js | 1 + .../codemirror/mode/markdown/markdown.js | 8 +- libraries/codemirror/mode/meta.js | 3 +- .../codemirror/mode/modelica/modelica.js | 6 +- libraries/codemirror/mode/mscgen/mscgen.js | 8 +- libraries/codemirror/mode/mumps/mumps.js | 2 +- libraries/codemirror/mode/oz/oz.js | 4 +- libraries/codemirror/mode/pegjs/pegjs.js | 6 +- libraries/codemirror/mode/perl/perl.js | 8 +- libraries/codemirror/mode/php/php.js | 4 +- libraries/codemirror/mode/pug/pug.js | 2 +- libraries/codemirror/mode/puppet/puppet.js | 2 +- libraries/codemirror/mode/python/python.js | 2 +- libraries/codemirror/mode/rpm/rpm.js | 8 +- libraries/codemirror/mode/ruby/ruby.js | 41 +- libraries/codemirror/mode/sass/sass.js | 9 +- libraries/codemirror/mode/scheme/scheme.js | 6 +- libraries/codemirror/mode/shell/shell.js | 16 + libraries/codemirror/mode/sieve/sieve.js | 2 +- libraries/codemirror/mode/soy/soy.js | 45 +- libraries/codemirror/mode/sparql/sparql.js | 14 +- libraries/codemirror/mode/sql/sql.js | 10 +- libraries/codemirror/mode/stylus/stylus.js | 8 +- .../codemirror/mode/tiddlywiki/tiddlywiki.js | 2 +- .../codemirror/mode/vbscript/vbscript.js | 4 +- .../codemirror/mode/velocity/velocity.js | 2 +- libraries/codemirror/mode/verilog/verilog.js | 141 +++- libraries/codemirror/mode/wast/wast.js | 89 +- libraries/codemirror/mode/xml/xml.js | 4 +- .../mode/yaml-frontmatter/yaml-frontmatter.js | 2 +- libraries/codemirror/mode/yaml/yaml.js | 8 +- 60 files changed, 537 insertions(+), 1592 deletions(-) delete mode 100644 libraries/codemirror/mode/clike/scala.html delete mode 100644 libraries/codemirror/mode/css/gss.html delete mode 100644 libraries/codemirror/mode/css/less.html delete mode 100644 libraries/codemirror/mode/css/scss.html delete mode 100644 libraries/codemirror/mode/javascript/json-ld.html delete mode 100644 libraries/codemirror/mode/javascript/typescript.html diff --git a/libraries/codemirror/addon/edit/matchbrackets.js b/libraries/codemirror/addon/edit/matchbrackets.js index 2c47e0703..43dc8840f 100644 --- a/libraries/codemirror/addon/edit/matchbrackets.js +++ b/libraries/codemirror/addon/edit/matchbrackets.js @@ -38,7 +38,7 @@ if (config && config.strict && (dir > 0) != (pos == where.ch)) return null; var style = cm.getTokenTypeAt(Pos(where.line, pos + 1)); - var found = scanForBracket(cm, Pos(where.line, pos + (dir > 0 ? 1 : 0)), dir, style || null, config); + var found = scanForBracket(cm, Pos(where.line, pos + (dir > 0 ? 1 : 0)), dir, style, config); if (found == null) return null; return {from: Pos(where.line, pos), to: found && found.pos, match: found && found.ch == match.charAt(0), forward: dir > 0}; @@ -67,7 +67,8 @@ if (lineNo == where.line) pos = where.ch - (dir < 0 ? 1 : 0); for (; pos != end; pos += dir) { var ch = line.charAt(pos); - if (re.test(ch) && (style === undefined || cm.getTokenTypeAt(Pos(lineNo, pos + 1)) == style)) { + if (re.test(ch) && (style === undefined || + (cm.getTokenTypeAt(Pos(lineNo, pos + 1)) || "") == (style || ""))) { var match = matching[ch]; if (match && (match.charAt(1) == ">") == (dir > 0)) stack.push(ch); else if (!stack.length) return {pos: Pos(lineNo, pos), ch: ch}; @@ -80,11 +81,12 @@ function matchBrackets(cm, autoclear, config) { // Disable brace matching in long lines, since it'll cause hugely slow updates - var maxHighlightLen = cm.state.matchBrackets.maxHighlightLineLength || 1000; + var maxHighlightLen = cm.state.matchBrackets.maxHighlightLineLength || 1000, + highlightNonMatching = config && config.highlightNonMatching; var marks = [], ranges = cm.listSelections(); for (var i = 0; i < ranges.length; i++) { var match = ranges[i].empty() && findMatchingBracket(cm, ranges[i].head, config); - if (match && cm.getLine(match.from.line).length <= maxHighlightLen) { + if (match && (match.match || highlightNonMatching !== false) && cm.getLine(match.from.line).length <= maxHighlightLen) { var style = match.match ? "CodeMirror-matchingbracket" : "CodeMirror-nonmatchingbracket"; marks.push(cm.markText(match.from, Pos(match.from.line, match.from.ch + 1), {className: style})); if (match.to && cm.getLine(match.to.line).length <= maxHighlightLen) @@ -94,7 +96,7 @@ if (marks.length) { // Kludge to work around the IE bug from issue #1193, where text - // input stops going to the textare whever this fires. + // input stops going to the textarea whenever this fires. if (ie_lt8 && cm.state.focused) cm.focus(); var clear = function() { @@ -117,25 +119,25 @@ }); } - CodeMirror.defineOption("matchBrackets", false, function(cm, val, old) { - function clear(cm) { - if (cm.state.matchBrackets && cm.state.matchBrackets.currentlyHighlighted) { - cm.state.matchBrackets.currentlyHighlighted(); - cm.state.matchBrackets.currentlyHighlighted = null; - } + function clearHighlighted(cm) { + if (cm.state.matchBrackets && cm.state.matchBrackets.currentlyHighlighted) { + cm.state.matchBrackets.currentlyHighlighted(); + cm.state.matchBrackets.currentlyHighlighted = null; } + } + CodeMirror.defineOption("matchBrackets", false, function(cm, val, old) { if (old && old != CodeMirror.Init) { cm.off("cursorActivity", doMatchBrackets); cm.off("focus", doMatchBrackets) - cm.off("blur", clear) - clear(cm); + cm.off("blur", clearHighlighted) + clearHighlighted(cm); } if (val) { cm.state.matchBrackets = typeof val == "object" ? val : {}; cm.on("cursorActivity", doMatchBrackets); cm.on("focus", doMatchBrackets) - cm.on("blur", clear) + cm.on("blur", clearHighlighted) } }); diff --git a/libraries/codemirror/addon/lint/lint.css b/libraries/codemirror/addon/lint/lint.css index f097cfe34..087186595 100644 --- a/libraries/codemirror/addon/lint/lint.css +++ b/libraries/codemirror/addon/lint/lint.css @@ -25,22 +25,20 @@ -ms-transition: opacity .4s; } -.CodeMirror-lint-mark-error, .CodeMirror-lint-mark-warning { +.CodeMirror-lint-mark { background-position: left bottom; background-repeat: repeat-x; } -.CodeMirror-lint-mark-error { - background-image: - url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAADCAYAAAC09K7GAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sJDw4cOCW1/KIAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAHElEQVQI12NggIL/DAz/GdA5/xkY/qPKMDAwAADLZwf5rvm+LQAAAABJRU5ErkJggg==") - ; -} - .CodeMirror-lint-mark-warning { background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAADCAYAAAC09K7GAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sJFhQXEbhTg7YAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAMklEQVQI12NkgIIvJ3QXMjAwdDN+OaEbysDA4MPAwNDNwMCwiOHLCd1zX07o6kBVGQEAKBANtobskNMAAAAASUVORK5CYII="); } -.CodeMirror-lint-marker-error, .CodeMirror-lint-marker-warning { +.CodeMirror-lint-mark-error { + background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAADCAYAAAC09K7GAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sJDw4cOCW1/KIAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAHElEQVQI12NggIL/DAz/GdA5/xkY/qPKMDAwAADLZwf5rvm+LQAAAABJRU5ErkJggg=="); +} + +.CodeMirror-lint-marker { background-position: center center; background-repeat: no-repeat; cursor: pointer; @@ -51,20 +49,20 @@ position: relative; } -.CodeMirror-lint-message-error, .CodeMirror-lint-message-warning { +.CodeMirror-lint-message { padding-left: 18px; background-position: top left; background-repeat: no-repeat; } -.CodeMirror-lint-marker-error, .CodeMirror-lint-message-error { - background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAAHlBMVEW7AAC7AACxAAC7AAC7AAAAAAC4AAC5AAD///+7AAAUdclpAAAABnRSTlMXnORSiwCK0ZKSAAAATUlEQVR42mWPOQ7AQAgDuQLx/z8csYRmPRIFIwRGnosRrpamvkKi0FTIiMASR3hhKW+hAN6/tIWhu9PDWiTGNEkTtIOucA5Oyr9ckPgAWm0GPBog6v4AAAAASUVORK5CYII="); -} - .CodeMirror-lint-marker-warning, .CodeMirror-lint-message-warning { background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAANlBMVEX/uwDvrwD/uwD/uwD/uwD/uwD/uwD/uwD/uwD6twD/uwAAAADurwD2tQD7uAD+ugAAAAD/uwDhmeTRAAAADHRSTlMJ8mN1EYcbmiixgACm7WbuAAAAVklEQVR42n3PUQqAIBBFUU1LLc3u/jdbOJoW1P08DA9Gba8+YWJ6gNJoNYIBzAA2chBth5kLmG9YUoG0NHAUwFXwO9LuBQL1giCQb8gC9Oro2vp5rncCIY8L8uEx5ZkAAAAASUVORK5CYII="); } +.CodeMirror-lint-marker-error, .CodeMirror-lint-message-error { + background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAAHlBMVEW7AAC7AACxAAC7AAC7AAAAAAC4AAC5AAD///+7AAAUdclpAAAABnRSTlMXnORSiwCK0ZKSAAAATUlEQVR42mWPOQ7AQAgDuQLx/z8csYRmPRIFIwRGnosRrpamvkKi0FTIiMASR3hhKW+hAN6/tIWhu9PDWiTGNEkTtIOucA5Oyr9ckPgAWm0GPBog6v4AAAAASUVORK5CYII="); +} + .CodeMirror-lint-marker-multiple { background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAcAAAAHCAMAAADzjKfhAAAACVBMVEUAAAAAAAC/v7914kyHAAAAAXRSTlMAQObYZgAAACNJREFUeNo1ioEJAAAIwmz/H90iFFSGJgFMe3gaLZ0od+9/AQZ0ADosbYraAAAAAElFTkSuQmCC"); background-repeat: no-repeat; diff --git a/libraries/codemirror/addon/lint/lint.js b/libraries/codemirror/addon/lint/lint.js index 5bc1af18a..395f0d931 100644 --- a/libraries/codemirror/addon/lint/lint.js +++ b/libraries/codemirror/addon/lint/lint.js @@ -83,10 +83,10 @@ function makeMarker(cm, labels, severity, multiple, tooltips) { var marker = document.createElement("div"), inner = marker; - marker.className = "CodeMirror-lint-marker-" + severity; + marker.className = "CodeMirror-lint-marker CodeMirror-lint-marker-" + severity; if (multiple) { inner = marker.appendChild(document.createElement("div")); - inner.className = "CodeMirror-lint-marker-multiple"; + inner.className = "CodeMirror-lint-marker CodeMirror-lint-marker-multiple"; } if (tooltips != false) CodeMirror.on(inner, "mouseover", function(e) { @@ -114,7 +114,7 @@ var severity = ann.severity; if (!severity) severity = "error"; var tip = document.createElement("div"); - tip.className = "CodeMirror-lint-message-" + severity; + tip.className = "CodeMirror-lint-message CodeMirror-lint-message-" + severity; if (typeof ann.messageHTML != 'undefined') { tip.innerHTML = ann.messageHTML; } else { @@ -170,6 +170,10 @@ var anns = annotations[line]; if (!anns) continue; + // filter out duplicate messages + var message = []; + anns = anns.filter(function(item) { return message.indexOf(item.message) > -1 ? false : message.push(item.message) }); + var maxSeverity = null; var tipLabel = state.hasGutter && document.createDocumentFragment(); @@ -183,13 +187,13 @@ if (state.hasGutter) tipLabel.appendChild(annotationTooltip(ann)); if (ann.to) state.marked.push(cm.markText(ann.from, ann.to, { - className: "CodeMirror-lint-mark-" + severity, + className: "CodeMirror-lint-mark CodeMirror-lint-mark-" + severity, __annotation: ann })); } - + // use original annotations[line] to show multiple messages if (state.hasGutter) - cm.setGutterMarker(line, GUTTER_ID, makeMarker(cm, tipLabel, maxSeverity, anns.length > 1, + cm.setGutterMarker(line, GUTTER_ID, makeMarker(cm, tipLabel, maxSeverity, annotations[line].length > 1, state.options.tooltips)); } if (options.onUpdateLinting) options.onUpdateLinting(annotationsNotSorted, annotations, cm); diff --git a/libraries/codemirror/addon/mode/simple.js b/libraries/codemirror/addon/mode/simple.js index 655f99147..a1c626417 100644 --- a/libraries/codemirror/addon/mode/simple.js +++ b/libraries/codemirror/addon/mode/simple.js @@ -137,10 +137,9 @@ var token = rule.token if (token && token.apply) token = token(matches) if (matches.length > 2 && rule.token && typeof rule.token != "string") { - state.pending = []; for (var j = 2; j < matches.length; j++) if (matches[j]) - state.pending.push({text: matches[j], token: rule.token[j - 1]}); + (state.pending || (state.pending = [])).push({text: matches[j], token: rule.token[j - 1]}); stream.backUp(matches[0].length - (matches[1] ? matches[1].length : 0)); return token[0]; } else if (token && token.join) { diff --git a/libraries/codemirror/addon/search/match-highlighter.js b/libraries/codemirror/addon/search/match-highlighter.js index 3a4a7dedc..9b181ebc0 100644 --- a/libraries/codemirror/addon/search/match-highlighter.js +++ b/libraries/codemirror/addon/search/match-highlighter.js @@ -16,7 +16,7 @@ // highlighted only if the selected text is a word. showToken, when enabled, // will cause the current token to be highlighted when nothing is selected. // delay is used to specify how much time to wait, in milliseconds, before -// highlighting the matches. If annotateScrollbar is enabled, the occurences +// highlighting the matches. If annotateScrollbar is enabled, the occurrences // will be highlighted on the scrollbar via the matchesonscrollbar addon. (function(mod) { diff --git a/libraries/codemirror/codemirror.css b/libraries/codemirror/codemirror.css index 56896500e..a64f97c77 100644 --- a/libraries/codemirror/codemirror.css +++ b/libraries/codemirror/codemirror.css @@ -184,6 +184,7 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #a22;} position: absolute; z-index: 6; display: none; + outline: none; } .CodeMirror-vscrollbar { right: 0; top: 0; diff --git a/libraries/codemirror/codemirror.js b/libraries/codemirror/codemirror.js index 7cee4096d..055963b04 100644 --- a/libraries/codemirror/codemirror.js +++ b/libraries/codemirror/codemirror.js @@ -32,7 +32,7 @@ var mac_geMountainLion = /Mac OS X 1\d\D([8-9]|\d\d)\D/.test(userAgent); var phantom = /PhantomJS/.test(userAgent); - var ios = !edge && /AppleWebKit/.test(userAgent) && /Mobile\/\w+/.test(userAgent); + var ios = safari && (/Mobile\/\w+/.test(userAgent) || navigator.maxTouchPoints > 2); var android = /Android/.test(userAgent); // This is woefully incomplete. Suggestions for alternative methods welcome. var mobile = ios || android || /webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(userAgent); @@ -1841,7 +1841,7 @@ } } builder.trailingSpace = displayText.charCodeAt(text.length - 1) == 32; - if (style || startStyle || endStyle || mustWrap || css) { + if (style || startStyle || endStyle || mustWrap || css || attributes) { var fullStyle = style || ""; if (startStyle) { fullStyle += startStyle; } if (endStyle) { fullStyle += endStyle; } @@ -3276,26 +3276,31 @@ var on = true; display.cursorDiv.style.visibility = ""; if (cm.options.cursorBlinkRate > 0) - { display.blinker = setInterval(function () { return display.cursorDiv.style.visibility = (on = !on) ? "" : "hidden"; }, - cm.options.cursorBlinkRate); } + { display.blinker = setInterval(function () { + if (!cm.hasFocus()) { onBlur(cm); } + display.cursorDiv.style.visibility = (on = !on) ? "" : "hidden"; + }, cm.options.cursorBlinkRate); } else if (cm.options.cursorBlinkRate < 0) { display.cursorDiv.style.visibility = "hidden"; } } function ensureFocus(cm) { - if (!cm.state.focused) { cm.display.input.focus(); onFocus(cm); } + if (!cm.hasFocus()) { + cm.display.input.focus(); + if (!cm.state.focused) { onFocus(cm); } + } } function delayBlurEvent(cm) { cm.state.delayingBlurEvent = true; setTimeout(function () { if (cm.state.delayingBlurEvent) { cm.state.delayingBlurEvent = false; - onBlur(cm); + if (cm.state.focused) { onBlur(cm); } } }, 100); } function onFocus(cm, e) { - if (cm.state.delayingBlurEvent) { cm.state.delayingBlurEvent = false; } + if (cm.state.delayingBlurEvent && !cm.state.draggingText) { cm.state.delayingBlurEvent = false; } if (cm.options.readOnly == "nocursor") { return } if (!cm.state.focused) { @@ -3477,14 +3482,15 @@ if (newTop != screentop) { result.scrollTop = newTop; } } - var screenleft = cm.curOp && cm.curOp.scrollLeft != null ? cm.curOp.scrollLeft : display.scroller.scrollLeft; - var screenw = displayWidth(cm) - (cm.options.fixedGutter ? display.gutters.offsetWidth : 0); + var gutterSpace = cm.options.fixedGutter ? 0 : display.gutters.offsetWidth; + var screenleft = cm.curOp && cm.curOp.scrollLeft != null ? cm.curOp.scrollLeft : display.scroller.scrollLeft - gutterSpace; + var screenw = displayWidth(cm) - display.gutters.offsetWidth; var tooWide = rect.right - rect.left > screenw; if (tooWide) { rect.right = rect.left + screenw; } if (rect.left < 10) { result.scrollLeft = 0; } else if (rect.left < screenleft) - { result.scrollLeft = Math.max(0, rect.left - (tooWide ? 0 : 10)); } + { result.scrollLeft = Math.max(0, rect.left + gutterSpace - (tooWide ? 0 : 10)); } else if (rect.right > screenw + screenleft - 3) { result.scrollLeft = rect.right + (tooWide ? 0 : 10) - screenw; } return result @@ -4792,19 +4798,19 @@ }); } - function History(startGen) { + function History(prev) { // Arrays of change events and selections. Doing something adds an // event to done and clears undo. Undoing moves events from done // to undone, redoing moves them in the other direction. this.done = []; this.undone = []; - this.undoDepth = Infinity; + this.undoDepth = prev ? prev.undoDepth : Infinity; // Used to track when changes can be merged into a single undo // event this.lastModTime = this.lastSelTime = 0; this.lastOp = this.lastSelOp = null; this.lastOrigin = this.lastSelOrigin = null; // Used by the isClean() method - this.generation = this.maxGeneration = startGen || 1; + this.generation = this.maxGeneration = prev ? prev.maxGeneration : 1; } // Create a history change event from an updateDoc-style change @@ -5109,7 +5115,7 @@ (cmp(sel.primary().head, doc.sel.primary().head) < 0 ? -1 : 1); setSelectionInner(doc, skipAtomicInSelection(doc, sel, bias, true)); - if (!(options && options.scroll === false) && doc.cm) + if (!(options && options.scroll === false) && doc.cm && doc.cm.getOption("readOnly") != "nocursor") { ensureCursorVisible(doc.cm); } } @@ -5766,7 +5772,7 @@ changeLine(doc, handle, "widget", function (line) { var widgets = line.widgets || (line.widgets = []); if (widget.insertAt == null) { widgets.push(widget); } - else { widgets.splice(Math.min(widgets.length - 1, Math.max(0, widget.insertAt)), 0, widget); } + else { widgets.splice(Math.min(widgets.length, Math.max(0, widget.insertAt)), 0, widget); } widget.line = line; if (cm && !lineIsHidden(doc, line)) { var aboveVisible = heightAtLine(line) < doc.scrollTop; @@ -6175,7 +6181,7 @@ var out = []; for (var i = 0; i < ranges.length; i++) { out[i] = new Range(clipPos(this, ranges[i].anchor), - clipPos(this, ranges[i].head)); } + clipPos(this, ranges[i].head || ranges[i].anchor)); } if (primary == null) { primary = Math.min(ranges.length - 1, this.sel.primIndex); } setSelection(this, normalizeSelection(this.cm, out, primary), options); }), @@ -6238,7 +6244,7 @@ clearHistory: function() { var this$1 = this; - this.history = new History(this.history.maxGeneration); + this.history = new History(this.history); linkedDocs(this, function (doc) { return doc.history = this$1.history; }, true); }, @@ -6259,7 +6265,7 @@ undone: copyHistoryArray(this.history.undone)} }, setHistory: function(histData) { - var hist = this.history = new History(this.history.maxGeneration); + var hist = this.history = new History(this.history); hist.done = copyHistoryArray(histData.done.slice(0), null, true); hist.undone = copyHistoryArray(histData.undone.slice(0), null, true); }, @@ -7002,7 +7008,7 @@ goGroupRight: function (cm) { return cm.moveH(1, "group"); }, goGroupLeft: function (cm) { return cm.moveH(-1, "group"); }, goWordRight: function (cm) { return cm.moveH(1, "word"); }, - delCharBefore: function (cm) { return cm.deleteH(-1, "char"); }, + delCharBefore: function (cm) { return cm.deleteH(-1, "codepoint"); }, delCharAfter: function (cm) { return cm.deleteH(1, "char"); }, delWordBefore: function (cm) { return cm.deleteH(-1, "word"); }, delWordAfter: function (cm) { return cm.deleteH(1, "word"); }, @@ -7375,6 +7381,10 @@ var dragEnd = operation(cm, function (e) { if (webkit) { display.scroller.draggable = false; } cm.state.draggingText = false; + if (cm.state.delayingBlurEvent) { + if (cm.hasFocus()) { cm.state.delayingBlurEvent = false; } + else { delayBlurEvent(cm); } + } off(display.wrapper.ownerDocument, "mouseup", dragEnd); off(display.wrapper.ownerDocument, "mousemove", mouseMove); off(display.scroller, "dragstart", dragStart); @@ -7398,15 +7408,15 @@ if (webkit) { display.scroller.draggable = true; } cm.state.draggingText = dragEnd; dragEnd.copy = !behavior.moveOnDrag; - // IE's approach to draggable - if (display.scroller.dragDrop) { display.scroller.dragDrop(); } on(display.wrapper.ownerDocument, "mouseup", dragEnd); on(display.wrapper.ownerDocument, "mousemove", mouseMove); on(display.scroller, "dragstart", dragStart); on(display.scroller, "drop", dragEnd); - delayBlurEvent(cm); + cm.state.delayingBlurEvent = true; setTimeout(function () { return display.input.focus(); }, 20); + // IE's approach to draggable + if (display.scroller.dragDrop) { display.scroller.dragDrop(); } } function rangeForUnit(cm, pos, unit) { @@ -7419,6 +7429,7 @@ // Normal selection, as opposed to text dragging. function leftButtonSelect(cm, event, start, behavior) { + if (ie) { delayBlurEvent(cm); } var display = cm.display, doc = cm.doc; e_preventDefault(event); @@ -7697,7 +7708,7 @@ for (var i = newBreaks.length - 1; i >= 0; i--) { replaceRange(cm.doc, val, newBreaks[i], Pos(newBreaks[i].line, newBreaks[i].ch + val.length)); } }); - option("specialChars", /[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b-\u200c\u200e\u200f\u2028\u2029\ufeff\ufff9-\ufffc]/g, function (cm, val, old) { + option("specialChars", /[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b\u200e\u200f\u2028\u2029\ufeff\ufff9-\ufffc]/g, function (cm, val, old) { cm.state.specialChars = new RegExp(val.source + (val.test("\t") ? "" : "|\t"), "g"); if (old != Init) { cm.refresh(); } }); @@ -7877,7 +7888,9 @@ attachDoc(this, doc); if ((options.autofocus && !mobile) || this.hasFocus()) - { setTimeout(bind(onFocus, this), 20); } + { setTimeout(function () { + if (this$1.hasFocus() && !this$1.state.focused) { onFocus(this$1); } + }, 20); } else { onBlur(this); } @@ -8640,14 +8653,14 @@ } // Used for horizontal relative motion. Dir is -1 or 1 (left or - // right), unit can be "char", "column" (like char, but doesn't - // cross line boundaries), "word" (across next word), or "group" (to - // the start of next group of word or non-word-non-whitespace - // chars). The visually param controls whether, in right-to-left - // text, direction 1 means to move towards the next index in the - // string, or towards the character to the right of the current - // position. The resulting position will have a hitSide=true - // property if it reached the end of the document. + // right), unit can be "codepoint", "char", "column" (like char, but + // doesn't cross line boundaries), "word" (across next word), or + // "group" (to the start of next group of word or + // non-word-non-whitespace chars). The visually param controls + // whether, in right-to-left text, direction 1 means to move towards + // the next index in the string, or towards the character to the right + // of the current position. The resulting position will have a + // hitSide=true property if it reached the end of the document. function findPosH(doc, pos, dir, unit, visually) { var oldPos = pos; var origDir = dir; @@ -8661,7 +8674,15 @@ } function moveOnce(boundToLine) { var next; - if (visually) { + if (unit == "codepoint") { + var ch = lineObj.text.charCodeAt(pos.ch + (dir > 0 ? 0 : -1)); + if (isNaN(ch)) { + next = null; + } else { + var astral = dir > 0 ? ch >= 0xD800 && ch < 0xDC00 : ch >= 0xDC00 && ch < 0xDFFF; + next = new Pos(pos.line, Math.max(0, Math.min(lineObj.text.length, pos.ch + dir * (astral ? 2 : 1))), -dir); + } + } else if (visually) { next = moveVisually(doc.cm, lineObj, pos, dir); } else { next = moveLogically(lineObj, pos, dir); @@ -8677,7 +8698,7 @@ return true } - if (unit == "char") { + if (unit == "char" || unit == "codepoint") { moveOnce(); } else if (unit == "column") { moveOnce(true); @@ -8745,6 +8766,7 @@ var input = this, cm = input.cm; var div = input.div = display.lineDiv; + div.contentEditable = true; disableBrowserMagic(div, cm.options.spellcheck, cm.options.autocorrect, cm.options.autocapitalize); function belongsToInput(e) { @@ -9621,6 +9643,7 @@ TextareaInput.prototype.readOnlyChanged = function (val) { if (!val) { this.reset(); } this.textarea.disabled = val == "nocursor"; + this.textarea.readOnly = !!val; }; TextareaInput.prototype.setUneditable = function () {}; @@ -9771,7 +9794,7 @@ addLegacyProps(CodeMirror); - CodeMirror.version = "5.57.0"; + CodeMirror.version = "5.60.0"; return CodeMirror; diff --git a/libraries/codemirror/mode/asn.1/asn.1.js b/libraries/codemirror/mode/asn.1/asn.1.js index d3ecb0878..df1330b68 100644 --- a/libraries/codemirror/mode/asn.1/asn.1.js +++ b/libraries/codemirror/mode/asn.1/asn.1.js @@ -190,7 +190,7 @@ " NetworkAddress BITS BMPString TimeStamp TimeTicks" + " TruthValue RowStatus DisplayString GeneralString" + " GraphicString IA5String NumericString" + - " PrintableString SnmpAdminAtring TeletexString" + + " PrintableString SnmpAdminString TeletexString" + " UTF8String VideotexString VisibleString StringStore" + " ISO646String T61String UniversalString Unsigned32" + " Integer32 Gauge Gauge32 Counter Counter32 Counter64"), diff --git a/libraries/codemirror/mode/clike/clike.js b/libraries/codemirror/mode/clike/clike.js index 37da2ec96..05b8f77f1 100644 --- a/libraries/codemirror/mode/clike/clike.js +++ b/libraries/codemirror/mode/clike/clike.js @@ -82,15 +82,15 @@ CodeMirror.defineMode("clike", function(config, parserConfig) { state.tokenize = tokenString(ch); return state.tokenize(stream, state); } - if (isPunctuationChar.test(ch)) { - curPunc = ch; - return null; - } if (numberStart.test(ch)) { stream.backUp(1) if (stream.match(number)) return "number" stream.next() } + if (isPunctuationChar.test(ch)) { + curPunc = ch; + return null; + } if (ch == "/") { if (stream.eat("*")) { state.tokenize = tokenComment; @@ -350,8 +350,8 @@ CodeMirror.defineMode("clike", function(config, parserConfig) { function cpp11StringHook(stream, state) { stream.backUp(1); // Raw strings. - if (stream.match(/(R|u8R|uR|UR|LR)/)) { - var match = stream.match(/"([^\s\\()]{0,16})\(/); + if (stream.match(/^(?:R|u8R|uR|UR|LR)/)) { + var match = stream.match(/^"([^\s\\()]{0,16})\(/); if (!match) { return false; } @@ -360,8 +360,8 @@ CodeMirror.defineMode("clike", function(config, parserConfig) { return tokenRawString(stream, state); } // Unicode strings/chars. - if (stream.match(/(u8|u|U|L)/)) { - if (stream.match(/["']/, /* eat */ false)) { + if (stream.match(/^(?:u8|u|U|L)/)) { + if (stream.match(/^["']/, /* eat */ false)) { return "string"; } return false; @@ -749,7 +749,7 @@ CodeMirror.defineMode("clike", function(config, parserConfig) { "gl_ModelViewMatrix gl_ProjectionMatrix gl_ModelViewProjectionMatrix " + "gl_TextureMatrix gl_NormalMatrix gl_ModelViewMatrixInverse " + "gl_ProjectionMatrixInverse gl_ModelViewProjectionMatrixInverse " + - "gl_TexureMatrixTranspose gl_ModelViewMatrixInverseTranspose " + + "gl_TextureMatrixTranspose gl_ModelViewMatrixInverseTranspose " + "gl_ProjectionMatrixInverseTranspose " + "gl_ModelViewProjectionMatrixInverseTranspose " + "gl_TextureMatrixInverseTranspose " + diff --git a/libraries/codemirror/mode/clike/scala.html b/libraries/codemirror/mode/clike/scala.html deleted file mode 100644 index 3d2123c01..000000000 --- a/libraries/codemirror/mode/clike/scala.html +++ /dev/null @@ -1,767 +0,0 @@ - - -CodeMirror: Scala mode - - - - - - - - - - -
-

Scala mode

-
- -
- - -
diff --git a/libraries/codemirror/mode/clojure/clojure.js b/libraries/codemirror/mode/clojure/clojure.js index 25d308ab4..0b9d6acc3 100644 --- a/libraries/codemirror/mode/clojure/clojure.js +++ b/libraries/codemirror/mode/clojure/clojure.js @@ -160,10 +160,10 @@ CodeMirror.defineMode("clojure", function (options) { var numberLiteral = /^(?:[+\-]?\d+(?:(?:N|(?:[eE][+\-]?\d+))|(?:\.?\d*(?:M|(?:[eE][+\-]?\d+))?)|\/\d+|[xX][0-9a-fA-F]+|r[0-9a-zA-Z]+)?(?=[\\\[\]\s"#'(),;@^`{}~]|$))/; var characterLiteral = /^(?:\\(?:backspace|formfeed|newline|return|space|tab|o[0-7]{3}|u[0-9A-Fa-f]{4}|x[0-9A-Fa-f]{4}|.)?(?=[\\\[\]\s"(),;@^`{}~]|$))/; - // simple-namespace := /^[^\\\/\[\]\d\s"#'(),;@^`{}~][^\\\[\]\s"(),;@^`{}~]*/ + // simple-namespace := /^[^\\\/\[\]\d\s"#'(),;@^`{}~.][^\\\[\]\s"(),;@^`{}~.\/]*/ // simple-symbol := /^(?:\/|[^\\\/\[\]\d\s"#'(),;@^`{}~][^\\\[\]\s"(),;@^`{}~]*)/ // qualified-symbol := ((<.>)*)? - var qualifiedSymbol = /^(?:(?:[^\\\/\[\]\d\s"#'(),;@^`{}~][^\\\[\]\s"(),;@^`{}~]*(?:\.[^\\\/\[\]\d\s"#'(),;@^`{}~][^\\\[\]\s"(),;@^`{}~]*)*\/)?(?:\/|[^\\\/\[\]\d\s"#'(),;@^`{}~][^\\\[\]\s"(),;@^`{}~]*)*(?=[\\\[\]\s"(),;@^`{}~]|$))/; + var qualifiedSymbol = /^(?:(?:[^\\\/\[\]\d\s"#'(),;@^`{}~.][^\\\[\]\s"(),;@^`{}~.\/]*(?:\.[^\\\/\[\]\d\s"#'(),;@^`{}~.][^\\\[\]\s"(),;@^`{}~.\/]*)*\/)?(?:\/|[^\\\/\[\]\d\s"#'(),;@^`{}~][^\\\[\]\s"(),;@^`{}~]*)*(?=[\\\[\]\s"(),;@^`{}~]|$))/; function base(stream, state) { if (stream.eatSpace() || stream.eat(",")) return ["space", null]; diff --git a/libraries/codemirror/mode/crystal/crystal.js b/libraries/codemirror/mode/crystal/crystal.js index 5c601c6ab..14dea98e2 100644 --- a/libraries/codemirror/mode/crystal/crystal.js +++ b/libraries/codemirror/mode/crystal/crystal.js @@ -194,17 +194,17 @@ // Numbers if (stream.eat("0")) { if (stream.eat("x")) { - stream.match(/^[0-9a-fA-F]+/); + stream.match(/^[0-9a-fA-F_]+/); } else if (stream.eat("o")) { - stream.match(/^[0-7]+/); + stream.match(/^[0-7_]+/); } else if (stream.eat("b")) { - stream.match(/^[01]+/); + stream.match(/^[01_]+/); } return "number"; } if (stream.eat(/^\d/)) { - stream.match(/^\d*(?:\.\d+)?(?:[eE][+-]?\d+)?/); + stream.match(/^[\d_]*(?:\.[\d_]+)?(?:[eE][+-]?\d+)?/); return "number"; } diff --git a/libraries/codemirror/mode/css/css.js b/libraries/codemirror/mode/css/css.js index 77ca0c10e..88a869bfe 100644 --- a/libraries/codemirror/mode/css/css.js +++ b/libraries/codemirror/mode/css/css.js @@ -29,7 +29,8 @@ CodeMirror.defineMode("css", function(config, parserConfig) { valueKeywords = parserConfig.valueKeywords || {}, allowNested = parserConfig.allowNested, lineComment = parserConfig.lineComment, - supportsAtComponent = parserConfig.supportsAtComponent === true; + supportsAtComponent = parserConfig.supportsAtComponent === true, + highlightNonStandardPropertyKeywords = config.highlightNonStandardPropertyKeywords !== false; var type, override; function ret(style, tp) { type = tp; return style; } @@ -77,8 +78,8 @@ CodeMirror.defineMode("css", function(config, parserConfig) { return ret("qualifier", "qualifier"); } else if (/[:;{}\[\]\(\)]/.test(ch)) { return ret(null, ch); - } else if (stream.match(/[\w-.]+(?=\()/)) { - if (/^(url(-prefix)?|domain|regexp)$/.test(stream.current().toLowerCase())) { + } else if (stream.match(/^[\w-.]+(?=\()/)) { + if (/^(url(-prefix)?|domain|regexp)$/i.test(stream.current())) { state.tokenize = tokenParenthesized; } return ret("variable callee", "variable"); @@ -107,7 +108,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) { function tokenParenthesized(stream, state) { stream.next(); // Must be '(' - if (!stream.match(/\s*[\"\')]/, false)) + if (!stream.match(/^\s*[\"\')]/, false)) state.tokenize = tokenString(")"); else state.tokenize = null; @@ -197,7 +198,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) { override = "property"; return "maybeprop"; } else if (nonStandardPropertyKeywords.hasOwnProperty(word)) { - override = "string-2"; + override = highlightNonStandardPropertyKeywords ? "string-2" : "property"; return "maybeprop"; } else if (allowNested) { override = stream.match(/^\s*:(?:\s|$)/, false) ? "property" : "tag"; @@ -291,7 +292,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) { else if (propertyKeywords.hasOwnProperty(word)) override = "property"; else if (nonStandardPropertyKeywords.hasOwnProperty(word)) - override = "string-2"; + override = highlightNonStandardPropertyKeywords ? "string-2" : "property"; else if (valueKeywords.hasOwnProperty(word)) override = "atom"; else if (colorKeywords.hasOwnProperty(word)) @@ -780,7 +781,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) { } }, ":": function(stream) { - if (stream.match(/\s*\{/, false)) + if (stream.match(/^\s*\{/, false)) return [null, null] return false; }, diff --git a/libraries/codemirror/mode/css/gss.html b/libraries/codemirror/mode/css/gss.html deleted file mode 100644 index 17d24f8ac..000000000 --- a/libraries/codemirror/mode/css/gss.html +++ /dev/null @@ -1,104 +0,0 @@ - - -CodeMirror: Closure Stylesheets (GSS) mode - - - - - - - - - - - - - -
-

Closure Stylesheets (GSS) mode

-
- - -

A mode for Closure Stylesheets (GSS).

-

MIME type defined: text/x-gss.

- -

Parsing/Highlighting Tests: normal, verbose.

- -
diff --git a/libraries/codemirror/mode/css/less.html b/libraries/codemirror/mode/css/less.html deleted file mode 100644 index f7611ef08..000000000 --- a/libraries/codemirror/mode/css/less.html +++ /dev/null @@ -1,152 +0,0 @@ - - -CodeMirror: LESS mode - - - - - - - - - - -
-

LESS mode

-
- - -

The LESS mode is a sub-mode of the CSS mode (defined in css.js).

- -

Parsing/Highlighting Tests: normal, verbose.

-
diff --git a/libraries/codemirror/mode/css/scss.html b/libraries/codemirror/mode/css/scss.html deleted file mode 100644 index 525bab2fe..000000000 --- a/libraries/codemirror/mode/css/scss.html +++ /dev/null @@ -1,158 +0,0 @@ - - -CodeMirror: SCSS mode - - - - - - - - - - -
-

SCSS mode

-
- - -

The SCSS mode is a sub-mode of the CSS mode (defined in css.js).

- -

Parsing/Highlighting Tests: normal, verbose.

- -
diff --git a/libraries/codemirror/mode/cypher/cypher.js b/libraries/codemirror/mode/cypher/cypher.js index aa76eb9e3..6d88fa0ed 100644 --- a/libraries/codemirror/mode/cypher/cypher.js +++ b/libraries/codemirror/mode/cypher/cypher.js @@ -21,11 +21,11 @@ var tokenBase = function(stream/*, state*/) { var ch = stream.next(); if (ch ==='"') { - stream.match(/.*?"/); + stream.match(/^[^"]*"/); return "string"; } if (ch === "'") { - stream.match(/.*?'/); + stream.match(/^[^']*'/); return "string"; } if (/[{}\(\),\.;\[\]]/.test(ch)) { diff --git a/libraries/codemirror/mode/dtd/dtd.js b/libraries/codemirror/mode/dtd/dtd.js index 74b8c6bde..1bff91cba 100644 --- a/libraries/codemirror/mode/dtd/dtd.js +++ b/libraries/codemirror/mode/dtd/dtd.js @@ -34,7 +34,7 @@ CodeMirror.defineMode("dtd", function(config) { state.tokenize = inBlock("meta", "?>"); return ret("meta", ch); } else if (ch == "#" && stream.eatWhile(/[\w]/)) return ret("atom", "tag"); - else if (ch == "|") return ret("keyword", "seperator"); + else if (ch == "|") return ret("keyword", "separator"); else if (ch.match(/[\(\)\[\]\-\.,\+\?>]/)) return ret(null, ch);//if(ch === ">") return ret(null, "endtag"); else else if (ch.match(/[\[\]]/)) return ret("rule", ch); else if (ch == "\"" || ch == "'") { @@ -112,7 +112,7 @@ CodeMirror.defineMode("dtd", function(config) { indent: function(state, textAfter) { var n = state.stack.length; - if( textAfter.match(/\]\s+|\]/) )n=n-1; + if( textAfter.charAt(0) === ']' )n--; else if(textAfter.substr(textAfter.length-1, textAfter.length) === ">"){ if(textAfter.substr(0,1) === "<") {} else if( type == "doindent" && textAfter.length > 1 ) {} diff --git a/libraries/codemirror/mode/ebnf/ebnf.js b/libraries/codemirror/mode/ebnf/ebnf.js index 238bbe23b..d8fb3f3a2 100644 --- a/libraries/codemirror/mode/ebnf/ebnf.js +++ b/libraries/codemirror/mode/ebnf/ebnf.js @@ -41,10 +41,10 @@ state.stringType = stream.peek(); stream.next(); // Skip quote state.stack.unshift(stateType._string); - } else if (stream.match(/^\/\*/)) { //comments starting with /* + } else if (stream.match('/*')) { //comments starting with /* state.stack.unshift(stateType.comment); state.commentType = commentType.slash; - } else if (stream.match(/^\(\*/)) { //comments starting with (* + } else if (stream.match('(*')) { //comments starting with (* state.stack.unshift(stateType.comment); state.commentType = commentType.parenthesis; } @@ -69,10 +69,10 @@ case stateType.comment: while (state.stack[0] === stateType.comment && !stream.eol()) { - if (state.commentType === commentType.slash && stream.match(/\*\//)) { + if (state.commentType === commentType.slash && stream.match('*/')) { state.stack.shift(); // Clear flag state.commentType = null; - } else if (state.commentType === commentType.parenthesis && stream.match(/\*\)/)) { + } else if (state.commentType === commentType.parenthesis && stream.match('*)')) { state.stack.shift(); // Clear flag state.commentType = null; } else { @@ -83,7 +83,7 @@ case stateType.characterClass: while (state.stack[0] === stateType.characterClass && !stream.eol()) { - if (!(stream.match(/^[^\]\\]+/) || stream.match(/^\\./))) { + if (!(stream.match(/^[^\]\\]+/) || stream.match('.'))) { state.stack.shift(); } } @@ -168,10 +168,10 @@ } } - if (stream.match(/^\/\//)) { + if (stream.match('//')) { stream.skipToEnd(); return "comment"; - } else if (stream.match(/return/)) { + } else if (stream.match('return')) { return "operator"; } else if (stream.match(/^[a-zA-Z_][a-zA-Z0-9_]*/)) { if (stream.match(/(?=[\(.])/)) { diff --git a/libraries/codemirror/mode/erlang/erlang.js b/libraries/codemirror/mode/erlang/erlang.js index f0541bb95..d827296f3 100644 --- a/libraries/codemirror/mode/erlang/erlang.js +++ b/libraries/codemirror/mode/erlang/erlang.js @@ -339,8 +339,8 @@ CodeMirror.defineMode("erlang", function(cmCfg) { } function lookahead(stream) { - var m = stream.match(/([\n\s]+|%[^\n]*\n)*(.)/,false); - return m ? m.pop() : ""; + var m = stream.match(/^\s*([^\s%])/, false) + return m ? m[1] : ""; } function is_member(element,list) { diff --git a/libraries/codemirror/mode/factor/factor.js b/libraries/codemirror/mode/factor/factor.js index 7108278cc..4c876d4d2 100644 --- a/libraries/codemirror/mode/factor/factor.js +++ b/libraries/codemirror/mode/factor/factor.js @@ -16,7 +16,7 @@ "use strict"; CodeMirror.defineSimpleMode("factor", { - // The start state contains the rules that are intially used + // The start state contains the rules that are initially used start: [ // comments {regex: /#?!.*/, token: "comment"}, diff --git a/libraries/codemirror/mode/gas/gas.js b/libraries/codemirror/mode/gas/gas.js index e34d7a7b6..b3515abe7 100644 --- a/libraries/codemirror/mode/gas/gas.js +++ b/libraries/codemirror/mode/gas/gas.js @@ -302,11 +302,11 @@ CodeMirror.defineMode("gas", function(_config, parserConfig) { } if (ch === '{') { - return "braket"; + return "bracket"; } if (ch === '}') { - return "braket"; + return "bracket"; } if (/\d/.test(ch)) { diff --git a/libraries/codemirror/mode/haml/haml.js b/libraries/codemirror/mode/haml/haml.js index 3c8f505eb..d941d9743 100644 --- a/libraries/codemirror/mode/haml/haml.js +++ b/libraries/codemirror/mode/haml/haml.js @@ -72,7 +72,7 @@ } } - // donot handle --> as valid ruby, make it HTML close comment instead + // do not handle --> as valid ruby, make it HTML close comment instead if (state.startOfLine && !stream.match("-->", false) && (ch == "=" || ch == "-" )) { state.tokenize = ruby; return state.tokenize(stream, state); diff --git a/libraries/codemirror/mode/htmlmixed/htmlmixed.js b/libraries/codemirror/mode/htmlmixed/htmlmixed.js index 8341ac826..66a158274 100644 --- a/libraries/codemirror/mode/htmlmixed/htmlmixed.js +++ b/libraries/codemirror/mode/htmlmixed/htmlmixed.js @@ -74,7 +74,8 @@ name: "xml", htmlMode: true, multilineTagIndentFactor: parserConfig.multilineTagIndentFactor, - multilineTagIndentPastTag: parserConfig.multilineTagIndentPastTag + multilineTagIndentPastTag: parserConfig.multilineTagIndentPastTag, + allowMissingTagName: parserConfig.allowMissingTagName, }); var tags = {}; diff --git a/libraries/codemirror/mode/idl/idl.js b/libraries/codemirror/mode/idl/idl.js index 168761cd8..37302bb90 100644 --- a/libraries/codemirror/mode/idl/idl.js +++ b/libraries/codemirror/mode/idl/idl.js @@ -62,7 +62,7 @@ 'empty', 'enable_sysrtn', 'eof', 'eos', 'erase', 'erf', 'erfc', 'erfcx', 'erode', 'errorplot', 'errplot', 'estimator_filter', 'execute', 'exit', 'exp', - 'expand', 'expand_path', 'expint', 'extrac', 'extract_slice', + 'expand', 'expand_path', 'expint', 'extract', 'extract_slice', 'f_cvf', 'f_pdf', 'factorial', 'fft', 'file_basename', 'file_chmod', 'file_copy', 'file_delete', 'file_dirname', 'file_expand_path', 'file_gunzip', 'file_gzip', 'file_info', diff --git a/libraries/codemirror/mode/javascript/javascript.js b/libraries/codemirror/mode/javascript/javascript.js index 9c751d23f..a42f23d07 100644 --- a/libraries/codemirror/mode/javascript/javascript.js +++ b/libraries/codemirror/mode/javascript/javascript.js @@ -111,7 +111,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { if (ch != ">" || !state.lexical || state.lexical.type != ">") { if (stream.eat("=")) { if (ch == "!" || ch == "=") stream.eat("=") - } else if (/[<>*+\-]/.test(ch)) { + } else if (/[<>*+\-|&?]/.test(ch)) { stream.eat(ch) if (ch == ">") stream.eat(ch) } @@ -126,7 +126,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { var kw = keywords[word] return ret(kw.type, kw.style, word) } - if (word == "async" && stream.match(/^(\s|\/\*.*?\*\/)*[\[\(\w]/, false)) + if (word == "async" && stream.match(/^(\s|\/\*([^*]|\*(?!\/))*?\*\/)*[\[\(\w]/, false)) return ret("async", "keyword", word) } return ret("variable", "variable", word) @@ -218,7 +218,8 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { // Parser - var atomicTypes = {"atom": true, "number": true, "variable": true, "string": true, "regexp": true, "this": true, "jsonld-keyword": true}; + var atomicTypes = {"atom": true, "number": true, "variable": true, "string": true, + "regexp": true, "this": true, "import": true, "jsonld-keyword": true}; function JSLexical(indented, column, type, align, prev, info) { this.indented = indented; @@ -441,7 +442,6 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { if (type == "{") return contCommasep(objprop, "}", null, maybeop); if (type == "quasi") return pass(quasi, maybeop); if (type == "new") return cont(maybeTarget(noComma)); - if (type == "import") return cont(expression); return cont(); } function maybeexpression(type) { @@ -605,7 +605,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { } } function typeexpr(type, value) { - if (value == "keyof" || value == "typeof" || value == "infer") { + if (value == "keyof" || value == "typeof" || value == "infer" || value == "readonly") { cx.marked = "keyword" return cont(value == "typeof" ? expressionNoComma : typeexpr) } @@ -616,13 +616,18 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { if (value == "|" || value == "&") return cont(typeexpr) if (type == "string" || type == "number" || type == "atom") return cont(afterType); if (type == "[") return cont(pushlex("]"), commasep(typeexpr, "]", ","), poplex, afterType) - if (type == "{") return cont(pushlex("}"), commasep(typeprop, "}", ",;"), poplex, afterType) + if (type == "{") return cont(pushlex("}"), typeprops, poplex, afterType) if (type == "(") return cont(commasep(typearg, ")"), maybeReturnType, afterType) if (type == "<") return cont(commasep(typeexpr, ">"), typeexpr) } function maybeReturnType(type) { if (type == "=>") return cont(typeexpr) } + function typeprops(type) { + if (type.match(/[\}\)\]]/)) return cont() + if (type == "," || type == ";") return cont(typeprops) + return pass(typeprop, typeprops) + } function typeprop(type, value) { if (type == "variable" || cx.style == "keyword") { cx.marked = "property" @@ -635,6 +640,8 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { return cont(expect("variable"), maybetypeOrIn, expect("]"), typeprop) } else if (type == "(") { return pass(functiondecl, typeprop) + } else if (!type.match(/[;\}\)\],]/)) { + return cont() } } function typearg(type, value) { @@ -795,6 +802,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { function afterImport(type) { if (type == "string") return cont(); if (type == "(") return pass(expression); + if (type == ".") return pass(maybeoperatorComma); return pass(importSpec, maybeMoreImports, maybeFrom); } function importSpec(type, value) { @@ -868,7 +876,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { }, indent: function(state, textAfter) { - if (state.tokenize == tokenComment) return CodeMirror.Pass; + if (state.tokenize == tokenComment || state.tokenize == tokenQuasi) return CodeMirror.Pass; if (state.tokenize != tokenBase) return 0; var firstChar = textAfter && textAfter.charAt(0), lexical = state.lexical, top // Kludge to prevent 'maybelse' from blocking lexical scope pops @@ -925,9 +933,10 @@ CodeMirror.defineMIME("text/ecmascript", "javascript"); CodeMirror.defineMIME("application/javascript", "javascript"); CodeMirror.defineMIME("application/x-javascript", "javascript"); CodeMirror.defineMIME("application/ecmascript", "javascript"); -CodeMirror.defineMIME("application/json", {name: "javascript", json: true}); -CodeMirror.defineMIME("application/x-json", {name: "javascript", json: true}); -CodeMirror.defineMIME("application/ld+json", {name: "javascript", jsonld: true}); +CodeMirror.defineMIME("application/json", { name: "javascript", json: true }); +CodeMirror.defineMIME("application/x-json", { name: "javascript", json: true }); +CodeMirror.defineMIME("application/manifest+json", { name: "javascript", json: true }) +CodeMirror.defineMIME("application/ld+json", { name: "javascript", jsonld: true }); CodeMirror.defineMIME("text/typescript", { name: "javascript", typescript: true }); CodeMirror.defineMIME("application/typescript", { name: "javascript", typescript: true }); diff --git a/libraries/codemirror/mode/javascript/json-ld.html b/libraries/codemirror/mode/javascript/json-ld.html deleted file mode 100644 index 6a29c1445..000000000 --- a/libraries/codemirror/mode/javascript/json-ld.html +++ /dev/null @@ -1,72 +0,0 @@ - - -CodeMirror: JSON-LD mode - - - - - - - - - - - - -
-

JSON-LD mode

- - -
- - - -

This is a specialization of the JavaScript mode.

-
diff --git a/libraries/codemirror/mode/javascript/typescript.html b/libraries/codemirror/mode/javascript/typescript.html deleted file mode 100644 index 7da84d2ad..000000000 --- a/libraries/codemirror/mode/javascript/typescript.html +++ /dev/null @@ -1,62 +0,0 @@ - - -CodeMirror: TypeScript mode - - - - - - - - - - -
-

TypeScript mode

- - -
- - - -

This is a specialization of the JavaScript mode.

-
diff --git a/libraries/codemirror/mode/julia/julia.js b/libraries/codemirror/mode/julia/julia.js index f1d2cd5c4..de9f987d8 100644 --- a/libraries/codemirror/mode/julia/julia.js +++ b/libraries/codemirror/mode/julia/julia.js @@ -80,7 +80,7 @@ CodeMirror.defineMode("julia", function(config, parserConf) { // tokenizers function tokenBase(stream, state) { // Handle multiline comments - if (stream.match(/^#=/, false)) { + if (stream.match('#=', false)) { state.tokenize = tokenComment; return state.tokenize(stream, state); } @@ -141,10 +141,10 @@ CodeMirror.defineMode("julia", function(config, parserConf) { } if (inArray(state)) { - if (state.lastToken == "end" && stream.match(/^:/)) { + if (state.lastToken == "end" && stream.match(':')) { return "operator"; } - if (stream.match(/^end/)) { + if (stream.match('end')) { return "number"; } } @@ -201,7 +201,7 @@ CodeMirror.defineMode("julia", function(config, parserConf) { } // Handle Chars - if (stream.match(/^'/)) { + if (stream.match('\'')) { state.tokenize = tokenChar; return state.tokenize(stream, state); } @@ -241,10 +241,6 @@ CodeMirror.defineMode("julia", function(config, parserConf) { state.isDefinition = false; return "def"; } - if (stream.match(/^({[^}]*})*\(/, false)) { - state.tokenize = tokenCallOrDef; - return state.tokenize(stream, state); - } state.leavingExpr = true; return "variable"; } @@ -254,49 +250,11 @@ CodeMirror.defineMode("julia", function(config, parserConf) { return "error"; } - function tokenCallOrDef(stream, state) { - var match = stream.match(/^(\(\s*)/); - if (match) { - if (state.firstParenPos < 0) - state.firstParenPos = state.scopes.length; - state.scopes.push('('); - state.charsAdvanced += match[1].length; - } - if (currentScope(state) == '(' && stream.match(/^\)/)) { - state.scopes.pop(); - state.charsAdvanced += 1; - if (state.scopes.length <= state.firstParenPos) { - 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"; - } - } - // Unfortunately javascript does not support multiline strings, so we have - // to undo anything done upto here if a function call or definition splits - // over two or more lines. - if (stream.match(/^$/g, false)) { - stream.backUp(state.charsAdvanced); - while (state.scopes.length > state.firstParenPos) - state.scopes.pop(); - state.firstParenPos = -1; - state.charsAdvanced = 0; - state.tokenize = tokenBase; - return "builtin"; - } - state.charsAdvanced += stream.match(/^([^()]*)/)[1].length; - return state.tokenize(stream, state); - } - function tokenAnnotation(stream, state) { - stream.match(/.*?(?=,|;|{|}|\(|\)|=|$|\s)/); - if (stream.match(/^{/)) { + stream.match(/.*?(?=[,;{}()=\s]|$)/); + if (stream.match('{')) { state.nestedParameters++; - } else if (stream.match(/^}/) && state.nestedParameters > 0) { + } else if (stream.match('}') && state.nestedParameters > 0) { state.nestedParameters--; } if (state.nestedParameters > 0) { @@ -308,13 +266,13 @@ CodeMirror.defineMode("julia", function(config, parserConf) { } function tokenComment(stream, state) { - if (stream.match(/^#=/)) { + if (stream.match('#=')) { state.nestedComments++; } if (!stream.match(/.*?(?=(#=|=#))/)) { stream.skipToEnd(); } - if (stream.match(/^=#/)) { + if (stream.match('=#')) { state.nestedComments--; if (state.nestedComments == 0) state.tokenize = tokenBase; @@ -345,7 +303,7 @@ CodeMirror.defineMode("julia", function(config, parserConf) { return "string"; } if (!stream.match(/^[^']+(?=')/)) { stream.skipToEnd(); } - if (stream.match(/^'/)) { state.tokenize = tokenBase; } + if (stream.match('\'')) { state.tokenize = tokenBase; } return "error"; } @@ -383,7 +341,6 @@ CodeMirror.defineMode("julia", function(config, parserConf) { nestedComments: 0, nestedGenerators: 0, nestedParameters: 0, - charsAdvanced: 0, firstParenPos: -1 }; }, diff --git a/libraries/codemirror/mode/lua/lua.js b/libraries/codemirror/mode/lua/lua.js index 202f37358..2fad0180f 100644 --- a/libraries/codemirror/mode/lua/lua.js +++ b/libraries/codemirror/mode/lua/lua.js @@ -148,6 +148,7 @@ CodeMirror.defineMode("lua", function(config, parserConfig) { return state.basecol + indentUnit * (state.indentDepth - (closing ? 1 : 0)); }, + electricInput: /^\s*(?:end|until|else|\)|\})$/, lineComment: "--", blockCommentStart: "--[[", blockCommentEnd: "]]" diff --git a/libraries/codemirror/mode/markdown/markdown.js b/libraries/codemirror/mode/markdown/markdown.js index 287f39b55..a9e272ea8 100644 --- a/libraries/codemirror/mode/markdown/markdown.js +++ b/libraries/codemirror/mode/markdown/markdown.js @@ -223,7 +223,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { // Add this list item's content's indentation to the stack state.listStack.push(state.indentation); - // Reset inline styles which shouldn't propagate aross list items + // Reset inline styles which shouldn't propagate across list items state.em = false; state.strong = false; state.code = false; @@ -612,7 +612,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { return getType(state); } } else if (ch === ' ') { - if (stream.match(/^~~/, true)) { // Probably surrounded by space + if (stream.match('~~', true)) { // Probably surrounded by space if (stream.peek() === ' ') { // Surrounded by spaces, ignore return getType(state); } else { // Not surrounded by spaces, back up pointer @@ -711,7 +711,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { } function footnoteLinkInside(stream, state) { - if (stream.match(/^\]:/, true)) { + if (stream.match(']:', true)) { state.f = state.inline = footnoteUrl; if (modeCfg.highlightFormatting) state.formatting = "link"; var returnType = getType(state); @@ -735,7 +735,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { if (stream.peek() === undefined) { // End of line, set flag to check next line state.linkTitle = true; } else { // More content on line, check if link title - stream.match(/^(?:\s+(?:"(?:[^"\\]|\\\\|\\.)+"|'(?:[^'\\]|\\\\|\\.)+'|\((?:[^)\\]|\\\\|\\.)+\)))?/, true); + stream.match(/^(?:\s+(?:"(?:[^"\\]|\\.)+"|'(?:[^'\\]|\\.)+'|\((?:[^)\\]|\\.)+\)))?/, true); } state.f = state.inline = inlineNormal; return tokenTypes.linkHref + " url"; diff --git a/libraries/codemirror/mode/meta.js b/libraries/codemirror/mode/meta.js index 3bae4ad4a..45c6e7aa1 100644 --- a/libraries/codemirror/mode/meta.js +++ b/libraries/codemirror/mode/meta.js @@ -169,7 +169,8 @@ {name: "Z80", mime: "text/x-z80", mode: "z80", ext: ["z80"]}, {name: "mscgen", mime: "text/x-mscgen", mode: "mscgen", ext: ["mscgen", "mscin", "msc"]}, {name: "xu", mime: "text/x-xu", mode: "mscgen", ext: ["xu"]}, - {name: "msgenny", mime: "text/x-msgenny", mode: "mscgen", ext: ["msgenny"]} + {name: "msgenny", mime: "text/x-msgenny", mode: "mscgen", ext: ["msgenny"]}, + {name: "WebAssembly", mime: "text/webassembly", mode: "wast", ext: ["wat", "wast"]}, ]; // Ensure all modes have a mime property for backwards compatibility for (var i = 0; i < CodeMirror.modeInfo.length; i++) { diff --git a/libraries/codemirror/mode/modelica/modelica.js b/libraries/codemirror/mode/modelica/modelica.js index a83a4135d..2e9622f03 100644 --- a/libraries/codemirror/mode/modelica/modelica.js +++ b/libraries/codemirror/mode/modelica/modelica.js @@ -90,7 +90,7 @@ return "error"; } - function tokenUnsignedNuber(stream, state) { + function tokenUnsignedNumber(stream, state) { stream.eatWhile(isDigit); if (stream.eat('.')) { stream.eatWhile(isDigit); @@ -164,9 +164,9 @@ else if(ch == '"') { state.tokenize = tokenString; } - // UNSIGNED_NUBER + // UNSIGNED_NUMBER else if(isDigit.test(ch)) { - state.tokenize = tokenUnsignedNuber; + state.tokenize = tokenUnsignedNumber; } // ERROR else { diff --git a/libraries/codemirror/mode/mscgen/mscgen.js b/libraries/codemirror/mode/mscgen/mscgen.js index 6f4f9cd8f..8d39341cf 100644 --- a/libraries/codemirror/mode/mscgen/mscgen.js +++ b/libraries/codemirror/mode/mscgen/mscgen.js @@ -72,11 +72,11 @@ CodeMirror.defineMIME("text/x-msgenny", {name: "mscgen", language: "msgenny"}); function wordRegexpBoundary(pWords) { - return new RegExp("\\b(" + pWords.join("|") + ")\\b", "i"); + return new RegExp("^\\b(?:" + pWords.join("|") + ")\\b", "i"); } function wordRegexp(pWords) { - return new RegExp("(" + pWords.join("|") + ")", "i"); + return new RegExp("^(?:" + pWords.join("|") + ")", "i"); } function startStateFn() { @@ -153,7 +153,7 @@ return "variable"; /* attribute lists */ - if (!pConfig.inAttributeList && !!pConfig.attributes && pStream.match(/\[/, true, true)) { + if (!pConfig.inAttributeList && !!pConfig.attributes && pStream.match('[', true, true)) { pConfig.inAttributeList = true; return "bracket"; } @@ -161,7 +161,7 @@ if (pConfig.attributes !== null && pStream.match(wordRegexpBoundary(pConfig.attributes), true, true)) { return "attribute"; } - if (pStream.match(/]/, true, true)) { + if (pStream.match(']', true, true)) { pConfig.inAttributeList = false; return "bracket"; } diff --git a/libraries/codemirror/mode/mumps/mumps.js b/libraries/codemirror/mode/mumps/mumps.js index 3671c9cb3..c53b4bf3a 100644 --- a/libraries/codemirror/mode/mumps/mumps.js +++ b/libraries/codemirror/mode/mumps/mumps.js @@ -26,7 +26,7 @@ var brackets = new RegExp("[()]"); var identifiers = new RegExp("^[%A-Za-z][A-Za-z0-9]*"); var commandKeywords = ["break","close","do","else","for","goto", "halt", "hang", "if", "job","kill","lock","merge","new","open", "quit", "read", "set", "tcommit", "trollback", "tstart", "use", "view", "write", "xecute", "b","c","d","e","f","g", "h", "i", "j","k","l","m","n","o", "q", "r", "s", "tc", "tro", "ts", "u", "v", "w", "x"]; - // The following list includes instrinsic functions _and_ special variables + // The following list includes intrinsic functions _and_ special variables var intrinsicFuncsWords = ["\\$ascii", "\\$char", "\\$data", "\\$ecode", "\\$estack", "\\$etrap", "\\$extract", "\\$find", "\\$fnumber", "\\$get", "\\$horolog", "\\$io", "\\$increment", "\\$job", "\\$justify", "\\$length", "\\$name", "\\$next", "\\$order", "\\$piece", "\\$qlength", "\\$qsubscript", "\\$query", "\\$quit", "\\$random", "\\$reverse", "\\$select", "\\$stack", "\\$test", "\\$text", "\\$translate", "\\$view", "\\$x", "\\$y", "\\$a", "\\$c", "\\$d", "\\$e", "\\$ec", "\\$es", "\\$et", "\\$f", "\\$fn", "\\$g", "\\$h", "\\$i", "\\$j", "\\$l", "\\$n", "\\$na", "\\$o", "\\$p", "\\$q", "\\$ql", "\\$qs", "\\$r", "\\$re", "\\$s", "\\$st", "\\$t", "\\$tr", "\\$v", "\\$z"]; var intrinsicFuncs = wordRegexp(intrinsicFuncsWords); var command = wordRegexp(commandKeywords); diff --git a/libraries/codemirror/mode/oz/oz.js b/libraries/codemirror/mode/oz/oz.js index a9738495b..73857e4c7 100644 --- a/libraries/codemirror/mode/oz/oz.js +++ b/libraries/codemirror/mode/oz/oz.js @@ -45,7 +45,7 @@ CodeMirror.defineMode("oz", function (conf) { } // Special [] keyword - if (stream.match(/(\[])/)) { + if (stream.match('[]')) { return "keyword" } @@ -130,7 +130,7 @@ CodeMirror.defineMode("oz", function (conf) { return "operator"; } - // If nothing match, we skip the entire alphanumerical block + // If nothing match, we skip the entire alphanumeric block stream.eatWhile(/\w/); return "variable"; diff --git a/libraries/codemirror/mode/pegjs/pegjs.js b/libraries/codemirror/mode/pegjs/pegjs.js index 19d5fa4c0..ac011d3c8 100644 --- a/libraries/codemirror/mode/pegjs/pegjs.js +++ b/libraries/codemirror/mode/pegjs/pegjs.js @@ -39,7 +39,7 @@ CodeMirror.defineMode("pegjs", function (config) { stream.next(); // Skip quote state.inString = true; // Update state } - if (!state.inString && !state.inComment && stream.match(/^\/\*/)) { + if (!state.inString && !state.inComment && stream.match('/*')) { state.inComment = true; } @@ -59,7 +59,7 @@ CodeMirror.defineMode("pegjs", function (config) { return state.lhs ? "property string" : "string"; // Token style } else if (state.inComment) { while (state.inComment && !stream.eol()) { - if (stream.match(/\*\//)) { + if (stream.match('*/')) { state.inComment = false; // Clear flag } else { stream.match(/^.[^\*]*/); @@ -76,7 +76,7 @@ CodeMirror.defineMode("pegjs", function (config) { stream.next(); state.inCharacterClass = true; return 'bracket'; - } else if (stream.match(/^\/\//)) { + } else if (stream.match('//')) { stream.skipToEnd(); return "comment"; } else if (state.braced || stream.peek() === '{') { diff --git a/libraries/codemirror/mode/perl/perl.js b/libraries/codemirror/mode/perl/perl.js index a3101a7c5..ffe7877af 100644 --- a/libraries/codemirror/mode/perl/perl.js +++ b/libraries/codemirror/mode/perl/perl.js @@ -347,7 +347,7 @@ CodeMirror.defineMode("perl",function(){ lc :1, // - return lower-case version of a string lcfirst :1, // - return a string with just the next letter in lower case length :1, // - return the number of bytes in a string - 'link' :1, // - create a hard link in the filesytem + 'link' :1, // - create a hard link in the filesystem listen :1, // - register your socket as a server local : 2, // - create a temporary value for a global variable (dynamic scoping) localtime :1, // - convert UNIX time into record or string using local time @@ -441,7 +441,7 @@ CodeMirror.defineMode("perl",function(){ state :1, // - declare and assign a state variable (persistent lexical scoping) study :1, // - optimize input data for repeated searches 'sub' :1, // - declare a subroutine, possibly anonymously - 'substr' :1, // - get or alter a portion of a stirng + 'substr' :1, // - get or alter a portion of a string symlink :1, // - create a symbolic link to a file syscall :1, // - execute an arbitrary system call sysopen :1, // - open a file, pipe, or descriptor @@ -516,7 +516,7 @@ CodeMirror.defineMode("perl",function(){ if(stream.match(/^\-?[\d\.]/,false)) if(stream.match(/^(\-?(\d*\.\d+(e[+-]?\d+)?|\d+\.\d*)|0x[\da-fA-F]+|0b[01]+|\d+(e[+-]?\d+)?)/)) return 'number'; - if(stream.match(/^<<(?=\w)/)){ // NOTE: <\w/, false)) { + if (stream.match(/^->\w/, false)) { // Match object operator state.tokenize = matchSequence([ [["->", null]], @@ -106,7 +106,7 @@ }, "<": function(stream, state) { var before; - if (before = stream.match(/<<\s*/)) { + if (before = stream.match(/^<<\s*/)) { var quoted = stream.eat(/['"]/); stream.eatWhile(/[\w\.]/); var delim = stream.current().slice(before[0].length + (quoted ? 2 : 1)); diff --git a/libraries/codemirror/mode/pug/pug.js b/libraries/codemirror/mode/pug/pug.js index a4c0e16b8..73e9ae2fc 100644 --- a/libraries/codemirror/mode/pug/pug.js +++ b/libraries/codemirror/mode/pug/pug.js @@ -261,7 +261,7 @@ CodeMirror.defineMode("pug", function (config) { } return 'variable'; } - if (stream.match(/^\+#{/, false)) { + if (stream.match('+#{', false)) { stream.next(); state.mixinCallAfter = true; return interpolation(stream, state); diff --git a/libraries/codemirror/mode/puppet/puppet.js b/libraries/codemirror/mode/puppet/puppet.js index 364934209..a92ca1107 100644 --- a/libraries/codemirror/mode/puppet/puppet.js +++ b/libraries/codemirror/mode/puppet/puppet.js @@ -176,7 +176,7 @@ CodeMirror.defineMode("puppet", function () { // Match characters that we are going to assume // are trying to be regex if (ch == '/') { - stream.match(/.*?\//); + stream.match(/^[^\/]*\//); return 'variable-3'; } // Match all the numbers diff --git a/libraries/codemirror/mode/python/python.js b/libraries/codemirror/mode/python/python.js index de5fd38a1..1befb4045 100644 --- a/libraries/codemirror/mode/python/python.js +++ b/libraries/codemirror/mode/python/python.js @@ -282,7 +282,7 @@ } function pushBracketScope(stream, state, type) { - var align = stream.match(/^([\s\[\{\(]|#.*)*$/, false) ? null : stream.column() + 1 + var align = stream.match(/^[\s\[\{\(]*(?:#|$)/, false) ? null : stream.column() + 1 state.scopes.push({offset: state.indent + hangingIndent, type: type, align: align}) diff --git a/libraries/codemirror/mode/rpm/rpm.js b/libraries/codemirror/mode/rpm/rpm.js index 2dece2eab..bb9ec9ffa 100644 --- a/libraries/codemirror/mode/rpm/rpm.js +++ b/libraries/codemirror/mode/rpm/rpm.js @@ -12,14 +12,14 @@ "use strict"; CodeMirror.defineMode("rpm-changes", function() { - var headerSeperator = /^-+$/; + var headerSeparator = /^-+$/; var headerLine = /^(Mon|Tue|Wed|Thu|Fri|Sat|Sun) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) ?\d{1,2} \d{2}:\d{2}(:\d{2})? [A-Z]{3,4} \d{4} - /; var simpleEmail = /^[\w+.-]+@[\w.-]+/; return { token: function(stream) { if (stream.sol()) { - if (stream.match(headerSeperator)) { return 'tag'; } + if (stream.match(headerSeparator)) { return 'tag'; } if (stream.match(headerLine)) { return 'tag'; } } if (stream.match(simpleEmail)) { return 'string'; } @@ -80,12 +80,12 @@ CodeMirror.defineMode("rpm-spec", function() { // Macros like '%make_install' or '%attr(0775,root,root)' if (stream.match(/^%[\w]+/)) { - if (stream.match(/^\(/)) { state.macroParameters = true; } + if (stream.match('(')) { state.macroParameters = true; } return "keyword"; } if (state.macroParameters) { if (stream.match(/^\d+/)) { return "number";} - if (stream.match(/^\)/)) { + if (stream.match(')')) { state.macroParameters = false; return "keyword"; } diff --git a/libraries/codemirror/mode/ruby/ruby.js b/libraries/codemirror/mode/ruby/ruby.js index dd0e603e5..85bbfc657 100644 --- a/libraries/codemirror/mode/ruby/ruby.js +++ b/libraries/codemirror/mode/ruby/ruby.js @@ -11,25 +11,28 @@ })(function(CodeMirror) { "use strict"; +function wordObj(words) { + var o = {}; + for (var i = 0, e = words.length; i < e; ++i) o[words[i]] = true; + return o; +} + +var keywordList = [ + "alias", "and", "BEGIN", "begin", "break", "case", "class", "def", "defined?", "do", "else", + "elsif", "END", "end", "ensure", "false", "for", "if", "in", "module", "next", "not", "or", + "redo", "rescue", "retry", "return", "self", "super", "then", "true", "undef", "unless", + "until", "when", "while", "yield", "nil", "raise", "throw", "catch", "fail", "loop", "callcc", + "caller", "lambda", "proc", "public", "protected", "private", "require", "load", + "require_relative", "extend", "autoload", "__END__", "__FILE__", "__LINE__", "__dir__" +], keywords = wordObj(keywordList); + +var indentWords = wordObj(["def", "class", "case", "for", "while", "until", "module", "then", + "catch", "loop", "proc", "begin"]); +var dedentWords = wordObj(["end", "until"]); +var opening = {"[": "]", "{": "}", "(": ")"}; +var closing = {"]": "[", "}": "{", ")": "("}; + CodeMirror.defineMode("ruby", function(config) { - function wordObj(words) { - var o = {}; - for (var i = 0, e = words.length; i < e; ++i) o[words[i]] = true; - return o; - } - var keywords = wordObj([ - "alias", "and", "BEGIN", "begin", "break", "case", "class", "def", "defined?", "do", "else", - "elsif", "END", "end", "ensure", "false", "for", "if", "in", "module", "next", "not", "or", - "redo", "rescue", "retry", "return", "self", "super", "then", "true", "undef", "unless", - "until", "when", "while", "yield", "nil", "raise", "throw", "catch", "fail", "loop", "callcc", - "caller", "lambda", "proc", "public", "protected", "private", "require", "load", - "require_relative", "extend", "autoload", "__END__", "__FILE__", "__LINE__", "__dir__" - ]); - var indentWords = wordObj(["def", "class", "case", "for", "while", "until", "module", "then", - "catch", "loop", "proc", "begin"]); - var dedentWords = wordObj(["end", "until"]); - var opening = {"[": "]", "{": "}", "(": ")"}; - var closing = {"]": "[", "}": "{", ")": "("}; var curPunc; function chain(newtok, stream, state) { @@ -295,4 +298,6 @@ CodeMirror.defineMode("ruby", function(config) { CodeMirror.defineMIME("text/x-ruby", "ruby"); +CodeMirror.registerHelper("hintWords", "ruby", keywordList); + }); diff --git a/libraries/codemirror/mode/sass/sass.js b/libraries/codemirror/mode/sass/sass.js index c37ab0b28..d8427bff5 100644 --- a/libraries/codemirror/mode/sass/sass.js +++ b/libraries/codemirror/mode/sass/sass.js @@ -231,7 +231,7 @@ CodeMirror.defineMode("sass", function(config) { } if(ch === "@"){ - if(stream.match(/@extend/)){ + if(stream.match('@extend')){ if(!stream.match(/\s*[\w]/)) dedent(state); } @@ -445,7 +445,12 @@ CodeMirror.defineMode("sass", function(config) { indent: function(state) { return state.scopes[0].offset; - } + }, + + blockCommentStart: "/*", + blockCommentEnd: "*/", + lineComment: "//", + fold: "indent" }; }, "css"); diff --git a/libraries/codemirror/mode/scheme/scheme.js b/libraries/codemirror/mode/scheme/scheme.js index 56e4e332e..370250d85 100644 --- a/libraries/codemirror/mode/scheme/scheme.js +++ b/libraries/codemirror/mode/scheme/scheme.js @@ -26,8 +26,8 @@ CodeMirror.defineMode("scheme", function () { return obj; } - var keywords = makeKeywords("λ case-lambda call/cc class define-class exit-handler field import inherit init-field interface let*-values let-values let/ec mixin opt-lambda override protect provide public rename require require-for-syntax syntax syntax-case syntax-error unit/sig unless when with-syntax and begin call-with-current-continuation call-with-input-file call-with-output-file case cond define define-syntax delay do dynamic-wind else for-each if lambda let let* let-syntax letrec letrec-syntax map or syntax-rules abs acos angle append apply asin assoc assq assv atan boolean? caar cadr call-with-input-file call-with-output-file call-with-values car cdddar cddddr cdr ceiling char->integer char-alphabetic? char-ci<=? char-ci=? char-ci>? char-downcase char-lower-case? char-numeric? char-ready? char-upcase char-upper-case? char-whitespace? char<=? char=? char>? char? close-input-port close-output-port complex? cons cos current-input-port current-output-port denominator display eof-object? eq? equal? eqv? eval even? exact->inexact exact? exp expt #f floor force gcd imag-part inexact->exact inexact? input-port? integer->char integer? interaction-environment lcm length list list->string list->vector list-ref list-tail list? load log magnitude make-polar make-rectangular make-string make-vector max member memq memv min modulo negative? newline not null-environment null? number->string number? numerator odd? open-input-file open-output-file output-port? pair? peek-char port? positive? procedure? quasiquote quote quotient rational? rationalize read read-char real-part real? remainder reverse round scheme-report-environment set! set-car! set-cdr! sin sqrt string string->list string->number string->symbol string-append string-ci<=? string-ci=? string-ci>? string-copy string-fill! string-length string-ref string-set! string<=? string=? string>? string? substring symbol->string symbol? #t tan transcript-off transcript-on truncate values vector vector->list vector-fill! vector-length vector-ref vector-set! with-input-from-file with-output-to-file write write-char zero?"); - var indentKeys = makeKeywords("define let letrec let* lambda"); + var keywords = makeKeywords("λ case-lambda call/cc class cond-expand define-class define-values exit-handler field import inherit init-field interface let*-values let-values let/ec mixin opt-lambda override protect provide public rename require require-for-syntax syntax syntax-case syntax-error unit/sig unless when with-syntax and begin call-with-current-continuation call-with-input-file call-with-output-file case cond define define-syntax define-macro defmacro delay do dynamic-wind else for-each if lambda let let* let-syntax letrec letrec-syntax map or syntax-rules abs acos angle append apply asin assoc assq assv atan boolean? caar cadr call-with-input-file call-with-output-file call-with-values car cdddar cddddr cdr ceiling char->integer char-alphabetic? char-ci<=? char-ci=? char-ci>? char-downcase char-lower-case? char-numeric? char-ready? char-upcase char-upper-case? char-whitespace? char<=? char=? char>? char? close-input-port close-output-port complex? cons cos current-input-port current-output-port denominator display eof-object? eq? equal? eqv? eval even? exact->inexact exact? exp expt #f floor force gcd imag-part inexact->exact inexact? input-port? integer->char integer? interaction-environment lcm length list list->string list->vector list-ref list-tail list? load log magnitude make-polar make-rectangular make-string make-vector max member memq memv min modulo negative? newline not null-environment null? number->string number? numerator odd? open-input-file open-output-file output-port? pair? peek-char port? positive? procedure? quasiquote quote quotient rational? rationalize read read-char real-part real? remainder reverse round scheme-report-environment set! set-car! set-cdr! sin sqrt string string->list string->number string->symbol string-append string-ci<=? string-ci=? string-ci>? string-copy string-fill! string-length string-ref string-set! string<=? string=? string>? string? substring symbol->string symbol? #t tan transcript-off transcript-on truncate values vector vector->list vector-fill! vector-length vector-ref vector-set! with-input-from-file with-output-to-file write write-char zero?"); + var indentKeys = makeKeywords("define let letrec let* lambda define-macro defmacro let-syntax letrec-syntax let-values let*-values define-syntax syntax-rules define-values when unless"); function stateStack(indent, type, prev) { // represents a state stack object this.indent = indent; @@ -170,7 +170,7 @@ CodeMirror.defineMode("scheme", function () { } else if (stream.match(/^[-+0-9.]/, false)) { hasRadix = false; numTest = isDecimalNumber; - // re-consume the intial # if all matches failed + // re-consume the initial # if all matches failed } else if (!hasExactness) { stream.eat('#'); } diff --git a/libraries/codemirror/mode/shell/shell.js b/libraries/codemirror/mode/shell/shell.js index 5af12413b..8271485f5 100644 --- a/libraries/codemirror/mode/shell/shell.js +++ b/libraries/codemirror/mode/shell/shell.js @@ -70,6 +70,14 @@ CodeMirror.defineMode('shell', function() { stream.eatWhile(/\w/); return 'attribute'; } + if (ch == "<") { + if (stream.match("<<")) return "operator" + var heredoc = stream.match(/^<-?\s*['"]?([^'"]*)['"]?/) + if (heredoc) { + state.tokens.unshift(tokenHeredoc(heredoc[1])) + return 'string-2' + } + } if (/\d/.test(ch)) { stream.eatWhile(/\d/); if(stream.eol() || !/\w/.test(stream.peek())) { @@ -129,6 +137,14 @@ CodeMirror.defineMode('shell', function() { return 'def'; }; + function tokenHeredoc(delim) { + return function(stream, state) { + if (stream.sol() && stream.string == delim) state.tokens.shift() + stream.skipToEnd() + return "string-2" + } + } + function tokenize(stream, state) { return (state.tokens[0] || tokenBase) (stream, state); }; diff --git a/libraries/codemirror/mode/sieve/sieve.js b/libraries/codemirror/mode/sieve/sieve.js index f02a867e7..b7236401a 100644 --- a/libraries/codemirror/mode/sieve/sieve.js +++ b/libraries/codemirror/mode/sieve/sieve.js @@ -43,7 +43,7 @@ CodeMirror.defineMode("sieve", function(config) { if (ch == "(") { state._indent.push("("); // add virtual angel wings so that editor behaves... - // ...more sane incase of broken brackets + // ...more sane in case of broken brackets state._indent.push("{"); return null; } diff --git a/libraries/codemirror/mode/soy/soy.js b/libraries/codemirror/mode/soy/soy.js index d31c947ee..1f8a13c47 100644 --- a/libraries/codemirror/mode/soy/soy.js +++ b/libraries/codemirror/mode/soy/soy.js @@ -16,6 +16,8 @@ "alias": { noEndTag: true }, "delpackage": { noEndTag: true }, "namespace": { noEndTag: true, soyState: "namespace-def" }, + "@attribute": paramData, + "@attribute?": paramData, "@param": paramData, "@param?": paramData, "@inject": paramData, @@ -53,7 +55,7 @@ CodeMirror.defineMode("soy", function(config) { var textMode = CodeMirror.getMode(config, "text/plain"); var modes = { - html: CodeMirror.getMode(config, {name: "text/html", multilineTagIndentFactor: 2, multilineTagIndentPastTag: false}), + html: CodeMirror.getMode(config, {name: "text/html", multilineTagIndentFactor: 2, multilineTagIndentPastTag: false, allowMissingTagName: true}), attributes: textMode, text: textMode, uri: textMode, @@ -274,6 +276,11 @@ return null; case "param-def": + if (match = stream.match(/^\*/)) { + state.soyState.pop(); + state.soyState.push("param-type"); + return "type"; + } if (match = stream.match(/^\w+/)) { state.variables = prepend(state.variables, match[0]); state.soyState.pop(); @@ -404,7 +411,7 @@ return null; case "list-literal": - if (stream.match(/\]/)) { + if (stream.match(']')) { state.soyState.pop(); state.lookupVariables = true; popcontext(state); @@ -456,8 +463,15 @@ return null; case "tag": - var endTag = state.tag[0] == "/"; - var tagName = endTag ? state.tag.substring(1) : state.tag; + var endTag; + var tagName; + if (state.tag === undefined) { + endTag = true; + tagName = ''; + } else { + endTag = state.tag[0] == "/"; + tagName = endTag ? state.tag.substring(1) : state.tag; + } var tag = tags[tagName]; if (stream.match(/^\/?}/)) { var selfClosed = stream.current() == "/}"; @@ -491,15 +505,26 @@ } return expression(stream, state); + case "template-call-expression": + if (stream.match(/^([\w-?]+)(?==)/)) { + return "attribute"; + } else if (stream.eat('>')) { + state.soyState.pop(); + return "keyword"; + } else if (stream.eat('/>')) { + state.soyState.pop(); + return "keyword"; + } + return expression(stream, state); case "literal": - if (stream.match(/^(?=\{\/literal})/)) { + if (stream.match('{/literal}', false)) { state.soyState.pop(); return this.token(stream, state); } return tokenUntil(stream, state, /\{\/literal}/); } - if (stream.match(/^\{literal}/)) { + if (stream.match('{literal}')) { state.indent += config.indentUnit; state.soyState.push("literal"); state.context = new Context(state.context, "literal", state.variables); @@ -556,6 +581,14 @@ state.soyState.push("import"); state.indent += 2 * config.indentUnit; return "keyword"; + } else if (match = stream.match('<{')) { + state.soyState.push("template-call-expression"); + state.indent += 2 * config.indentUnit; + state.soyState.push("tag"); + return "keyword"; + } else if (match = stream.match('')) { + state.indent -= 1 * config.indentUnit; + return "keyword"; } return tokenUntil(stream, state, /\{|\s+\/\/|\/\*/); diff --git a/libraries/codemirror/mode/sparql/sparql.js b/libraries/codemirror/mode/sparql/sparql.js index bb79abff7..73997c667 100644 --- a/libraries/codemirror/mode/sparql/sparql.js +++ b/libraries/codemirror/mode/sparql/sparql.js @@ -60,12 +60,18 @@ CodeMirror.defineMode("sparql", function(config) { stream.skipToEnd(); return "comment"; } + else if (ch === "^") { + ch = stream.peek(); + if (ch === "^") stream.eat("^"); + else stream.eatWhile(operatorChars); + return "operator"; + } else if (operatorChars.test(ch)) { stream.eatWhile(operatorChars); return "operator"; } else if (ch == ":") { - stream.eatWhile(/[\w\d\._\-]/); + eatPnLocal(stream); return "atom"; } else if (ch == "@") { @@ -75,7 +81,7 @@ CodeMirror.defineMode("sparql", function(config) { else { stream.eatWhile(/[_\w\d]/); if (stream.eat(":")) { - stream.eatWhile(/[\w\d_\-]/); + eatPnLocal(stream); return "atom"; } var word = stream.current(); @@ -88,6 +94,10 @@ CodeMirror.defineMode("sparql", function(config) { } } + function eatPnLocal(stream) { + while (stream.match(/([:\w\d._-]|\\[-\\_~.!$&'()*+,;=/?#@%]|%[a-fA-F0-9][a-fA-F0-9])/)); + } + function tokenLiteral(quote) { return function(stream, state) { var escaped = false, ch; diff --git a/libraries/codemirror/mode/sql/sql.js b/libraries/codemirror/mode/sql/sql.js index 4127cd9a0..ead4d6db2 100644 --- a/libraries/codemirror/mode/sql/sql.js +++ b/libraries/codemirror/mode/sql/sql.js @@ -243,9 +243,9 @@ CodeMirror.defineMode("sql", function(config, parserConfig) { // varName can be quoted with ` or ' or " // ref: http://dev.mysql.com/doc/refman/5.5/en/user-variables.html if (stream.eat("@")) { - stream.match(/^session\./); - stream.match(/^local\./); - stream.match(/^global\./); + stream.match('session.'); + stream.match('local.'); + stream.match('global.'); } if (stream.eat("'")) { @@ -370,7 +370,7 @@ CodeMirror.defineMode("sql", function(config, parserConfig) { "$": hookVar, // The preferred way to escape Identifiers is using double quotes, ref: http://sqlite.org/lang_keywords.html "\"": hookIdentifierDoublequote, - // there is also support for backtics, ref: http://sqlite.org/lang_keywords.html + // there is also support for backticks, ref: http://sqlite.org/lang_keywords.html "`": hookIdentifier } }); @@ -451,7 +451,7 @@ CodeMirror.defineMode("sql", function(config, parserConfig) { // Spark SQL CodeMirror.defineMIME("text/x-sparksql", { name: "sql", - keywords: set("add after all alter analyze and anti archive array as asc at between bucket buckets by cache cascade case cast change clear cluster clustered codegen collection column columns comment commit compact compactions compute concatenate cost create cross cube current current_date current_timestamp database databases datata dbproperties defined delete delimited deny desc describe dfs directories distinct distribute drop else end escaped except exchange exists explain export extended external false fields fileformat first following for format formatted from full function functions global grant group grouping having if ignore import in index indexes inner inpath inputformat insert intersect interval into is items join keys last lateral lazy left like limit lines list load local location lock locks logical macro map minus msck natural no not null nulls of on optimize option options or order out outer outputformat over overwrite partition partitioned partitions percent preceding principals purge range recordreader recordwriter recover reduce refresh regexp rename repair replace reset restrict revoke right rlike role roles rollback rollup row rows schema schemas select semi separated serde serdeproperties set sets show skewed sort sorted start statistics stored stratify struct table tables tablesample tblproperties temp temporary terminated then to touch transaction transactions transform true truncate unarchive unbounded uncache union unlock unset use using values view when where window with"), + keywords: set("add after all alter analyze and anti archive array as asc at between bucket buckets by cache cascade case cast change clear cluster clustered codegen collection column columns comment commit compact compactions compute concatenate cost create cross cube current current_date current_timestamp database databases data dbproperties defined delete delimited deny desc describe dfs directories distinct distribute drop else end escaped except exchange exists explain export extended external false fields fileformat first following for format formatted from full function functions global grant group grouping having if ignore import in index indexes inner inpath inputformat insert intersect interval into is items join keys last lateral lazy left like limit lines list load local location lock locks logical macro map minus msck natural no not null nulls of on optimize option options or order out outer outputformat over overwrite partition partitioned partitions percent preceding principals purge range recordreader recordwriter recover reduce refresh regexp rename repair replace reset restrict revoke right rlike role roles rollback rollup row rows schema schemas select semi separated serde serdeproperties set sets show skewed sort sorted start statistics stored stratify struct table tables tablesample tblproperties temp temporary terminated then to touch transaction transactions transform true truncate unarchive unbounded uncache union unlock unset use using values view when where window with"), builtin: set("tinyint smallint int bigint boolean float double string binary timestamp decimal array map struct uniontype delimited serde sequencefile textfile rcfile inputformat outputformat"), atoms: set("false true null"), operatorChars: /^[*\/+\-%<>!=~&|^]/, diff --git a/libraries/codemirror/mode/stylus/stylus.js b/libraries/codemirror/mode/stylus/stylus.js index 653958e83..5cddff032 100644 --- a/libraries/codemirror/mode/stylus/stylus.js +++ b/libraries/codemirror/mode/stylus/stylus.js @@ -138,7 +138,7 @@ // Variable if (stream.match(/^(\.|\[)[\w-\'\"\]]+/i, false)) { if (!wordIsTag(stream.current())) { - stream.match(/\./); + stream.match('.'); return ["variable-2", "variable-name"]; } } @@ -722,6 +722,9 @@ return indent; }, electricChars: "}", + blockCommentStart: "/*", + blockCommentEnd: "*/", + blockCommentContinue: " * ", lineComment: "//", fold: "indent" }; @@ -731,7 +734,8 @@ var tagKeywords_ = ["a","abbr","address","area","article","aside","audio", "b", "base","bdi", "bdo","bgsound","blockquote","body","br","button","canvas","caption","cite", "code","col","colgroup","data","datalist","dd","del","details","dfn","div", "dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1", "h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe", "img","input","ins","kbd","keygen","label","legend","li","link","main","map", "mark","marquee","menu","menuitem","meta","meter","nav","nobr","noframes", "noscript","object","ol","optgroup","option","output","p","param","pre", "progress","q","rp","rt","ruby","s","samp","script","section","select", "small","source","span","strong","style","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","track", "u","ul","var","video"]; // github.com/codemirror/CodeMirror/blob/master/mode/css/css.js - var documentTypes_ = ["domain", "regexp", "url", "url-prefix"]; + // Note, "url-prefix" should precede "url" in order to match correctly in documentTypesRegexp + var documentTypes_ = ["domain", "regexp", "url-prefix", "url"]; var mediaTypes_ = ["all","aural","braille","handheld","print","projection","screen","tty","tv","embossed"]; var mediaFeatures_ = ["width","min-width","max-width","height","min-height","max-height","device-width","min-device-width","max-device-width","device-height","min-device-height","max-device-height","aspect-ratio","min-aspect-ratio","max-aspect-ratio","device-aspect-ratio","min-device-aspect-ratio","max-device-aspect-ratio","color","min-color","max-color","color-index","min-color-index","max-color-index","monochrome","min-monochrome","max-monochrome","resolution","min-resolution","max-resolution","scan","grid"]; var propertyKeywords_ = ["align-content","align-items","align-self","alignment-adjust","alignment-baseline","anchor-point","animation","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-timing-function","appearance","azimuth","backface-visibility","background","background-attachment","background-clip","background-color","background-image","background-origin","background-position","background-repeat","background-size","baseline-shift","binding","bleed","bookmark-label","bookmark-level","bookmark-state","bookmark-target","border","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-decoration-break","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","clear","clip","color","color-profile","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","content","counter-increment","counter-reset","crop","cue","cue-after","cue-before","cursor","direction","display","dominant-baseline","drop-initial-after-adjust","drop-initial-after-align","drop-initial-before-adjust","drop-initial-before-align","drop-initial-size","drop-initial-value","elevation","empty-cells","fit","fit-position","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","float-offset","flow-from","flow-into","font","font-feature-settings","font-family","font-kerning","font-language-override","font-size","font-size-adjust","font-stretch","font-style","font-synthesis","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-ligatures","font-variant-numeric","font-variant-position","font-weight","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-position","grid-auto-rows","grid-column","grid-column-end","grid-column-start","grid-row","grid-row-end","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphens","icon","image-orientation","image-rendering","image-resolution","inline-box-align","justify-content","left","letter-spacing","line-break","line-height","line-stacking","line-stacking-ruby","line-stacking-shift","line-stacking-strategy","list-style","list-style-image","list-style-position","list-style-type","margin","margin-bottom","margin-left","margin-right","margin-top","marker-offset","marks","marquee-direction","marquee-loop","marquee-play-count","marquee-speed","marquee-style","max-height","max-width","min-height","min-width","move-to","nav-down","nav-index","nav-left","nav-right","nav-up","object-fit","object-position","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-style","overflow-wrap","overflow-x","overflow-y","padding","padding-bottom","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","page-policy","pause","pause-after","pause-before","perspective","perspective-origin","pitch","pitch-range","play-during","position","presentation-level","punctuation-trim","quotes","region-break-after","region-break-before","region-break-inside","region-fragment","rendering-intent","resize","rest","rest-after","rest-before","richness","right","rotation","rotation-point","ruby-align","ruby-overhang","ruby-position","ruby-span","shape-image-threshold","shape-inside","shape-margin","shape-outside","size","speak","speak-as","speak-header","speak-numeral","speak-punctuation","speech-rate","stress","string-set","tab-size","table-layout","target","target-name","target-new","target-position","text-align","text-align-last","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-style","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-height","text-indent","text-justify","text-outline","text-overflow","text-shadow","text-size-adjust","text-space-collapse","text-transform","text-underline-position","text-wrap","top","transform","transform-origin","transform-style","transition","transition-delay","transition-duration","transition-property","transition-timing-function","unicode-bidi","vertical-align","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","volume","white-space","widows","width","will-change","word-break","word-spacing","word-wrap","z-index","clip-path","clip-rule","mask","enable-background","filter","flood-color","flood-opacity","lighting-color","stop-color","stop-opacity","pointer-events","color-interpolation","color-interpolation-filters","color-rendering","fill","fill-opacity","fill-rule","image-rendering","marker","marker-end","marker-mid","marker-start","shape-rendering","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","text-rendering","baseline-shift","dominant-baseline","glyph-orientation-horizontal","glyph-orientation-vertical","text-anchor","writing-mode","font-smoothing","osx-font-smoothing"]; diff --git a/libraries/codemirror/mode/tiddlywiki/tiddlywiki.js b/libraries/codemirror/mode/tiddlywiki/tiddlywiki.js index a4fb89f65..6a9ce447b 100644 --- a/libraries/codemirror/mode/tiddlywiki/tiddlywiki.js +++ b/libraries/codemirror/mode/tiddlywiki/tiddlywiki.js @@ -114,7 +114,7 @@ CodeMirror.defineMode("tiddlywiki", function () { return 'header'; } - if (ch == '{' && stream.match(/\{\{/)) + if (ch == '{' && stream.match('{{')) return chain(stream, state, twTokenCode); // rudimentary html:// file:// link matching. TW knows much more ... diff --git a/libraries/codemirror/mode/vbscript/vbscript.js b/libraries/codemirror/mode/vbscript/vbscript.js index 0670c0cee..403394813 100644 --- a/libraries/codemirror/mode/vbscript/vbscript.js +++ b/libraries/codemirror/mode/vbscript/vbscript.js @@ -32,7 +32,7 @@ CodeMirror.defineMode("vbscript", function(conf, parserConf) { var singleOperators = new RegExp("^[\\+\\-\\*/&\\\\\\^<>=]"); var doubleOperators = new RegExp("^((<>)|(<=)|(>=))"); var singleDelimiters = new RegExp('^[\\.,]'); - var brakets = new RegExp('^[\\(\\)]'); + var brackets = new RegExp('^[\\(\\)]'); var identifiers = new RegExp("^[A-Za-z][_A-Za-z0-9]*"); var openingKeywords = ['class','sub','select','while','if','function', 'property', 'with', 'for']; @@ -183,7 +183,7 @@ CodeMirror.defineMode("vbscript", function(conf, parserConf) { return null; } - if (stream.match(brakets)) { + if (stream.match(brackets)) { return "bracket"; } diff --git a/libraries/codemirror/mode/velocity/velocity.js b/libraries/codemirror/mode/velocity/velocity.js index 56caa671b..1d17c84eb 100644 --- a/libraries/codemirror/mode/velocity/velocity.js +++ b/libraries/codemirror/mode/velocity/velocity.js @@ -48,7 +48,7 @@ CodeMirror.defineMode("velocity", function() { else if (state.inParams) return chain(stream, state, tokenString(ch)); } - // is it one of the special signs []{}().,;? Seperator? + // is it one of the special signs []{}().,;? Separator? else if (/[\[\]{}\(\),;\.]/.test(ch)) { if (ch == "(" && beforeParams) state.inParams = true; diff --git a/libraries/codemirror/mode/verilog/verilog.js b/libraries/codemirror/mode/verilog/verilog.js index 43990452d..6c799f298 100644 --- a/libraries/codemirror/mode/verilog/verilog.js +++ b/libraries/codemirror/mode/verilog/verilog.js @@ -16,6 +16,12 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) { var indentUnit = config.indentUnit, statementIndentUnit = parserConfig.statementIndentUnit || indentUnit, dontAlignCalls = parserConfig.dontAlignCalls, + // compilerDirectivesUseRegularIndentation - If set, Compiler directive + // indentation follows the same rules as everything else. Otherwise if + // false, compiler directives will track their own indentation. + // For example, `ifdef nested inside another `ifndef will be indented, + // but a `ifdef inside a function block may not be indented. + compilerDirectivesUseRegularIndentation = parserConfig.compilerDirectivesUseRegularIndentation, noIndentKeywords = parserConfig.noIndentKeywords || [], multiLineStrings = parserConfig.multiLineStrings, hooks = parserConfig.hooks || {}; @@ -62,7 +68,7 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) { binary_module_path_operator ::= == | != | && | || | & | | | ^ | ^~ | ~^ */ - var isOperatorChar = /[\+\-\*\/!~&|^%=?:]/; + var isOperatorChar = /[\+\-\*\/!~&|^%=?:<>]/; var isBracketChar = /[\[\]{}()]/; var unsignedNumber = /\d[0-9_]*/; @@ -72,8 +78,13 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) { var hexLiteral = /\d*\s*'s?h\s*[0-9a-fxz?][0-9a-fxz?_]*/i; var realLiteral = /(\d[\d_]*(\.\d[\d_]*)?E-?[\d_]+)|(\d[\d_]*\.\d[\d_]*)/i; - var closingBracketOrWord = /^((\w+)|[)}\]])/; + var closingBracketOrWord = /^((`?\w+)|[)}\]])/; var closingBracket = /[)}\]]/; + var compilerDirectiveRegex = new RegExp( + "^(`(?:ifdef|ifndef|elsif|else|endif|undef|undefineall|define|include|begin_keywords|celldefine|default|" + + "nettype|end_keywords|endcelldefine|line|nounconnected_drive|pragma|resetall|timescale|unconnected_drive))\\b"); + var compilerDirectiveBeginRegex = /^(`(?:ifdef|ifndef|elsif|else))\b/; + var compilerDirectiveEndRegex = /^(`(?:elsif|else|endif))\b/; var curPunc; var curKeyword; @@ -96,6 +107,7 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) { openClose["do" ] = "while"; openClose["fork" ] = "join;join_any;join_none"; openClose["covergroup"] = "endgroup"; + openClose["macro_begin"] = "macro_end"; for (var i in noIndentKeywords) { var keyword = noIndentKeywords[i]; @@ -105,7 +117,7 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) { } // Keywords which open statements that are ended with a semi-colon - var statementKeywords = words("always always_comb always_ff always_latch assert assign assume else export for foreach forever if import initial repeat while"); + var statementKeywords = words("always always_comb always_ff always_latch assert assign assume else export for foreach forever if import initial repeat while extern typedef"); function tokenBase(stream, state) { var ch = stream.peek(), style; @@ -125,6 +137,23 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) { if (ch == '`') { stream.next(); if (stream.eatWhile(/[\w\$_]/)) { + var cur = stream.current(); + curKeyword = cur; + // Macros that end in _begin, are start of block and end with _end + if (cur.startsWith("`uvm_") && cur.endsWith("_begin")) { + var keywordClose = curKeyword.substr(0,curKeyword.length - 5) + "end"; + openClose[cur] = keywordClose; + curPunc = "newblock"; + } else { + stream.eatSpace(); + if (stream.peek() == '(') { + // Check if this is a block + curPunc = "newmacro"; + } + var withSpace = stream.current(); + // Move the stream back before the spaces + stream.backUp(withSpace.length - cur.length); + } return "def"; } else { return null; @@ -145,6 +174,12 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) { stream.eatWhile(/[\d_.]/); return "def"; } + // Event + if (ch == '@') { + stream.next(); + stream.eatWhile(/[@]/); + return "def"; + } // Strings if (ch == '"') { stream.next(); @@ -178,6 +213,7 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) { // Operators if (stream.eatWhile(isOperatorChar)) { + curPunc = stream.current(); return "meta"; } @@ -187,6 +223,15 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) { if (keywords[cur]) { if (openClose[cur]) { curPunc = "newblock"; + if (cur === "fork") { + // Fork can be a statement instead of block in cases of: + // "disable fork;" and "wait fork;" (trailing semicolon) + stream.eatSpace() + if (stream.peek() == ';') { + curPunc = "newstatement"; + } + stream.backUp(stream.current().length - cur.length); + } } if (statementKeywords[cur]) { curPunc = "newstatement"; @@ -226,16 +271,17 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) { return "comment"; } - function Context(indented, column, type, align, prev) { + function Context(indented, column, type, scopekind, align, prev) { this.indented = indented; this.column = column; this.type = type; + this.scopekind = scopekind; this.align = align; this.prev = prev; } - function pushContext(state, col, type) { + function pushContext(state, col, type, scopekind) { var indent = state.indented; - var c = new Context(indent, col, type, null, state.context); + var c = new Context(indent, col, type, scopekind ? scopekind : "", null, state.context); return state.context = c; } function popContext(state) { @@ -261,6 +307,16 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) { } } + function isInsideScopeKind(ctx, scopekind) { + if (ctx == null) { + return false; + } + if (ctx.scopekind === scopekind) { + return true; + } + return isInsideScopeKind(ctx.prev, scopekind); + } + function buildElectricInputRegEx() { // Reindentation should occur on any bracket char: {}()[] // or on a match of any of the block closing keywords, at @@ -287,8 +343,9 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) { startState: function(basecolumn) { var state = { tokenize: null, - context: new Context((basecolumn || 0) - indentUnit, 0, "top", false), + context: new Context((basecolumn || 0) - indentUnit, 0, "top", "top", false), indented: 0, + compilerDirectiveIndented: 0, startOfLine: true }; if (hooks.startState) hooks.startState(state); @@ -313,15 +370,42 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) { curPunc = null; curKeyword = null; var style = (state.tokenize || tokenBase)(stream, state); - if (style == "comment" || style == "meta" || style == "variable") return style; + if (style == "comment" || style == "meta" || style == "variable") { + if (((curPunc === "=") || (curPunc === "<=")) && !isInsideScopeKind(ctx, "assignment")) { + // '<=' could be nonblocking assignment or lessthan-equals (which shouldn't cause indent) + // Search through the context to see if we are already in an assignment. + // '=' could be inside port declaration with comma or ')' afterward, or inside for(;;) block. + pushContext(state, stream.column() + curPunc.length, "assignment", "assignment"); + if (ctx.align == null) ctx.align = true; + } + return style; + } if (ctx.align == null) ctx.align = true; - if (curPunc == ctx.type) { - popContext(state); - } else if ((curPunc == ";" && ctx.type == "statement") || + var isClosingAssignment = ctx.type == "assignment" && + closingBracket.test(curPunc) && ctx.prev && ctx.prev.type === curPunc; + if (curPunc == ctx.type || isClosingAssignment) { + if (isClosingAssignment) { + ctx = popContext(state); + } + ctx = popContext(state); + if (curPunc == ")") { + // Handle closing macros, assuming they could have a semicolon or begin/end block inside. + if (ctx && (ctx.type === "macro")) { + ctx = popContext(state); + while (ctx && (ctx.type == "statement" || ctx.type == "assignment")) ctx = popContext(state); + } + } else if (curPunc == "}") { + // Handle closing statements like constraint block: "foreach () {}" which + // do not have semicolon at end. + if (ctx && (ctx.type === "statement")) { + while (ctx && (ctx.type == "statement")) ctx = popContext(state); + } + } + } else if (((curPunc == ";" || curPunc == ",") && (ctx.type == "statement" || ctx.type == "assignment")) || (ctx.type && isClosing(curKeyword, ctx.type))) { ctx = popContext(state); - while (ctx && ctx.type == "statement") ctx = popContext(state); + while (ctx && (ctx.type == "statement" || ctx.type == "assignment")) ctx = popContext(state); } else if (curPunc == "{") { pushContext(state, stream.column(), "}"); } else if (curPunc == "[") { @@ -329,9 +413,9 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) { } else if (curPunc == "(") { pushContext(state, stream.column(), ")"); } else if (ctx && ctx.type == "endcase" && curPunc == ":") { - pushContext(state, stream.column(), "statement"); + pushContext(state, stream.column(), "statement", "case"); } else if (curPunc == "newstatement") { - pushContext(state, stream.column(), "statement"); + pushContext(state, stream.column(), "statement", curKeyword); } else if (curPunc == "newblock") { if (curKeyword == "function" && ctx && (ctx.type == "statement" || ctx.type == "endgroup")) { // The 'function' keyword can appear in some other contexts where it actually does not @@ -339,9 +423,23 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) { // Do nothing in this case } else if (curKeyword == "task" && ctx && ctx.type == "statement") { // Same thing for task + } else if (curKeyword == "class" && ctx && ctx.type == "statement") { + // Same thing for class (e.g. typedef) } else { var close = openClose[curKeyword]; - pushContext(state, stream.column(), close); + pushContext(state, stream.column(), close, curKeyword); + } + } else if (curPunc == "newmacro" || (curKeyword && curKeyword.match(compilerDirectiveRegex))) { + if (curPunc == "newmacro") { + // Macros (especially if they have parenthesis) potentially have a semicolon + // or complete statement/block inside, and should be treated as such. + pushContext(state, stream.column(), "macro", "macro"); + } + if (curKeyword.match(compilerDirectiveEndRegex)) { + state.compilerDirectiveIndented -= statementIndentUnit; + } + if (curKeyword.match(compilerDirectiveBeginRegex)) { + state.compilerDirectiveIndented += statementIndentUnit; } } @@ -361,8 +459,15 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) { var possibleClosing = textAfter.match(closingBracketOrWord); if (possibleClosing) closing = isClosing(possibleClosing[0], ctx.type); + if (!compilerDirectivesUseRegularIndentation && textAfter.match(compilerDirectiveRegex)) { + if (textAfter.match(compilerDirectiveEndRegex)) { + return state.compilerDirectiveIndented - statementIndentUnit; + } + return state.compilerDirectiveIndented; + } if (ctx.type == "statement") return ctx.indented + (firstChar == "{" ? 0 : statementIndentUnit); - else if (closingBracket.test(ctx.type) && ctx.align && !dontAlignCalls) return ctx.column + (closing ? 0 : 1); + else if ((closingBracket.test(ctx.type) || ctx.type == "assignment") + && ctx.align && !dontAlignCalls) return ctx.column + (closing ? 0 : 1); else if (ctx.type == ")" && !closing) return ctx.indented + statementIndentUnit; else return ctx.indented + (closing ? 0 : indentUnit); }, @@ -437,7 +542,7 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) { }; var tlvIndentUnit = 3; var tlvTrackStatements = false; - var tlvIdentMatch = /^([~!@#\$%\^&\*-\+=\?\/\\\|'"<>]+)([\d\w_]*)/; // Matches an identifiere. + var tlvIdentMatch = /^([~!@#\$%\^&\*-\+=\?\/\\\|'"<>]+)([\d\w_]*)/; // Matches an identifier. // Note that ':' is excluded, because of it's use in [:]. var tlvFirstLevelIndentMatch = /^[! ] /; var tlvLineIndentationMatch = /^[! ] */; @@ -614,7 +719,7 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) { } else { // Just swallow one character and try again. // This enables subsequent identifier match with preceding symbol character, which - // is legal within a statement. (Eg, !$reset). It also enables detection of + // is legal within a statement. (E.g., !$reset). It also enables detection of // comment start with preceding symbols. stream.backUp(stream.current().length - 1); style = "tlv-default"; diff --git a/libraries/codemirror/mode/wast/wast.js b/libraries/codemirror/mode/wast/wast.js index 9348ad3e0..9bddc8878 100644 --- a/libraries/codemirror/mode/wast/wast.js +++ b/libraries/codemirror/mode/wast/wast.js @@ -11,11 +11,96 @@ })(function(CodeMirror) { "use strict"; +var kKeywords = [ + "align", + "block", + "br(_if|_table|_on_(cast|data|func|i31|null))?", + "call(_indirect|_ref)?", + "current_memory", + "\\bdata\\b", + "drop", + "elem", + "else", + "end", + "export", + "\\bextern\\b", + "\\bfunc\\b", + "global(\\.(get|set))?", + "if", + "import", + "local(\\.(get|set|tee))?", + "loop", + "module", + "mut", + "nop", + "offset", + "param", + "result", + "return(_call(_indirect|_ref)?)?", + "select", + "start", + "table(\\.(size|get|set|size|grow|fill|init|copy))?", + "then", + "type", + "unreachable", + + // Numeric opcodes. + "i(32|64)\\.(store(8|16)|(load(8|16)_[su]))", + "i64\\.(load32_[su]|store32)", + "[fi](32|64)\\.(const|load|store)", + "f(32|64)\\.(abs|add|ceil|copysign|div|eq|floor|[gl][et]|max|min|mul|nearest|neg?|sqrt|sub|trunc)", + "i(32|64)\\.(a[dn]d|c[lt]z|(div|rem)_[su]|eqz?|[gl][te]_[su]|mul|ne|popcnt|rot[lr]|sh(l|r_[su])|sub|x?or)", + "i64\\.extend_[su]_i32", + "i32\\.wrap_i64", + "i(32|64)\\.trunc_f(32|64)_[su]", + "f(32|64)\\.convert_i(32|64)_[su]", + "f64\\.promote_f32", + "f32\\.demote_f64", + "f32\\.reinterpret_i32", + "i32\\.reinterpret_f32", + "f64\\.reinterpret_i64", + "i64\\.reinterpret_f64", + // Atomics. + "memory(\\.((atomic\\.(notify|wait(32|64)))|grow|size))?", + "i64\.atomic\\.(load32_u|store32|rmw32\\.(a[dn]d|sub|x?or|(cmp)?xchg)_u)", + "i(32|64)\\.atomic\\.(load((8|16)_u)?|store(8|16)?|rmw(\\.(a[dn]d|sub|x?or|(cmp)?xchg)|(8|16)\\.(a[dn]d|sub|x?or|(cmp)?xchg)_u))", + // SIMD. + "v128\\.load(8x8|16x4|32x2)_[su]", + "v128\\.load(8|16|32|64)_splat", + "v128\\.(load|store)(8|16|32|64)_lane", + "v128\\.load(32|64)_zero", + "v128\.(load|store|const|not|andnot|and|or|xor|bitselect|any_true)", + "i(8x16|16x8)\\.(extract_lane_[su]|(add|sub)_sat_[su]|avgr_u)", + "i(8x16|16x8|32x4|64x2)\\.(neg|add|sub|abs|shl|shr_[su]|all_true|bitmask|eq|ne|[lg][te]_s)", + "(i(8x16|16x8|32x4|64x2)|f(32x4|64x2))\.(splat|replace_lane)", + "i(8x16|16x8|32x4)\\.(([lg][te]_u)|((min|max)_[su]))", + "f(32x4|64x2)\\.(neg|add|sub|abs|nearest|eq|ne|[lg][te]|sqrt|mul|div|min|max|ceil|floor|trunc)", + "[fi](32x4|64x2)\\.extract_lane", + "i8x16\\.(shuffle|swizzle|popcnt|narrow_i16x8_[su])", + "i16x8\\.(narrow_i32x4_[su]|mul|extadd_pairwise_i8x16_[su]|q15mulr_sat_s)", + "i16x8\\.(extend|extmul)_(low|high)_i8x16_[su]", + "i32x4\\.(mul|dot_i16x8_s|trunc_sat_f64x2_[su]_zero)", + "i32x4\\.((extend|extmul)_(low|high)_i16x8_|trunc_sat_f32x4_|extadd_pairwise_i16x8_)[su]", + "i64x2\\.(mul|(extend|extmul)_(low|high)_i32x4_[su])", + "f32x4\\.(convert_i32x4_[su]|demote_f64x2_zero)", + "f64x2\\.(promote_low_f32x4|convert_low_i32x4_[su])", + // Reference types, function references, and GC. + "\\bany\\b", + "array\\.len", + "(array|struct)(\\.(new_(default_)?with_rtt|get(_[su])?|set))?", + "\\beq\\b", + "field", + "i31\\.(new|get_[su])", + "\\bnull\\b", + "ref(\\.(([ai]s_(data|func|i31))|cast|eq|func|(is_|as_non_)?null|test))?", + "rtt(\\.(canon|sub))?", +]; + CodeMirror.defineSimpleMode('wast', { start: [ {regex: /[+\-]?(?:nan(?::0x[0-9a-fA-F]+)?|infinity|inf|0x[0-9a-fA-F]+\.?[0-9a-fA-F]*p[+\/-]?\d+|\d+(?:\.\d*)?[eE][+\-]?\d*|\d+\.\d*|0x[0-9a-fA-F]+|\d+)/, token: "number"}, - {regex: /mut|nop|block|if|then|else|loop|br_if|br_table|br|call(_indirect)?|drop|end|return(_call(_indirect)?)?|local\.(get|set|tee)|global\.(get|set)|i(32|64)\.(store(8|16)|(load(8|16)_[su]))|i64\.(load32_[su]|store32)|[fi](32|64)\.(const|load|store)|f(32|64)\.(abs|add|ceil|copysign|div|eq|floor|[gl][et]|max|min|mul|nearest|neg?|sqrt|sub|trunc)|i(32|64)\.(a[dn]d|c[lt]z|(div|rem)_[su]|eqz?|[gl][te]_[su]|mul|ne|popcnt|rot[lr]|sh(l|r_[su])|sub|x?or)|i64\.extend_[su]_i32|i32\.wrap_i64|i(32|64)\.trunc_f(32|64)_[su]|f(32|64)\.convert_i(32|64)_[su]|f64\.promote_f32|f32\.demote_f64|f32\.reinterpret_i32|i32\.reinterpret_f32|f64\.reinterpret_i64|i64\.reinterpret_f64|select|unreachable|current_memory|memory(\.((atomic\.(notify|wait(32|64)))|grow|size))?|type|func|param|result|local|global|module|table|start|elem|data|align|offset|import|export|i64\.atomic\.(load32_u|store32|rmw32\.(a[dn]d|sub|x?or|(cmp)?xchg)_u)|i(32|64)\.atomic\.(load((8|16)_u)?|store(8|16)?|rmw(\.(a[dn]d|sub|x?or|(cmp)?xchg)|(8|16)\.(a[dn]d|sub|x?or|(cmp)?xchg)_u))|v128\.(load|store|const|not|andnot|and|or|xor|bitselect)|i(8x16|16x8|32x4|64x2)\.(shl|shr_[su])|i(8x16|16x8)\.(extract_lane_[su]|((add|sub)_saturate_[su])|avgr_u)|(i(8x16|16x8|32x4|64x2)|f(32x4|64x2))\.(splat|replace_lane|neg|add|sub)|i(8x16|16x8|32x4)\.(eq|ne|([lg][te]_[su])|abs|any_true|all_true|bitmask|((min|max)_[su]))|f(32x4|64x2)\.(eq|ne|[lg][te]|abs|sqrt|mul|div|min|max)|[fi](32x4|64x2)\.extract_lane|v8x16\.(shuffle|swizzle)|i16x8\.(load8x8_[su]|narrow_i32x4_[su]|widen_(low|high)_i8x16_[su]|mul)|i32x4\.(load16x4_[su]|widen_(low|high)_i16x8_[su]|mul|trunc_sat_f32x4_[su])|i64x2\.(load32x2_[su]|mul)|(v(8x16|16x8|32x4|64x2)\.load_splat)|i8x16\.narrow_i16x8_[su]|f32x4\.convert_i32x4_[su]/, token: "keyword"}, - {regex: /\b(anyfunc|[fi](32|64))\b/, token: "atom"}, + {regex: new RegExp(kKeywords.join('|')), token: "keyword"}, + {regex: /\b((any|data|eq|extern|i31|func)ref|[fi](32|64)|i(8|16))\b/, token: "atom"}, {regex: /\$([a-zA-Z0-9_`\+\-\*\/\\\^~=<>!\?@#$%&|:\.]+)/, token: "variable-2"}, {regex: /"(?:[^"\\\x00-\x1f\x7f]|\\[nt\\'"]|\\[0-9a-fA-F][0-9a-fA-F])*"/, token: "string"}, {regex: /\(;.*?/, token: "comment", next: "comment"}, diff --git a/libraries/codemirror/mode/xml/xml.js b/libraries/codemirror/mode/xml/xml.js index 73c6e0e0d..46806ac42 100644 --- a/libraries/codemirror/mode/xml/xml.js +++ b/libraries/codemirror/mode/xml/xml.js @@ -189,7 +189,7 @@ CodeMirror.defineMode("xml", function(editorConf, config_) { function Context(state, tagName, startOfLine) { this.prev = state.context; - this.tagName = tagName; + this.tagName = tagName || ""; this.indent = state.indented; this.startOfLine = startOfLine; if (config.doNotIndent.hasOwnProperty(tagName) || (state.context && state.context.noIndent)) @@ -399,7 +399,7 @@ CodeMirror.defineMode("xml", function(editorConf, config_) { xmlCurrentContext: function(state) { var context = [] for (var cx = state.context; cx; cx = cx.prev) - if (cx.tagName) context.push(cx.tagName) + context.push(cx.tagName) return context.reverse() } }; diff --git a/libraries/codemirror/mode/yaml-frontmatter/yaml-frontmatter.js b/libraries/codemirror/mode/yaml-frontmatter/yaml-frontmatter.js index 87fdf80d0..f9050ad6a 100644 --- a/libraries/codemirror/mode/yaml-frontmatter/yaml-frontmatter.js +++ b/libraries/codemirror/mode/yaml-frontmatter/yaml-frontmatter.js @@ -36,7 +36,7 @@ }, token: function (stream, state) { if (state.state == START) { - if (stream.match(/---/, false)) { + if (stream.match('---', false)) { state.state = FRONTMATTER return yamlMode.token(stream, state.inner) } else { diff --git a/libraries/codemirror/mode/yaml/yaml.js b/libraries/codemirror/mode/yaml/yaml.js index a29d7ea4a..d46494102 100644 --- a/libraries/codemirror/mode/yaml/yaml.js +++ b/libraries/codemirror/mode/yaml/yaml.js @@ -38,9 +38,9 @@ CodeMirror.defineMode("yaml", function() { state.pair = false; state.pairStart = false; /* document start */ - if(stream.match(/---/)) { return "def"; } + if(stream.match('---')) { return "def"; } /* document end */ - if (stream.match(/\.\.\./)) { return "def"; } + if (stream.match('...')) { return "def"; } /* array list item */ if (stream.match(/\s*-\s+/)) { return 'meta'; } } @@ -57,12 +57,12 @@ CodeMirror.defineMode("yaml", function() { return 'meta'; } - /* list seperator */ + /* list separator */ if (state.inlineList > 0 && !esc && ch == ',') { stream.next(); return 'meta'; } - /* pairs seperator */ + /* pairs separator */ if (state.inlinePairs > 0 && !esc && ch == ',') { state.keyCol = 0; state.pair = false;