mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
ckeditor 5.60.0
This commit is contained in:
parent
c43b20ec2b
commit
f739dbfe87
30
libraries/codemirror/addon/edit/matchbrackets.js
vendored
30
libraries/codemirror/addon/edit/matchbrackets.js
vendored
@ -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)
|
||||
}
|
||||
});
|
||||
|
||||
|
24
libraries/codemirror/addon/lint/lint.css
vendored
24
libraries/codemirror/addon/lint/lint.css
vendored
@ -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;
|
||||
|
16
libraries/codemirror/addon/lint/lint.js
vendored
16
libraries/codemirror/addon/lint/lint.js
vendored
@ -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);
|
||||
|
3
libraries/codemirror/addon/mode/simple.js
vendored
3
libraries/codemirror/addon/mode/simple.js
vendored
@ -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) {
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
||||
|
2
libraries/codemirror/mode/asn.1/asn.1.js
vendored
2
libraries/codemirror/mode/asn.1/asn.1.js
vendored
@ -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"),
|
||||
|
18
libraries/codemirror/mode/clike/clike.js
vendored
18
libraries/codemirror/mode/clike/clike.js
vendored
@ -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 " +
|
||||
|
767
libraries/codemirror/mode/clike/scala.html
vendored
767
libraries/codemirror/mode/clike/scala.html
vendored
@ -1,767 +0,0 @@
|
||||
<!doctype html>
|
||||
|
||||
<title>CodeMirror: Scala mode</title>
|
||||
<meta charset="utf-8"/>
|
||||
<link rel=stylesheet href="../../doc/docs.css">
|
||||
|
||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
||||
<link rel="stylesheet" href="../../theme/ambiance.css">
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="../../addon/edit/matchbrackets.js"></script>
|
||||
<script src="clike.js"></script>
|
||||
<div id=nav>
|
||||
<a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png" alt=""></a>
|
||||
|
||||
<ul>
|
||||
<li><a href="../../index.html">Home</a>
|
||||
<li><a href="../../doc/manual.html">Manual</a>
|
||||
<li><a href="https://github.com/codemirror/codemirror">Code</a>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><a href="../index.html">Language modes</a>
|
||||
<li><a class=active href="#">Scala</a>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<article>
|
||||
<h2>Scala mode</h2>
|
||||
<form>
|
||||
<textarea id="code" name="code">
|
||||
|
||||
/* __ *\
|
||||
** ________ ___ / / ___ Scala API **
|
||||
** / __/ __// _ | / / / _ | (c) 2003-2011, LAMP/EPFL **
|
||||
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
|
||||
** /____/\___/_/ |_/____/_/ | | **
|
||||
** |/ **
|
||||
\* */
|
||||
|
||||
package scala.collection
|
||||
|
||||
import generic._
|
||||
import mutable.{ Builder, ListBuffer }
|
||||
import annotation.{tailrec, migration, bridge}
|
||||
import annotation.unchecked.{ uncheckedVariance => uV }
|
||||
import parallel.ParIterable
|
||||
|
||||
/** A template trait for traversable collections of type `Traversable[A]`.
|
||||
*
|
||||
* $traversableInfo
|
||||
* @define mutability
|
||||
* @define traversableInfo
|
||||
* This is a base trait of all kinds of $mutability Scala collections. It
|
||||
* implements the behavior common to all collections, in terms of a method
|
||||
* `foreach` with signature:
|
||||
* {{{
|
||||
* def foreach[U](f: Elem => U): Unit
|
||||
* }}}
|
||||
* Collection classes mixing in this trait provide a concrete
|
||||
* `foreach` method which traverses all the
|
||||
* elements contained in the collection, applying a given function to each.
|
||||
* They also need to provide a method `newBuilder`
|
||||
* which creates a builder for collections of the same kind.
|
||||
*
|
||||
* A traversable class might or might not have two properties: strictness
|
||||
* and orderedness. Neither is represented as a type.
|
||||
*
|
||||
* The instances of a strict collection class have all their elements
|
||||
* computed before they can be used as values. By contrast, instances of
|
||||
* a non-strict collection class may defer computation of some of their
|
||||
* elements until after the instance is available as a value.
|
||||
* A typical example of a non-strict collection class is a
|
||||
* <a href="../immutable/Stream.html" target="ContentFrame">
|
||||
* `scala.collection.immutable.Stream`</a>.
|
||||
* A more general class of examples are `TraversableViews`.
|
||||
*
|
||||
* If a collection is an instance of an ordered collection class, traversing
|
||||
* its elements with `foreach` will always visit elements in the
|
||||
* same order, even for different runs of the program. If the class is not
|
||||
* ordered, `foreach` can visit elements in different orders for
|
||||
* different runs (but it will keep the same order in the same run).'
|
||||
*
|
||||
* A typical example of a collection class which is not ordered is a
|
||||
* `HashMap` of objects. The traversal order for hash maps will
|
||||
* depend on the hash codes of its elements, and these hash codes might
|
||||
* differ from one run to the next. By contrast, a `LinkedHashMap`
|
||||
* is ordered because it's `foreach` method visits elements in the
|
||||
* order they were inserted into the `HashMap`.
|
||||
*
|
||||
* @author Martin Odersky
|
||||
* @version 2.8
|
||||
* @since 2.8
|
||||
* @tparam A the element type of the collection
|
||||
* @tparam Repr the type of the actual collection containing the elements.
|
||||
*
|
||||
* @define Coll Traversable
|
||||
* @define coll traversable collection
|
||||
*/
|
||||
trait TraversableLike[+A, +Repr] extends HasNewBuilder[A, Repr]
|
||||
with FilterMonadic[A, Repr]
|
||||
with TraversableOnce[A]
|
||||
with GenTraversableLike[A, Repr]
|
||||
with Parallelizable[A, ParIterable[A]]
|
||||
{
|
||||
self =>
|
||||
|
||||
import Traversable.breaks._
|
||||
|
||||
/** The type implementing this traversable */
|
||||
protected type Self = Repr
|
||||
|
||||
/** The collection of type $coll underlying this `TraversableLike` object.
|
||||
* By default this is implemented as the `TraversableLike` object itself,
|
||||
* but this can be overridden.
|
||||
*/
|
||||
def repr: Repr = this.asInstanceOf[Repr]
|
||||
|
||||
/** The underlying collection seen as an instance of `$Coll`.
|
||||
* By default this is implemented as the current collection object itself,
|
||||
* but this can be overridden.
|
||||
*/
|
||||
protected[this] def thisCollection: Traversable[A] = this.asInstanceOf[Traversable[A]]
|
||||
|
||||
/** A conversion from collections of type `Repr` to `$Coll` objects.
|
||||
* By default this is implemented as just a cast, but this can be overridden.
|
||||
*/
|
||||
protected[this] def toCollection(repr: Repr): Traversable[A] = repr.asInstanceOf[Traversable[A]]
|
||||
|
||||
/** Creates a new builder for this collection type.
|
||||
*/
|
||||
protected[this] def newBuilder: Builder[A, Repr]
|
||||
|
||||
protected[this] def parCombiner = ParIterable.newCombiner[A]
|
||||
|
||||
/** Applies a function `f` to all elements of this $coll.
|
||||
*
|
||||
* Note: this method underlies the implementation of most other bulk operations.
|
||||
* It's important to implement this method in an efficient way.
|
||||
*
|
||||
*
|
||||
* @param f the function that is applied for its side-effect to every element.
|
||||
* The result of function `f` is discarded.
|
||||
*
|
||||
* @tparam U the type parameter describing the result of function `f`.
|
||||
* This result will always be ignored. Typically `U` is `Unit`,
|
||||
* but this is not necessary.
|
||||
*
|
||||
* @usecase def foreach(f: A => Unit): Unit
|
||||
*/
|
||||
def foreach[U](f: A => U): Unit
|
||||
|
||||
/** Tests whether this $coll is empty.
|
||||
*
|
||||
* @return `true` if the $coll contain no elements, `false` otherwise.
|
||||
*/
|
||||
def isEmpty: Boolean = {
|
||||
var result = true
|
||||
breakable {
|
||||
for (x <- this) {
|
||||
result = false
|
||||
break
|
||||
}
|
||||
}
|
||||
result
|
||||
}
|
||||
|
||||
/** Tests whether this $coll is known to have a finite size.
|
||||
* All strict collections are known to have finite size. For a non-strict collection
|
||||
* such as `Stream`, the predicate returns `true` if all elements have been computed.
|
||||
* It returns `false` if the stream is not yet evaluated to the end.
|
||||
*
|
||||
* Note: many collection methods will not work on collections of infinite sizes.
|
||||
*
|
||||
* @return `true` if this collection is known to have finite size, `false` otherwise.
|
||||
*/
|
||||
def hasDefiniteSize = true
|
||||
|
||||
def ++[B >: A, That](that: GenTraversableOnce[B])(implicit bf: CanBuildFrom[Repr, B, That]): That = {
|
||||
val b = bf(repr)
|
||||
if (that.isInstanceOf[IndexedSeqLike[_, _]]) b.sizeHint(this, that.seq.size)
|
||||
b ++= thisCollection
|
||||
b ++= that.seq
|
||||
b.result
|
||||
}
|
||||
|
||||
@bridge
|
||||
def ++[B >: A, That](that: TraversableOnce[B])(implicit bf: CanBuildFrom[Repr, B, That]): That =
|
||||
++(that: GenTraversableOnce[B])(bf)
|
||||
|
||||
/** Concatenates this $coll with the elements of a traversable collection.
|
||||
* It differs from ++ in that the right operand determines the type of the
|
||||
* resulting collection rather than the left one.
|
||||
*
|
||||
* @param that the traversable to append.
|
||||
* @tparam B the element type of the returned collection.
|
||||
* @tparam That $thatinfo
|
||||
* @param bf $bfinfo
|
||||
* @return a new collection of type `That` which contains all elements
|
||||
* of this $coll followed by all elements of `that`.
|
||||
*
|
||||
* @usecase def ++:[B](that: TraversableOnce[B]): $Coll[B]
|
||||
*
|
||||
* @return a new $coll which contains all elements of this $coll
|
||||
* followed by all elements of `that`.
|
||||
*/
|
||||
def ++:[B >: A, That](that: TraversableOnce[B])(implicit bf: CanBuildFrom[Repr, B, That]): That = {
|
||||
val b = bf(repr)
|
||||
if (that.isInstanceOf[IndexedSeqLike[_, _]]) b.sizeHint(this, that.size)
|
||||
b ++= that
|
||||
b ++= thisCollection
|
||||
b.result
|
||||
}
|
||||
|
||||
/** This overload exists because: for the implementation of ++: we should reuse
|
||||
* that of ++ because many collections override it with more efficient versions.
|
||||
* Since TraversableOnce has no '++' method, we have to implement that directly,
|
||||
* but Traversable and down can use the overload.
|
||||
*/
|
||||
def ++:[B >: A, That](that: Traversable[B])(implicit bf: CanBuildFrom[Repr, B, That]): That =
|
||||
(that ++ seq)(breakOut)
|
||||
|
||||
def map[B, That](f: A => B)(implicit bf: CanBuildFrom[Repr, B, That]): That = {
|
||||
val b = bf(repr)
|
||||
b.sizeHint(this)
|
||||
for (x <- this) b += f(x)
|
||||
b.result
|
||||
}
|
||||
|
||||
def flatMap[B, That](f: A => GenTraversableOnce[B])(implicit bf: CanBuildFrom[Repr, B, That]): That = {
|
||||
val b = bf(repr)
|
||||
for (x <- this) b ++= f(x).seq
|
||||
b.result
|
||||
}
|
||||
|
||||
/** Selects all elements of this $coll which satisfy a predicate.
|
||||
*
|
||||
* @param p the predicate used to test elements.
|
||||
* @return a new $coll consisting of all elements of this $coll that satisfy the given
|
||||
* predicate `p`. The order of the elements is preserved.
|
||||
*/
|
||||
def filter(p: A => Boolean): Repr = {
|
||||
val b = newBuilder
|
||||
for (x <- this)
|
||||
if (p(x)) b += x
|
||||
b.result
|
||||
}
|
||||
|
||||
/** Selects all elements of this $coll which do not satisfy a predicate.
|
||||
*
|
||||
* @param p the predicate used to test elements.
|
||||
* @return a new $coll consisting of all elements of this $coll that do not satisfy the given
|
||||
* predicate `p`. The order of the elements is preserved.
|
||||
*/
|
||||
def filterNot(p: A => Boolean): Repr = filter(!p(_))
|
||||
|
||||
def collect[B, That](pf: PartialFunction[A, B])(implicit bf: CanBuildFrom[Repr, B, That]): That = {
|
||||
val b = bf(repr)
|
||||
for (x <- this) if (pf.isDefinedAt(x)) b += pf(x)
|
||||
b.result
|
||||
}
|
||||
|
||||
/** Builds a new collection by applying an option-valued function to all
|
||||
* elements of this $coll on which the function is defined.
|
||||
*
|
||||
* @param f the option-valued function which filters and maps the $coll.
|
||||
* @tparam B the element type of the returned collection.
|
||||
* @tparam That $thatinfo
|
||||
* @param bf $bfinfo
|
||||
* @return a new collection of type `That` resulting from applying the option-valued function
|
||||
* `f` to each element and collecting all defined results.
|
||||
* The order of the elements is preserved.
|
||||
*
|
||||
* @usecase def filterMap[B](f: A => Option[B]): $Coll[B]
|
||||
*
|
||||
* @param pf the partial function which filters and maps the $coll.
|
||||
* @return a new $coll resulting from applying the given option-valued function
|
||||
* `f` to each element and collecting all defined results.
|
||||
* The order of the elements is preserved.
|
||||
def filterMap[B, That](f: A => Option[B])(implicit bf: CanBuildFrom[Repr, B, That]): That = {
|
||||
val b = bf(repr)
|
||||
for (x <- this)
|
||||
f(x) match {
|
||||
case Some(y) => b += y
|
||||
case _ =>
|
||||
}
|
||||
b.result
|
||||
}
|
||||
*/
|
||||
|
||||
/** Partitions this $coll in two ${coll}s according to a predicate.
|
||||
*
|
||||
* @param p the predicate on which to partition.
|
||||
* @return a pair of ${coll}s: the first $coll consists of all elements that
|
||||
* satisfy the predicate `p` and the second $coll consists of all elements
|
||||
* that don't. The relative order of the elements in the resulting ${coll}s
|
||||
* is the same as in the original $coll.
|
||||
*/
|
||||
def partition(p: A => Boolean): (Repr, Repr) = {
|
||||
val l, r = newBuilder
|
||||
for (x <- this) (if (p(x)) l else r) += x
|
||||
(l.result, r.result)
|
||||
}
|
||||
|
||||
def groupBy[K](f: A => K): immutable.Map[K, Repr] = {
|
||||
val m = mutable.Map.empty[K, Builder[A, Repr]]
|
||||
for (elem <- this) {
|
||||
val key = f(elem)
|
||||
val bldr = m.getOrElseUpdate(key, newBuilder)
|
||||
bldr += elem
|
||||
}
|
||||
val b = immutable.Map.newBuilder[K, Repr]
|
||||
for ((k, v) <- m)
|
||||
b += ((k, v.result))
|
||||
|
||||
b.result
|
||||
}
|
||||
|
||||
/** Tests whether a predicate holds for all elements of this $coll.
|
||||
*
|
||||
* $mayNotTerminateInf
|
||||
*
|
||||
* @param p the predicate used to test elements.
|
||||
* @return `true` if the given predicate `p` holds for all elements
|
||||
* of this $coll, otherwise `false`.
|
||||
*/
|
||||
def forall(p: A => Boolean): Boolean = {
|
||||
var result = true
|
||||
breakable {
|
||||
for (x <- this)
|
||||
if (!p(x)) { result = false; break }
|
||||
}
|
||||
result
|
||||
}
|
||||
|
||||
/** Tests whether a predicate holds for some of the elements of this $coll.
|
||||
*
|
||||
* $mayNotTerminateInf
|
||||
*
|
||||
* @param p the predicate used to test elements.
|
||||
* @return `true` if the given predicate `p` holds for some of the
|
||||
* elements of this $coll, otherwise `false`.
|
||||
*/
|
||||
def exists(p: A => Boolean): Boolean = {
|
||||
var result = false
|
||||
breakable {
|
||||
for (x <- this)
|
||||
if (p(x)) { result = true; break }
|
||||
}
|
||||
result
|
||||
}
|
||||
|
||||
/** Finds the first element of the $coll satisfying a predicate, if any.
|
||||
*
|
||||
* $mayNotTerminateInf
|
||||
* $orderDependent
|
||||
*
|
||||
* @param p the predicate used to test elements.
|
||||
* @return an option value containing the first element in the $coll
|
||||
* that satisfies `p`, or `None` if none exists.
|
||||
*/
|
||||
def find(p: A => Boolean): Option[A] = {
|
||||
var result: Option[A] = None
|
||||
breakable {
|
||||
for (x <- this)
|
||||
if (p(x)) { result = Some(x); break }
|
||||
}
|
||||
result
|
||||
}
|
||||
|
||||
def scan[B >: A, That](z: B)(op: (B, B) => B)(implicit cbf: CanBuildFrom[Repr, B, That]): That = scanLeft(z)(op)
|
||||
|
||||
def scanLeft[B, That](z: B)(op: (B, A) => B)(implicit bf: CanBuildFrom[Repr, B, That]): That = {
|
||||
val b = bf(repr)
|
||||
b.sizeHint(this, 1)
|
||||
var acc = z
|
||||
b += acc
|
||||
for (x <- this) { acc = op(acc, x); b += acc }
|
||||
b.result
|
||||
}
|
||||
|
||||
@migration(2, 9,
|
||||
"This scanRight definition has changed in 2.9.\n" +
|
||||
"The previous behavior can be reproduced with scanRight.reverse."
|
||||
)
|
||||
def scanRight[B, That](z: B)(op: (A, B) => B)(implicit bf: CanBuildFrom[Repr, B, That]): That = {
|
||||
var scanned = List(z)
|
||||
var acc = z
|
||||
for (x <- reversed) {
|
||||
acc = op(x, acc)
|
||||
scanned ::= acc
|
||||
}
|
||||
val b = bf(repr)
|
||||
for (elem <- scanned) b += elem
|
||||
b.result
|
||||
}
|
||||
|
||||
/** Selects the first element of this $coll.
|
||||
* $orderDependent
|
||||
* @return the first element of this $coll.
|
||||
* @throws `NoSuchElementException` if the $coll is empty.
|
||||
*/
|
||||
def head: A = {
|
||||
var result: () => A = () => throw new NoSuchElementException
|
||||
breakable {
|
||||
for (x <- this) {
|
||||
result = () => x
|
||||
break
|
||||
}
|
||||
}
|
||||
result()
|
||||
}
|
||||
|
||||
/** Optionally selects the first element.
|
||||
* $orderDependent
|
||||
* @return the first element of this $coll if it is nonempty, `None` if it is empty.
|
||||
*/
|
||||
def headOption: Option[A] = if (isEmpty) None else Some(head)
|
||||
|
||||
/** Selects all elements except the first.
|
||||
* $orderDependent
|
||||
* @return a $coll consisting of all elements of this $coll
|
||||
* except the first one.
|
||||
* @throws `UnsupportedOperationException` if the $coll is empty.
|
||||
*/
|
||||
override def tail: Repr = {
|
||||
if (isEmpty) throw new UnsupportedOperationException("empty.tail")
|
||||
drop(1)
|
||||
}
|
||||
|
||||
/** Selects the last element.
|
||||
* $orderDependent
|
||||
* @return The last element of this $coll.
|
||||
* @throws NoSuchElementException If the $coll is empty.
|
||||
*/
|
||||
def last: A = {
|
||||
var lst = head
|
||||
for (x <- this)
|
||||
lst = x
|
||||
lst
|
||||
}
|
||||
|
||||
/** Optionally selects the last element.
|
||||
* $orderDependent
|
||||
* @return the last element of this $coll$ if it is nonempty, `None` if it is empty.
|
||||
*/
|
||||
def lastOption: Option[A] = if (isEmpty) None else Some(last)
|
||||
|
||||
/** Selects all elements except the last.
|
||||
* $orderDependent
|
||||
* @return a $coll consisting of all elements of this $coll
|
||||
* except the last one.
|
||||
* @throws `UnsupportedOperationException` if the $coll is empty.
|
||||
*/
|
||||
def init: Repr = {
|
||||
if (isEmpty) throw new UnsupportedOperationException("empty.init")
|
||||
var lst = head
|
||||
var follow = false
|
||||
val b = newBuilder
|
||||
b.sizeHint(this, -1)
|
||||
for (x <- this.seq) {
|
||||
if (follow) b += lst
|
||||
else follow = true
|
||||
lst = x
|
||||
}
|
||||
b.result
|
||||
}
|
||||
|
||||
def take(n: Int): Repr = slice(0, n)
|
||||
|
||||
def drop(n: Int): Repr =
|
||||
if (n <= 0) {
|
||||
val b = newBuilder
|
||||
b.sizeHint(this)
|
||||
b ++= thisCollection result
|
||||
}
|
||||
else sliceWithKnownDelta(n, Int.MaxValue, -n)
|
||||
|
||||
def slice(from: Int, until: Int): Repr = sliceWithKnownBound(math.max(from, 0), until)
|
||||
|
||||
// Precondition: from >= 0, until > 0, builder already configured for building.
|
||||
private[this] def sliceInternal(from: Int, until: Int, b: Builder[A, Repr]): Repr = {
|
||||
var i = 0
|
||||
breakable {
|
||||
for (x <- this.seq) {
|
||||
if (i >= from) b += x
|
||||
i += 1
|
||||
if (i >= until) break
|
||||
}
|
||||
}
|
||||
b.result
|
||||
}
|
||||
// Precondition: from >= 0
|
||||
private[scala] def sliceWithKnownDelta(from: Int, until: Int, delta: Int): Repr = {
|
||||
val b = newBuilder
|
||||
if (until <= from) b.result
|
||||
else {
|
||||
b.sizeHint(this, delta)
|
||||
sliceInternal(from, until, b)
|
||||
}
|
||||
}
|
||||
// Precondition: from >= 0
|
||||
private[scala] def sliceWithKnownBound(from: Int, until: Int): Repr = {
|
||||
val b = newBuilder
|
||||
if (until <= from) b.result
|
||||
else {
|
||||
b.sizeHintBounded(until - from, this)
|
||||
sliceInternal(from, until, b)
|
||||
}
|
||||
}
|
||||
|
||||
def takeWhile(p: A => Boolean): Repr = {
|
||||
val b = newBuilder
|
||||
breakable {
|
||||
for (x <- this) {
|
||||
if (!p(x)) break
|
||||
b += x
|
||||
}
|
||||
}
|
||||
b.result
|
||||
}
|
||||
|
||||
def dropWhile(p: A => Boolean): Repr = {
|
||||
val b = newBuilder
|
||||
var go = false
|
||||
for (x <- this) {
|
||||
if (!p(x)) go = true
|
||||
if (go) b += x
|
||||
}
|
||||
b.result
|
||||
}
|
||||
|
||||
def span(p: A => Boolean): (Repr, Repr) = {
|
||||
val l, r = newBuilder
|
||||
var toLeft = true
|
||||
for (x <- this) {
|
||||
toLeft = toLeft && p(x)
|
||||
(if (toLeft) l else r) += x
|
||||
}
|
||||
(l.result, r.result)
|
||||
}
|
||||
|
||||
def splitAt(n: Int): (Repr, Repr) = {
|
||||
val l, r = newBuilder
|
||||
l.sizeHintBounded(n, this)
|
||||
if (n >= 0) r.sizeHint(this, -n)
|
||||
var i = 0
|
||||
for (x <- this) {
|
||||
(if (i < n) l else r) += x
|
||||
i += 1
|
||||
}
|
||||
(l.result, r.result)
|
||||
}
|
||||
|
||||
/** Iterates over the tails of this $coll. The first value will be this
|
||||
* $coll and the final one will be an empty $coll, with the intervening
|
||||
* values the results of successive applications of `tail`.
|
||||
*
|
||||
* @return an iterator over all the tails of this $coll
|
||||
* @example `List(1,2,3).tails = Iterator(List(1,2,3), List(2,3), List(3), Nil)`
|
||||
*/
|
||||
def tails: Iterator[Repr] = iterateUntilEmpty(_.tail)
|
||||
|
||||
/** Iterates over the inits of this $coll. The first value will be this
|
||||
* $coll and the final one will be an empty $coll, with the intervening
|
||||
* values the results of successive applications of `init`.
|
||||
*
|
||||
* @return an iterator over all the inits of this $coll
|
||||
* @example `List(1,2,3).inits = Iterator(List(1,2,3), List(1,2), List(1), Nil)`
|
||||
*/
|
||||
def inits: Iterator[Repr] = iterateUntilEmpty(_.init)
|
||||
|
||||
/** Copies elements of this $coll to an array.
|
||||
* Fills the given array `xs` with at most `len` elements of
|
||||
* this $coll, starting at position `start`.
|
||||
* Copying will stop once either the end of the current $coll is reached,
|
||||
* or the end of the array is reached, or `len` elements have been copied.
|
||||
*
|
||||
* $willNotTerminateInf
|
||||
*
|
||||
* @param xs the array to fill.
|
||||
* @param start the starting index.
|
||||
* @param len the maximal number of elements to copy.
|
||||
* @tparam B the type of the elements of the array.
|
||||
*
|
||||
*
|
||||
* @usecase def copyToArray(xs: Array[A], start: Int, len: Int): Unit
|
||||
*/
|
||||
def copyToArray[B >: A](xs: Array[B], start: Int, len: Int) {
|
||||
var i = start
|
||||
val end = (start + len) min xs.length
|
||||
breakable {
|
||||
for (x <- this) {
|
||||
if (i >= end) break
|
||||
xs(i) = x
|
||||
i += 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def toTraversable: Traversable[A] = thisCollection
|
||||
def toIterator: Iterator[A] = toStream.iterator
|
||||
def toStream: Stream[A] = toBuffer.toStream
|
||||
|
||||
/** Converts this $coll to a string.
|
||||
*
|
||||
* @return a string representation of this collection. By default this
|
||||
* string consists of the `stringPrefix` of this $coll,
|
||||
* followed by all elements separated by commas and enclosed in parentheses.
|
||||
*/
|
||||
override def toString = mkString(stringPrefix + "(", ", ", ")")
|
||||
|
||||
/** Defines the prefix of this object's `toString` representation.
|
||||
*
|
||||
* @return a string representation which starts the result of `toString`
|
||||
* applied to this $coll. By default the string prefix is the
|
||||
* simple name of the collection class $coll.
|
||||
*/
|
||||
def stringPrefix : String = {
|
||||
var string = repr.asInstanceOf[AnyRef].getClass.getName
|
||||
val idx1 = string.lastIndexOf('.' : Int)
|
||||
if (idx1 != -1) string = string.substring(idx1 + 1)
|
||||
val idx2 = string.indexOf('$')
|
||||
if (idx2 != -1) string = string.substring(0, idx2)
|
||||
string
|
||||
}
|
||||
|
||||
/** Creates a non-strict view of this $coll.
|
||||
*
|
||||
* @return a non-strict view of this $coll.
|
||||
*/
|
||||
def view = new TraversableView[A, Repr] {
|
||||
protected lazy val underlying = self.repr
|
||||
override def foreach[U](f: A => U) = self foreach f
|
||||
}
|
||||
|
||||
/** Creates a non-strict view of a slice of this $coll.
|
||||
*
|
||||
* Note: the difference between `view` and `slice` is that `view` produces
|
||||
* a view of the current $coll, whereas `slice` produces a new $coll.
|
||||
*
|
||||
* Note: `view(from, to)` is equivalent to `view.slice(from, to)`
|
||||
* $orderDependent
|
||||
*
|
||||
* @param from the index of the first element of the view
|
||||
* @param until the index of the element following the view
|
||||
* @return a non-strict view of a slice of this $coll, starting at index `from`
|
||||
* and extending up to (but not including) index `until`.
|
||||
*/
|
||||
def view(from: Int, until: Int): TraversableView[A, Repr] = view.slice(from, until)
|
||||
|
||||
/** Creates a non-strict filter of this $coll.
|
||||
*
|
||||
* Note: the difference between `c filter p` and `c withFilter p` is that
|
||||
* the former creates a new collection, whereas the latter only
|
||||
* restricts the domain of subsequent `map`, `flatMap`, `foreach`,
|
||||
* and `withFilter` operations.
|
||||
* $orderDependent
|
||||
*
|
||||
* @param p the predicate used to test elements.
|
||||
* @return an object of class `WithFilter`, which supports
|
||||
* `map`, `flatMap`, `foreach`, and `withFilter` operations.
|
||||
* All these operations apply to those elements of this $coll which
|
||||
* satisfy the predicate `p`.
|
||||
*/
|
||||
def withFilter(p: A => Boolean): FilterMonadic[A, Repr] = new WithFilter(p)
|
||||
|
||||
/** A class supporting filtered operations. Instances of this class are
|
||||
* returned by method `withFilter`.
|
||||
*/
|
||||
class WithFilter(p: A => Boolean) extends FilterMonadic[A, Repr] {
|
||||
|
||||
/** Builds a new collection by applying a function to all elements of the
|
||||
* outer $coll containing this `WithFilter` instance that satisfy predicate `p`.
|
||||
*
|
||||
* @param f the function to apply to each element.
|
||||
* @tparam B the element type of the returned collection.
|
||||
* @tparam That $thatinfo
|
||||
* @param bf $bfinfo
|
||||
* @return a new collection of type `That` resulting from applying
|
||||
* the given function `f` to each element of the outer $coll
|
||||
* that satisfies predicate `p` and collecting the results.
|
||||
*
|
||||
* @usecase def map[B](f: A => B): $Coll[B]
|
||||
*
|
||||
* @return a new $coll resulting from applying the given function
|
||||
* `f` to each element of the outer $coll that satisfies
|
||||
* predicate `p` and collecting the results.
|
||||
*/
|
||||
def map[B, That](f: A => B)(implicit bf: CanBuildFrom[Repr, B, That]): That = {
|
||||
val b = bf(repr)
|
||||
for (x <- self)
|
||||
if (p(x)) b += f(x)
|
||||
b.result
|
||||
}
|
||||
|
||||
/** Builds a new collection by applying a function to all elements of the
|
||||
* outer $coll containing this `WithFilter` instance that satisfy
|
||||
* predicate `p` and concatenating the results.
|
||||
*
|
||||
* @param f the function to apply to each element.
|
||||
* @tparam B the element type of the returned collection.
|
||||
* @tparam That $thatinfo
|
||||
* @param bf $bfinfo
|
||||
* @return a new collection of type `That` resulting from applying
|
||||
* the given collection-valued function `f` to each element
|
||||
* of the outer $coll that satisfies predicate `p` and
|
||||
* concatenating the results.
|
||||
*
|
||||
* @usecase def flatMap[B](f: A => TraversableOnce[B]): $Coll[B]
|
||||
*
|
||||
* @return a new $coll resulting from applying the given collection-valued function
|
||||
* `f` to each element of the outer $coll that satisfies predicate `p` and concatenating the results.
|
||||
*/
|
||||
def flatMap[B, That](f: A => GenTraversableOnce[B])(implicit bf: CanBuildFrom[Repr, B, That]): That = {
|
||||
val b = bf(repr)
|
||||
for (x <- self)
|
||||
if (p(x)) b ++= f(x).seq
|
||||
b.result
|
||||
}
|
||||
|
||||
/** Applies a function `f` to all elements of the outer $coll containing
|
||||
* this `WithFilter` instance that satisfy predicate `p`.
|
||||
*
|
||||
* @param f the function that is applied for its side-effect to every element.
|
||||
* The result of function `f` is discarded.
|
||||
*
|
||||
* @tparam U the type parameter describing the result of function `f`.
|
||||
* This result will always be ignored. Typically `U` is `Unit`,
|
||||
* but this is not necessary.
|
||||
*
|
||||
* @usecase def foreach(f: A => Unit): Unit
|
||||
*/
|
||||
def foreach[U](f: A => U): Unit =
|
||||
for (x <- self)
|
||||
if (p(x)) f(x)
|
||||
|
||||
/** Further refines the filter for this $coll.
|
||||
*
|
||||
* @param q the predicate used to test elements.
|
||||
* @return an object of class `WithFilter`, which supports
|
||||
* `map`, `flatMap`, `foreach`, and `withFilter` operations.
|
||||
* All these operations apply to those elements of this $coll which
|
||||
* satisfy the predicate `q` in addition to the predicate `p`.
|
||||
*/
|
||||
def withFilter(q: A => Boolean): WithFilter =
|
||||
new WithFilter(x => p(x) && q(x))
|
||||
}
|
||||
|
||||
// A helper for tails and inits.
|
||||
private def iterateUntilEmpty(f: Traversable[A @uV] => Traversable[A @uV]): Iterator[Repr] = {
|
||||
val it = Iterator.iterate(thisCollection)(f) takeWhile (x => !x.isEmpty)
|
||||
it ++ Iterator(Nil) map (newBuilder ++= _ result)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
</textarea>
|
||||
</form>
|
||||
|
||||
<script>
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
||||
lineNumbers: true,
|
||||
matchBrackets: true,
|
||||
theme: "ambiance",
|
||||
mode: "text/x-scala"
|
||||
});
|
||||
</script>
|
||||
</article>
|
4
libraries/codemirror/mode/clojure/clojure.js
vendored
4
libraries/codemirror/mode/clojure/clojure.js
vendored
@ -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 := (<simple-namespace>(<.><simple-namespace>)*</>)?<simple-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];
|
||||
|
8
libraries/codemirror/mode/crystal/crystal.js
vendored
8
libraries/codemirror/mode/crystal/crystal.js
vendored
@ -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";
|
||||
}
|
||||
|
||||
|
15
libraries/codemirror/mode/css/css.js
vendored
15
libraries/codemirror/mode/css/css.js
vendored
@ -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;
|
||||
},
|
||||
|
104
libraries/codemirror/mode/css/gss.html
vendored
104
libraries/codemirror/mode/css/gss.html
vendored
@ -1,104 +0,0 @@
|
||||
<!doctype html>
|
||||
|
||||
<title>CodeMirror: Closure Stylesheets (GSS) mode</title>
|
||||
<meta charset="utf-8"/>
|
||||
<link rel=stylesheet href="../../doc/docs.css">
|
||||
|
||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
||||
<link rel="stylesheet" href="../../addon/hint/show-hint.css">
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="css.js"></script>
|
||||
<script src="../../addon/edit/matchbrackets.js"></script>
|
||||
<script src="../../addon/hint/show-hint.js"></script>
|
||||
<script src="../../addon/hint/css-hint.js"></script>
|
||||
<style>.CodeMirror {background: #f8f8f8;}</style>
|
||||
<div id=nav>
|
||||
<a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png" alt=""></a>
|
||||
|
||||
<ul>
|
||||
<li><a href="../../index.html">Home</a>
|
||||
<li><a href="../../doc/manual.html">Manual</a>
|
||||
<li><a href="https://github.com/codemirror/codemirror">Code</a>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><a href="../index.html">Language modes</a>
|
||||
<li><a class=active href="#">Closure Stylesheets (GSS)</a>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<article>
|
||||
<h2>Closure Stylesheets (GSS) mode</h2>
|
||||
<form><textarea id="code" name="code">
|
||||
/* Some example Closure Stylesheets */
|
||||
|
||||
@provide 'some.styles';
|
||||
|
||||
@require 'other.styles';
|
||||
|
||||
@component {
|
||||
|
||||
@def FONT_FAMILY "Times New Roman", Georgia, Serif;
|
||||
@def FONT_SIZE_NORMAL 15px;
|
||||
@def FONT_NORMAL normal FONT_SIZE_NORMAL FONT_FAMILY;
|
||||
|
||||
@def BG_COLOR rgb(235, 239, 249);
|
||||
|
||||
@def DIALOG_BORDER_COLOR rgb(107, 144, 218);
|
||||
@def DIALOG_BG_COLOR BG_COLOR;
|
||||
|
||||
@def LEFT_HAND_NAV_WIDTH 180px;
|
||||
@def LEFT_HAND_NAV_PADDING 3px;
|
||||
|
||||
@defmixin size(WIDTH, HEIGHT) {
|
||||
width: WIDTH;
|
||||
height: HEIGHT;
|
||||
}
|
||||
|
||||
body {
|
||||
background-color: BG_COLOR;
|
||||
margin: 0;
|
||||
padding: 3em 6em;
|
||||
font: FONT_NORMAL;
|
||||
color: #000;
|
||||
}
|
||||
|
||||
#navigation a {
|
||||
font-weight: bold;
|
||||
text-decoration: none !important;
|
||||
}
|
||||
|
||||
.dialog {
|
||||
background-color: DIALOG_BG_COLOR;
|
||||
border: 1px solid DIALOG_BORDER_COLOR;
|
||||
}
|
||||
|
||||
.content {
|
||||
position: absolute;
|
||||
margin-left: add(LEFT_HAND_NAV_PADDING, /* padding left */
|
||||
LEFT_HAND_NAV_WIDTH,
|
||||
LEFT_HAND_NAV_PADDING); /* padding right */
|
||||
|
||||
}
|
||||
|
||||
.logo {
|
||||
@mixin size(150px, 55px);
|
||||
background-image: url('http://www.google.com/images/logo_sm.gif');
|
||||
}
|
||||
|
||||
}
|
||||
</textarea></form>
|
||||
<script>
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
||||
extraKeys: {"Ctrl-Space": "autocomplete"},
|
||||
lineNumbers: true,
|
||||
matchBrackets: true,
|
||||
mode: "text/x-gss"
|
||||
});
|
||||
</script>
|
||||
|
||||
<p>A mode for <a href="https://github.com/google/closure-stylesheets">Closure Stylesheets</a> (GSS).</p>
|
||||
<p><strong>MIME type defined:</strong> <code>text/x-gss</code>.</p>
|
||||
|
||||
<p><strong>Parsing/Highlighting Tests:</strong> <a href="../../test/index.html#gss_*">normal</a>, <a href="../../test/index.html#verbose,gss_*">verbose</a>.</p>
|
||||
|
||||
</article>
|
152
libraries/codemirror/mode/css/less.html
vendored
152
libraries/codemirror/mode/css/less.html
vendored
@ -1,152 +0,0 @@
|
||||
<!doctype html>
|
||||
|
||||
<title>CodeMirror: LESS mode</title>
|
||||
<meta charset="utf-8"/>
|
||||
<link rel=stylesheet href="../../doc/docs.css">
|
||||
|
||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="../../addon/edit/matchbrackets.js"></script>
|
||||
<script src="css.js"></script>
|
||||
<style>.CodeMirror {border: 1px solid #ddd; line-height: 1.2;}</style>
|
||||
<div id=nav>
|
||||
<a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png" alt=""></a>
|
||||
|
||||
<ul>
|
||||
<li><a href="../../index.html">Home</a>
|
||||
<li><a href="../../doc/manual.html">Manual</a>
|
||||
<li><a href="https://github.com/codemirror/codemirror">Code</a>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><a href="../index.html">Language modes</a>
|
||||
<li><a class=active href="#">LESS</a>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<article>
|
||||
<h2>LESS mode</h2>
|
||||
<form><textarea id="code" name="code">@media screen and (device-aspect-ratio: 16/9) { … }
|
||||
@media screen and (device-aspect-ratio: 1280/720) { … }
|
||||
@media screen and (device-aspect-ratio: 2560/1440) { … }
|
||||
|
||||
html:lang(fr-be)
|
||||
|
||||
tr:nth-child(2n+1) /* represents every odd row of an HTML table */
|
||||
|
||||
img:nth-of-type(2n+1) { float: right; }
|
||||
img:nth-of-type(2n) { float: left; }
|
||||
|
||||
body > h2:not(:first-of-type):not(:last-of-type)
|
||||
|
||||
html|*:not(:link):not(:visited)
|
||||
*|*:not(:hover)
|
||||
p::first-line { text-transform: uppercase }
|
||||
|
||||
@namespace foo url(http://www.example.com);
|
||||
foo|h1 { color: blue } /* first rule */
|
||||
|
||||
span[hello="Ocean"][goodbye="Land"]
|
||||
|
||||
E[foo]{
|
||||
padding:65px;
|
||||
}
|
||||
|
||||
input[type="search"]::-webkit-search-decoration,
|
||||
input[type="search"]::-webkit-search-cancel-button {
|
||||
-webkit-appearance: none; // Inner-padding issues in Chrome OSX, Safari 5
|
||||
}
|
||||
button::-moz-focus-inner,
|
||||
input::-moz-focus-inner { // Inner padding and border oddities in FF3/4
|
||||
padding: 0;
|
||||
border: 0;
|
||||
}
|
||||
.btn {
|
||||
// reset here as of 2.0.3 due to Recess property order
|
||||
border-color: #ccc;
|
||||
border-color: rgba(0,0,0,.1) rgba(0,0,0,.1) rgba(0,0,0,.25);
|
||||
}
|
||||
fieldset span button, fieldset span input[type="file"] {
|
||||
font-size:12px;
|
||||
font-family:Arial, Helvetica, sans-serif;
|
||||
}
|
||||
|
||||
.rounded-corners (@radius: 5px) {
|
||||
border-radius: @radius;
|
||||
-webkit-border-radius: @radius;
|
||||
-moz-border-radius: @radius;
|
||||
}
|
||||
|
||||
@import url("something.css");
|
||||
|
||||
@light-blue: hsl(190, 50%, 65%);
|
||||
|
||||
#menu {
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
z-index: 3;
|
||||
clear: both;
|
||||
display: block;
|
||||
background-color: @blue;
|
||||
height: 42px;
|
||||
border-top: 2px solid lighten(@alpha-blue, 20%);
|
||||
border-bottom: 2px solid darken(@alpha-blue, 25%);
|
||||
.box-shadow(0, 1px, 8px, 0.6);
|
||||
-moz-box-shadow: 0 0 0 #000; // Because firefox sucks.
|
||||
|
||||
&.docked {
|
||||
background-color: hsla(210, 60%, 40%, 0.4);
|
||||
}
|
||||
&:hover {
|
||||
background-color: @blue;
|
||||
}
|
||||
|
||||
#dropdown {
|
||||
margin: 0 0 0 117px;
|
||||
padding: 0;
|
||||
padding-top: 5px;
|
||||
display: none;
|
||||
width: 190px;
|
||||
border-top: 2px solid @medium;
|
||||
color: @highlight;
|
||||
border: 2px solid darken(@medium, 25%);
|
||||
border-left-color: darken(@medium, 15%);
|
||||
border-right-color: darken(@medium, 15%);
|
||||
border-top-width: 0;
|
||||
background-color: darken(@medium, 10%);
|
||||
ul {
|
||||
padding: 0px;
|
||||
}
|
||||
li {
|
||||
font-size: 14px;
|
||||
display: block;
|
||||
text-align: left;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
a {
|
||||
display: block;
|
||||
padding: 0px 15px;
|
||||
text-decoration: none;
|
||||
color: white;
|
||||
&:hover {
|
||||
background-color: darken(@medium, 15%);
|
||||
text-decoration: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
.border-radius(5px, bottom);
|
||||
.box-shadow(0, 6px, 8px, 0.5);
|
||||
}
|
||||
}
|
||||
</textarea></form>
|
||||
<script>
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
||||
lineNumbers: true,
|
||||
matchBrackets: true,
|
||||
mode: "text/x-less"
|
||||
});
|
||||
</script>
|
||||
|
||||
<p>The LESS mode is a sub-mode of the <a href="index.html">CSS mode</a> (defined in <code>css.js</code>).</p>
|
||||
|
||||
<p><strong>Parsing/Highlighting Tests:</strong> <a href="../../test/index.html#less_*">normal</a>, <a href="../../test/index.html#verbose,less_*">verbose</a>.</p>
|
||||
</article>
|
158
libraries/codemirror/mode/css/scss.html
vendored
158
libraries/codemirror/mode/css/scss.html
vendored
@ -1,158 +0,0 @@
|
||||
<!doctype html>
|
||||
|
||||
<title>CodeMirror: SCSS mode</title>
|
||||
<meta charset="utf-8"/>
|
||||
<link rel=stylesheet href="../../doc/docs.css">
|
||||
|
||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="../../addon/edit/matchbrackets.js"></script>
|
||||
<script src="css.js"></script>
|
||||
<style>.CodeMirror {background: #f8f8f8;}</style>
|
||||
<div id=nav>
|
||||
<a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png" alt=""></a>
|
||||
|
||||
<ul>
|
||||
<li><a href="../../index.html">Home</a>
|
||||
<li><a href="../../doc/manual.html">Manual</a>
|
||||
<li><a href="https://github.com/codemirror/codemirror">Code</a>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><a href="../index.html">Language modes</a>
|
||||
<li><a class=active href="#">SCSS</a>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<article>
|
||||
<h2>SCSS mode</h2>
|
||||
<form><textarea id="code" name="code">
|
||||
/* Some example SCSS */
|
||||
|
||||
@import "compass/css3";
|
||||
$variable: #333;
|
||||
|
||||
$blue: #3bbfce;
|
||||
$margin: 16px;
|
||||
|
||||
.content-navigation {
|
||||
#nested {
|
||||
background-color: black;
|
||||
}
|
||||
border-color: $blue;
|
||||
color:
|
||||
darken($blue, 9%);
|
||||
}
|
||||
|
||||
.border {
|
||||
padding: $margin / 2;
|
||||
margin: $margin / 2;
|
||||
border-color: $blue;
|
||||
}
|
||||
|
||||
@mixin table-base {
|
||||
th {
|
||||
text-align: center;
|
||||
font-weight: bold;
|
||||
}
|
||||
td, th {padding: 2px}
|
||||
}
|
||||
|
||||
table.hl {
|
||||
margin: 2em 0;
|
||||
td.ln {
|
||||
text-align: right;
|
||||
}
|
||||
}
|
||||
|
||||
li {
|
||||
font: {
|
||||
family: serif;
|
||||
weight: bold;
|
||||
size: 1.2em;
|
||||
}
|
||||
}
|
||||
|
||||
@mixin left($dist) {
|
||||
float: left;
|
||||
margin-left: $dist;
|
||||
}
|
||||
|
||||
#data {
|
||||
@include left(10px);
|
||||
@include table-base;
|
||||
}
|
||||
|
||||
.source {
|
||||
@include flow-into(target);
|
||||
border: 10px solid green;
|
||||
margin: 20px;
|
||||
width: 200px; }
|
||||
|
||||
.new-container {
|
||||
@include flow-from(target);
|
||||
border: 10px solid red;
|
||||
margin: 20px;
|
||||
width: 200px; }
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 3em 6em;
|
||||
font-family: tahoma, arial, sans-serif;
|
||||
color: #000;
|
||||
}
|
||||
|
||||
@mixin yellow() {
|
||||
background: yellow;
|
||||
}
|
||||
|
||||
.big {
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.nested {
|
||||
@include border-radius(3px);
|
||||
@extend .big;
|
||||
p {
|
||||
background: whitesmoke;
|
||||
a {
|
||||
color: red;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#navigation a {
|
||||
font-weight: bold;
|
||||
text-decoration: none !important;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 2.5em;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 1.7em;
|
||||
}
|
||||
|
||||
h1:before, h2:before {
|
||||
content: "::";
|
||||
}
|
||||
|
||||
code {
|
||||
font-family: courier, monospace;
|
||||
font-size: 80%;
|
||||
color: #418A8A;
|
||||
}
|
||||
</textarea></form>
|
||||
<script>
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
||||
lineNumbers: true,
|
||||
matchBrackets: true,
|
||||
mode: "text/x-scss"
|
||||
});
|
||||
</script>
|
||||
|
||||
<p>The SCSS mode is a sub-mode of the <a href="index.html">CSS mode</a> (defined in <code>css.js</code>).</p>
|
||||
|
||||
<p><strong>Parsing/Highlighting Tests:</strong> <a href="../../test/index.html#scss_*">normal</a>, <a href="../../test/index.html#verbose,scss_*">verbose</a>.</p>
|
||||
|
||||
</article>
|
4
libraries/codemirror/mode/cypher/cypher.js
vendored
4
libraries/codemirror/mode/cypher/cypher.js
vendored
@ -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)) {
|
||||
|
4
libraries/codemirror/mode/dtd/dtd.js
vendored
4
libraries/codemirror/mode/dtd/dtd.js
vendored
@ -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 ) {}
|
||||
|
14
libraries/codemirror/mode/ebnf/ebnf.js
vendored
14
libraries/codemirror/mode/ebnf/ebnf.js
vendored
@ -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(/(?=[\(.])/)) {
|
||||
|
4
libraries/codemirror/mode/erlang/erlang.js
vendored
4
libraries/codemirror/mode/erlang/erlang.js
vendored
@ -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) {
|
||||
|
2
libraries/codemirror/mode/factor/factor.js
vendored
2
libraries/codemirror/mode/factor/factor.js
vendored
@ -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"},
|
||||
|
4
libraries/codemirror/mode/gas/gas.js
vendored
4
libraries/codemirror/mode/gas/gas.js
vendored
@ -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)) {
|
||||
|
2
libraries/codemirror/mode/haml/haml.js
vendored
2
libraries/codemirror/mode/haml/haml.js
vendored
@ -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);
|
||||
|
@ -74,7 +74,8 @@
|
||||
name: "xml",
|
||||
htmlMode: true,
|
||||
multilineTagIndentFactor: parserConfig.multilineTagIndentFactor,
|
||||
multilineTagIndentPastTag: parserConfig.multilineTagIndentPastTag
|
||||
multilineTagIndentPastTag: parserConfig.multilineTagIndentPastTag,
|
||||
allowMissingTagName: parserConfig.allowMissingTagName,
|
||||
});
|
||||
|
||||
var tags = {};
|
||||
|
2
libraries/codemirror/mode/idl/idl.js
vendored
2
libraries/codemirror/mode/idl/idl.js
vendored
@ -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',
|
||||
|
@ -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 });
|
||||
|
||||
|
@ -1,72 +0,0 @@
|
||||
<!doctype html>
|
||||
|
||||
<title>CodeMirror: JSON-LD mode</title>
|
||||
<meta charset="utf-8"/>
|
||||
<link rel=stylesheet href="../../doc/docs.css">
|
||||
|
||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="../../addon/edit/matchbrackets.js"></script>
|
||||
<script src="../../addon/comment/continuecomment.js"></script>
|
||||
<script src="../../addon/comment/comment.js"></script>
|
||||
<script src="javascript.js"></script>
|
||||
<style>.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
|
||||
<div id="nav">
|
||||
<a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"/></a>
|
||||
|
||||
<ul>
|
||||
<li><a href="../../index.html">Home</a>
|
||||
<li><a href="../../doc/manual.html">Manual</a>
|
||||
<li><a href="https://github.com/codemirror/codemirror">Code</a>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><a href="../index.html">Language modes</a>
|
||||
<li><a class=active href="#">JSON-LD</a>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<article>
|
||||
<h2>JSON-LD mode</h2>
|
||||
|
||||
|
||||
<div><textarea id="code" name="code">
|
||||
{
|
||||
"@context": {
|
||||
"name": "http://schema.org/name",
|
||||
"description": "http://schema.org/description",
|
||||
"image": {
|
||||
"@id": "http://schema.org/image",
|
||||
"@type": "@id"
|
||||
},
|
||||
"geo": "http://schema.org/geo",
|
||||
"latitude": {
|
||||
"@id": "http://schema.org/latitude",
|
||||
"@type": "xsd:float"
|
||||
},
|
||||
"longitude": {
|
||||
"@id": "http://schema.org/longitude",
|
||||
"@type": "xsd:float"
|
||||
},
|
||||
"xsd": "http://www.w3.org/2001/XMLSchema#"
|
||||
},
|
||||
"name": "The Empire State Building",
|
||||
"description": "The Empire State Building is a 102-story landmark in New York City.",
|
||||
"image": "http://www.civil.usherbrooke.ca/cours/gci215a/empire-state-building.jpg",
|
||||
"geo": {
|
||||
"latitude": "40.75",
|
||||
"longitude": "73.98"
|
||||
}
|
||||
}
|
||||
</textarea></div>
|
||||
|
||||
<script>
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
||||
matchBrackets: true,
|
||||
autoCloseBrackets: true,
|
||||
mode: "application/ld+json",
|
||||
lineWrapping: true
|
||||
});
|
||||
</script>
|
||||
|
||||
<p>This is a specialization of the <a href="index.html">JavaScript mode</a>.</p>
|
||||
</article>
|
@ -1,62 +0,0 @@
|
||||
<!doctype html>
|
||||
|
||||
<title>CodeMirror: TypeScript mode</title>
|
||||
<meta charset="utf-8"/>
|
||||
<link rel=stylesheet href="../../doc/docs.css">
|
||||
|
||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="../../addon/edit/matchbrackets.js"></script>
|
||||
<script src="javascript.js"></script>
|
||||
<style>.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
|
||||
<div id=nav>
|
||||
<a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png" alt=""></a>
|
||||
|
||||
<ul>
|
||||
<li><a href="../../index.html">Home</a>
|
||||
<li><a href="../../doc/manual.html">Manual</a>
|
||||
<li><a href="https://github.com/codemirror/codemirror">Code</a>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><a href="../index.html">Language modes</a>
|
||||
<li><a class=active href="#">TypeScript</a>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<article>
|
||||
<h2>TypeScript mode</h2>
|
||||
|
||||
|
||||
<div><textarea id="code" name="code">
|
||||
class Greeter {
|
||||
greeting: string;
|
||||
constructor (message: string) {
|
||||
this.greeting = message;
|
||||
}
|
||||
greet() {
|
||||
return "Hello, " + this.greeting;
|
||||
}
|
||||
}
|
||||
|
||||
var greeter = new Greeter("world");
|
||||
|
||||
var button = document.createElement('button')
|
||||
button.innerText = "Say Hello"
|
||||
button.onclick = function() {
|
||||
alert(greeter.greet())
|
||||
}
|
||||
|
||||
document.body.appendChild(button)
|
||||
|
||||
</textarea></div>
|
||||
|
||||
<script>
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
||||
lineNumbers: true,
|
||||
matchBrackets: true,
|
||||
mode: "text/typescript"
|
||||
});
|
||||
</script>
|
||||
|
||||
<p>This is a specialization of the <a href="index.html">JavaScript mode</a>.</p>
|
||||
</article>
|
63
libraries/codemirror/mode/julia/julia.js
vendored
63
libraries/codemirror/mode/julia/julia.js
vendored
@ -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
|
||||
};
|
||||
},
|
||||
|
1
libraries/codemirror/mode/lua/lua.js
vendored
1
libraries/codemirror/mode/lua/lua.js
vendored
@ -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: "]]"
|
||||
|
@ -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";
|
||||
|
3
libraries/codemirror/mode/meta.js
vendored
3
libraries/codemirror/mode/meta.js
vendored
@ -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++) {
|
||||
|
@ -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 {
|
||||
|
8
libraries/codemirror/mode/mscgen/mscgen.js
vendored
8
libraries/codemirror/mode/mscgen/mscgen.js
vendored
@ -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";
|
||||
}
|
||||
|
2
libraries/codemirror/mode/mumps/mumps.js
vendored
2
libraries/codemirror/mode/mumps/mumps.js
vendored
@ -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);
|
||||
|
4
libraries/codemirror/mode/oz/oz.js
vendored
4
libraries/codemirror/mode/oz/oz.js
vendored
@ -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";
|
||||
|
6
libraries/codemirror/mode/pegjs/pegjs.js
vendored
6
libraries/codemirror/mode/pegjs/pegjs.js
vendored
@ -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() === '{') {
|
||||
|
8
libraries/codemirror/mode/perl/perl.js
vendored
8
libraries/codemirror/mode/perl/perl.js
vendored
@ -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: <<SOMETHING\n...\nSOMETHING\n
|
||||
if(stream.match(/^<<(?=[_a-zA-Z])/)){ // NOTE: <<SOMETHING\n...\nSOMETHING\n
|
||||
stream.eatWhile(/\w/);
|
||||
return tokenSOMETHING(stream,state,stream.current().substr(2));}
|
||||
if(stream.sol()&&stream.match(/^\=item(?!\w)/)){// NOTE: \n=item...\n=cut\n
|
||||
@ -697,7 +697,7 @@ CodeMirror.defineMode("perl",function(){
|
||||
return "variable-2";}
|
||||
stream.pos=p;}
|
||||
if(/[$@%&]/.test(ch)){
|
||||
if(stream.eatWhile(/[\w$\[\]]/)||stream.eat("{")&&stream.eatWhile(/[\w$\[\]]/)&&stream.eat("}")){
|
||||
if(stream.eatWhile(/[\w$]/)||stream.eat("{")&&stream.eatWhile(/[\w$]/)&&stream.eat("}")){
|
||||
var c=stream.current();
|
||||
if(PERL[c])
|
||||
return "variable-2";
|
||||
|
4
libraries/codemirror/mode/php/php.js
vendored
4
libraries/codemirror/mode/php/php.js
vendored
@ -53,7 +53,7 @@
|
||||
[["]", null]]
|
||||
], closing, escapes);
|
||||
}
|
||||
if (stream.match(/\-\>\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));
|
||||
|
2
libraries/codemirror/mode/pug/pug.js
vendored
2
libraries/codemirror/mode/pug/pug.js
vendored
@ -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);
|
||||
|
2
libraries/codemirror/mode/puppet/puppet.js
vendored
2
libraries/codemirror/mode/puppet/puppet.js
vendored
@ -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
|
||||
|
2
libraries/codemirror/mode/python/python.js
vendored
2
libraries/codemirror/mode/python/python.js
vendored
@ -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})
|
||||
|
8
libraries/codemirror/mode/rpm/rpm.js
vendored
8
libraries/codemirror/mode/rpm/rpm.js
vendored
@ -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";
|
||||
}
|
||||
|
41
libraries/codemirror/mode/ruby/ruby.js
vendored
41
libraries/codemirror/mode/ruby/ruby.js
vendored
@ -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);
|
||||
|
||||
});
|
||||
|
9
libraries/codemirror/mode/sass/sass.js
vendored
9
libraries/codemirror/mode/sass/sass.js
vendored
@ -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");
|
||||
|
||||
|
6
libraries/codemirror/mode/scheme/scheme.js
vendored
6
libraries/codemirror/mode/scheme/scheme.js
vendored
@ -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-ci>=? char-ci>? char-downcase char-lower-case? char-numeric? char-ready? char-upcase char-upper-case? char-whitespace? char<=? char<? 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-ci>=? string-ci>? string-copy string-fill! string-length string-ref string-set! string<=? string<? 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-ci>=? char-ci>? char-downcase char-lower-case? char-numeric? char-ready? char-upcase char-upper-case? char-whitespace? char<=? char<? 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-ci>=? string-ci>? string-copy string-fill! string-length string-ref string-set! string<=? string<? 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('#');
|
||||
}
|
||||
|
16
libraries/codemirror/mode/shell/shell.js
vendored
16
libraries/codemirror/mode/shell/shell.js
vendored
@ -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);
|
||||
};
|
||||
|
2
libraries/codemirror/mode/sieve/sieve.js
vendored
2
libraries/codemirror/mode/sieve/sieve.js
vendored
@ -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;
|
||||
}
|
||||
|
45
libraries/codemirror/mode/soy/soy.js
vendored
45
libraries/codemirror/mode/soy/soy.js
vendored
@ -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+\/\/|\/\*/);
|
||||
|
14
libraries/codemirror/mode/sparql/sparql.js
vendored
14
libraries/codemirror/mode/sparql/sparql.js
vendored
@ -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;
|
||||
|
10
libraries/codemirror/mode/sql/sql.js
vendored
10
libraries/codemirror/mode/sql/sql.js
vendored
@ -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: /^[*\/+\-%<>!=~&|^]/,
|
||||
|
8
libraries/codemirror/mode/stylus/stylus.js
vendored
8
libraries/codemirror/mode/stylus/stylus.js
vendored
File diff suppressed because one or more lines are too long
@ -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 ...
|
||||
|
@ -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";
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
141
libraries/codemirror/mode/verilog/verilog.js
vendored
141
libraries/codemirror/mode/verilog/verilog.js
vendored
@ -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";
|
||||
|
89
libraries/codemirror/mode/wast/wast.js
vendored
89
libraries/codemirror/mode/wast/wast.js
vendored
@ -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"},
|
||||
|
4
libraries/codemirror/mode/xml/xml.js
vendored
4
libraries/codemirror/mode/xml/xml.js
vendored
@ -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()
|
||||
}
|
||||
};
|
||||
|
@ -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 {
|
||||
|
8
libraries/codemirror/mode/yaml/yaml.js
vendored
8
libraries/codemirror/mode/yaml/yaml.js
vendored
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user