mirror of https://github.com/status-im/codimd.git
Update CodeMirror to 5.19.0 and rename jade to pug
This commit is contained in:
parent
fb5d7e4359
commit
795ea21191
|
@ -144,7 +144,7 @@ var cursorMenuThrottle = 50;
|
||||||
var cursorActivityDebounce = 50;
|
var cursorActivityDebounce = 50;
|
||||||
var cursorAnimatePeriod = 100;
|
var cursorAnimatePeriod = 100;
|
||||||
var supportContainers = ['success', 'info', 'warning', 'danger'];
|
var supportContainers = ['success', 'info', 'warning', 'danger'];
|
||||||
var supportCodeModes = ['javascript', 'htmlmixed', 'htmlembedded', 'css', 'xml', 'clike', 'clojure', 'ruby', 'python', 'shell', 'php', 'sql', 'coffeescript', 'yaml', 'jade', 'lua', 'cmake', 'nginx', 'perl', 'sass', 'r', 'dockerfile', 'tiddlywiki', 'mediawiki'];
|
var supportCodeModes = ['javascript', 'htmlmixed', 'htmlembedded', 'css', 'xml', 'clike', 'clojure', 'ruby', 'python', 'shell', 'php', 'sql', 'coffeescript', 'yaml', 'pug', 'lua', 'cmake', 'nginx', 'perl', 'sass', 'r', 'dockerfile', 'tiddlywiki', 'mediawiki'];
|
||||||
var supportCharts = ['sequence', 'flow', 'graphviz', 'mermaid'];
|
var supportCharts = ['sequence', 'flow', 'graphviz', 'mermaid'];
|
||||||
var supportHeaders = [
|
var supportHeaders = [
|
||||||
{
|
{
|
||||||
|
|
|
@ -103,6 +103,7 @@
|
||||||
self.lineComment(from, to, options);
|
self.lineComment(from, to, options);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (/\bcomment\b/.test(self.getTokenTypeAt(Pos(from.line, 0)))) return
|
||||||
|
|
||||||
var end = Math.min(to.line, self.lastLine());
|
var end = Math.min(to.line, self.lastLine());
|
||||||
if (end != from.line && to.ch == 0 && nonWS.test(self.getLine(end))) --end;
|
if (end != from.line && to.ch == 0 && nonWS.test(self.getLine(end))) --end;
|
||||||
|
@ -140,7 +141,7 @@
|
||||||
var line = self.getLine(i);
|
var line = self.getLine(i);
|
||||||
var found = line.indexOf(lineString);
|
var found = line.indexOf(lineString);
|
||||||
if (found > -1 && !/comment/.test(self.getTokenTypeAt(Pos(i, found + 1)))) found = -1;
|
if (found > -1 && !/comment/.test(self.getTokenTypeAt(Pos(i, found + 1)))) found = -1;
|
||||||
if (found == -1 && (i != end || i == start) && nonWS.test(line)) break lineComment;
|
if (found == -1 && nonWS.test(line)) break lineComment;
|
||||||
if (found > -1 && nonWS.test(line.slice(0, found))) break lineComment;
|
if (found > -1 && nonWS.test(line.slice(0, found))) break lineComment;
|
||||||
lines.push(line);
|
lines.push(line);
|
||||||
}
|
}
|
||||||
|
@ -162,13 +163,15 @@
|
||||||
var endString = options.blockCommentEnd || mode.blockCommentEnd;
|
var endString = options.blockCommentEnd || mode.blockCommentEnd;
|
||||||
if (!startString || !endString) return false;
|
if (!startString || !endString) return false;
|
||||||
var lead = options.blockCommentLead || mode.blockCommentLead;
|
var lead = options.blockCommentLead || mode.blockCommentLead;
|
||||||
var startLine = self.getLine(start), endLine = end == start ? startLine : self.getLine(end);
|
var startLine = self.getLine(start), open = startLine.indexOf(startString)
|
||||||
var open = startLine.indexOf(startString), close = endLine.lastIndexOf(endString);
|
if (open == -1) return false
|
||||||
|
var endLine = end == start ? startLine : self.getLine(end)
|
||||||
|
var close = endLine.indexOf(endString, end == start ? open + startString.length : 0);
|
||||||
if (close == -1 && start != end) {
|
if (close == -1 && start != end) {
|
||||||
endLine = self.getLine(--end);
|
endLine = self.getLine(--end);
|
||||||
close = endLine.lastIndexOf(endString);
|
close = endLine.indexOf(endString);
|
||||||
}
|
}
|
||||||
if (open == -1 || close == -1 ||
|
if (close == -1 ||
|
||||||
!/comment/.test(self.getTokenTypeAt(Pos(start, open + 1))) ||
|
!/comment/.test(self.getTokenTypeAt(Pos(start, open + 1))) ||
|
||||||
!/comment/.test(self.getTokenTypeAt(Pos(end, close + 1))))
|
!/comment/.test(self.getTokenTypeAt(Pos(end, close + 1))))
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -21,8 +21,8 @@
|
||||||
function Iter(cm, line, ch, range) {
|
function Iter(cm, line, ch, range) {
|
||||||
this.line = line; this.ch = ch;
|
this.line = line; this.ch = ch;
|
||||||
this.cm = cm; this.text = cm.getLine(line);
|
this.cm = cm; this.text = cm.getLine(line);
|
||||||
this.min = range ? range.from : cm.firstLine();
|
this.min = range ? Math.max(range.from, cm.firstLine()) : cm.firstLine();
|
||||||
this.max = range ? range.to - 1 : cm.lastLine();
|
this.max = range ? Math.min(range.to - 1, cm.lastLine()) : cm.lastLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
function tagAt(iter, ch) {
|
function tagAt(iter, ch) {
|
||||||
|
|
|
@ -97,6 +97,15 @@
|
||||||
var coffeescriptKeywords = ("and break catch class continue delete do else extends false finally for " +
|
var coffeescriptKeywords = ("and break catch class continue delete do else extends false finally for " +
|
||||||
"if in instanceof isnt new no not null of off on or return switch then throw true try typeof until void while with yes").split(" ");
|
"if in instanceof isnt new no not null of off on or return switch then throw true try typeof until void while with yes").split(" ");
|
||||||
|
|
||||||
|
function forAllProps(obj, callback) {
|
||||||
|
if (!Object.getOwnPropertyNames || !Object.getPrototypeOf) {
|
||||||
|
for (var name in obj) callback(name)
|
||||||
|
} else {
|
||||||
|
for (var o = obj; o; o = Object.getPrototypeOf(o))
|
||||||
|
Object.getOwnPropertyNames(o).forEach(callback)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function getCompletions(token, context, keywords, options) {
|
function getCompletions(token, context, keywords, options) {
|
||||||
var found = [], start = token.string, global = options && options.globalScope || window;
|
var found = [], start = token.string, global = options && options.globalScope || window;
|
||||||
function maybeAdd(str) {
|
function maybeAdd(str) {
|
||||||
|
@ -106,7 +115,7 @@
|
||||||
if (typeof obj == "string") forEach(stringProps, maybeAdd);
|
if (typeof obj == "string") forEach(stringProps, maybeAdd);
|
||||||
else if (obj instanceof Array) forEach(arrayProps, maybeAdd);
|
else if (obj instanceof Array) forEach(arrayProps, maybeAdd);
|
||||||
else if (obj instanceof Function) forEach(funcProps, maybeAdd);
|
else if (obj instanceof Function) forEach(funcProps, maybeAdd);
|
||||||
for (var name in obj) maybeAdd(name);
|
forAllProps(obj, maybeAdd)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (context && context.length) {
|
if (context && context.length) {
|
||||||
|
|
|
@ -45,6 +45,7 @@
|
||||||
this.options[name] = (options && options.hasOwnProperty(name) ? options : defaults)[name]
|
this.options[name] = (options && options.hasOwnProperty(name) ? options : defaults)[name]
|
||||||
this.overlay = this.timeout = null;
|
this.overlay = this.timeout = null;
|
||||||
this.matchesonscroll = null;
|
this.matchesonscroll = null;
|
||||||
|
this.active = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
CodeMirror.defineOption("highlightSelectionMatches", false, function(cm, val, old) {
|
CodeMirror.defineOption("highlightSelectionMatches", false, function(cm, val, old) {
|
||||||
|
@ -53,16 +54,34 @@
|
||||||
clearTimeout(cm.state.matchHighlighter.timeout);
|
clearTimeout(cm.state.matchHighlighter.timeout);
|
||||||
cm.state.matchHighlighter = null;
|
cm.state.matchHighlighter = null;
|
||||||
cm.off("cursorActivity", cursorActivity);
|
cm.off("cursorActivity", cursorActivity);
|
||||||
|
cm.off("focus", onFocus)
|
||||||
}
|
}
|
||||||
if (val) {
|
if (val) {
|
||||||
cm.state.matchHighlighter = new State(val);
|
var state = cm.state.matchHighlighter = new State(val);
|
||||||
highlightMatches(cm);
|
if (cm.hasFocus()) {
|
||||||
|
state.active = true
|
||||||
|
highlightMatches(cm)
|
||||||
|
} else {
|
||||||
|
cm.on("focus", onFocus)
|
||||||
|
}
|
||||||
cm.on("cursorActivity", cursorActivity);
|
cm.on("cursorActivity", cursorActivity);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function cursorActivity(cm) {
|
function cursorActivity(cm) {
|
||||||
var state = cm.state.matchHighlighter;
|
var state = cm.state.matchHighlighter;
|
||||||
|
if (state.active || cm.hasFocus()) scheduleHighlight(cm, state)
|
||||||
|
}
|
||||||
|
|
||||||
|
function onFocus(cm) {
|
||||||
|
var state = cm.state.matchHighlighter
|
||||||
|
if (!state.active) {
|
||||||
|
state.active = true
|
||||||
|
scheduleHighlight(cm, state)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function scheduleHighlight(cm, state) {
|
||||||
clearTimeout(state.timeout);
|
clearTimeout(state.timeout);
|
||||||
state.timeout = setTimeout(function() {highlightMatches(cm);}, state.options.delay);
|
state.timeout = setTimeout(function() {highlightMatches(cm);}, state.options.delay);
|
||||||
}
|
}
|
||||||
|
|
|
@ -136,8 +136,11 @@
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
persistentDialog(cm, queryDialog, q, searchNext, function(event, query) {
|
persistentDialog(cm, queryDialog, q, searchNext, function(event, query) {
|
||||||
var cmd = CodeMirror.keyMap[cm.getOption("keyMap")][CodeMirror.keyName(event)];
|
var keyName = CodeMirror.keyName(event)
|
||||||
if (cmd == "findNext" || cmd == "findPrev") {
|
var cmd = CodeMirror.keyMap[cm.getOption("keyMap")][keyName]
|
||||||
|
if (!cmd) cmd = cm.getOption('extraKeys')[keyName]
|
||||||
|
if (cmd == "findNext" || cmd == "findPrev" ||
|
||||||
|
cmd == "findPersistentNext" || cmd == "findPersistentPrev") {
|
||||||
CodeMirror.e_stop(event);
|
CodeMirror.e_stop(event);
|
||||||
startSearch(cm, getSearchState(cm), query);
|
startSearch(cm, getSearchState(cm), query);
|
||||||
cm.execCommand(cmd);
|
cm.execCommand(cmd);
|
||||||
|
@ -146,7 +149,7 @@
|
||||||
searchNext(query, event);
|
searchNext(query, event);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (immediate) {
|
if (immediate && q) {
|
||||||
startSearch(cm, state, q);
|
startSearch(cm, state, q);
|
||||||
findNext(cm, rev);
|
findNext(cm, rev);
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -30,7 +30,7 @@ addon/fold/foldgutter.js \
|
||||||
addon/fold/markdown-fold.js \
|
addon/fold/markdown-fold.js \
|
||||||
addon/fold/xml-fold.js \
|
addon/fold/xml-fold.js \
|
||||||
mode/xml/xml.js \
|
mode/xml/xml.js \
|
||||||
mode/markdown/markdown.js \
|
mode/markdown/markdown_math.js \
|
||||||
mode/gfm/gfm.js \
|
mode/gfm/gfm.js \
|
||||||
mode/javascript/javascript.js \
|
mode/javascript/javascript.js \
|
||||||
mode/css/css.js \
|
mode/css/css.js \
|
||||||
|
@ -45,7 +45,7 @@ mode/php/php.js \
|
||||||
mode/sql/sql.js \
|
mode/sql/sql.js \
|
||||||
mode/coffeescript/coffeescript.js \
|
mode/coffeescript/coffeescript.js \
|
||||||
mode/yaml/yaml.js \
|
mode/yaml/yaml.js \
|
||||||
mode/jade/jade.js \
|
mode/pug/pug.js \
|
||||||
mode/lua/lua.js \
|
mode/lua/lua.js \
|
||||||
mode/cmake/cmake.js \
|
mode/cmake/cmake.js \
|
||||||
mode/nginx/nginx.js \
|
mode/nginx/nginx.js \
|
||||||
|
|
|
@ -780,9 +780,13 @@
|
||||||
|
|
||||||
if (lastInsertModeKeyTimer) { window.clearTimeout(lastInsertModeKeyTimer); }
|
if (lastInsertModeKeyTimer) { window.clearTimeout(lastInsertModeKeyTimer); }
|
||||||
if (keysAreChars) {
|
if (keysAreChars) {
|
||||||
var here = cm.getCursor();
|
var selections = cm.listSelections();
|
||||||
|
for (var i = 0; i < selections.length; i++) {
|
||||||
|
var here = selections[i].head;
|
||||||
cm.replaceRange('', offsetCursor(here, 0, -(keys.length - 1)), here, '+input');
|
cm.replaceRange('', offsetCursor(here, 0, -(keys.length - 1)), here, '+input');
|
||||||
}
|
}
|
||||||
|
vimGlobalState.macroModeState.lastInsertModeChanges.changes.pop();
|
||||||
|
}
|
||||||
clearInputState(cm);
|
clearInputState(cm);
|
||||||
return match.command;
|
return match.command;
|
||||||
}
|
}
|
||||||
|
@ -818,7 +822,7 @@
|
||||||
// TODO: Look into using CodeMirror's multi-key handling.
|
// TODO: Look into using CodeMirror's multi-key handling.
|
||||||
// Return no-op since we are caching the key. Counts as handled, but
|
// Return no-op since we are caching the key. Counts as handled, but
|
||||||
// don't want act on it just yet.
|
// don't want act on it just yet.
|
||||||
return function() {};
|
return function() { return true; };
|
||||||
} else {
|
} else {
|
||||||
return function() {
|
return function() {
|
||||||
return cm.operation(function() {
|
return cm.operation(function() {
|
||||||
|
@ -4874,6 +4878,10 @@
|
||||||
if (changeObj.origin == '+input' || changeObj.origin == 'paste'
|
if (changeObj.origin == '+input' || changeObj.origin == 'paste'
|
||||||
|| changeObj.origin === undefined /* only in testing */) {
|
|| changeObj.origin === undefined /* only in testing */) {
|
||||||
var text = changeObj.text.join('\n');
|
var text = changeObj.text.join('\n');
|
||||||
|
if (lastChange.maybeReset) {
|
||||||
|
lastChange.changes = [];
|
||||||
|
lastChange.maybeReset = false;
|
||||||
|
}
|
||||||
lastChange.changes.push(text);
|
lastChange.changes.push(text);
|
||||||
}
|
}
|
||||||
// Change objects may be chained with next.
|
// Change objects may be chained with next.
|
||||||
|
@ -4896,7 +4904,7 @@
|
||||||
lastChange.expectCursorActivityForChange = false;
|
lastChange.expectCursorActivityForChange = false;
|
||||||
} else {
|
} else {
|
||||||
// Cursor moved outside the context of an edit. Reset the change.
|
// Cursor moved outside the context of an edit. Reset the change.
|
||||||
lastChange.changes = [];
|
lastChange.maybeReset = true;
|
||||||
}
|
}
|
||||||
} else if (!cm.curOp.isVimOp) {
|
} else if (!cm.curOp.isVimOp) {
|
||||||
handleExternalSelection(cm, vim);
|
handleExternalSelection(cm, vim);
|
||||||
|
@ -4960,6 +4968,10 @@
|
||||||
var keyName = CodeMirror.keyName(e);
|
var keyName = CodeMirror.keyName(e);
|
||||||
if (!keyName) { return; }
|
if (!keyName) { return; }
|
||||||
function onKeyFound() {
|
function onKeyFound() {
|
||||||
|
if (lastChange.maybeReset) {
|
||||||
|
lastChange.changes = [];
|
||||||
|
lastChange.maybeReset = false;
|
||||||
|
}
|
||||||
lastChange.changes.push(new InsertModeKey(keyName));
|
lastChange.changes.push(new InsertModeKey(keyName));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -592,8 +592,12 @@
|
||||||
var comp = compensateForHScroll(display) - display.scroller.scrollLeft + cm.doc.scrollLeft;
|
var comp = compensateForHScroll(display) - display.scroller.scrollLeft + cm.doc.scrollLeft;
|
||||||
var gutterW = display.gutters.offsetWidth, left = comp + "px";
|
var gutterW = display.gutters.offsetWidth, left = comp + "px";
|
||||||
for (var i = 0; i < view.length; i++) if (!view[i].hidden) {
|
for (var i = 0; i < view.length; i++) if (!view[i].hidden) {
|
||||||
if (cm.options.fixedGutter && view[i].gutter)
|
if (cm.options.fixedGutter) {
|
||||||
|
if (view[i].gutter)
|
||||||
view[i].gutter.style.left = left;
|
view[i].gutter.style.left = left;
|
||||||
|
if (view[i].gutterBackground)
|
||||||
|
view[i].gutterBackground.style.left = left;
|
||||||
|
}
|
||||||
var align = view[i].alignable;
|
var align = view[i].alignable;
|
||||||
if (align) for (var j = 0; j < align.length; j++)
|
if (align) for (var j = 0; j < align.length; j++)
|
||||||
align[j].style.left = left;
|
align[j].style.left = left;
|
||||||
|
@ -1149,7 +1153,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function handlePaste(e, cm) {
|
function handlePaste(e, cm) {
|
||||||
var pasted = e.clipboardData && e.clipboardData.getData("text/plain");
|
var pasted = e.clipboardData && e.clipboardData.getData("Text");
|
||||||
if (pasted) {
|
if (pasted) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if (!cm.isReadOnly() && !cm.options.disableInput)
|
if (!cm.isReadOnly() && !cm.options.disableInput)
|
||||||
|
@ -1193,10 +1197,10 @@
|
||||||
return {text: text, ranges: ranges};
|
return {text: text, ranges: ranges};
|
||||||
}
|
}
|
||||||
|
|
||||||
function disableBrowserMagic(field) {
|
function disableBrowserMagic(field, spellcheck) {
|
||||||
field.setAttribute("autocorrect", "off");
|
field.setAttribute("autocorrect", "off");
|
||||||
field.setAttribute("autocapitalize", "off");
|
field.setAttribute("autocapitalize", "off");
|
||||||
field.setAttribute("spellcheck", "false");
|
field.setAttribute("spellcheck", !!spellcheck);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TEXTAREA INPUT STYLE
|
// TEXTAREA INPUT STYLE
|
||||||
|
@ -1576,10 +1580,14 @@
|
||||||
init: function(display) {
|
init: function(display) {
|
||||||
var input = this, cm = input.cm;
|
var input = this, cm = input.cm;
|
||||||
var div = input.div = display.lineDiv;
|
var div = input.div = display.lineDiv;
|
||||||
disableBrowserMagic(div);
|
disableBrowserMagic(div, cm.options.spellcheck);
|
||||||
|
|
||||||
on(div, "paste", function(e) {
|
on(div, "paste", function(e) {
|
||||||
if (!signalDOMEvent(cm, e)) handlePaste(e, cm);
|
if (signalDOMEvent(cm, e) || handlePaste(e, cm)) return
|
||||||
|
// IE doesn't fire input events, so we schedule a read for the pasted content in this way
|
||||||
|
if (ie_version <= 11) setTimeout(operation(cm, function() {
|
||||||
|
if (!input.pollContent()) regChange(cm);
|
||||||
|
}), 20)
|
||||||
})
|
})
|
||||||
|
|
||||||
on(div, "compositionstart", function(e) {
|
on(div, "compositionstart", function(e) {
|
||||||
|
@ -1639,12 +1647,16 @@
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// iOS exposes the clipboard API, but seems to discard content inserted into it
|
if (e.clipboardData) {
|
||||||
if (e.clipboardData && !ios) {
|
|
||||||
e.preventDefault();
|
|
||||||
e.clipboardData.clearData();
|
e.clipboardData.clearData();
|
||||||
e.clipboardData.setData("text/plain", lastCopied.text.join("\n"));
|
var content = lastCopied.text.join("\n")
|
||||||
} else {
|
// iOS exposes the clipboard API, but seems to discard content inserted into it
|
||||||
|
e.clipboardData.setData("Text", content);
|
||||||
|
if (e.clipboardData.getData("Text") == content) {
|
||||||
|
e.preventDefault();
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
// Old-fashioned briefly-focus-a-textarea hack
|
// Old-fashioned briefly-focus-a-textarea hack
|
||||||
var kludge = hiddenTextarea(), te = kludge.firstChild;
|
var kludge = hiddenTextarea(), te = kludge.firstChild;
|
||||||
cm.display.lineSpace.insertBefore(kludge, cm.display.lineSpace.firstChild);
|
cm.display.lineSpace.insertBefore(kludge, cm.display.lineSpace.firstChild);
|
||||||
|
@ -1654,9 +1666,9 @@
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
cm.display.lineSpace.removeChild(kludge);
|
cm.display.lineSpace.removeChild(kludge);
|
||||||
hadFocus.focus();
|
hadFocus.focus();
|
||||||
|
if (hadFocus == div) input.showPrimarySelection()
|
||||||
}, 50);
|
}, 50);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
on(div, "copy", onCopyCut);
|
on(div, "copy", onCopyCut);
|
||||||
on(div, "cut", onCopyCut);
|
on(div, "cut", onCopyCut);
|
||||||
},
|
},
|
||||||
|
@ -1963,7 +1975,7 @@
|
||||||
if (found)
|
if (found)
|
||||||
return badPos(Pos(found.line, found.ch + dist), bad);
|
return badPos(Pos(found.line, found.ch + dist), bad);
|
||||||
else
|
else
|
||||||
dist += after.textContent.length;
|
dist += before.textContent.length;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3533,8 +3545,8 @@
|
||||||
on(inp, "keyup", function(e) { onKeyUp.call(cm, e); });
|
on(inp, "keyup", function(e) { onKeyUp.call(cm, e); });
|
||||||
on(inp, "keydown", operation(cm, onKeyDown));
|
on(inp, "keydown", operation(cm, onKeyDown));
|
||||||
on(inp, "keypress", operation(cm, onKeyPress));
|
on(inp, "keypress", operation(cm, onKeyPress));
|
||||||
on(inp, "focus", bind(onFocus, cm));
|
on(inp, "focus", function (e) { onFocus(cm, e); });
|
||||||
on(inp, "blur", bind(onBlur, cm));
|
on(inp, "blur", function (e) { onBlur(cm, e); });
|
||||||
}
|
}
|
||||||
|
|
||||||
function dragDropChanged(cm, value, old) {
|
function dragDropChanged(cm, value, old) {
|
||||||
|
@ -4262,12 +4274,12 @@
|
||||||
}, 100);
|
}, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
function onFocus(cm) {
|
function onFocus(cm, e) {
|
||||||
if (cm.state.delayingBlurEvent) cm.state.delayingBlurEvent = false;
|
if (cm.state.delayingBlurEvent) cm.state.delayingBlurEvent = false;
|
||||||
|
|
||||||
if (cm.options.readOnly == "nocursor") return;
|
if (cm.options.readOnly == "nocursor") return;
|
||||||
if (!cm.state.focused) {
|
if (!cm.state.focused) {
|
||||||
signal(cm, "focus", cm);
|
signal(cm, "focus", cm, e);
|
||||||
cm.state.focused = true;
|
cm.state.focused = true;
|
||||||
addClass(cm.display.wrapper, "CodeMirror-focused");
|
addClass(cm.display.wrapper, "CodeMirror-focused");
|
||||||
// This test prevents this from firing when a context
|
// This test prevents this from firing when a context
|
||||||
|
@ -4281,11 +4293,11 @@
|
||||||
}
|
}
|
||||||
restartBlink(cm);
|
restartBlink(cm);
|
||||||
}
|
}
|
||||||
function onBlur(cm) {
|
function onBlur(cm, e) {
|
||||||
if (cm.state.delayingBlurEvent) return;
|
if (cm.state.delayingBlurEvent) return;
|
||||||
|
|
||||||
if (cm.state.focused) {
|
if (cm.state.focused) {
|
||||||
signal(cm, "blur", cm);
|
signal(cm, "blur", cm, e);
|
||||||
cm.state.focused = false;
|
cm.state.focused = false;
|
||||||
rmClass(cm.display.wrapper, "CodeMirror-focused");
|
rmClass(cm.display.wrapper, "CodeMirror-focused");
|
||||||
}
|
}
|
||||||
|
@ -4907,7 +4919,8 @@
|
||||||
var doc = cm.doc, x = pos.left, y;
|
var doc = cm.doc, x = pos.left, y;
|
||||||
if (unit == "page") {
|
if (unit == "page") {
|
||||||
var pageSize = Math.min(cm.display.wrapper.clientHeight, window.innerHeight || document.documentElement.clientHeight);
|
var pageSize = Math.min(cm.display.wrapper.clientHeight, window.innerHeight || document.documentElement.clientHeight);
|
||||||
y = pos.top + dir * (pageSize - (dir < 0 ? 1.5 : .5) * textHeight(cm.display));
|
var moveAmount = Math.max(pageSize - .5 * textHeight(cm.display), 3);
|
||||||
|
y = (dir > 0 ? pos.bottom : pos.top) + dir * moveAmount;
|
||||||
} else if (unit == "line") {
|
} else if (unit == "line") {
|
||||||
y = dir > 0 ? pos.bottom + 3 : pos.top - 3;
|
y = dir > 0 ? pos.bottom + 3 : pos.top - 3;
|
||||||
}
|
}
|
||||||
|
@ -4960,7 +4973,10 @@
|
||||||
addOverlay: methodOp(function(spec, options) {
|
addOverlay: methodOp(function(spec, options) {
|
||||||
var mode = spec.token ? spec : CodeMirror.getMode(this.options, spec);
|
var mode = spec.token ? spec : CodeMirror.getMode(this.options, spec);
|
||||||
if (mode.startState) throw new Error("Overlays may not be stateful.");
|
if (mode.startState) throw new Error("Overlays may not be stateful.");
|
||||||
this.state.overlays.push({mode: mode, modeSpec: spec, opaque: options && options.opaque});
|
insertSorted(this.state.overlays,
|
||||||
|
{mode: mode, modeSpec: spec, opaque: options && options.opaque,
|
||||||
|
priority: (options && options.priority) || 0},
|
||||||
|
function(overlay) { return overlay.priority })
|
||||||
this.state.modeGen++;
|
this.state.modeGen++;
|
||||||
regChange(this);
|
regChange(this);
|
||||||
}),
|
}),
|
||||||
|
@ -5432,6 +5448,9 @@
|
||||||
option("inputStyle", mobile ? "contenteditable" : "textarea", function() {
|
option("inputStyle", mobile ? "contenteditable" : "textarea", function() {
|
||||||
throw new Error("inputStyle can not (yet) be changed in a running editor"); // FIXME
|
throw new Error("inputStyle can not (yet) be changed in a running editor"); // FIXME
|
||||||
}, true);
|
}, true);
|
||||||
|
option("spellcheck", false, function(cm, val) {
|
||||||
|
cm.getInputField().spellcheck = val
|
||||||
|
}, true);
|
||||||
option("rtlMoveVisually", !windows);
|
option("rtlMoveVisually", !windows);
|
||||||
option("wholeLineUpdateBefore", true);
|
option("wholeLineUpdateBefore", true);
|
||||||
|
|
||||||
|
@ -5541,6 +5560,8 @@
|
||||||
spec.name = found.name;
|
spec.name = found.name;
|
||||||
} else if (typeof spec == "string" && /^[\w\-]+\/[\w\-]+\+xml$/.test(spec)) {
|
} else if (typeof spec == "string" && /^[\w\-]+\/[\w\-]+\+xml$/.test(spec)) {
|
||||||
return CodeMirror.resolveMode("application/xml");
|
return CodeMirror.resolveMode("application/xml");
|
||||||
|
} else if (typeof spec == "string" && /^[\w\-]+\/[\w\-]+\+json$/.test(spec)) {
|
||||||
|
return CodeMirror.resolveMode("application/json");
|
||||||
}
|
}
|
||||||
if (typeof spec == "string") return {name: spec};
|
if (typeof spec == "string") return {name: spec};
|
||||||
else return spec || {name: "null"};
|
else return spec || {name: "null"};
|
||||||
|
@ -6852,7 +6873,7 @@
|
||||||
}
|
}
|
||||||
if (!flattenSpans || curStyle != style) {
|
if (!flattenSpans || curStyle != style) {
|
||||||
while (curStart < stream.start) {
|
while (curStart < stream.start) {
|
||||||
curStart = Math.min(stream.start, curStart + 50000);
|
curStart = Math.min(stream.start, curStart + 5000);
|
||||||
f(curStart, curStyle);
|
f(curStart, curStyle);
|
||||||
}
|
}
|
||||||
curStyle = style;
|
curStyle = style;
|
||||||
|
@ -6860,8 +6881,10 @@
|
||||||
stream.start = stream.pos;
|
stream.start = stream.pos;
|
||||||
}
|
}
|
||||||
while (curStart < stream.pos) {
|
while (curStart < stream.pos) {
|
||||||
// Webkit seems to refuse to render text nodes longer than 57444 characters
|
// Webkit seems to refuse to render text nodes longer than 57444
|
||||||
var pos = Math.min(stream.pos, curStart + 50000);
|
// characters, and returns inaccurate measurements in nodes
|
||||||
|
// starting around 5000 chars.
|
||||||
|
var pos = Math.min(stream.pos, curStart + 5000);
|
||||||
f(pos, curStyle);
|
f(pos, curStyle);
|
||||||
curStart = pos;
|
curStart = pos;
|
||||||
}
|
}
|
||||||
|
@ -7970,7 +7993,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
// Register a change in the history. Merges changes that are within
|
// Register a change in the history. Merges changes that are within
|
||||||
// a single operation, ore are close together with an origin that
|
// a single operation, or are close together with an origin that
|
||||||
// allows merging (starting with "+") into a single event.
|
// allows merging (starting with "+") into a single event.
|
||||||
function addChangeToHistory(doc, change, selAfter, opId) {
|
function addChangeToHistory(doc, change, selAfter, opId) {
|
||||||
if(change.origin == "ignoreHistory") return;
|
if(change.origin == "ignoreHistory") return;
|
||||||
|
@ -8374,6 +8397,12 @@
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function insertSorted(array, value, score) {
|
||||||
|
var pos = 0, priority = score(value)
|
||||||
|
while (pos < array.length && score(array[pos]) <= priority) pos++
|
||||||
|
array.splice(pos, 0, value)
|
||||||
|
}
|
||||||
|
|
||||||
function nothing() {}
|
function nothing() {}
|
||||||
|
|
||||||
function createObj(base, props) {
|
function createObj(base, props) {
|
||||||
|
@ -8942,7 +8971,7 @@
|
||||||
|
|
||||||
// THE END
|
// THE END
|
||||||
|
|
||||||
CodeMirror.version = "5.17.1";
|
CodeMirror.version = "5.19.0";
|
||||||
|
|
||||||
return CodeMirror;
|
return CodeMirror;
|
||||||
});
|
});
|
||||||
|
|
|
@ -62,7 +62,7 @@
|
||||||
var curPunc;
|
var curPunc;
|
||||||
var funcs = wordRegexp(["abs", "acos", "allShortestPaths", "asin", "atan", "atan2", "avg", "ceil", "coalesce", "collect", "cos", "cot", "count", "degrees", "e", "endnode", "exp", "extract", "filter", "floor", "haversin", "head", "id", "keys", "labels", "last", "left", "length", "log", "log10", "lower", "ltrim", "max", "min", "node", "nodes", "percentileCont", "percentileDisc", "pi", "radians", "rand", "range", "reduce", "rel", "relationship", "relationships", "replace", "reverse", "right", "round", "rtrim", "shortestPath", "sign", "sin", "size", "split", "sqrt", "startnode", "stdev", "stdevp", "str", "substring", "sum", "tail", "tan", "timestamp", "toFloat", "toInt", "toString", "trim", "type", "upper"]);
|
var funcs = wordRegexp(["abs", "acos", "allShortestPaths", "asin", "atan", "atan2", "avg", "ceil", "coalesce", "collect", "cos", "cot", "count", "degrees", "e", "endnode", "exp", "extract", "filter", "floor", "haversin", "head", "id", "keys", "labels", "last", "left", "length", "log", "log10", "lower", "ltrim", "max", "min", "node", "nodes", "percentileCont", "percentileDisc", "pi", "radians", "rand", "range", "reduce", "rel", "relationship", "relationships", "replace", "reverse", "right", "round", "rtrim", "shortestPath", "sign", "sin", "size", "split", "sqrt", "startnode", "stdev", "stdevp", "str", "substring", "sum", "tail", "tan", "timestamp", "toFloat", "toInt", "toString", "trim", "type", "upper"]);
|
||||||
var preds = wordRegexp(["all", "and", "any", "contains", "exists", "has", "in", "none", "not", "or", "single", "xor"]);
|
var preds = wordRegexp(["all", "and", "any", "contains", "exists", "has", "in", "none", "not", "or", "single", "xor"]);
|
||||||
var keywords = wordRegexp(["as", "asc", "ascending", "assert", "by", "case", "commit", "constraint", "create", "csv", "cypher", "delete", "desc", "descending", "detach", "distinct", "drop", "else", "end", "ends", "explain", "false", "fieldterminator", "foreach", "from", "headers", "in", "index", "is", "join", "limit", "load", "match", "merge", "null", "on", "optional", "order", "periodic", "profile", "remove", "return", "scan", "set", "skip", "start", "starts", "then", "true", "union", "unique", "unwind", "using", "when", "where", "with"]);
|
var keywords = wordRegexp(["as", "asc", "ascending", "assert", "by", "case", "commit", "constraint", "create", "csv", "cypher", "delete", "desc", "descending", "detach", "distinct", "drop", "else", "end", "ends", "explain", "false", "fieldterminator", "foreach", "from", "headers", "in", "index", "is", "join", "limit", "load", "match", "merge", "null", "on", "optional", "order", "periodic", "profile", "remove", "return", "scan", "set", "skip", "start", "starts", "then", "true", "union", "unique", "unwind", "using", "when", "where", "with", "call", "yield"]);
|
||||||
var operatorChars = /[*+\-<>=&|~%^]/;
|
var operatorChars = /[*+\-<>=&|~%^]/;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -433,15 +433,16 @@ CodeMirror.defineMode("erlang", function(cmCfg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function maybe_drop_post(s) {
|
function maybe_drop_post(s) {
|
||||||
|
if (!s.length) return s
|
||||||
var last = s.length-1;
|
var last = s.length-1;
|
||||||
|
|
||||||
if (s[last].type === "dot") {
|
if (s[last].type === "dot") {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
if (s[last].type === "fun" && s[last-1].token === "fun") {
|
if (last > 1 && s[last].type === "fun" && s[last-1].token === "fun") {
|
||||||
return s.slice(0,last-1);
|
return s.slice(0,last-1);
|
||||||
}
|
}
|
||||||
switch (s[s.length-1].token) {
|
switch (s[last].token) {
|
||||||
case "}": return d(s,{g:["{"]});
|
case "}": return d(s,{g:["{"]});
|
||||||
case "]": return d(s,{i:["["]});
|
case "]": return d(s,{i:["["]});
|
||||||
case ")": return d(s,{i:["("]});
|
case ")": return d(s,{i:["("]});
|
||||||
|
|
|
@ -46,7 +46,7 @@
|
||||||
|
|
||||||
function getAttrValue(text, attr) {
|
function getAttrValue(text, attr) {
|
||||||
var match = text.match(getAttrRegexp(attr))
|
var match = text.match(getAttrRegexp(attr))
|
||||||
return match ? match[2] : ""
|
return match ? /^\s*(.*?)\s*$/.exec(match[2])[1] : ""
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTagRegexp(tagName, anchored) {
|
function getTagRegexp(tagName, anchored) {
|
||||||
|
|
|
@ -76,7 +76,6 @@ option.</p>
|
||||||
<li><a href="http/index.html">HTTP</a></li>
|
<li><a href="http/index.html">HTTP</a></li>
|
||||||
<li><a href="idl/index.html">IDL</a></li>
|
<li><a href="idl/index.html">IDL</a></li>
|
||||||
<li><a href="clike/index.html">Java</a></li>
|
<li><a href="clike/index.html">Java</a></li>
|
||||||
<li><a href="jade/index.html">Jade</a></li>
|
|
||||||
<li><a href="javascript/index.html">JavaScript</a> (<a href="jsx/index.html">JSX</a>)</li>
|
<li><a href="javascript/index.html">JavaScript</a> (<a href="jsx/index.html">JSX</a>)</li>
|
||||||
<li><a href="jinja2/index.html">Jinja2</a></li>
|
<li><a href="jinja2/index.html">Jinja2</a></li>
|
||||||
<li><a href="julia/index.html">Julia</a></li>
|
<li><a href="julia/index.html">Julia</a></li>
|
||||||
|
@ -107,6 +106,7 @@ option.</p>
|
||||||
<li><a href="powershell/index.html">PowerShell</a></li>
|
<li><a href="powershell/index.html">PowerShell</a></li>
|
||||||
<li><a href="properties/index.html">Properties files</a></li>
|
<li><a href="properties/index.html">Properties files</a></li>
|
||||||
<li><a href="protobuf/index.html">ProtoBuf</a></li>
|
<li><a href="protobuf/index.html">ProtoBuf</a></li>
|
||||||
|
<li><a href="pug/index.html">Pug</a></li>
|
||||||
<li><a href="puppet/index.html">Puppet</a></li>
|
<li><a href="puppet/index.html">Puppet</a></li>
|
||||||
<li><a href="python/index.html">Python</a></li>
|
<li><a href="python/index.html">Python</a></li>
|
||||||
<li><a href="q/index.html">Q</a></li>
|
<li><a href="q/index.html">Q</a></li>
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||||
|
|
||||||
// TODO actually recognize syntax of TypeScript constructs
|
|
||||||
|
|
||||||
(function(mod) {
|
(function(mod) {
|
||||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||||
mod(require("../../lib/codemirror"));
|
mod(require("../../lib/codemirror"));
|
||||||
|
@ -56,6 +54,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
||||||
"namespace": C,
|
"namespace": C,
|
||||||
"module": kw("module"),
|
"module": kw("module"),
|
||||||
"enum": kw("module"),
|
"enum": kw("module"),
|
||||||
|
"type": kw("type"),
|
||||||
|
|
||||||
// scope modifiers
|
// scope modifiers
|
||||||
"public": kw("modifier"),
|
"public": kw("modifier"),
|
||||||
|
@ -345,19 +344,19 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
||||||
|
|
||||||
function statement(type, value) {
|
function statement(type, value) {
|
||||||
if (type == "var") return cont(pushlex("vardef", value.length), vardef, expect(";"), poplex);
|
if (type == "var") return cont(pushlex("vardef", value.length), vardef, expect(";"), poplex);
|
||||||
if (type == "keyword a") return cont(pushlex("form"), expression, statement, poplex);
|
if (type == "keyword a") return cont(pushlex("form"), parenExpr, statement, poplex);
|
||||||
if (type == "keyword b") return cont(pushlex("form"), statement, poplex);
|
if (type == "keyword b") return cont(pushlex("form"), statement, poplex);
|
||||||
if (type == "{") return cont(pushlex("}"), block, poplex);
|
if (type == "{") return cont(pushlex("}"), block, poplex);
|
||||||
if (type == ";") return cont();
|
if (type == ";") return cont();
|
||||||
if (type == "if") {
|
if (type == "if") {
|
||||||
if (cx.state.lexical.info == "else" && cx.state.cc[cx.state.cc.length - 1] == poplex)
|
if (cx.state.lexical.info == "else" && cx.state.cc[cx.state.cc.length - 1] == poplex)
|
||||||
cx.state.cc.pop()();
|
cx.state.cc.pop()();
|
||||||
return cont(pushlex("form"), expression, statement, poplex, maybeelse);
|
return cont(pushlex("form"), parenExpr, statement, poplex, maybeelse);
|
||||||
}
|
}
|
||||||
if (type == "function") return cont(functiondef);
|
if (type == "function") return cont(functiondef);
|
||||||
if (type == "for") return cont(pushlex("form"), forspec, statement, poplex);
|
if (type == "for") return cont(pushlex("form"), forspec, statement, poplex);
|
||||||
if (type == "variable") return cont(pushlex("stat"), maybelabel);
|
if (type == "variable") return cont(pushlex("stat"), maybelabel);
|
||||||
if (type == "switch") return cont(pushlex("form"), expression, pushlex("}", "switch"), expect("{"),
|
if (type == "switch") return cont(pushlex("form"), parenExpr, pushlex("}", "switch"), expect("{"),
|
||||||
block, poplex, poplex);
|
block, poplex, poplex);
|
||||||
if (type == "case") return cont(expression, expect(":"));
|
if (type == "case") return cont(expression, expect(":"));
|
||||||
if (type == "default") return cont(expect(":"));
|
if (type == "default") return cont(expect(":"));
|
||||||
|
@ -367,6 +366,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
||||||
if (type == "export") return cont(pushlex("stat"), afterExport, poplex);
|
if (type == "export") return cont(pushlex("stat"), afterExport, poplex);
|
||||||
if (type == "import") return cont(pushlex("stat"), afterImport, poplex);
|
if (type == "import") return cont(pushlex("stat"), afterImport, poplex);
|
||||||
if (type == "module") return cont(pushlex("form"), pattern, pushlex("}"), expect("{"), block, poplex, poplex)
|
if (type == "module") return cont(pushlex("form"), pattern, pushlex("}"), expect("{"), block, poplex, poplex)
|
||||||
|
if (type == "type") return cont(typeexpr, expect("operator"), typeexpr, expect(";"));
|
||||||
if (type == "async") return cont(statement)
|
if (type == "async") return cont(statement)
|
||||||
return pass(pushlex("stat"), expression, expect(";"), poplex);
|
return pass(pushlex("stat"), expression, expect(";"), poplex);
|
||||||
}
|
}
|
||||||
|
@ -376,6 +376,10 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
||||||
function expressionNoComma(type) {
|
function expressionNoComma(type) {
|
||||||
return expressionInner(type, true);
|
return expressionInner(type, true);
|
||||||
}
|
}
|
||||||
|
function parenExpr(type) {
|
||||||
|
if (type != "(") return pass()
|
||||||
|
return cont(pushlex(")"), expression, expect(")"), poplex)
|
||||||
|
}
|
||||||
function expressionInner(type, noComma) {
|
function expressionInner(type, noComma) {
|
||||||
if (cx.state.fatArrowAt == cx.stream.start) {
|
if (cx.state.fatArrowAt == cx.stream.start) {
|
||||||
var body = noComma ? arrowBodyNoComma : arrowBody;
|
var body = noComma ? arrowBodyNoComma : arrowBody;
|
||||||
|
@ -463,8 +467,10 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
||||||
if (type == "variable") {cx.marked = "property"; return cont();}
|
if (type == "variable") {cx.marked = "property"; return cont();}
|
||||||
}
|
}
|
||||||
function objprop(type, value) {
|
function objprop(type, value) {
|
||||||
if (type == "async") return cont(objprop);
|
if (type == "async") {
|
||||||
if (type == "variable" || cx.style == "keyword") {
|
cx.marked = "property";
|
||||||
|
return cont(objprop);
|
||||||
|
} else if (type == "variable" || cx.style == "keyword") {
|
||||||
cx.marked = "property";
|
cx.marked = "property";
|
||||||
if (value == "get" || value == "set") return cont(getterSetter);
|
if (value == "get" || value == "set") return cont(getterSetter);
|
||||||
return cont(afterprop);
|
return cont(afterprop);
|
||||||
|
@ -479,6 +485,8 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
||||||
return cont(expression, expect("]"), afterprop);
|
return cont(expression, expect("]"), afterprop);
|
||||||
} else if (type == "spread") {
|
} else if (type == "spread") {
|
||||||
return cont(expression);
|
return cont(expression);
|
||||||
|
} else if (type == ":") {
|
||||||
|
return pass(afterprop)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function getterSetter(type) {
|
function getterSetter(type) {
|
||||||
|
@ -517,14 +525,34 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
||||||
if (type == "}") return cont();
|
if (type == "}") return cont();
|
||||||
return pass(statement, block);
|
return pass(statement, block);
|
||||||
}
|
}
|
||||||
function maybetype(type) {
|
function maybetype(type, value) {
|
||||||
if (isTS && type == ":") return cont(typeexpr);
|
if (isTS) {
|
||||||
|
if (type == ":") return cont(typeexpr);
|
||||||
|
if (value == "?") return cont(maybetype);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
function maybedefault(_, value) {
|
function maybedefault(_, value) {
|
||||||
if (value == "=") return cont(expressionNoComma);
|
if (value == "=") return cont(expressionNoComma);
|
||||||
}
|
}
|
||||||
function typeexpr(type) {
|
function typeexpr(type) {
|
||||||
if (type == "variable") {cx.marked = "variable-3"; return cont(afterType);}
|
if (type == "variable") {cx.marked = "variable-3"; return cont(afterType);}
|
||||||
|
if (type == "{") return cont(commasep(typeprop, "}"))
|
||||||
|
if (type == "(") return cont(commasep(typearg, ")"), maybeReturnType)
|
||||||
|
}
|
||||||
|
function maybeReturnType(type) {
|
||||||
|
if (type == "=>") return cont(typeexpr)
|
||||||
|
}
|
||||||
|
function typeprop(type) {
|
||||||
|
if (type == "variable" || cx.style == "keyword") {
|
||||||
|
cx.marked = "property"
|
||||||
|
return cont(typeprop)
|
||||||
|
} else if (type == ":") {
|
||||||
|
return cont(typeexpr)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function typearg(type) {
|
||||||
|
if (type == "variable") return cont(typearg)
|
||||||
|
else if (type == ":") return cont(typeexpr)
|
||||||
}
|
}
|
||||||
function afterType(type, value) {
|
function afterType(type, value) {
|
||||||
if (value == "<") return cont(commasep(typeexpr, ">"), afterType)
|
if (value == "<") return cont(commasep(typeexpr, ">"), afterType)
|
||||||
|
@ -593,18 +621,19 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
||||||
if (type == "variable") {register(value); return cont(classNameAfter);}
|
if (type == "variable") {register(value); return cont(classNameAfter);}
|
||||||
}
|
}
|
||||||
function classNameAfter(type, value) {
|
function classNameAfter(type, value) {
|
||||||
if (value == "extends") return cont(expression, classNameAfter);
|
if (value == "extends") return cont(isTS ? typeexpr : expression, classNameAfter);
|
||||||
if (type == "{") return cont(pushlex("}"), classBody, poplex);
|
if (type == "{") return cont(pushlex("}"), classBody, poplex);
|
||||||
}
|
}
|
||||||
function classBody(type, value) {
|
function classBody(type, value) {
|
||||||
if (type == "variable" || cx.style == "keyword") {
|
if (type == "variable" || cx.style == "keyword") {
|
||||||
if (value == "static") {
|
if ((value == "static" || value == "get" || value == "set" ||
|
||||||
|
(isTS && (value == "public" || value == "private" || value == "protected"))) &&
|
||||||
|
cx.stream.match(/^\s+[\w$\xa1-\uffff]/, false)) {
|
||||||
cx.marked = "keyword";
|
cx.marked = "keyword";
|
||||||
return cont(classBody);
|
return cont(classBody);
|
||||||
}
|
}
|
||||||
cx.marked = "property";
|
cx.marked = "property";
|
||||||
if (value == "get" || value == "set") return cont(classGetterSetter, functiondef, classBody);
|
return cont(isTS ? classfield : functiondef, classBody);
|
||||||
return cont(functiondef, classBody);
|
|
||||||
}
|
}
|
||||||
if (value == "*") {
|
if (value == "*") {
|
||||||
cx.marked = "keyword";
|
cx.marked = "keyword";
|
||||||
|
@ -613,10 +642,9 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
||||||
if (type == ";") return cont(classBody);
|
if (type == ";") return cont(classBody);
|
||||||
if (type == "}") return cont();
|
if (type == "}") return cont();
|
||||||
}
|
}
|
||||||
function classGetterSetter(type) {
|
function classfield(type) {
|
||||||
if (type != "variable") return pass();
|
if (type == ":") return cont(typeexpr)
|
||||||
cx.marked = "property";
|
return pass(functiondef)
|
||||||
return cont();
|
|
||||||
}
|
}
|
||||||
function afterExport(_type, value) {
|
function afterExport(_type, value) {
|
||||||
if (value == "*") { cx.marked = "keyword"; return cont(maybeFrom, expect(";")); }
|
if (value == "*") { cx.marked = "keyword"; return cont(maybeFrom, expect(";")); }
|
||||||
|
@ -685,14 +713,18 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
||||||
indent: function(state, textAfter) {
|
indent: function(state, textAfter) {
|
||||||
if (state.tokenize == tokenComment) return CodeMirror.Pass;
|
if (state.tokenize == tokenComment) return CodeMirror.Pass;
|
||||||
if (state.tokenize != tokenBase) return 0;
|
if (state.tokenize != tokenBase) return 0;
|
||||||
var firstChar = textAfter && textAfter.charAt(0), lexical = state.lexical;
|
var firstChar = textAfter && textAfter.charAt(0), lexical = state.lexical, top
|
||||||
// Kludge to prevent 'maybelse' from blocking lexical scope pops
|
// Kludge to prevent 'maybelse' from blocking lexical scope pops
|
||||||
if (!/^\s*else\b/.test(textAfter)) for (var i = state.cc.length - 1; i >= 0; --i) {
|
if (!/^\s*else\b/.test(textAfter)) for (var i = state.cc.length - 1; i >= 0; --i) {
|
||||||
var c = state.cc[i];
|
var c = state.cc[i];
|
||||||
if (c == poplex) lexical = lexical.prev;
|
if (c == poplex) lexical = lexical.prev;
|
||||||
else if (c != maybeelse) break;
|
else if (c != maybeelse) break;
|
||||||
}
|
}
|
||||||
if (lexical.type == "stat" && firstChar == "}") lexical = lexical.prev;
|
while ((lexical.type == "stat" || lexical.type == "form") &&
|
||||||
|
(firstChar == "}" || ((top = state.cc[state.cc.length - 1]) &&
|
||||||
|
(top == maybeoperatorComma || top == maybeoperatorNoComma) &&
|
||||||
|
!/^[,\.=+\-*:?[\(]/.test(textAfter))))
|
||||||
|
lexical = lexical.prev;
|
||||||
if (statementIndent && lexical.type == ")" && lexical.prev.type == "stat")
|
if (statementIndent && lexical.type == ")" && lexical.prev.type == "stat")
|
||||||
lexical = lexical.prev;
|
lexical = lexical.prev;
|
||||||
var type = lexical.type, closing = firstChar == type;
|
var type = lexical.type, closing = firstChar == type;
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
|
|
||||||
MT("class",
|
MT("class",
|
||||||
"[keyword class] [def Point] [keyword extends] [variable SuperThing] {",
|
"[keyword class] [def Point] [keyword extends] [variable SuperThing] {",
|
||||||
" [property get] [property prop]() { [keyword return] [number 24]; }",
|
" [keyword get] [property prop]() { [keyword return] [number 24]; }",
|
||||||
" [property constructor]([def x], [def y]) {",
|
" [property constructor]([def x], [def y]) {",
|
||||||
" [keyword super]([string 'something']);",
|
" [keyword super]([string 'something']);",
|
||||||
" [keyword this].[property x] [operator =] [variable-2 x];",
|
" [keyword this].[property x] [operator =] [variable-2 x];",
|
||||||
|
@ -140,6 +140,19 @@
|
||||||
" [number 1];",
|
" [number 1];",
|
||||||
"[number 2];");
|
"[number 2];");
|
||||||
|
|
||||||
|
MT("indent_semicolonless_if",
|
||||||
|
"[keyword function] [def foo]() {",
|
||||||
|
" [keyword if] ([variable x])",
|
||||||
|
" [variable foo]()",
|
||||||
|
"}")
|
||||||
|
|
||||||
|
MT("indent_semicolonless_if_with_statement",
|
||||||
|
"[keyword function] [def foo]() {",
|
||||||
|
" [keyword if] ([variable x])",
|
||||||
|
" [variable foo]()",
|
||||||
|
" [variable bar]()",
|
||||||
|
"}")
|
||||||
|
|
||||||
MT("multilinestring",
|
MT("multilinestring",
|
||||||
"[keyword var] [def x] [operator =] [string 'foo\\]",
|
"[keyword var] [def x] [operator =] [string 'foo\\]",
|
||||||
"[string bar'];");
|
"[string bar'];");
|
||||||
|
@ -167,6 +180,23 @@
|
||||||
" }",
|
" }",
|
||||||
"}");
|
"}");
|
||||||
|
|
||||||
|
var ts_mode = CodeMirror.getMode({indentUnit: 2}, "application/typescript")
|
||||||
|
function TS(name) {
|
||||||
|
test.mode(name, ts_mode, Array.prototype.slice.call(arguments, 1))
|
||||||
|
}
|
||||||
|
|
||||||
|
TS("extend_type",
|
||||||
|
"[keyword class] [def Foo] [keyword extends] [variable-3 Some][operator <][variable-3 Type][operator >] {}")
|
||||||
|
|
||||||
|
TS("arrow_type",
|
||||||
|
"[keyword let] [def x]: ([variable arg]: [variable-3 Type]) [operator =>] [variable-3 ReturnType]")
|
||||||
|
|
||||||
|
TS("typescript_class",
|
||||||
|
"[keyword class] [def Foo] {",
|
||||||
|
" [keyword public] [keyword static] [property main]() {}",
|
||||||
|
" [keyword private] [property _foo]: [variable-3 string];",
|
||||||
|
"}")
|
||||||
|
|
||||||
var jsonld_mode = CodeMirror.getMode(
|
var jsonld_mode = CodeMirror.getMode(
|
||||||
{indentUnit: 2},
|
{indentUnit: 2},
|
||||||
{name: "javascript", jsonld: true}
|
{name: "javascript", jsonld: true}
|
||||||
|
|
|
@ -84,6 +84,6 @@ var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
||||||
<p>JSX Mode for <a href="http://facebook.github.io/react">React</a>'s
|
<p>JSX Mode for <a href="http://facebook.github.io/react">React</a>'s
|
||||||
JavaScript syntax extension.</p>
|
JavaScript syntax extension.</p>
|
||||||
|
|
||||||
<p><strong>MIME types defined:</strong> <code>text/jsx</code>.</p>
|
<p><strong>MIME types defined:</strong> <code>text/jsx</code>, <code>text/typescript-jsx</code>.</p>
|
||||||
|
|
||||||
</article>
|
</article>
|
||||||
|
|
|
@ -144,4 +144,5 @@
|
||||||
}, "xml", "javascript")
|
}, "xml", "javascript")
|
||||||
|
|
||||||
CodeMirror.defineMIME("text/jsx", "jsx")
|
CodeMirror.defineMIME("text/jsx", "jsx")
|
||||||
|
CodeMirror.defineMIME("text/typescript-jsx", {name: "jsx", base: {name: "javascript", typescript: true}})
|
||||||
});
|
});
|
||||||
|
|
|
@ -50,7 +50,7 @@
|
||||||
startState: function(){
|
startState: function(){
|
||||||
return {
|
return {
|
||||||
next: 'start',
|
next: 'start',
|
||||||
lastToken: null
|
lastToken: {style: null, indent: 0, content: ""}
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
token: function(stream, state){
|
token: function(stream, state){
|
||||||
|
|
|
@ -56,7 +56,7 @@
|
||||||
{name: "Gherkin", mime: "text/x-feature", mode: "gherkin", ext: ["feature"]},
|
{name: "Gherkin", mime: "text/x-feature", mode: "gherkin", ext: ["feature"]},
|
||||||
{name: "GitHub Flavored Markdown", mime: "text/x-gfm", mode: "gfm", file: /^(readme|contributing|history).md$/i},
|
{name: "GitHub Flavored Markdown", mime: "text/x-gfm", mode: "gfm", file: /^(readme|contributing|history).md$/i},
|
||||||
{name: "Go", mime: "text/x-go", mode: "go", ext: ["go"]},
|
{name: "Go", mime: "text/x-go", mode: "go", ext: ["go"]},
|
||||||
{name: "Groovy", mime: "text/x-groovy", mode: "groovy", ext: ["groovy", "gradle"]},
|
{name: "Groovy", mime: "text/x-groovy", mode: "groovy", ext: ["groovy", "gradle"], file: /^Jenkinsfile$/},
|
||||||
{name: "HAML", mime: "text/x-haml", mode: "haml", ext: ["haml"]},
|
{name: "HAML", mime: "text/x-haml", mode: "haml", ext: ["haml"]},
|
||||||
{name: "Haskell", mime: "text/x-haskell", mode: "haskell", ext: ["hs"]},
|
{name: "Haskell", mime: "text/x-haskell", mode: "haskell", ext: ["hs"]},
|
||||||
{name: "Haskell (Literate)", mime: "text/x-literate-haskell", mode: "haskell-literate", ext: ["lhs"]},
|
{name: "Haskell (Literate)", mime: "text/x-literate-haskell", mode: "haskell-literate", ext: ["lhs"]},
|
||||||
|
@ -66,7 +66,7 @@
|
||||||
{name: "HTML", mime: "text/html", mode: "htmlmixed", ext: ["html", "htm"], alias: ["xhtml"]},
|
{name: "HTML", mime: "text/html", mode: "htmlmixed", ext: ["html", "htm"], alias: ["xhtml"]},
|
||||||
{name: "HTTP", mime: "message/http", mode: "http"},
|
{name: "HTTP", mime: "message/http", mode: "http"},
|
||||||
{name: "IDL", mime: "text/x-idl", mode: "idl", ext: ["pro"]},
|
{name: "IDL", mime: "text/x-idl", mode: "idl", ext: ["pro"]},
|
||||||
{name: "Jade", mime: "text/x-jade", mode: "jade", ext: ["jade"]},
|
{name: "Pug", mime: "text/x-pug", mode: "pug", ext: ["jade", "pug"], alias: ["jade"]},
|
||||||
{name: "Java", mime: "text/x-java", mode: "clike", ext: ["java"]},
|
{name: "Java", mime: "text/x-java", mode: "clike", ext: ["java"]},
|
||||||
{name: "Java Server Pages", mime: "application/x-jsp", mode: "htmlembedded", ext: ["jsp"], alias: ["jsp"]},
|
{name: "Java Server Pages", mime: "application/x-jsp", mode: "htmlembedded", ext: ["jsp"], alias: ["jsp"]},
|
||||||
{name: "JavaScript", mimes: ["text/javascript", "text/ecmascript", "application/javascript", "application/x-javascript", "application/ecmascript"],
|
{name: "JavaScript", mimes: ["text/javascript", "text/ecmascript", "application/javascript", "application/x-javascript", "application/ecmascript"],
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<!doctype html>
|
<!doctype html>
|
||||||
|
|
||||||
<title>CodeMirror: Jade Templating Mode</title>
|
<title>CodeMirror: Pug Templating Mode</title>
|
||||||
<meta charset="utf-8"/>
|
<meta charset="utf-8"/>
|
||||||
<link rel=stylesheet href="../../doc/docs.css">
|
<link rel=stylesheet href="../../doc/docs.css">
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@
|
||||||
<script src="../css/css.js"></script>
|
<script src="../css/css.js"></script>
|
||||||
<script src="../xml/xml.js"></script>
|
<script src="../xml/xml.js"></script>
|
||||||
<script src="../htmlmixed/htmlmixed.js"></script>
|
<script src="../htmlmixed/htmlmixed.js"></script>
|
||||||
<script src="jade.js"></script>
|
<script src="pug.js"></script>
|
||||||
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
|
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
|
||||||
<div id=nav>
|
<div id=nav>
|
||||||
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
|
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
|
||||||
|
@ -22,17 +22,17 @@
|
||||||
</ul>
|
</ul>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="../index.html">Language modes</a>
|
<li><a href="../index.html">Language modes</a>
|
||||||
<li><a class=active href="#">Jade Templating Mode</a>
|
<li><a class=active href="#">Pug Templating Mode</a>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<article>
|
<article>
|
||||||
<h2>Jade Templating Mode</h2>
|
<h2>Pug Templating Mode</h2>
|
||||||
<form><textarea id="code" name="code">
|
<form><textarea id="code" name="code">
|
||||||
doctype html
|
doctype html
|
||||||
html
|
html
|
||||||
head
|
head
|
||||||
title= "Jade Templating CodeMirror Mode Example"
|
title= "Pug Templating CodeMirror Mode Example"
|
||||||
link(rel='stylesheet', href='/css/bootstrap.min.css')
|
link(rel='stylesheet', href='/css/bootstrap.min.css')
|
||||||
link(rel='stylesheet', href='/css/index.css')
|
link(rel='stylesheet', href='/css/index.css')
|
||||||
script(type='text/javascript', src='/js/jquery-1.9.1.min.js')
|
script(type='text/javascript', src='/js/jquery-1.9.1.min.js')
|
||||||
|
@ -60,11 +60,11 @@ doctype html
|
||||||
</textarea></form>
|
</textarea></form>
|
||||||
<script>
|
<script>
|
||||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
||||||
mode: {name: "jade", alignCDATA: true},
|
mode: {name: "pug", alignCDATA: true},
|
||||||
lineNumbers: true
|
lineNumbers: true
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
<h3>The Jade Templating Mode</h3>
|
<h3>The Pug Templating Mode</h3>
|
||||||
<p> Created by Forbes Lindesay. Managed as part of a Brackets extension at <a href="https://github.com/ForbesLindesay/jade-brackets">https://github.com/ForbesLindesay/jade-brackets</a>.</p>
|
<p> Created by Forbes Lindesay. Managed as part of a Brackets extension at <a href="https://github.com/ForbesLindesay/jade-brackets">https://github.com/ForbesLindesay/jade-brackets</a>.</p>
|
||||||
<p><strong>MIME type defined:</strong> <code>text/x-jade</code>.</p>
|
<p><strong>MIME type defined:</strong> <code>text/x-pug</code>, <code>text/x-jade</code>.</p>
|
||||||
</article>
|
</article>
|
|
@ -11,7 +11,7 @@
|
||||||
})(function(CodeMirror) {
|
})(function(CodeMirror) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
CodeMirror.defineMode('jade', function (config) {
|
CodeMirror.defineMode("pug", function (config) {
|
||||||
// token types
|
// token types
|
||||||
var KEYWORD = 'keyword';
|
var KEYWORD = 'keyword';
|
||||||
var DOCTYPE = 'meta';
|
var DOCTYPE = 'meta';
|
||||||
|
@ -585,6 +585,7 @@ CodeMirror.defineMode('jade', function (config) {
|
||||||
};
|
};
|
||||||
}, 'javascript', 'css', 'htmlmixed');
|
}, 'javascript', 'css', 'htmlmixed');
|
||||||
|
|
||||||
CodeMirror.defineMIME('text/x-jade', 'jade');
|
CodeMirror.defineMIME('text/x-pug', 'pug');
|
||||||
|
CodeMirror.defineMIME('text/x-jade', 'pug');
|
||||||
|
|
||||||
});
|
});
|
|
@ -176,7 +176,7 @@ def pairwise_cython(double[:, ::1] X):
|
||||||
</script>
|
</script>
|
||||||
<h2>Configuration Options for Python mode:</h2>
|
<h2>Configuration Options for Python mode:</h2>
|
||||||
<ul>
|
<ul>
|
||||||
<li>version - 2/3 - The version of Python to recognize. Default is 2.</li>
|
<li>version - 2/3 - The version of Python to recognize. Default is 3.</li>
|
||||||
<li>singleLineStringErrors - true/false - If you have a single-line string that is not terminated at the end of the line, this will show subsequent lines as errors if true, otherwise it will consider the newline as the end of the string. Default is false.</li>
|
<li>singleLineStringErrors - true/false - If you have a single-line string that is not terminated at the end of the line, this will show subsequent lines as errors if true, otherwise it will consider the newline as the end of the string. Default is false.</li>
|
||||||
<li>hangingIndent - int - If you want to write long arguments to a function starting on a new line, how much that line should be indented. Defaults to one normal indentation unit.</li>
|
<li>hangingIndent - int - If you want to write long arguments to a function starting on a new line, how much that line should be indented. Defaults to one normal indentation unit.</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -55,7 +55,7 @@
|
||||||
if (parserConf.extra_builtins != undefined)
|
if (parserConf.extra_builtins != undefined)
|
||||||
myBuiltins = myBuiltins.concat(parserConf.extra_builtins);
|
myBuiltins = myBuiltins.concat(parserConf.extra_builtins);
|
||||||
|
|
||||||
var py3 = parserConf.version && parseInt(parserConf.version, 10) == 3
|
var py3 = !(parserConf.version && Number(parserConf.version) < 3)
|
||||||
if (py3) {
|
if (py3) {
|
||||||
// since http://legacy.python.org/dev/peps/pep-0465/ @ is also an operator
|
// since http://legacy.python.org/dev/peps/pep-0465/ @ is also an operator
|
||||||
var singleOperators = parserConf.singleOperators || /^[\+\-\*\/%&|\^~<>!@]/;
|
var singleOperators = parserConf.singleOperators || /^[\+\-\*\/%&|\^~<>!@]/;
|
||||||
|
@ -185,7 +185,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function tokenStringFactory(delimiter) {
|
function tokenStringFactory(delimiter) {
|
||||||
while ("rub".indexOf(delimiter.charAt(0).toLowerCase()) >= 0)
|
while ("rubf".indexOf(delimiter.charAt(0).toLowerCase()) >= 0)
|
||||||
delimiter = delimiter.substr(1);
|
delimiter = delimiter.substr(1);
|
||||||
|
|
||||||
var singleline = delimiter.length == 1;
|
var singleline = delimiter.length == 1;
|
||||||
|
|
|
@ -137,12 +137,13 @@
|
||||||
stream.next();
|
stream.next();
|
||||||
return 'comment';
|
return 'comment';
|
||||||
}
|
}
|
||||||
} else if (!state.continueString && (ch === '"' || ch === "'")) {
|
} else if ((ch === '"' || ch === "'") && !state.continueString) {
|
||||||
// Have we found a string?
|
state.continueString = ch
|
||||||
state.continueString = ch; //save the matching quote in the state
|
return "string"
|
||||||
return "string";
|
} else if (state.continueString) {
|
||||||
} else if (state.continueString !== null) {
|
if (state.continueString == ch) {
|
||||||
if (stream.skipTo(state.continueString)) {
|
state.continueString = null;
|
||||||
|
} else if (stream.skipTo(state.continueString)) {
|
||||||
// quote found on this line
|
// quote found on this line
|
||||||
stream.next();
|
stream.next();
|
||||||
state.continueString = null;
|
state.continueString = null;
|
||||||
|
@ -187,12 +188,12 @@
|
||||||
if (stream.peek() === '.') stream.skipTo(' ');
|
if (stream.peek() === '.') stream.skipTo(' ');
|
||||||
state.nextword = false;
|
state.nextword = false;
|
||||||
return 'variable-2';
|
return 'variable-2';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
word = word.toLowerCase()
|
||||||
// Are we in a DATA Step?
|
// Are we in a DATA Step?
|
||||||
if (state.inDataStep) {
|
if (state.inDataStep) {
|
||||||
if (word.toLowerCase() === 'run;' || stream.match(/run\s;/)) {
|
if (word === 'run;' || stream.match(/run\s;/)) {
|
||||||
state.inDataStep = false;
|
state.inDataStep = false;
|
||||||
return 'builtin';
|
return 'builtin';
|
||||||
}
|
}
|
||||||
|
@ -203,84 +204,84 @@
|
||||||
else return 'variable';
|
else return 'variable';
|
||||||
}
|
}
|
||||||
// do we have a DATA Step keyword
|
// do we have a DATA Step keyword
|
||||||
if (word && words.hasOwnProperty(word.toLowerCase()) &&
|
if (word && words.hasOwnProperty(word) &&
|
||||||
(words[word.toLowerCase()].state.indexOf("inDataStep") !== -1 ||
|
(words[word].state.indexOf("inDataStep") !== -1 ||
|
||||||
words[word.toLowerCase()].state.indexOf("ALL") !== -1)) {
|
words[word].state.indexOf("ALL") !== -1)) {
|
||||||
//backup to the start of the word
|
//backup to the start of the word
|
||||||
if (stream.start < stream.pos)
|
if (stream.start < stream.pos)
|
||||||
stream.backUp(stream.pos - stream.start);
|
stream.backUp(stream.pos - stream.start);
|
||||||
//advance the length of the word and return
|
//advance the length of the word and return
|
||||||
for (var i = 0; i < word.length; ++i) stream.next();
|
for (var i = 0; i < word.length; ++i) stream.next();
|
||||||
return words[word.toLowerCase()].style;
|
return words[word].style;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Are we in an Proc statement?
|
// Are we in an Proc statement?
|
||||||
if (state.inProc) {
|
if (state.inProc) {
|
||||||
if (word.toLowerCase() === 'run;' || word.toLowerCase() === 'quit;') {
|
if (word === 'run;' || word === 'quit;') {
|
||||||
state.inProc = false;
|
state.inProc = false;
|
||||||
return 'builtin';
|
return 'builtin';
|
||||||
}
|
}
|
||||||
// do we have a proc keyword
|
// do we have a proc keyword
|
||||||
if (word && words.hasOwnProperty(word.toLowerCase()) &&
|
if (word && words.hasOwnProperty(word) &&
|
||||||
(words[word.toLowerCase()].state.indexOf("inProc") !== -1 ||
|
(words[word].state.indexOf("inProc") !== -1 ||
|
||||||
words[word.toLowerCase()].state.indexOf("ALL") !== -1)) {
|
words[word].state.indexOf("ALL") !== -1)) {
|
||||||
stream.match(/[\w]+/);
|
stream.match(/[\w]+/);
|
||||||
return words[word].style;
|
return words[word].style;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Are we in a Macro statement?
|
// Are we in a Macro statement?
|
||||||
if (state.inMacro) {
|
if (state.inMacro) {
|
||||||
if (word.toLowerCase() === '%mend') {
|
if (word === '%mend') {
|
||||||
if (stream.peek() === ';') stream.next();
|
if (stream.peek() === ';') stream.next();
|
||||||
state.inMacro = false;
|
state.inMacro = false;
|
||||||
return 'builtin';
|
return 'builtin';
|
||||||
}
|
}
|
||||||
if (word && words.hasOwnProperty(word.toLowerCase()) &&
|
if (word && words.hasOwnProperty(word) &&
|
||||||
(words[word.toLowerCase()].state.indexOf("inMacro") !== -1 ||
|
(words[word].state.indexOf("inMacro") !== -1 ||
|
||||||
words[word.toLowerCase()].state.indexOf("ALL") !== -1)) {
|
words[word].state.indexOf("ALL") !== -1)) {
|
||||||
stream.match(/[\w]+/);
|
stream.match(/[\w]+/);
|
||||||
return words[word.toLowerCase()].style;
|
return words[word].style;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 'atom';
|
return 'atom';
|
||||||
}
|
}
|
||||||
// Do we have Keywords specific words?
|
// Do we have Keywords specific words?
|
||||||
if (word && words.hasOwnProperty(word.toLowerCase())) {
|
if (word && words.hasOwnProperty(word)) {
|
||||||
// Negates the initial next()
|
// Negates the initial next()
|
||||||
stream.backUp(1);
|
stream.backUp(1);
|
||||||
// Actually move the stream
|
// Actually move the stream
|
||||||
stream.match(/[\w]+/);
|
stream.match(/[\w]+/);
|
||||||
if (word.toLowerCase() === 'data' && /=/.test(stream.peek()) === false) {
|
if (word === 'data' && /=/.test(stream.peek()) === false) {
|
||||||
state.inDataStep = true;
|
state.inDataStep = true;
|
||||||
state.nextword = true;
|
state.nextword = true;
|
||||||
return 'builtin';
|
return 'builtin';
|
||||||
}
|
}
|
||||||
if (word.toLowerCase() === 'proc') {
|
if (word === 'proc') {
|
||||||
state.inProc = true;
|
state.inProc = true;
|
||||||
state.nextword = true;
|
state.nextword = true;
|
||||||
return 'builtin';
|
return 'builtin';
|
||||||
}
|
}
|
||||||
if (word.toLowerCase() === '%macro') {
|
if (word === '%macro') {
|
||||||
state.inMacro = true;
|
state.inMacro = true;
|
||||||
state.nextword = true;
|
state.nextword = true;
|
||||||
return 'builtin';
|
return 'builtin';
|
||||||
}
|
}
|
||||||
if (/title[1-9]/i.test(word)) return 'def';
|
if (/title[1-9]/.test(word)) return 'def';
|
||||||
|
|
||||||
if (word.toLowerCase() === 'footnote') {
|
if (word === 'footnote') {
|
||||||
stream.eat(/[1-9]/);
|
stream.eat(/[1-9]/);
|
||||||
return 'def';
|
return 'def';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns their value as state in the prior define methods
|
// Returns their value as state in the prior define methods
|
||||||
if (state.inDataStep === true && words[word.toLowerCase()].state.indexOf("inDataStep") !== -1)
|
if (state.inDataStep === true && words[word].state.indexOf("inDataStep") !== -1)
|
||||||
return words[word.toLowerCase()].style;
|
return words[word].style;
|
||||||
if (state.inProc === true && words[word.toLowerCase()].state.indexOf("inProc") !== -1)
|
if (state.inProc === true && words[word].state.indexOf("inProc") !== -1)
|
||||||
return words[word.toLowerCase()].style;
|
return words[word].style;
|
||||||
if (state.inMacro === true && words[word.toLowerCase()].state.indexOf("inMacro") !== -1)
|
if (state.inMacro === true && words[word].state.indexOf("inMacro") !== -1)
|
||||||
return words[word.toLowerCase()].style;
|
return words[word].style;
|
||||||
if (words[word.toLowerCase()].state.indexOf("ALL") !== -1)
|
if (words[word].state.indexOf("ALL") !== -1)
|
||||||
return words[word.toLowerCase()].style;
|
return words[word].style;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
// Unrecognized syntax
|
// Unrecognized syntax
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
<script src="../css/css.js"></script>
|
<script src="../css/css.js"></script>
|
||||||
<script src="../coffeescript/coffeescript.js"></script>
|
<script src="../coffeescript/coffeescript.js"></script>
|
||||||
<script src="../sass/sass.js"></script>
|
<script src="../sass/sass.js"></script>
|
||||||
<script src="../jade/jade.js"></script>
|
<script src="../pug/pug.js"></script>
|
||||||
|
|
||||||
<script src="../handlebars/handlebars.js"></script>
|
<script src="../handlebars/handlebars.js"></script>
|
||||||
<script src="../htmlmixed/htmlmixed.js"></script>
|
<script src="../htmlmixed/htmlmixed.js"></script>
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
require("../css/css"),
|
require("../css/css"),
|
||||||
require("../sass/sass"),
|
require("../sass/sass"),
|
||||||
require("../stylus/stylus"),
|
require("../stylus/stylus"),
|
||||||
require("../jade/jade"),
|
require("../pug/pug"),
|
||||||
require("../handlebars/handlebars"));
|
require("../handlebars/handlebars"));
|
||||||
} else if (typeof define === "function" && define.amd) { // AMD
|
} else if (typeof define === "function" && define.amd) { // AMD
|
||||||
define(["../../lib/codemirror",
|
define(["../../lib/codemirror",
|
||||||
|
@ -23,7 +23,7 @@
|
||||||
"../css/css",
|
"../css/css",
|
||||||
"../sass/sass",
|
"../sass/sass",
|
||||||
"../stylus/stylus",
|
"../stylus/stylus",
|
||||||
"../jade/jade",
|
"../pug/pug",
|
||||||
"../handlebars/handlebars"], mod);
|
"../handlebars/handlebars"], mod);
|
||||||
} else { // Plain browser env
|
} else { // Plain browser env
|
||||||
mod(CodeMirror);
|
mod(CodeMirror);
|
||||||
|
@ -42,9 +42,9 @@
|
||||||
],
|
],
|
||||||
template: [
|
template: [
|
||||||
["lang", /^vue-template$/i, "vue"],
|
["lang", /^vue-template$/i, "vue"],
|
||||||
["lang", /^jade$/i, "jade"],
|
["lang", /^pug$/i, "pug"],
|
||||||
["lang", /^handlebars$/i, "handlebars"],
|
["lang", /^handlebars$/i, "handlebars"],
|
||||||
["type", /^(text\/)?(x-)?jade$/i, "jade"],
|
["type", /^(text\/)?(x-)?pug$/i, "pug"],
|
||||||
["type", /^text\/x-handlebars-template$/i, "handlebars"],
|
["type", /^text\/x-handlebars-template$/i, "handlebars"],
|
||||||
[null, null, "vue-template"]
|
[null, null, "vue-template"]
|
||||||
]
|
]
|
||||||
|
@ -63,7 +63,7 @@
|
||||||
|
|
||||||
CodeMirror.defineMode("vue", function (config) {
|
CodeMirror.defineMode("vue", function (config) {
|
||||||
return CodeMirror.getMode(config, {name: "htmlmixed", tags: tagLanguages});
|
return CodeMirror.getMode(config, {name: "htmlmixed", tags: tagLanguages});
|
||||||
}, "htmlmixed", "xml", "javascript", "coffeescript", "css", "sass", "stylus", "jade", "handlebars");
|
}, "htmlmixed", "xml", "javascript", "coffeescript", "css", "sass", "stylus", "pug", "handlebars");
|
||||||
|
|
||||||
CodeMirror.defineMIME("script/x-vue", "vue");
|
CodeMirror.defineMIME("script/x-vue", "vue");
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,94 +1,85 @@
|
||||||
/*
|
/*
|
||||||
|
|
||||||
Name: Panda Syntax
|
Name: Panda Syntax
|
||||||
Author: Siamak Mokhtari (http://github.com/siamak/)
|
Author: Siamak Mokhtari (http://github.com/siamak/)
|
||||||
|
|
||||||
CodeMirror template by Siamak Mokhtari (https://github.com/siamak/atom-panda-syntax)
|
CodeMirror template by Siamak Mokhtari (https://github.com/siamak/atom-panda-syntax)
|
||||||
|
|
||||||
*/
|
*/
|
||||||
.cm-s-panda-syntax {
|
.cm-s-panda-syntax {
|
||||||
/*font-family: 'Operator Mono', 'Source Sans Pro', Helvetica, Arial, sans-serif;*/
|
|
||||||
font-family: 'Operator Mono', 'Source Sans Pro', Menlo, Monaco, Consolas, Courier New, monospace;
|
|
||||||
background: #292A2B;
|
background: #292A2B;
|
||||||
color: #E6E6E6;
|
color: #E6E6E6;
|
||||||
|
line-height: 1.5;
|
||||||
|
font-family: 'Operator Mono', 'Source Sans Pro', Menlo, Monaco, Consolas, Courier New, monospace;
|
||||||
}
|
}
|
||||||
|
.cm-s-panda-syntax .CodeMirror-cursor { border-color: #ff2c6d; }
|
||||||
.cm-s-panda-syntax .CodeMirror-activeline-background {
|
.cm-s-panda-syntax .CodeMirror-activeline-background {
|
||||||
background: #404954;
|
background: rgba(99, 123, 156, 0.1);
|
||||||
|
}
|
||||||
|
.cm-s-panda-syntax .CodeMirror-selected {
|
||||||
|
background: #FFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
.cm-s-panda-syntax .cm-comment {
|
.cm-s-panda-syntax .cm-comment {
|
||||||
font-style: italic;
|
font-style: italic;
|
||||||
color: #676B79;
|
color: #676B79;
|
||||||
}
|
}
|
||||||
.cm-s-panda-syntax .cm-string,
|
.cm-s-panda-syntax .cm-operator {
|
||||||
.cm-s-panda-syntax .cm-string-2 {
|
color: #f3f3f3;
|
||||||
|
}
|
||||||
|
.cm-s-panda-syntax .cm-string {
|
||||||
color: #19F9D8;
|
color: #19F9D8;
|
||||||
}
|
}
|
||||||
|
.cm-s-panda-syntax .cm-string-2 {
|
||||||
|
color: #FFB86C;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cm-s-panda-syntax .cm-tag {
|
||||||
|
color: #ff2c6d;
|
||||||
|
}
|
||||||
|
.cm-s-panda-syntax .cm-meta {
|
||||||
|
color: #b084eb;
|
||||||
|
}
|
||||||
|
|
||||||
.cm-s-panda-syntax .cm-number {
|
.cm-s-panda-syntax .cm-number {
|
||||||
color: #FFB86C;
|
color: #FFB86C;
|
||||||
}
|
}
|
||||||
.cm-s-panda-syntax .cm-atom {
|
.cm-s-panda-syntax .cm-atom {
|
||||||
color: #FFB86C;
|
color: #ff2c6d;
|
||||||
}
|
}
|
||||||
|
|
||||||
.cm-s-panda-syntax .cm-keyword {
|
.cm-s-panda-syntax .cm-keyword {
|
||||||
color: #FF75B5;
|
color: #FF75B5;
|
||||||
}
|
}
|
||||||
.cm-s-panda-syntax .cm-keyword-2 {
|
|
||||||
color: #FF75B5;
|
|
||||||
}
|
|
||||||
.cm-s-panda-syntax .cm-keyword-3 {
|
|
||||||
color: #B084EB;
|
|
||||||
}
|
|
||||||
|
|
||||||
.cm-s-panda-syntax .cm-variable {
|
.cm-s-panda-syntax .cm-variable {
|
||||||
color: #FF9AC1;
|
color: #ffb86c;
|
||||||
}
|
}
|
||||||
.cm-s-panda-syntax .cm-variable-2 {
|
.cm-s-panda-syntax .cm-variable-2 {
|
||||||
color: #e6e6e6;
|
color: #ff9ac1;
|
||||||
}
|
}
|
||||||
.cm-s-panda-syntax .cm-variable-3 {
|
.cm-s-panda-syntax .cm-variable-3 {
|
||||||
color: #82B1FF;
|
color: #ff9ac1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.cm-s-panda-syntax .cm-def {
|
.cm-s-panda-syntax .cm-def {
|
||||||
/*font-style: italic;*/
|
|
||||||
color: #e6e6e6;
|
color: #e6e6e6;
|
||||||
}
|
}
|
||||||
.cm-s-panda-syntax .cm-def-2 {
|
|
||||||
font-style: italic;
|
|
||||||
color: #ffcc95;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
.cm-s-panda-syntax .cm-property {
|
.cm-s-panda-syntax .cm-property {
|
||||||
color: #6FC1FF;
|
color: #f3f3f3;
|
||||||
|
}
|
||||||
|
.cm-s-panda-syntax .cm-unit {
|
||||||
|
color: #ffb86c;
|
||||||
}
|
}
|
||||||
|
|
||||||
.cm-s-panda-syntax .cm-matchingbracket,
|
.cm-s-panda-syntax .cm-attribute {
|
||||||
.CodeMirror .CodeMirror-matchingbracket {
|
color: #ffb86c;
|
||||||
color: #E6E6E6 !important;
|
}
|
||||||
border-bottom: 1px dotted #19f9d8;
|
|
||||||
|
.cm-s-panda-syntax .CodeMirror-matchingbracket {
|
||||||
|
border-bottom: 1px dotted #19F9D8;
|
||||||
padding-bottom: 2px;
|
padding-bottom: 2px;
|
||||||
|
color: #e6e6e6;
|
||||||
}
|
}
|
||||||
|
.CodeMirror-gutters {
|
||||||
.cm-s-panda-syntax .CodeMirror-gutters {
|
background: #292a2b;
|
||||||
background: #292A2B;
|
border-right-color: rgba(255, 255, 255, 0.1);
|
||||||
color: #757575;
|
|
||||||
border: none;
|
|
||||||
}
|
}
|
||||||
.cm-s-panda-syntax .CodeMirror-guttermarker, .cm-s-panda-syntax .CodeMirror-guttermarker-subtle, .cm-s-panda-syntax .CodeMirror-linenumber {
|
.CodeMirror-linenumber {
|
||||||
color: #757575;
|
color: #e6e6e6;
|
||||||
|
opacity: 0.6;
|
||||||
}
|
}
|
||||||
.cm-s-panda-syntax .CodeMirror-linenumber {
|
|
||||||
padding-right: 10px;
|
|
||||||
}
|
|
||||||
.cm-s-panda-syntax .CodeMirror-cursor {
|
|
||||||
border-left: 1px solid #757575;
|
|
||||||
}
|
|
||||||
/*.cm-s-panda-syntax div.CodeMirror-selected { background: rgba(255, 255, 255, 0.5); }*/
|
|
||||||
.cm-s-panda-syntax.CodeMirror-focused div.CodeMirror-selected { background: rgba(255, 255, 255, 0.25); }
|
|
||||||
.cm-s-panda-syntax .CodeMirror-line::selection, .cm-s-panda-syntax .CodeMirror-line > span::selection, .cm-s-panda-syntax .CodeMirror-line > span > span::selection { background: rgba(255, 255, 255, 0.10); }
|
|
||||||
.cm-s-panda-syntax .CodeMirror-line::-moz-selection, .cm-s-panda-syntax .CodeMirror-line > span::-moz-selection, .cm-s-panda-syntax .CodeMirror-line > span > span::-moz-selection { background: rgba(255, 255, 255, 0.10); }
|
|
||||||
|
|
||||||
.cm-s-panda-syntax .CodeMirror-activeline-background { background: rgba(99, 123, 156, 0.125); }
|
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
background: #2c2827;
|
background: #2c2827;
|
||||||
color: #8F938F;
|
color: #8F938F;
|
||||||
line-height: 1.5;
|
line-height: 1.5;
|
||||||
font-size: 14px;
|
|
||||||
}
|
}
|
||||||
.cm-s-pastel-on-dark div.CodeMirror-selected { background: rgba(221,240,255,0.2); }
|
.cm-s-pastel-on-dark div.CodeMirror-selected { background: rgba(221,240,255,0.2); }
|
||||||
.cm-s-pastel-on-dark .CodeMirror-line::selection, .cm-s-pastel-on-dark .CodeMirror-line > span::selection, .cm-s-pastel-on-dark .CodeMirror-line > span > span::selection { background: rgba(221,240,255,0.2); }
|
.cm-s-pastel-on-dark .CodeMirror-line::selection, .cm-s-pastel-on-dark .CodeMirror-line > span::selection, .cm-s-pastel-on-dark .CodeMirror-line > span > span::selection { background: rgba(221,240,255,0.2); }
|
||||||
|
|
|
@ -155,8 +155,8 @@ http://ethanschoonover.com/solarized/img/solarized-palette.png
|
||||||
.cm-s-solarized .CodeMirror-cursor { border-left: 1px solid #819090; }
|
.cm-s-solarized .CodeMirror-cursor { border-left: 1px solid #819090; }
|
||||||
|
|
||||||
/* Fat cursor */
|
/* Fat cursor */
|
||||||
.cm-s-solarized.cm-s-light.cm-fat-cursor .CodeMirror-cursor { background: #fdf6e3; }
|
.cm-s-solarized.cm-s-light.cm-fat-cursor .CodeMirror-cursor { background: #77ee77; }
|
||||||
.cm-s-solarized.cm-s-light .cm-animate-fat-cursor { background-color: #fdf6e3; }
|
.cm-s-solarized.cm-s-light .cm-animate-fat-cursor { background-color: #77ee77; }
|
||||||
.cm-s-solarized.cm-s-dark.cm-fat-cursor .CodeMirror-cursor { background: #586e75; }
|
.cm-s-solarized.cm-s-dark.cm-fat-cursor .CodeMirror-cursor { background: #586e75; }
|
||||||
.cm-s-solarized.cm-s-dark .cm-animate-fat-cursor { background-color: #586e75; }
|
.cm-s-solarized.cm-s-dark .cm-animate-fat-cursor { background-color: #586e75; }
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue