mirror of
https://github.com/documize/community.git
synced 2025-07-21 06:09:42 +02:00
CodeMirror dependency upgraded to v5.32.0
For handling Markdown and Code section types
This commit is contained in:
parent
3337db6b27
commit
0336f84a83
351 changed files with 3408 additions and 1945 deletions
|
@ -101,7 +101,7 @@ export default Component.extend(TooltipMixin, {
|
|||
this.set('codeEditor', null);
|
||||
}
|
||||
|
||||
this.removeT0oltips();
|
||||
this.removeTooltips();
|
||||
|
||||
},
|
||||
|
||||
|
|
|
@ -5,8 +5,6 @@
|
|||
margin-bottom: 15px;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* BASICS */
|
||||
|
||||
.CodeMirror {
|
||||
|
@ -14,6 +12,7 @@
|
|||
font-family: monospace;
|
||||
height: 300px;
|
||||
color: black;
|
||||
direction: ltr;
|
||||
}
|
||||
|
||||
/* PADDING */
|
||||
|
@ -67,7 +66,12 @@
|
|||
.cm-fat-cursor div.CodeMirror-cursors {
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.cm-fat-cursor-mark {
|
||||
background-color: rgba(20, 255, 20, 0.5);
|
||||
-webkit-animation: blink 1.06s steps(1) infinite;
|
||||
-moz-animation: blink 1.06s steps(1) infinite;
|
||||
animation: blink 1.06s steps(1) infinite;
|
||||
}
|
||||
.cm-animate-fat-cursor {
|
||||
width: auto;
|
||||
border: 0;
|
||||
|
@ -128,7 +132,7 @@
|
|||
.cm-s-default .cm-property,
|
||||
.cm-s-default .cm-operator {}
|
||||
.cm-s-default .cm-variable-2 {color: #05a;}
|
||||
.cm-s-default .cm-variable-3 {color: #085;}
|
||||
.cm-s-default .cm-variable-3, .cm-s-default .cm-type {color: #085;}
|
||||
.cm-s-default .cm-comment {color: #a50;}
|
||||
.cm-s-default .cm-string {color: #a11;}
|
||||
.cm-s-default .cm-string-2 {color: #f50;}
|
||||
|
@ -148,8 +152,8 @@
|
|||
|
||||
/* Default styles for common addons */
|
||||
|
||||
div.CodeMirror span.CodeMirror-matchingbracket {color: #0f0;}
|
||||
div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
|
||||
div.CodeMirror span.CodeMirror-matchingbracket {color: #0b0;}
|
||||
div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #a22;}
|
||||
.CodeMirror-matchingtag { background: rgba(255, 150, 0, .3); }
|
||||
.CodeMirror-activeline-background {background: #e8f2ff;}
|
||||
|
||||
|
@ -232,11 +236,8 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
|
|||
cursor: default;
|
||||
z-index: 4;
|
||||
}
|
||||
.CodeMirror-gutter-wrapper {
|
||||
-webkit-user-select: none;
|
||||
-moz-user-select: none;
|
||||
user-select: none;
|
||||
}
|
||||
.CodeMirror-gutter-wrapper ::selection { background-color: transparent }
|
||||
.CodeMirror-gutter-wrapper ::-moz-selection { background-color: transparent }
|
||||
|
||||
.CodeMirror-lines {
|
||||
cursor: text;
|
||||
|
@ -281,6 +282,8 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
|
|||
|
||||
.CodeMirror-widget {}
|
||||
|
||||
.CodeMirror-rtl pre { direction: rtl; }
|
||||
|
||||
.CodeMirror-code {
|
||||
outline: none;
|
||||
}
|
||||
|
@ -329,8 +332,8 @@ div.CodeMirror-dragcursors {
|
|||
.CodeMirror-line::-moz-selection, .CodeMirror-line > span::-moz-selection, .CodeMirror-line > span > span::-moz-selection { background: #d7d4f0; }
|
||||
|
||||
.cm-searching {
|
||||
background: #ffa;
|
||||
background: rgba(255, 255, 0, .4);
|
||||
background-color: #ffa;
|
||||
background-color: rgba(255, 255, 0, .4);
|
||||
}
|
||||
|
||||
/* Used to force a border model for a node */
|
||||
|
|
12
gui/public/codemirror/addon/comment/comment.js
vendored
Executable file → Normal file
12
gui/public/codemirror/addon/comment/comment.js
vendored
Executable file → Normal file
|
@ -46,7 +46,7 @@
|
|||
|
||||
// Rough heuristic to try and detect lines that are part of multi-line string
|
||||
function probablyInsideString(cm, pos, line) {
|
||||
return /\bstring\b/.test(cm.getTokenTypeAt(Pos(pos.line, 0))) && !/^[\'\"`]/.test(line)
|
||||
return /\bstring\b/.test(cm.getTokenTypeAt(Pos(pos.line, 0))) && !/^[\'\"\`]/.test(line)
|
||||
}
|
||||
|
||||
function getMode(cm, pos) {
|
||||
|
@ -172,13 +172,11 @@
|
|||
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) {
|
||||
endLine = self.getLine(--end);
|
||||
close = endLine.indexOf(endString);
|
||||
}
|
||||
var insideStart = Pos(start, open + 1), insideEnd = Pos(end, close + 1)
|
||||
if (close == -1 ||
|
||||
!/comment/.test(self.getTokenTypeAt(Pos(start, open + 1))) ||
|
||||
!/comment/.test(self.getTokenTypeAt(Pos(end, close + 1))))
|
||||
!/comment/.test(self.getTokenTypeAt(insideStart)) ||
|
||||
!/comment/.test(self.getTokenTypeAt(insideEnd)) ||
|
||||
self.getRange(insideStart, insideEnd, "\n").indexOf(endString) > -1)
|
||||
return false;
|
||||
|
||||
// Avoid killing block comments completely outside the selection.
|
||||
|
|
35
gui/public/codemirror/addon/comment/continuecomment.js
vendored
Executable file → Normal file
35
gui/public/codemirror/addon/comment/continuecomment.js
vendored
Executable file → Normal file
|
@ -9,39 +9,32 @@
|
|||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
var modes = ["clike", "css", "javascript"];
|
||||
|
||||
for (var i = 0; i < modes.length; ++i)
|
||||
CodeMirror.extendMode(modes[i], {blockCommentContinue: " * "});
|
||||
|
||||
function continueComment(cm) {
|
||||
if (cm.getOption("disableInput")) return CodeMirror.Pass;
|
||||
var ranges = cm.listSelections(), mode, inserts = [];
|
||||
for (var i = 0; i < ranges.length; i++) {
|
||||
var pos = ranges[i].head, token = cm.getTokenAt(pos);
|
||||
if (token.type != "comment") return CodeMirror.Pass;
|
||||
var modeHere = CodeMirror.innerMode(cm.getMode(), token.state).mode;
|
||||
var pos = ranges[i].head
|
||||
if (!/\bcomment\b/.test(cm.getTokenTypeAt(pos))) return CodeMirror.Pass;
|
||||
var modeHere = cm.getModeAt(pos)
|
||||
if (!mode) mode = modeHere;
|
||||
else if (mode != modeHere) return CodeMirror.Pass;
|
||||
|
||||
var insert = null;
|
||||
if (mode.blockCommentStart && mode.blockCommentContinue) {
|
||||
var end = token.string.indexOf(mode.blockCommentEnd);
|
||||
var full = cm.getRange(CodeMirror.Pos(pos.line, 0), CodeMirror.Pos(pos.line, token.end)), found;
|
||||
if (end != -1 && end == token.string.length - mode.blockCommentEnd.length && pos.ch >= end) {
|
||||
var line = cm.getLine(pos.line).slice(0, pos.ch)
|
||||
var end = line.lastIndexOf(mode.blockCommentEnd), found
|
||||
if (end != -1 && end == pos.ch - mode.blockCommentEnd.length) {
|
||||
// Comment ended, don't continue it
|
||||
} else if (token.string.indexOf(mode.blockCommentStart) == 0) {
|
||||
insert = full.slice(0, token.start);
|
||||
if (!/^\s*$/.test(insert)) {
|
||||
insert = "";
|
||||
for (var j = 0; j < token.start; ++j) insert += " ";
|
||||
} else if ((found = line.lastIndexOf(mode.blockCommentStart)) > -1 && found > end) {
|
||||
insert = line.slice(0, found)
|
||||
if (/\S/.test(insert)) {
|
||||
insert = ""
|
||||
for (var j = 0; j < found; ++j) insert += " "
|
||||
}
|
||||
} else if ((found = full.indexOf(mode.blockCommentContinue)) != -1 &&
|
||||
found + mode.blockCommentContinue.length > token.start &&
|
||||
/^\s*$/.test(full.slice(0, found))) {
|
||||
insert = full.slice(0, found);
|
||||
} else if ((found = line.indexOf(mode.blockCommentContinue)) > -1 && !/\S/.test(line.slice(0, found))) {
|
||||
insert = line.slice(0, found)
|
||||
}
|
||||
if (insert != null) insert += mode.blockCommentContinue;
|
||||
if (insert != null) insert += mode.blockCommentContinue
|
||||
}
|
||||
if (insert == null && mode.lineComment && continueLineCommentEnabled(cm)) {
|
||||
var line = cm.getLine(pos.line), found = line.indexOf(mode.lineComment);
|
||||
|
|
0
gui/public/codemirror/addon/dialog/dialog.css
vendored
Executable file → Normal file
0
gui/public/codemirror/addon/dialog/dialog.css
vendored
Executable file → Normal file
0
gui/public/codemirror/addon/dialog/dialog.js
vendored
Executable file → Normal file
0
gui/public/codemirror/addon/dialog/dialog.js
vendored
Executable file → Normal file
0
gui/public/codemirror/addon/display/autorefresh.js
vendored
Executable file → Normal file
0
gui/public/codemirror/addon/display/autorefresh.js
vendored
Executable file → Normal file
0
gui/public/codemirror/addon/display/fullscreen.css
vendored
Executable file → Normal file
0
gui/public/codemirror/addon/display/fullscreen.css
vendored
Executable file → Normal file
0
gui/public/codemirror/addon/display/fullscreen.js
vendored
Executable file → Normal file
0
gui/public/codemirror/addon/display/fullscreen.js
vendored
Executable file → Normal file
2
gui/public/codemirror/addon/display/panel.js
vendored
Executable file → Normal file
2
gui/public/codemirror/addon/display/panel.js
vendored
Executable file → Normal file
|
@ -66,7 +66,7 @@
|
|||
Panel.prototype.changed = function(height) {
|
||||
var newHeight = height == null ? this.node.offsetHeight : height;
|
||||
var info = this.cm.state.panels;
|
||||
this.cm._setSize(null, info.height += (newHeight - this.height));
|
||||
this.cm._setSize(null, info.heightLeft -= (newHeight - this.height));
|
||||
this.height = newHeight;
|
||||
};
|
||||
|
||||
|
|
0
gui/public/codemirror/addon/display/placeholder.js
vendored
Executable file → Normal file
0
gui/public/codemirror/addon/display/placeholder.js
vendored
Executable file → Normal file
0
gui/public/codemirror/addon/display/rulers.js
vendored
Executable file → Normal file
0
gui/public/codemirror/addon/display/rulers.js
vendored
Executable file → Normal file
36
gui/public/codemirror/addon/edit/closebrackets.js
vendored
Executable file → Normal file
36
gui/public/codemirror/addon/edit/closebrackets.js
vendored
Executable file → Normal file
|
@ -23,6 +23,7 @@
|
|||
cm.state.closeBrackets = null;
|
||||
}
|
||||
if (val) {
|
||||
ensureBound(getOption(val, "pairs"))
|
||||
cm.state.closeBrackets = val;
|
||||
cm.addKeyMap(keyMap);
|
||||
}
|
||||
|
@ -34,10 +35,14 @@
|
|||
return defaults[name];
|
||||
}
|
||||
|
||||
var bind = defaults.pairs + "`";
|
||||
var keyMap = {Backspace: handleBackspace, Enter: handleEnter};
|
||||
for (var i = 0; i < bind.length; i++)
|
||||
keyMap["'" + bind.charAt(i) + "'"] = handler(bind.charAt(i));
|
||||
function ensureBound(chars) {
|
||||
for (var i = 0; i < chars.length; i++) {
|
||||
var ch = chars.charAt(i), key = "'" + ch + "'"
|
||||
if (!keyMap[key]) keyMap[key] = handler(ch)
|
||||
}
|
||||
}
|
||||
ensureBound(defaults.pairs + "`")
|
||||
|
||||
function handler(ch) {
|
||||
return function(cm) { return handleChar(cm, ch); };
|
||||
|
@ -79,7 +84,8 @@
|
|||
if (!around || explode.indexOf(around) % 2 != 0) return CodeMirror.Pass;
|
||||
}
|
||||
cm.operation(function() {
|
||||
cm.replaceSelection("\n\n", null);
|
||||
var linesep = cm.lineSeparator() || "\n";
|
||||
cm.replaceSelection(linesep + linesep, null);
|
||||
cm.execCommand("goCharLeft");
|
||||
ranges = cm.listSelections();
|
||||
for (var i = 0; i < ranges.length; i++) {
|
||||
|
@ -127,7 +133,8 @@
|
|||
(cur.ch <= 2 || cm.getRange(Pos(cur.line, cur.ch - 3), Pos(cur.line, cur.ch - 2)) != ch)) {
|
||||
curType = "addFour";
|
||||
} else if (identical) {
|
||||
if (!CodeMirror.isWordChar(next) && enteringString(cm, cur, ch)) curType = "both";
|
||||
var prev = cur.ch == 0 ? " " : cm.getRange(Pos(cur.line, cur.ch - 1), cur)
|
||||
if (!CodeMirror.isWordChar(next) && prev != ch && !CodeMirror.isWordChar(prev)) curType = "both";
|
||||
else return CodeMirror.Pass;
|
||||
} else if (opening && (cm.getLine(cur.line).length == cur.ch ||
|
||||
isClosingBracket(next, pairs) ||
|
||||
|
@ -179,24 +186,9 @@
|
|||
return str.length == 2 ? str : null;
|
||||
}
|
||||
|
||||
// Project the token type that will exists after the given char is
|
||||
// typed, and use it to determine whether it would cause the start
|
||||
// of a string token.
|
||||
function enteringString(cm, pos, ch) {
|
||||
var line = cm.getLine(pos.line);
|
||||
var token = cm.getTokenAt(pos);
|
||||
if (/\bstring2?\b/.test(token.type) || stringStartsAfter(cm, pos)) return false;
|
||||
var stream = new CodeMirror.StringStream(line.slice(0, pos.ch) + ch + line.slice(pos.ch), 4);
|
||||
stream.pos = stream.start = token.start;
|
||||
for (;;) {
|
||||
var type1 = cm.getMode().token(stream, token.state);
|
||||
if (stream.pos >= pos.ch + 1) return /\bstring2?\b/.test(type1);
|
||||
stream.start = stream.pos;
|
||||
}
|
||||
}
|
||||
|
||||
function stringStartsAfter(cm, pos) {
|
||||
var token = cm.getTokenAt(Pos(pos.line, pos.ch + 1))
|
||||
return /\bstring/.test(token.type) && token.start == pos.ch
|
||||
return /\bstring/.test(token.type) && token.start == pos.ch &&
|
||||
(pos.ch == 0 || !/\bstring/.test(cm.getTokenTypeAt(pos)))
|
||||
}
|
||||
});
|
||||
|
|
0
gui/public/codemirror/addon/edit/closetag.js
vendored
Executable file → Normal file
0
gui/public/codemirror/addon/edit/closetag.js
vendored
Executable file → Normal file
46
gui/public/codemirror/addon/edit/continuelist.js
vendored
Executable file → Normal file
46
gui/public/codemirror/addon/edit/continuelist.js
vendored
Executable file → Normal file
|
@ -11,8 +11,8 @@
|
|||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
var listRE = /^(\s*)(>[> ]*|- \[[x ]\]\s|[*+-]\s|(\d+)([.)]))(\s*)/,
|
||||
emptyListRE = /^(\s*)(>[> ]*|- \[[x ]\]|[*+-]|(\d+)[.)])(\s*)$/,
|
||||
var listRE = /^(\s*)(>[> ]*|[*+-] \[[x ]\]\s|[*+-]\s|(\d+)([.)]))(\s*)/,
|
||||
emptyListRE = /^(\s*)(>[> ]*|[*+-] \[[x ]\]|[*+-]|(\d+)[.)])(\s*)$/,
|
||||
unorderedListRE = /[*+-]\s/;
|
||||
|
||||
CodeMirror.commands.newlineAndIndentContinueMarkdownList = function(cm) {
|
||||
|
@ -25,7 +25,8 @@
|
|||
var inQuote = eolState.quote !== 0;
|
||||
|
||||
var line = cm.getLine(pos.line), match = listRE.exec(line);
|
||||
if (!ranges[i].empty() || (!inList && !inQuote) || !match) {
|
||||
var cursorBeforeBullet = /^\s*$/.test(line.slice(0, pos.ch));
|
||||
if (!ranges[i].empty() || (!inList && !inQuote) || !match || cursorBeforeBullet) {
|
||||
cm.execCommand("newlineAndIndent");
|
||||
return;
|
||||
}
|
||||
|
@ -43,9 +44,48 @@
|
|||
: (parseInt(match[3], 10) + 1) + match[4];
|
||||
|
||||
replacements[i] = "\n" + indent + bullet + after;
|
||||
|
||||
incrementRemainingMarkdownListNumbers(cm, pos);
|
||||
}
|
||||
}
|
||||
|
||||
cm.replaceSelections(replacements);
|
||||
};
|
||||
|
||||
// Auto-updating Markdown list numbers when a new item is added to the
|
||||
// middle of a list
|
||||
function incrementRemainingMarkdownListNumbers(cm, pos) {
|
||||
var startLine = pos.line, lookAhead = 0, skipCount = 0;
|
||||
var startItem = listRE.exec(cm.getLine(startLine)), startIndent = startItem[1];
|
||||
|
||||
do {
|
||||
lookAhead += 1;
|
||||
var nextLineNumber = startLine + lookAhead;
|
||||
var nextLine = cm.getLine(nextLineNumber), nextItem = listRE.exec(nextLine);
|
||||
|
||||
if (nextItem) {
|
||||
var nextIndent = nextItem[1];
|
||||
var newNumber = (parseInt(startItem[3], 10) + lookAhead - skipCount);
|
||||
var nextNumber = (parseInt(nextItem[3], 10)), itemNumber = nextNumber;
|
||||
|
||||
if (startIndent === nextIndent) {
|
||||
if (newNumber === nextNumber) itemNumber = nextNumber + 1;
|
||||
if (newNumber > nextNumber) itemNumber = newNumber + 1;
|
||||
cm.replaceRange(
|
||||
nextLine.replace(listRE, nextIndent + itemNumber + nextItem[4] + nextItem[5]),
|
||||
{
|
||||
line: nextLineNumber, ch: 0
|
||||
}, {
|
||||
line: nextLineNumber, ch: nextLine.length
|
||||
});
|
||||
} else {
|
||||
if (startIndent.length > nextIndent.length) return;
|
||||
// This doesn't run if the next line immediatley indents, as it is
|
||||
// not clear of the users intention (new indented item or same level)
|
||||
if ((startIndent.length < nextIndent.length) && (lookAhead === 1)) return;
|
||||
skipCount += 1;
|
||||
}
|
||||
}
|
||||
} while (nextItem);
|
||||
}
|
||||
});
|
||||
|
|
30
gui/public/codemirror/addon/edit/matchbrackets.js
vendored
Executable file → Normal file
30
gui/public/codemirror/addon/edit/matchbrackets.js
vendored
Executable file → Normal file
|
@ -16,12 +16,21 @@
|
|||
|
||||
var matching = {"(": ")>", ")": "(<", "[": "]>", "]": "[<", "{": "}>", "}": "{<"};
|
||||
|
||||
function findMatchingBracket(cm, where, strict, config) {
|
||||
function findMatchingBracket(cm, where, config) {
|
||||
var line = cm.getLineHandle(where.line), pos = where.ch - 1;
|
||||
var match = (pos >= 0 && matching[line.text.charAt(pos)]) || matching[line.text.charAt(++pos)];
|
||||
var afterCursor = config && config.afterCursor
|
||||
if (afterCursor == null)
|
||||
afterCursor = /(^| )cm-fat-cursor($| )/.test(cm.getWrapperElement().className)
|
||||
|
||||
// A cursor is defined as between two characters, but in in vim command mode
|
||||
// (i.e. not insert mode), the cursor is visually represented as a
|
||||
// highlighted box on top of the 2nd character. Otherwise, we allow matches
|
||||
// from before or after the cursor.
|
||||
var match = (!afterCursor && pos >= 0 && matching[line.text.charAt(pos)]) ||
|
||||
matching[line.text.charAt(++pos)];
|
||||
if (!match) return null;
|
||||
var dir = match.charAt(1) == ">" ? 1 : -1;
|
||||
if (strict && (dir > 0) != (pos == where.ch)) return null;
|
||||
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);
|
||||
|
@ -69,7 +78,7 @@
|
|||
var maxHighlightLen = cm.state.matchBrackets.maxHighlightLineLength || 1000;
|
||||
var marks = [], ranges = cm.listSelections();
|
||||
for (var i = 0; i < ranges.length; i++) {
|
||||
var match = ranges[i].empty() && findMatchingBracket(cm, ranges[i].head, false, config);
|
||||
var match = ranges[i].empty() && findMatchingBracket(cm, ranges[i].head, config);
|
||||
if (match && 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}));
|
||||
|
@ -113,8 +122,17 @@
|
|||
});
|
||||
|
||||
CodeMirror.defineExtension("matchBrackets", function() {matchBrackets(this, true);});
|
||||
CodeMirror.defineExtension("findMatchingBracket", function(pos, strict, config){
|
||||
return findMatchingBracket(this, pos, strict, config);
|
||||
CodeMirror.defineExtension("findMatchingBracket", function(pos, config, oldConfig){
|
||||
// Backwards-compatibility kludge
|
||||
if (oldConfig || typeof config == "boolean") {
|
||||
if (!oldConfig) {
|
||||
config = config ? {strict: true} : null
|
||||
} else {
|
||||
oldConfig.strict = config
|
||||
config = oldConfig
|
||||
}
|
||||
}
|
||||
return findMatchingBracket(this, pos, config)
|
||||
});
|
||||
CodeMirror.defineExtension("scanForBracket", function(pos, dir, style, config){
|
||||
return scanForBracket(this, pos, dir, style, config);
|
||||
|
|
0
gui/public/codemirror/addon/edit/matchtags.js
vendored
Executable file → Normal file
0
gui/public/codemirror/addon/edit/matchtags.js
vendored
Executable file → Normal file
0
gui/public/codemirror/addon/edit/trailingspace.js
vendored
Executable file → Normal file
0
gui/public/codemirror/addon/edit/trailingspace.js
vendored
Executable file → Normal file
0
gui/public/codemirror/addon/fold/brace-fold.js
vendored
Executable file → Normal file
0
gui/public/codemirror/addon/fold/brace-fold.js
vendored
Executable file → Normal file
0
gui/public/codemirror/addon/fold/comment-fold.js
vendored
Executable file → Normal file
0
gui/public/codemirror/addon/fold/comment-fold.js
vendored
Executable file → Normal file
2
gui/public/codemirror/addon/fold/foldcode.js
vendored
Executable file → Normal file
2
gui/public/codemirror/addon/fold/foldcode.js
vendored
Executable file → Normal file
|
@ -65,6 +65,8 @@
|
|||
widget = document.createElement("span");
|
||||
widget.appendChild(text);
|
||||
widget.className = "CodeMirror-foldmarker";
|
||||
} else if (widget) {
|
||||
widget = widget.cloneNode(true)
|
||||
}
|
||||
return widget;
|
||||
}
|
||||
|
|
0
gui/public/codemirror/addon/fold/foldgutter.css
vendored
Executable file → Normal file
0
gui/public/codemirror/addon/fold/foldgutter.css
vendored
Executable file → Normal file
0
gui/public/codemirror/addon/fold/foldgutter.js
vendored
Executable file → Normal file
0
gui/public/codemirror/addon/fold/foldgutter.js
vendored
Executable file → Normal file
2
gui/public/codemirror/addon/fold/indent-fold.js
vendored
Executable file → Normal file
2
gui/public/codemirror/addon/fold/indent-fold.js
vendored
Executable file → Normal file
|
@ -18,7 +18,7 @@ function lineIndent(cm, lineNo) {
|
|||
return -1
|
||||
return CodeMirror.countColumn(text, null, cm.getOption("tabSize"))
|
||||
}
|
||||
!
|
||||
|
||||
CodeMirror.registerHelper("fold", "indent", function(cm, start) {
|
||||
var myIndent = lineIndent(cm, start.line)
|
||||
if (myIndent < 0) return
|
||||
|
|
0
gui/public/codemirror/addon/fold/markdown-fold.js
vendored
Executable file → Normal file
0
gui/public/codemirror/addon/fold/markdown-fold.js
vendored
Executable file → Normal file
4
gui/public/codemirror/addon/fold/xml-fold.js
vendored
Executable file → Normal file
4
gui/public/codemirror/addon/fold/xml-fold.js
vendored
Executable file → Normal file
|
@ -163,10 +163,10 @@
|
|||
}
|
||||
};
|
||||
|
||||
CodeMirror.findEnclosingTag = function(cm, pos, range) {
|
||||
CodeMirror.findEnclosingTag = function(cm, pos, range, tag) {
|
||||
var iter = new Iter(cm, pos.line, pos.ch, range);
|
||||
for (;;) {
|
||||
var open = findMatchingOpen(iter);
|
||||
var open = findMatchingOpen(iter, tag);
|
||||
if (!open) break;
|
||||
var forward = new Iter(cm, pos.line, pos.ch, range);
|
||||
var close = findMatchingClose(forward, open.tag);
|
||||
|
|
0
gui/public/codemirror/addon/hint/anyword-hint.js
vendored
Executable file → Normal file
0
gui/public/codemirror/addon/hint/anyword-hint.js
vendored
Executable file → Normal file
0
gui/public/codemirror/addon/hint/css-hint.js
vendored
Executable file → Normal file
0
gui/public/codemirror/addon/hint/css-hint.js
vendored
Executable file → Normal file
0
gui/public/codemirror/addon/hint/html-hint.js
vendored
Executable file → Normal file
0
gui/public/codemirror/addon/hint/html-hint.js
vendored
Executable file → Normal file
0
gui/public/codemirror/addon/hint/javascript-hint.js
vendored
Executable file → Normal file
0
gui/public/codemirror/addon/hint/javascript-hint.js
vendored
Executable file → Normal file
0
gui/public/codemirror/addon/hint/show-hint.css
vendored
Executable file → Normal file
0
gui/public/codemirror/addon/hint/show-hint.css
vendored
Executable file → Normal file
8
gui/public/codemirror/addon/hint/show-hint.js
vendored
Executable file → Normal file
8
gui/public/codemirror/addon/hint/show-hint.js
vendored
Executable file → Normal file
|
@ -121,7 +121,6 @@
|
|||
var picked = (this.widget && this.widget.picked) || (first && this.options.completeSingle);
|
||||
if (this.widget) this.widget.close();
|
||||
|
||||
if (data && this.data && isNewCompletion(this.data, data)) return;
|
||||
this.data = data;
|
||||
|
||||
if (data && data.list.length) {
|
||||
|
@ -135,11 +134,6 @@
|
|||
}
|
||||
};
|
||||
|
||||
function isNewCompletion(old, nw) {
|
||||
var moved = CodeMirror.cmpPos(nw.from, old.from)
|
||||
return moved > 0 && old.to.ch - old.from.ch != nw.to.ch - nw.from.ch
|
||||
}
|
||||
|
||||
function parseOptions(cm, pos, options) {
|
||||
var editor = cm.options.hintOptions;
|
||||
var out = {};
|
||||
|
@ -302,7 +296,7 @@
|
|||
setTimeout(function(){cm.focus();}, 20);
|
||||
});
|
||||
|
||||
CodeMirror.signal(data, "select", completions[0], hints.firstChild);
|
||||
CodeMirror.signal(data, "select", completions[this.selectedHint], hints.childNodes[this.selectedHint]);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
47
gui/public/codemirror/addon/hint/sql-hint.js
vendored
Executable file → Normal file
47
gui/public/codemirror/addon/hint/sql-hint.js
vendored
Executable file → Normal file
|
@ -14,6 +14,7 @@
|
|||
var tables;
|
||||
var defaultTable;
|
||||
var keywords;
|
||||
var identifierQuote;
|
||||
var CONS = {
|
||||
QUERY_DIV: ";",
|
||||
ALIAS_KEYWORD: "AS"
|
||||
|
@ -28,6 +29,12 @@
|
|||
return CodeMirror.resolveMode(mode).keywords;
|
||||
}
|
||||
|
||||
function getIdentifierQuote(editor) {
|
||||
var mode = editor.doc.modeOption;
|
||||
if (mode === "sql") mode = "text/x-sql";
|
||||
return CodeMirror.resolveMode(mode).identifierQuote || "`";
|
||||
}
|
||||
|
||||
function getText(item) {
|
||||
return typeof item == "string" ? item : item.text;
|
||||
}
|
||||
|
@ -86,17 +93,25 @@
|
|||
}
|
||||
|
||||
function cleanName(name) {
|
||||
// Get rid name from backticks(`) and preceding dot(.)
|
||||
// Get rid name from identifierQuote and preceding dot(.)
|
||||
if (name.charAt(0) == ".") {
|
||||
name = name.substr(1);
|
||||
}
|
||||
return name.replace(/`/g, "");
|
||||
// replace doublicated identifierQuotes with single identifierQuotes
|
||||
// and remove single identifierQuotes
|
||||
var nameParts = name.split(identifierQuote+identifierQuote);
|
||||
for (var i = 0; i < nameParts.length; i++)
|
||||
nameParts[i] = nameParts[i].replace(new RegExp(identifierQuote,"g"), "");
|
||||
return nameParts.join(identifierQuote);
|
||||
}
|
||||
|
||||
function insertBackticks(name) {
|
||||
function insertIdentifierQuotes(name) {
|
||||
var nameParts = getText(name).split(".");
|
||||
for (var i = 0; i < nameParts.length; i++)
|
||||
nameParts[i] = "`" + nameParts[i] + "`";
|
||||
nameParts[i] = identifierQuote +
|
||||
// doublicate identifierQuotes
|
||||
nameParts[i].replace(new RegExp(identifierQuote,"g"), identifierQuote+identifierQuote) +
|
||||
identifierQuote;
|
||||
var escaped = nameParts.join(".");
|
||||
if (typeof name == "string") return escaped;
|
||||
name = shallowClone(name);
|
||||
|
@ -106,13 +121,13 @@
|
|||
|
||||
function nameCompletion(cur, token, result, editor) {
|
||||
// Try to complete table, column names and return start position of completion
|
||||
var useBacktick = false;
|
||||
var useIdentifierQuotes = false;
|
||||
var nameParts = [];
|
||||
var start = token.start;
|
||||
var cont = true;
|
||||
while (cont) {
|
||||
cont = (token.string.charAt(0) == ".");
|
||||
useBacktick = useBacktick || (token.string.charAt(0) == "`");
|
||||
useIdentifierQuotes = useIdentifierQuotes || (token.string.charAt(0) == identifierQuote);
|
||||
|
||||
start = token.start;
|
||||
nameParts.unshift(cleanName(token.string));
|
||||
|
@ -127,12 +142,12 @@
|
|||
// Try to complete table names
|
||||
var string = nameParts.join(".");
|
||||
addMatches(result, string, tables, function(w) {
|
||||
return useBacktick ? insertBackticks(w) : w;
|
||||
return useIdentifierQuotes ? insertIdentifierQuotes(w) : w;
|
||||
});
|
||||
|
||||
// Try to complete columns from defaultTable
|
||||
addMatches(result, string, defaultTable, function(w) {
|
||||
return useBacktick ? insertBackticks(w) : w;
|
||||
return useIdentifierQuotes ? insertIdentifierQuotes(w) : w;
|
||||
});
|
||||
|
||||
// Try to complete columns
|
||||
|
@ -162,7 +177,7 @@
|
|||
w = shallowClone(w);
|
||||
w.text = tableInsert + "." + w.text;
|
||||
}
|
||||
return useBacktick ? insertBackticks(w) : w;
|
||||
return useIdentifierQuotes ? insertIdentifierQuotes(w) : w;
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -170,12 +185,9 @@
|
|||
}
|
||||
|
||||
function eachWord(lineText, f) {
|
||||
if (!lineText) return;
|
||||
var excepted = /[,;]/g;
|
||||
var words = lineText.split(" ");
|
||||
for (var i = 0; i < words.length; i++) {
|
||||
f(words[i]?words[i].replace(excepted, '') : '');
|
||||
}
|
||||
var words = lineText.split(/\s+/)
|
||||
for (var i = 0; i < words.length; i++)
|
||||
if (words[i]) f(words[i].replace(/[,;]/g, ''))
|
||||
}
|
||||
|
||||
function findTableByAlias(alias, editor) {
|
||||
|
@ -232,6 +244,7 @@
|
|||
var disableKeywords = options && options.disableKeywords;
|
||||
defaultTable = defaultTableName && getTable(defaultTableName);
|
||||
keywords = getKeywords(editor);
|
||||
identifierQuote = getIdentifierQuote(editor);
|
||||
|
||||
if (defaultTableName && !defaultTable)
|
||||
defaultTable = findTableByAlias(defaultTableName, editor);
|
||||
|
@ -249,7 +262,7 @@
|
|||
token.string = token.string.slice(0, cur.ch - token.start);
|
||||
}
|
||||
|
||||
if (token.string.match(/^[.`\w@]\w*$/)) {
|
||||
if (token.string.match(/^[.`"\w@]\w*$/)) {
|
||||
search = token.string;
|
||||
start = token.start;
|
||||
end = token.end;
|
||||
|
@ -257,7 +270,7 @@
|
|||
start = end = cur.ch;
|
||||
search = "";
|
||||
}
|
||||
if (search.charAt(0) == "." || search.charAt(0) == "`") {
|
||||
if (search.charAt(0) == "." || search.charAt(0) == identifierQuote) {
|
||||
start = nameCompletion(cur, token, result, editor);
|
||||
} else {
|
||||
addMatches(result, search, tables, function(w) {return w;});
|
||||
|
|
0
gui/public/codemirror/addon/hint/xml-hint.js
vendored
Executable file → Normal file
0
gui/public/codemirror/addon/hint/xml-hint.js
vendored
Executable file → Normal file
6
gui/public/codemirror/addon/lint/coffeescript-lint.js
vendored
Executable file → Normal file
6
gui/public/codemirror/addon/lint/coffeescript-lint.js
vendored
Executable file → Normal file
|
@ -17,6 +17,12 @@
|
|||
|
||||
CodeMirror.registerHelper("lint", "coffeescript", function(text) {
|
||||
var found = [];
|
||||
if (!window.coffeelint) {
|
||||
if (window.console) {
|
||||
window.console.error("Error: window.coffeelint not defined, CodeMirror CoffeeScript linting cannot run.");
|
||||
}
|
||||
return found;
|
||||
}
|
||||
var parseError = function(err) {
|
||||
var loc = err.lineNumber;
|
||||
found.push({from: CodeMirror.Pos(loc-1, 0),
|
||||
|
|
11
gui/public/codemirror/addon/lint/css-lint.js
vendored
Executable file → Normal file
11
gui/public/codemirror/addon/lint/css-lint.js
vendored
Executable file → Normal file
|
@ -15,10 +15,15 @@
|
|||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
CodeMirror.registerHelper("lint", "css", function(text) {
|
||||
CodeMirror.registerHelper("lint", "css", function(text, options) {
|
||||
var found = [];
|
||||
if (!window.CSSLint) return found;
|
||||
var results = CSSLint.verify(text), messages = results.messages, message = null;
|
||||
if (!window.CSSLint) {
|
||||
if (window.console) {
|
||||
window.console.error("Error: window.CSSLint not defined, CodeMirror CSS linting cannot run.");
|
||||
}
|
||||
return found;
|
||||
}
|
||||
var results = CSSLint.verify(text, options), messages = results.messages, message = null;
|
||||
for ( var i = 0; i < messages.length; i++) {
|
||||
message = messages[i];
|
||||
var startLine = message.line -1, endLine = message.line -1, startCol = message.col -1, endCol = message.col;
|
||||
|
|
13
gui/public/codemirror/addon/lint/html-lint.js
vendored
Executable file → Normal file
13
gui/public/codemirror/addon/lint/html-lint.js
vendored
Executable file → Normal file
|
@ -11,8 +11,8 @@
|
|||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror", "htmlhint"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
mod(CodeMirror, window.HTMLHint);
|
||||
})(function(CodeMirror, HTMLHint) {
|
||||
"use strict";
|
||||
|
||||
var defaultRules = {
|
||||
|
@ -29,7 +29,14 @@
|
|||
|
||||
CodeMirror.registerHelper("lint", "html", function(text, options) {
|
||||
var found = [];
|
||||
if (!window.HTMLHint) return found;
|
||||
if (HTMLHint && !HTMLHint.verify) HTMLHint = HTMLHint.HTMLHint;
|
||||
if (!HTMLHint) HTMLHint = window.HTMLHint;
|
||||
if (!HTMLHint) {
|
||||
if (window.console) {
|
||||
window.console.error("Error: HTMLHint not found, not defined on window, or not available through define/require, CodeMirror HTML linting cannot run.");
|
||||
}
|
||||
return found;
|
||||
}
|
||||
var messages = HTMLHint.verify(text, options && options.rules || defaultRules);
|
||||
for (var i = 0; i < messages.length; i++) {
|
||||
var message = messages[i];
|
||||
|
|
7
gui/public/codemirror/addon/lint/javascript-lint.js
vendored
Executable file → Normal file
7
gui/public/codemirror/addon/lint/javascript-lint.js
vendored
Executable file → Normal file
|
@ -22,7 +22,12 @@
|
|||
"Unclosed string", "Stopping, unable to continue" ];
|
||||
|
||||
function validator(text, options) {
|
||||
if (!window.JSHINT) return [];
|
||||
if (!window.JSHINT) {
|
||||
if (window.console) {
|
||||
window.console.error("Error: window.JSHINT not defined, CodeMirror JavaScript linting cannot run.");
|
||||
}
|
||||
return [];
|
||||
}
|
||||
JSHINT(text, options, options.globals);
|
||||
var errors = JSHINT.data().errors, result = [];
|
||||
if (errors) parseErrors(errors, result);
|
||||
|
|
6
gui/public/codemirror/addon/lint/json-lint.js
vendored
Executable file → Normal file
6
gui/public/codemirror/addon/lint/json-lint.js
vendored
Executable file → Normal file
|
@ -17,6 +17,12 @@
|
|||
|
||||
CodeMirror.registerHelper("lint", "json", function(text) {
|
||||
var found = [];
|
||||
if (!window.jsonlint) {
|
||||
if (window.console) {
|
||||
window.console.error("Error: window.jsonlint not defined, CodeMirror JSON linting cannot run.");
|
||||
}
|
||||
return found;
|
||||
}
|
||||
jsonlint.parseError = function(str, hash) {
|
||||
var loc = hash.loc;
|
||||
found.push({from: CodeMirror.Pos(loc.first_line - 1, loc.first_column),
|
||||
|
|
0
gui/public/codemirror/addon/lint/lint.css
vendored
Executable file → Normal file
0
gui/public/codemirror/addon/lint/lint.css
vendored
Executable file → Normal file
17
gui/public/codemirror/addon/lint/lint.js
vendored
Executable file → Normal file
17
gui/public/codemirror/addon/lint/lint.js
vendored
Executable file → Normal file
|
@ -112,7 +112,11 @@
|
|||
if (!severity) severity = "error";
|
||||
var tip = document.createElement("div");
|
||||
tip.className = "CodeMirror-lint-message-" + severity;
|
||||
if (typeof ann.messageHTML != 'undefined') {
|
||||
tip.innerHTML = ann.messageHTML;
|
||||
} else {
|
||||
tip.appendChild(document.createTextNode(ann.message));
|
||||
}
|
||||
return tip;
|
||||
}
|
||||
|
||||
|
@ -134,13 +138,22 @@
|
|||
|
||||
function startLinting(cm) {
|
||||
var state = cm.state.lint, options = state.options;
|
||||
var passOptions = options.options || options; // Support deprecated passing of `options` property in options
|
||||
/*
|
||||
* Passing rules in `options` property prevents JSHint (and other linters) from complaining
|
||||
* about unrecognized rules like `onUpdateLinting`, `delay`, `lintOnChange`, etc.
|
||||
*/
|
||||
var passOptions = options.options || options;
|
||||
var getAnnotations = options.getAnnotations || cm.getHelper(CodeMirror.Pos(0, 0), "lint");
|
||||
if (!getAnnotations) return;
|
||||
if (options.async || getAnnotations.async) {
|
||||
lintAsync(cm, getAnnotations, passOptions)
|
||||
} else {
|
||||
updateLinting(cm, getAnnotations(cm.getValue(), passOptions, cm));
|
||||
var annotations = getAnnotations(cm.getValue(), passOptions, cm);
|
||||
if (!annotations) return;
|
||||
if (annotations.then) annotations.then(function(issues) {
|
||||
updateLinting(cm, issues);
|
||||
});
|
||||
else updateLinting(cm, annotations);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
17
gui/public/codemirror/addon/lint/yaml-lint.js
vendored
Executable file → Normal file
17
gui/public/codemirror/addon/lint/yaml-lint.js
vendored
Executable file → Normal file
|
@ -17,10 +17,23 @@
|
|||
|
||||
CodeMirror.registerHelper("lint", "yaml", function(text) {
|
||||
var found = [];
|
||||
if (!window.jsyaml) {
|
||||
if (window.console) {
|
||||
window.console.error("Error: window.jsyaml not defined, CodeMirror YAML linting cannot run.");
|
||||
}
|
||||
return found;
|
||||
}
|
||||
try { jsyaml.load(text); }
|
||||
catch(e) {
|
||||
var loc = e.mark;
|
||||
found.push({ from: CodeMirror.Pos(loc.line, loc.column), to: CodeMirror.Pos(loc.line, loc.column), message: e.message });
|
||||
var loc = e.mark,
|
||||
// js-yaml YAMLException doesn't always provide an accurate lineno
|
||||
// e.g., when there are multiple yaml docs
|
||||
// ---
|
||||
// ---
|
||||
// foo:bar
|
||||
from = loc ? CodeMirror.Pos(loc.line, loc.column) : CodeMirror.Pos(0, 0),
|
||||
to = from;
|
||||
found.push({ from: from, to: to, message: e.message });
|
||||
}
|
||||
return found;
|
||||
});
|
||||
|
|
0
gui/public/codemirror/addon/merge/merge.css
vendored
Executable file → Normal file
0
gui/public/codemirror/addon/merge/merge.css
vendored
Executable file → Normal file
51
gui/public/codemirror/addon/merge/merge.js
vendored
Executable file → Normal file
51
gui/public/codemirror/addon/merge/merge.js
vendored
Executable file → Normal file
|
@ -49,17 +49,17 @@
|
|||
if (Object.prototype.toString.call(classLocation) != "[object Array]") classLocation = [classLocation]
|
||||
this.classes.classLocation = classLocation
|
||||
|
||||
this.diff = getDiff(asString(orig), asString(options.value));
|
||||
this.diff = getDiff(asString(orig), asString(options.value), this.mv.options.ignoreWhitespace);
|
||||
this.chunks = getChunks(this.diff);
|
||||
this.diffOutOfDate = this.dealigned = false;
|
||||
this.needsScrollSync = null
|
||||
|
||||
this.showDifferences = options.showDifferences !== false;
|
||||
},
|
||||
registerEvents: function() {
|
||||
registerEvents: function(otherDv) {
|
||||
this.forceUpdate = registerUpdate(this);
|
||||
setScrollLock(this, true, false);
|
||||
registerScroll(this);
|
||||
registerScroll(this, otherDv);
|
||||
},
|
||||
setShowDifferences: function(val) {
|
||||
val = val !== false;
|
||||
|
@ -72,7 +72,7 @@
|
|||
|
||||
function ensureDiff(dv) {
|
||||
if (dv.diffOutOfDate) {
|
||||
dv.diff = getDiff(dv.orig.getValue(), dv.edit.getValue());
|
||||
dv.diff = getDiff(dv.orig.getValue(), dv.edit.getValue(), dv.mv.options.ignoreWhitespace);
|
||||
dv.chunks = getChunks(dv.diff);
|
||||
dv.diffOutOfDate = false;
|
||||
CodeMirror.signal(dv.edit, "updateDiff", dv.diff);
|
||||
|
@ -128,6 +128,7 @@
|
|||
}
|
||||
function swapDoc() {
|
||||
dv.diffOutOfDate = true;
|
||||
dv.dealigned = true;
|
||||
update("full");
|
||||
}
|
||||
dv.edit.on("change", change);
|
||||
|
@ -144,12 +145,13 @@
|
|||
return update;
|
||||
}
|
||||
|
||||
function registerScroll(dv) {
|
||||
function registerScroll(dv, otherDv) {
|
||||
dv.edit.on("scroll", function() {
|
||||
syncScroll(dv, true) && makeConnections(dv);
|
||||
});
|
||||
dv.orig.on("scroll", function() {
|
||||
syncScroll(dv, false) && makeConnections(dv);
|
||||
if (otherDv) syncScroll(otherDv, true) && makeConnections(otherDv);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -352,11 +354,11 @@
|
|||
var result = []
|
||||
for (var i = 0;; i++) {
|
||||
var chunk = chunks[i]
|
||||
var chunkStart = !chunk ? cm.lastLine() + 1 : isOrig ? chunk.origFrom : chunk.editFrom
|
||||
var chunkStart = !chunk ? 1e9 : isOrig ? chunk.origFrom : chunk.editFrom
|
||||
for (; trackI < tracker.alignable.length; trackI += 2) {
|
||||
var n = tracker.alignable[trackI] + 1
|
||||
if (n <= start) continue
|
||||
if (n < chunkStart) result.push(n)
|
||||
if (n <= chunkStart) result.push(n)
|
||||
else break
|
||||
}
|
||||
if (!chunk) break
|
||||
|
@ -370,14 +372,22 @@
|
|||
// lines that need to be aligned with each other.
|
||||
function mergeAlignable(result, origAlignable, chunks, setIndex) {
|
||||
var rI = 0, origI = 0, chunkI = 0, diff = 0
|
||||
for (;; rI++) {
|
||||
outer: for (;; rI++) {
|
||||
var nextR = result[rI], nextO = origAlignable[origI]
|
||||
if (!nextR && nextO == null) break
|
||||
|
||||
var rLine = nextR ? nextR[0] : 1e9, oLine = nextO == null ? 1e9 : nextO
|
||||
while (chunkI < chunks.length) {
|
||||
var chunk = chunks[chunkI]
|
||||
if (chunk.editTo > rLine) break
|
||||
if (chunk.origFrom <= oLine && chunk.origTo > oLine) {
|
||||
origI++
|
||||
rI--
|
||||
continue outer;
|
||||
}
|
||||
if (chunk.editTo > rLine) {
|
||||
if (chunk.editFrom <= rLine) continue outer;
|
||||
break
|
||||
}
|
||||
diff += (chunk.origTo - chunk.origFrom) - (chunk.editTo - chunk.editFrom)
|
||||
chunkI++
|
||||
}
|
||||
|
@ -467,7 +477,7 @@
|
|||
var elt = document.createElement("div");
|
||||
elt.className = "CodeMirror-merge-spacer";
|
||||
elt.style.height = size + "px"; elt.style.minWidth = "1px";
|
||||
return cm.addLineWidget(line, elt, {height: size, above: above, mergeSpacer: true});
|
||||
return cm.addLineWidget(line, elt, {height: size, above: above, mergeSpacer: true, handleMouseEvents: true});
|
||||
}
|
||||
|
||||
function drawConnectorsForChunk(dv, chunk, sTopOrig, sTopEdit, w) {
|
||||
|
@ -567,8 +577,8 @@
|
|||
this.aligners = [];
|
||||
alignChunks(this.left || this.right, true);
|
||||
}
|
||||
if (left) left.registerEvents()
|
||||
if (right) right.registerEvents()
|
||||
if (left) left.registerEvents(right)
|
||||
if (right) right.registerEvents(left)
|
||||
|
||||
|
||||
var onResize = function() {
|
||||
|
@ -634,14 +644,15 @@
|
|||
}
|
||||
|
||||
// Operations on diffs
|
||||
var dmp;
|
||||
function getDiff(a, b, ignoreWhitespace) {
|
||||
if (!dmp) dmp = new diff_match_patch();
|
||||
|
||||
var dmp = new diff_match_patch();
|
||||
function getDiff(a, b) {
|
||||
var diff = dmp.diff_main(a, b);
|
||||
// The library sometimes leaves in empty parts, which confuse the algorithm
|
||||
for (var i = 0; i < diff.length; ++i) {
|
||||
var part = diff[i];
|
||||
if (!part[1]) {
|
||||
if (ignoreWhitespace ? !/[^ \t]/.test(part[1]) : !part[1]) {
|
||||
diff.splice(i--, 1);
|
||||
} else if (i && diff[i - 1][0] == part[0]) {
|
||||
diff.splice(i--, 1);
|
||||
|
@ -658,7 +669,7 @@
|
|||
for (var i = 0; i < diff.length; ++i) {
|
||||
var part = diff[i], tp = part[0];
|
||||
if (tp == DIFF_EQUAL) {
|
||||
var startOff = startOfLineClean(diff, i) ? 0 : 1;
|
||||
var startOff = !startOfLineClean(diff, i) || edit.line < startEdit || orig.line < startOrig ? 1 : 0;
|
||||
var cleanFromEdit = edit.line + startOff, cleanFromOrig = orig.line + startOff;
|
||||
moveOver(edit, part[1], null, orig);
|
||||
var endOff = endOfLineClean(diff, i) ? 1 : 0;
|
||||
|
@ -727,6 +738,9 @@
|
|||
mark.clear();
|
||||
cm.removeLineClass(from, "wrap", "CodeMirror-merge-collapsed-line");
|
||||
}
|
||||
if (mark.explicitlyCleared) clear();
|
||||
CodeMirror.on(widget, "click", clear);
|
||||
mark.on("clear", clear);
|
||||
CodeMirror.on(widget, "click", clear);
|
||||
return {mark: mark, clear: clear};
|
||||
}
|
||||
|
@ -826,6 +840,7 @@
|
|||
function TrackAlignable(cm) {
|
||||
this.cm = cm
|
||||
this.alignable = []
|
||||
this.height = cm.doc.height
|
||||
var self = this
|
||||
cm.on("markerAdded", function(_, marker) {
|
||||
if (!marker.collapsed) return
|
||||
|
@ -855,11 +870,15 @@
|
|||
self.check(end, F_MARKER, self.hasMarker)
|
||||
if (nBefore || nAfter) self.check(change.from.line, F_MARKER, self.hasMarker)
|
||||
})
|
||||
cm.on("viewportChange", function() {
|
||||
if (self.cm.doc.height != self.height) self.signal()
|
||||
})
|
||||
}
|
||||
|
||||
TrackAlignable.prototype = {
|
||||
signal: function() {
|
||||
CodeMirror.signal(this, "realign")
|
||||
this.height = this.cm.doc.height
|
||||
},
|
||||
|
||||
set: function(n, flags) {
|
||||
|
|
0
gui/public/codemirror/addon/mode/loadmode.js
vendored
Executable file → Normal file
0
gui/public/codemirror/addon/mode/loadmode.js
vendored
Executable file → Normal file
0
gui/public/codemirror/addon/mode/multiplex.js
vendored
Executable file → Normal file
0
gui/public/codemirror/addon/mode/multiplex.js
vendored
Executable file → Normal file
0
gui/public/codemirror/addon/mode/multiplex_test.js
vendored
Executable file → Normal file
0
gui/public/codemirror/addon/mode/multiplex_test.js
vendored
Executable file → Normal file
0
gui/public/codemirror/addon/mode/overlay.js
vendored
Executable file → Normal file
0
gui/public/codemirror/addon/mode/overlay.js
vendored
Executable file → Normal file
13
gui/public/codemirror/addon/mode/simple.js
vendored
Executable file → Normal file
13
gui/public/codemirror/addon/mode/simple.js
vendored
Executable file → Normal file
|
@ -77,6 +77,7 @@
|
|||
|
||||
function asToken(val) {
|
||||
if (!val) return null;
|
||||
if (val.apply) return val
|
||||
if (typeof val == "string") return val.replace(/\./g, " ");
|
||||
var result = [];
|
||||
for (var i = 0; i < val.length; i++)
|
||||
|
@ -133,17 +134,19 @@
|
|||
state.indent.push(stream.indentation() + config.indentUnit);
|
||||
if (rule.data.dedent)
|
||||
state.indent.pop();
|
||||
if (matches.length > 2) {
|
||||
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]});
|
||||
stream.backUp(matches[0].length - (matches[1] ? matches[1].length : 0));
|
||||
return rule.token[0];
|
||||
} else if (rule.token && rule.token.join) {
|
||||
return rule.token[0];
|
||||
return token[0];
|
||||
} else if (token && token.join) {
|
||||
return token[0];
|
||||
} else {
|
||||
return rule.token;
|
||||
return token;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
0
gui/public/codemirror/addon/runmode/colorize.js
vendored
Executable file → Normal file
0
gui/public/codemirror/addon/runmode/colorize.js
vendored
Executable file → Normal file
3
gui/public/codemirror/addon/runmode/runmode-standalone.js
vendored
Executable file → Normal file
3
gui/public/codemirror/addon/runmode/runmode-standalone.js
vendored
Executable file → Normal file
|
@ -65,7 +65,8 @@ StringStream.prototype = {
|
|||
this.lineStart += n;
|
||||
try { return inner(); }
|
||||
finally { this.lineStart -= n; }
|
||||
}
|
||||
},
|
||||
lookAhead: function() { return null }
|
||||
};
|
||||
CodeMirror.StringStream = StringStream;
|
||||
|
||||
|
|
0
gui/public/codemirror/addon/runmode/runmode.js
vendored
Executable file → Normal file
0
gui/public/codemirror/addon/runmode/runmode.js
vendored
Executable file → Normal file
26
gui/public/codemirror/addon/runmode/runmode.node.js
vendored
Executable file → Normal file
26
gui/public/codemirror/addon/runmode/runmode.node.js
vendored
Executable file → Normal file
|
@ -7,7 +7,7 @@ function splitLines(string){return string.split(/\r\n?|\n/);};
|
|||
|
||||
// Counts the column offset in a string, taking tabs into account.
|
||||
// Used mostly to find indentation.
|
||||
var countColumn = function(string, end, tabSize, startIndex, startValue) {
|
||||
var countColumn = exports.countColumn = function(string, end, tabSize, startIndex, startValue) {
|
||||
if (end == null) {
|
||||
end = string.search(/[^\s\u00a0]/);
|
||||
if (end == -1) end = string.length;
|
||||
|
@ -22,12 +22,13 @@ var countColumn = function(string, end, tabSize, startIndex, startValue) {
|
|||
}
|
||||
};
|
||||
|
||||
function StringStream(string, tabSize) {
|
||||
function StringStream(string, tabSize, context) {
|
||||
this.pos = this.start = 0;
|
||||
this.string = string;
|
||||
this.tabSize = tabSize || 8;
|
||||
this.lastColumnPos = this.lastColumnValue = 0;
|
||||
this.lineStart = 0;
|
||||
this.context = context
|
||||
};
|
||||
|
||||
StringStream.prototype = {
|
||||
|
@ -91,6 +92,10 @@ StringStream.prototype = {
|
|||
this.lineStart += n;
|
||||
try { return inner(); }
|
||||
finally { this.lineStart -= n; }
|
||||
},
|
||||
lookAhead: function(n) {
|
||||
var line = this.context.line + n
|
||||
return line >= this.context.lines.length ? null : this.context.lines[line]
|
||||
}
|
||||
};
|
||||
exports.StringStream = StringStream;
|
||||
|
@ -158,14 +163,27 @@ exports.getMode = function(options, spec) {
|
|||
|
||||
return modeObj;
|
||||
};
|
||||
|
||||
exports.innerMode = function(mode, state) {
|
||||
var info;
|
||||
while (mode.innerMode) {
|
||||
info = mode.innerMode(state);
|
||||
if (!info || info.mode == mode) break;
|
||||
state = info.state;
|
||||
mode = info.mode;
|
||||
}
|
||||
return info || {mode: mode, state: state};
|
||||
}
|
||||
|
||||
exports.registerHelper = exports.registerGlobalHelper = Math.min;
|
||||
|
||||
exports.runMode = function(string, modespec, callback, options) {
|
||||
var mode = exports.getMode({indentUnit: 2}, modespec);
|
||||
var lines = splitLines(string), state = (options && options.state) || exports.startState(mode);
|
||||
for (var i = 0, e = lines.length; i < e; ++i) {
|
||||
var context = {lines: lines, line: 0}
|
||||
for (var i = 0, e = lines.length; i < e; ++i, ++context.line) {
|
||||
if (i) callback("\n");
|
||||
var stream = new exports.StringStream(lines[i]);
|
||||
var stream = new exports.StringStream(lines[i], 4, context);
|
||||
if (!stream.string && mode.blankLine) mode.blankLine(state);
|
||||
while (!stream.eol()) {
|
||||
var style = mode.token(stream, state);
|
||||
|
|
0
gui/public/codemirror/addon/scroll/annotatescrollbar.js
vendored
Executable file → Normal file
0
gui/public/codemirror/addon/scroll/annotatescrollbar.js
vendored
Executable file → Normal file
0
gui/public/codemirror/addon/scroll/scrollpastend.js
vendored
Executable file → Normal file
0
gui/public/codemirror/addon/scroll/scrollpastend.js
vendored
Executable file → Normal file
0
gui/public/codemirror/addon/scroll/simplescrollbars.css
vendored
Executable file → Normal file
0
gui/public/codemirror/addon/scroll/simplescrollbars.css
vendored
Executable file → Normal file
0
gui/public/codemirror/addon/scroll/simplescrollbars.js
vendored
Executable file → Normal file
0
gui/public/codemirror/addon/scroll/simplescrollbars.js
vendored
Executable file → Normal file
0
gui/public/codemirror/addon/search/jump-to-line.js
vendored
Executable file → Normal file
0
gui/public/codemirror/addon/search/jump-to-line.js
vendored
Executable file → Normal file
0
gui/public/codemirror/addon/search/match-highlighter.js
vendored
Executable file → Normal file
0
gui/public/codemirror/addon/search/match-highlighter.js
vendored
Executable file → Normal file
0
gui/public/codemirror/addon/search/matchesonscrollbar.css
vendored
Executable file → Normal file
0
gui/public/codemirror/addon/search/matchesonscrollbar.css
vendored
Executable file → Normal file
0
gui/public/codemirror/addon/search/matchesonscrollbar.js
vendored
Executable file → Normal file
0
gui/public/codemirror/addon/search/matchesonscrollbar.js
vendored
Executable file → Normal file
14
gui/public/codemirror/addon/search/search.js
vendored
Executable file → Normal file
14
gui/public/codemirror/addon/search/search.js
vendored
Executable file → Normal file
|
@ -54,7 +54,7 @@
|
|||
|
||||
function getSearchCursor(cm, query, pos) {
|
||||
// Heuristic: if the query string is all lowercase, do a case insensitive search.
|
||||
return cm.getSearchCursor(query, pos, queryCaseInsensitive(query));
|
||||
return cm.getSearchCursor(query, pos, {caseFold: queryCaseInsensitive(query), multiline: true});
|
||||
}
|
||||
|
||||
function persistentDialog(cm, text, deflt, onEnter, onKeyDown) {
|
||||
|
@ -99,7 +99,7 @@
|
|||
}
|
||||
|
||||
var queryDialog =
|
||||
'Search: <input type="text" style="width: 10em" class="CodeMirror-search-field"/> <span style="color: #888" class="CodeMirror-search-hint">(Use /re/ syntax for regexp search)</span>';
|
||||
'<span class="CodeMirror-search-label">Search:</span> <input type="text" style="width: 10em" class="CodeMirror-search-field"/> <span style="color: #888" class="CodeMirror-search-hint">(Use /re/ syntax for regexp search)</span>';
|
||||
|
||||
function startSearch(cm, state, query) {
|
||||
state.queryText = query;
|
||||
|
@ -117,6 +117,7 @@
|
|||
var state = getSearchState(cm);
|
||||
if (state.query) return findNext(cm, rev);
|
||||
var q = cm.getSelection() || state.lastQuery;
|
||||
if (q instanceof RegExp && q.source == "x^") q = null
|
||||
if (persistent && cm.openDialog) {
|
||||
var hiding = null
|
||||
var searchNext = function(query, event) {
|
||||
|
@ -137,8 +138,7 @@
|
|||
};
|
||||
persistentDialog(cm, queryDialog, q, searchNext, function(event, query) {
|
||||
var keyName = CodeMirror.keyName(event)
|
||||
var cmd = CodeMirror.keyMap[cm.getOption("keyMap")][keyName]
|
||||
if (!cmd) cmd = cm.getOption('extraKeys')[keyName]
|
||||
var extra = cm.getOption('extraKeys'), cmd = (extra && extra[keyName]) || CodeMirror.keyMap[cm.getOption("keyMap")][keyName]
|
||||
if (cmd == "findNext" || cmd == "findPrev" ||
|
||||
cmd == "findPersistentNext" || cmd == "findPersistentPrev") {
|
||||
CodeMirror.e_stop(event);
|
||||
|
@ -188,8 +188,8 @@
|
|||
|
||||
var replaceQueryDialog =
|
||||
' <input type="text" style="width: 10em" class="CodeMirror-search-field"/> <span style="color: #888" class="CodeMirror-search-hint">(Use /re/ syntax for regexp search)</span>';
|
||||
var replacementQueryDialog = 'With: <input type="text" style="width: 10em" class="CodeMirror-search-field"/>';
|
||||
var doReplaceConfirm = "Replace? <button>Yes</button> <button>No</button> <button>All</button> <button>Stop</button>";
|
||||
var replacementQueryDialog = '<span class="CodeMirror-search-label">With:</span> <input type="text" style="width: 10em" class="CodeMirror-search-field"/>';
|
||||
var doReplaceConfirm = '<span class="CodeMirror-search-label">Replace?</span> <button>Yes</button> <button>No</button> <button>All</button> <button>Stop</button>';
|
||||
|
||||
function replaceAll(cm, query, text) {
|
||||
cm.operation(function() {
|
||||
|
@ -205,7 +205,7 @@
|
|||
function replace(cm, all) {
|
||||
if (cm.getOption("readOnly")) return;
|
||||
var query = cm.getSelection() || getSearchState(cm).lastQuery;
|
||||
var dialogText = all ? "Replace all:" : "Replace:"
|
||||
var dialogText = '<span class="CodeMirror-search-label">' + (all ? 'Replace all:' : 'Replace:') + '</span>';
|
||||
dialog(cm, dialogText + replaceQueryDialog, dialogText, query, function(query) {
|
||||
if (!query) return;
|
||||
query = parseQuery(query);
|
||||
|
|
382
gui/public/codemirror/addon/search/searchcursor.js
vendored
Executable file → Normal file
382
gui/public/codemirror/addon/search/searchcursor.js
vendored
Executable file → Normal file
|
@ -3,187 +3,287 @@
|
|||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"));
|
||||
mod(require("../../lib/codemirror"))
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror"], mod);
|
||||
define(["../../lib/codemirror"], mod)
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
mod(CodeMirror)
|
||||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
var Pos = CodeMirror.Pos;
|
||||
"use strict"
|
||||
var Pos = CodeMirror.Pos
|
||||
|
||||
function SearchCursor(doc, query, pos, caseFold) {
|
||||
this.atOccurrence = false; this.doc = doc;
|
||||
if (caseFold == null && typeof query == "string") caseFold = false;
|
||||
function regexpFlags(regexp) {
|
||||
var flags = regexp.flags
|
||||
return flags != null ? flags : (regexp.ignoreCase ? "i" : "")
|
||||
+ (regexp.global ? "g" : "")
|
||||
+ (regexp.multiline ? "m" : "")
|
||||
}
|
||||
|
||||
pos = pos ? doc.clipPos(pos) : Pos(0, 0);
|
||||
this.pos = {from: pos, to: pos};
|
||||
function ensureGlobal(regexp) {
|
||||
return regexp.global ? regexp : new RegExp(regexp.source, regexpFlags(regexp) + "g")
|
||||
}
|
||||
|
||||
// The matches method is filled in based on the type of query.
|
||||
// It takes a position and a direction, and returns an object
|
||||
// describing the next occurrence of the query, or null if no
|
||||
// more matches were found.
|
||||
if (typeof query != "string") { // Regexp match
|
||||
if (!query.global) query = new RegExp(query.source, query.ignoreCase ? "ig" : "g");
|
||||
this.matches = function(reverse, pos) {
|
||||
if (reverse) {
|
||||
query.lastIndex = 0;
|
||||
var line = doc.getLine(pos.line).slice(0, pos.ch), cutOff = 0, match, start;
|
||||
function maybeMultiline(regexp) {
|
||||
return /\\s|\\n|\n|\\W|\\D|\[\^/.test(regexp.source)
|
||||
}
|
||||
|
||||
function searchRegexpForward(doc, regexp, start) {
|
||||
regexp = ensureGlobal(regexp)
|
||||
for (var line = start.line, ch = start.ch, last = doc.lastLine(); line <= last; line++, ch = 0) {
|
||||
regexp.lastIndex = ch
|
||||
var string = doc.getLine(line), match = regexp.exec(string)
|
||||
if (match)
|
||||
return {from: Pos(line, match.index),
|
||||
to: Pos(line, match.index + match[0].length),
|
||||
match: match}
|
||||
}
|
||||
}
|
||||
|
||||
function searchRegexpForwardMultiline(doc, regexp, start) {
|
||||
if (!maybeMultiline(regexp)) return searchRegexpForward(doc, regexp, start)
|
||||
|
||||
regexp = ensureGlobal(regexp)
|
||||
var string, chunk = 1
|
||||
for (var line = start.line, last = doc.lastLine(); line <= last;) {
|
||||
// This grows the search buffer in exponentially-sized chunks
|
||||
// between matches, so that nearby matches are fast and don't
|
||||
// require concatenating the whole document (in case we're
|
||||
// searching for something that has tons of matches), but at the
|
||||
// same time, the amount of retries is limited.
|
||||
for (var i = 0; i < chunk; i++) {
|
||||
var curLine = doc.getLine(line++)
|
||||
string = string == null ? curLine : string + "\n" + curLine
|
||||
}
|
||||
chunk = chunk * 2
|
||||
regexp.lastIndex = start.ch
|
||||
var match = regexp.exec(string)
|
||||
if (match) {
|
||||
var before = string.slice(0, match.index).split("\n"), inside = match[0].split("\n")
|
||||
var startLine = start.line + before.length - 1, startCh = before[before.length - 1].length
|
||||
return {from: Pos(startLine, startCh),
|
||||
to: Pos(startLine + inside.length - 1,
|
||||
inside.length == 1 ? startCh + inside[0].length : inside[inside.length - 1].length),
|
||||
match: match}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function lastMatchIn(string, regexp) {
|
||||
var cutOff = 0, match
|
||||
for (;;) {
|
||||
query.lastIndex = cutOff;
|
||||
var newMatch = query.exec(line);
|
||||
if (!newMatch) break;
|
||||
match = newMatch;
|
||||
start = match.index;
|
||||
cutOff = match.index + (match[0].length || 1);
|
||||
if (cutOff == line.length) break;
|
||||
}
|
||||
var matchLen = (match && match[0].length) || 0;
|
||||
if (!matchLen) {
|
||||
if (start == 0 && line.length == 0) {match = undefined;}
|
||||
else if (start != doc.getLine(pos.line).length) {
|
||||
matchLen++;
|
||||
regexp.lastIndex = cutOff
|
||||
var newMatch = regexp.exec(string)
|
||||
if (!newMatch) return match
|
||||
match = newMatch
|
||||
cutOff = match.index + (match[0].length || 1)
|
||||
if (cutOff == string.length) return match
|
||||
}
|
||||
}
|
||||
|
||||
function searchRegexpBackward(doc, regexp, start) {
|
||||
regexp = ensureGlobal(regexp)
|
||||
for (var line = start.line, ch = start.ch, first = doc.firstLine(); line >= first; line--, ch = -1) {
|
||||
var string = doc.getLine(line)
|
||||
if (ch > -1) string = string.slice(0, ch)
|
||||
var match = lastMatchIn(string, regexp)
|
||||
if (match)
|
||||
return {from: Pos(line, match.index),
|
||||
to: Pos(line, match.index + match[0].length),
|
||||
match: match}
|
||||
}
|
||||
}
|
||||
|
||||
function searchRegexpBackwardMultiline(doc, regexp, start) {
|
||||
regexp = ensureGlobal(regexp)
|
||||
var string, chunk = 1
|
||||
for (var line = start.line, first = doc.firstLine(); line >= first;) {
|
||||
for (var i = 0; i < chunk; i++) {
|
||||
var curLine = doc.getLine(line--)
|
||||
string = string == null ? curLine.slice(0, start.ch) : curLine + "\n" + string
|
||||
}
|
||||
chunk *= 2
|
||||
|
||||
var match = lastMatchIn(string, regexp)
|
||||
if (match) {
|
||||
var before = string.slice(0, match.index).split("\n"), inside = match[0].split("\n")
|
||||
var startLine = line + before.length, startCh = before[before.length - 1].length
|
||||
return {from: Pos(startLine, startCh),
|
||||
to: Pos(startLine + inside.length - 1,
|
||||
inside.length == 1 ? startCh + inside[0].length : inside[inside.length - 1].length),
|
||||
match: match}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var doFold, noFold
|
||||
if (String.prototype.normalize) {
|
||||
doFold = function(str) { return str.normalize("NFD").toLowerCase() }
|
||||
noFold = function(str) { return str.normalize("NFD") }
|
||||
} else {
|
||||
query.lastIndex = pos.ch;
|
||||
var line = doc.getLine(pos.line), match = query.exec(line);
|
||||
var matchLen = (match && match[0].length) || 0;
|
||||
var start = match && match.index;
|
||||
if (start + matchLen != line.length && !matchLen) matchLen = 1;
|
||||
doFold = function(str) { return str.toLowerCase() }
|
||||
noFold = function(str) { return str }
|
||||
}
|
||||
if (match && matchLen)
|
||||
return {from: Pos(pos.line, start),
|
||||
to: Pos(pos.line, start + matchLen),
|
||||
match: match};
|
||||
};
|
||||
} else { // String query
|
||||
var origQuery = query;
|
||||
if (caseFold) query = query.toLowerCase();
|
||||
var fold = caseFold ? function(str){return str.toLowerCase();} : function(str){return str;};
|
||||
var target = query.split("\n");
|
||||
// Different methods for single-line and multi-line queries
|
||||
if (target.length == 1) {
|
||||
if (!query.length) {
|
||||
// Empty string would match anything and never progress, so
|
||||
// we define it to match nothing instead.
|
||||
this.matches = function() {};
|
||||
|
||||
// Maps a position in a case-folded line back to a position in the original line
|
||||
// (compensating for codepoints increasing in number during folding)
|
||||
function adjustPos(orig, folded, pos, foldFunc) {
|
||||
if (orig.length == folded.length) return pos
|
||||
for (var min = 0, max = pos + Math.max(0, orig.length - folded.length);;) {
|
||||
if (min == max) return min
|
||||
var mid = (min + max) >> 1
|
||||
var len = foldFunc(orig.slice(0, mid)).length
|
||||
if (len == pos) return mid
|
||||
else if (len > pos) max = mid
|
||||
else min = mid + 1
|
||||
}
|
||||
}
|
||||
|
||||
function searchStringForward(doc, query, start, caseFold) {
|
||||
// Empty string would match anything and never progress, so we
|
||||
// define it to match nothing instead.
|
||||
if (!query.length) return null
|
||||
var fold = caseFold ? doFold : noFold
|
||||
var lines = fold(query).split(/\r|\n\r?/)
|
||||
|
||||
search: for (var line = start.line, ch = start.ch, last = doc.lastLine() + 1 - lines.length; line <= last; line++, ch = 0) {
|
||||
var orig = doc.getLine(line).slice(ch), string = fold(orig)
|
||||
if (lines.length == 1) {
|
||||
var found = string.indexOf(lines[0])
|
||||
if (found == -1) continue search
|
||||
var start = adjustPos(orig, string, found, fold) + ch
|
||||
return {from: Pos(line, adjustPos(orig, string, found, fold) + ch),
|
||||
to: Pos(line, adjustPos(orig, string, found + lines[0].length, fold) + ch)}
|
||||
} else {
|
||||
var cutFrom = string.length - lines[0].length
|
||||
if (string.slice(cutFrom) != lines[0]) continue search
|
||||
for (var i = 1; i < lines.length - 1; i++)
|
||||
if (fold(doc.getLine(line + i)) != lines[i]) continue search
|
||||
var end = doc.getLine(line + lines.length - 1), endString = fold(end), lastLine = lines[lines.length - 1]
|
||||
if (endString.slice(0, lastLine.length) != lastLine) continue search
|
||||
return {from: Pos(line, adjustPos(orig, string, cutFrom, fold) + ch),
|
||||
to: Pos(line + lines.length - 1, adjustPos(end, endString, lastLine.length, fold))}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function searchStringBackward(doc, query, start, caseFold) {
|
||||
if (!query.length) return null
|
||||
var fold = caseFold ? doFold : noFold
|
||||
var lines = fold(query).split(/\r|\n\r?/)
|
||||
|
||||
search: for (var line = start.line, ch = start.ch, first = doc.firstLine() - 1 + lines.length; line >= first; line--, ch = -1) {
|
||||
var orig = doc.getLine(line)
|
||||
if (ch > -1) orig = orig.slice(0, ch)
|
||||
var string = fold(orig)
|
||||
if (lines.length == 1) {
|
||||
var found = string.lastIndexOf(lines[0])
|
||||
if (found == -1) continue search
|
||||
return {from: Pos(line, adjustPos(orig, string, found, fold)),
|
||||
to: Pos(line, adjustPos(orig, string, found + lines[0].length, fold))}
|
||||
} else {
|
||||
var lastLine = lines[lines.length - 1]
|
||||
if (string.slice(0, lastLine.length) != lastLine) continue search
|
||||
for (var i = 1, start = line - lines.length + 1; i < lines.length - 1; i++)
|
||||
if (fold(doc.getLine(start + i)) != lines[i]) continue search
|
||||
var top = doc.getLine(line + 1 - lines.length), topString = fold(top)
|
||||
if (topString.slice(topString.length - lines[0].length) != lines[0]) continue search
|
||||
return {from: Pos(line + 1 - lines.length, adjustPos(top, topString, top.length - lines[0].length, fold)),
|
||||
to: Pos(line, adjustPos(orig, string, lastLine.length, fold))}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function SearchCursor(doc, query, pos, options) {
|
||||
this.atOccurrence = false
|
||||
this.doc = doc
|
||||
pos = pos ? doc.clipPos(pos) : Pos(0, 0)
|
||||
this.pos = {from: pos, to: pos}
|
||||
|
||||
var caseFold
|
||||
if (typeof options == "object") {
|
||||
caseFold = options.caseFold
|
||||
} else { // Backwards compat for when caseFold was the 4th argument
|
||||
caseFold = options
|
||||
options = null
|
||||
}
|
||||
|
||||
if (typeof query == "string") {
|
||||
if (caseFold == null) caseFold = false
|
||||
this.matches = function(reverse, pos) {
|
||||
if (reverse) {
|
||||
var orig = doc.getLine(pos.line).slice(0, pos.ch), line = fold(orig);
|
||||
var match = line.lastIndexOf(query);
|
||||
if (match > -1) {
|
||||
match = adjustPos(orig, line, match);
|
||||
return {from: Pos(pos.line, match), to: Pos(pos.line, match + origQuery.length)};
|
||||
return (reverse ? searchStringBackward : searchStringForward)(doc, query, pos, caseFold)
|
||||
}
|
||||
} else {
|
||||
var orig = doc.getLine(pos.line).slice(pos.ch), line = fold(orig);
|
||||
var match = line.indexOf(query);
|
||||
if (match > -1) {
|
||||
match = adjustPos(orig, line, match) + pos.ch;
|
||||
return {from: Pos(pos.line, match), to: Pos(pos.line, match + origQuery.length)};
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
} else {
|
||||
var origTarget = origQuery.split("\n");
|
||||
query = ensureGlobal(query)
|
||||
if (!options || options.multiline !== false)
|
||||
this.matches = function(reverse, pos) {
|
||||
var last = target.length - 1;
|
||||
if (reverse) {
|
||||
if (pos.line - (target.length - 1) < doc.firstLine()) return;
|
||||
if (fold(doc.getLine(pos.line).slice(0, origTarget[last].length)) != target[target.length - 1]) return;
|
||||
var to = Pos(pos.line, origTarget[last].length);
|
||||
for (var ln = pos.line - 1, i = last - 1; i >= 1; --i, --ln)
|
||||
if (target[i] != fold(doc.getLine(ln))) return;
|
||||
var line = doc.getLine(ln), cut = line.length - origTarget[0].length;
|
||||
if (fold(line.slice(cut)) != target[0]) return;
|
||||
return {from: Pos(ln, cut), to: to};
|
||||
} else {
|
||||
if (pos.line + (target.length - 1) > doc.lastLine()) return;
|
||||
var line = doc.getLine(pos.line), cut = line.length - origTarget[0].length;
|
||||
if (fold(line.slice(cut)) != target[0]) return;
|
||||
var from = Pos(pos.line, cut);
|
||||
for (var ln = pos.line + 1, i = 1; i < last; ++i, ++ln)
|
||||
if (target[i] != fold(doc.getLine(ln))) return;
|
||||
if (fold(doc.getLine(ln).slice(0, origTarget[last].length)) != target[last]) return;
|
||||
return {from: from, to: Pos(ln, origTarget[last].length)};
|
||||
return (reverse ? searchRegexpBackwardMultiline : searchRegexpForwardMultiline)(doc, query, pos)
|
||||
}
|
||||
};
|
||||
else
|
||||
this.matches = function(reverse, pos) {
|
||||
return (reverse ? searchRegexpBackward : searchRegexpForward)(doc, query, pos)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SearchCursor.prototype = {
|
||||
findNext: function() {return this.find(false);},
|
||||
findPrevious: function() {return this.find(true);},
|
||||
findNext: function() {return this.find(false)},
|
||||
findPrevious: function() {return this.find(true)},
|
||||
|
||||
find: function(reverse) {
|
||||
var self = this, pos = this.doc.clipPos(reverse ? this.pos.from : this.pos.to);
|
||||
function savePosAndFail(line) {
|
||||
var pos = Pos(line, 0);
|
||||
self.pos = {from: pos, to: pos};
|
||||
self.atOccurrence = false;
|
||||
return false;
|
||||
var result = this.matches(reverse, this.doc.clipPos(reverse ? this.pos.from : this.pos.to))
|
||||
|
||||
// Implements weird auto-growing behavior on null-matches for
|
||||
// backwards-compatiblity with the vim code (unfortunately)
|
||||
while (result && CodeMirror.cmpPos(result.from, result.to) == 0) {
|
||||
if (reverse) {
|
||||
if (result.from.ch) result.from = Pos(result.from.line, result.from.ch - 1)
|
||||
else if (result.from.line == this.doc.firstLine()) result = null
|
||||
else result = this.matches(reverse, this.doc.clipPos(Pos(result.from.line - 1)))
|
||||
} else {
|
||||
if (result.to.ch < this.doc.getLine(result.to.line).length) result.to = Pos(result.to.line, result.to.ch + 1)
|
||||
else if (result.to.line == this.doc.lastLine()) result = null
|
||||
else result = this.matches(reverse, Pos(result.to.line + 1, 0))
|
||||
}
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
if (this.pos = this.matches(reverse, pos)) {
|
||||
this.atOccurrence = true;
|
||||
return this.pos.match || true;
|
||||
}
|
||||
if (reverse) {
|
||||
if (!pos.line) return savePosAndFail(0);
|
||||
pos = Pos(pos.line-1, this.doc.getLine(pos.line-1).length);
|
||||
}
|
||||
else {
|
||||
var maxLine = this.doc.lineCount();
|
||||
if (pos.line == maxLine - 1) return savePosAndFail(maxLine);
|
||||
pos = Pos(pos.line + 1, 0);
|
||||
}
|
||||
if (result) {
|
||||
this.pos = result
|
||||
this.atOccurrence = true
|
||||
return this.pos.match || true
|
||||
} else {
|
||||
var end = Pos(reverse ? this.doc.firstLine() : this.doc.lastLine() + 1, 0)
|
||||
this.pos = {from: end, to: end}
|
||||
return this.atOccurrence = false
|
||||
}
|
||||
},
|
||||
|
||||
from: function() {if (this.atOccurrence) return this.pos.from;},
|
||||
to: function() {if (this.atOccurrence) return this.pos.to;},
|
||||
from: function() {if (this.atOccurrence) return this.pos.from},
|
||||
to: function() {if (this.atOccurrence) return this.pos.to},
|
||||
|
||||
replace: function(newText, origin) {
|
||||
if (!this.atOccurrence) return;
|
||||
var lines = CodeMirror.splitLines(newText);
|
||||
this.doc.replaceRange(lines, this.pos.from, this.pos.to, origin);
|
||||
if (!this.atOccurrence) return
|
||||
var lines = CodeMirror.splitLines(newText)
|
||||
this.doc.replaceRange(lines, this.pos.from, this.pos.to, origin)
|
||||
this.pos.to = Pos(this.pos.from.line + lines.length - 1,
|
||||
lines[lines.length - 1].length + (lines.length == 1 ? this.pos.from.ch : 0));
|
||||
}
|
||||
};
|
||||
|
||||
// Maps a position in a case-folded line back to a position in the original line
|
||||
// (compensating for codepoints increasing in number during folding)
|
||||
function adjustPos(orig, folded, pos) {
|
||||
if (orig.length == folded.length) return pos;
|
||||
for (var pos1 = Math.min(pos, orig.length);;) {
|
||||
var len1 = orig.slice(0, pos1).toLowerCase().length;
|
||||
if (len1 < pos) ++pos1;
|
||||
else if (len1 > pos) --pos1;
|
||||
else return pos1;
|
||||
lines[lines.length - 1].length + (lines.length == 1 ? this.pos.from.ch : 0))
|
||||
}
|
||||
}
|
||||
|
||||
CodeMirror.defineExtension("getSearchCursor", function(query, pos, caseFold) {
|
||||
return new SearchCursor(this.doc, query, pos, caseFold);
|
||||
});
|
||||
return new SearchCursor(this.doc, query, pos, caseFold)
|
||||
})
|
||||
CodeMirror.defineDocExtension("getSearchCursor", function(query, pos, caseFold) {
|
||||
return new SearchCursor(this, query, pos, caseFold);
|
||||
});
|
||||
return new SearchCursor(this, query, pos, caseFold)
|
||||
})
|
||||
|
||||
CodeMirror.defineExtension("selectMatches", function(query, caseFold) {
|
||||
var ranges = [];
|
||||
var cur = this.getSearchCursor(query, this.getCursor("from"), caseFold);
|
||||
var ranges = []
|
||||
var cur = this.getSearchCursor(query, this.getCursor("from"), caseFold)
|
||||
while (cur.findNext()) {
|
||||
if (CodeMirror.cmpPos(cur.to(), this.getCursor("to")) > 0) break;
|
||||
ranges.push({anchor: cur.from(), head: cur.to()});
|
||||
if (CodeMirror.cmpPos(cur.to(), this.getCursor("to")) > 0) break
|
||||
ranges.push({anchor: cur.from(), head: cur.to()})
|
||||
}
|
||||
if (ranges.length)
|
||||
this.setSelections(ranges, 0);
|
||||
});
|
||||
this.setSelections(ranges, 0)
|
||||
})
|
||||
});
|
||||
|
|
0
gui/public/codemirror/addon/selection/active-line.js
vendored
Executable file → Normal file
0
gui/public/codemirror/addon/selection/active-line.js
vendored
Executable file → Normal file
5
gui/public/codemirror/addon/selection/mark-selection.js
vendored
Executable file → Normal file
5
gui/public/codemirror/addon/selection/mark-selection.js
vendored
Executable file → Normal file
|
@ -34,11 +34,12 @@
|
|||
});
|
||||
|
||||
function onCursorActivity(cm) {
|
||||
if (cm.state.markedSelection)
|
||||
cm.operation(function() { update(cm); });
|
||||
}
|
||||
|
||||
function onChange(cm) {
|
||||
if (cm.state.markedSelection.length)
|
||||
if (cm.state.markedSelection && cm.state.markedSelection.length)
|
||||
cm.operation(function() { clear(cm); });
|
||||
}
|
||||
|
||||
|
@ -85,7 +86,7 @@
|
|||
if (!array.length) return coverRange(cm, from, to);
|
||||
|
||||
var coverStart = array[0].find(), coverEnd = array[array.length - 1].find();
|
||||
if (!coverStart || !coverEnd || to.line - from.line < CHUNK_SIZE ||
|
||||
if (!coverStart || !coverEnd || to.line - from.line <= CHUNK_SIZE ||
|
||||
cmp(from, coverEnd.to) >= 0 || cmp(to, coverStart.from) <= 0)
|
||||
return reset(cm);
|
||||
|
||||
|
|
0
gui/public/codemirror/addon/selection/selection-pointer.js
vendored
Executable file → Normal file
0
gui/public/codemirror/addon/selection/selection-pointer.js
vendored
Executable file → Normal file
0
gui/public/codemirror/addon/tern/tern.css
vendored
Executable file → Normal file
0
gui/public/codemirror/addon/tern/tern.css
vendored
Executable file → Normal file
38
gui/public/codemirror/addon/tern/tern.js
vendored
Executable file → Normal file
38
gui/public/codemirror/addon/tern/tern.js
vendored
Executable file → Normal file
|
@ -334,7 +334,11 @@
|
|||
tip.appendChild(document.createTextNode(tp.rettype ? ") ->\u00a0" : ")"));
|
||||
if (tp.rettype) tip.appendChild(elt("span", cls + "type", tp.rettype));
|
||||
var place = cm.cursorCoords(null, "page");
|
||||
ts.activeArgHints = makeTooltip(place.right + 1, place.bottom, tip);
|
||||
var tooltip = ts.activeArgHints = makeTooltip(place.right + 1, place.bottom, tip)
|
||||
setTimeout(function() {
|
||||
tooltip.clear = onEditorActivity(cm, function() {
|
||||
if (ts.activeArgHints == tooltip) closeArgHints(ts) })
|
||||
}, 20)
|
||||
}
|
||||
|
||||
function parseFnType(text) {
|
||||
|
@ -567,7 +571,7 @@
|
|||
return {type: "part",
|
||||
name: data.name,
|
||||
offsetLines: from.line,
|
||||
text: doc.getRange(from, Pos(endLine, 0))};
|
||||
text: doc.getRange(from, Pos(endLine, end.line == endLine ? null : 0))};
|
||||
}
|
||||
|
||||
// Generic utilities
|
||||
|
@ -604,11 +608,8 @@
|
|||
}
|
||||
function clear() {
|
||||
cm.state.ternTooltip = null;
|
||||
if (!tip.parentNode) return;
|
||||
cm.off("cursorActivity", clear);
|
||||
cm.off('blur', clear);
|
||||
cm.off('scroll', clear);
|
||||
fadeOut(tip);
|
||||
if (tip.parentNode) fadeOut(tip)
|
||||
clearActivity()
|
||||
}
|
||||
var mouseOnTip = false, old = false;
|
||||
CodeMirror.on(tip, "mousemove", function() { mouseOnTip = true; });
|
||||
|
@ -619,9 +620,20 @@
|
|||
}
|
||||
});
|
||||
setTimeout(maybeClear, ts.options.hintDelay ? ts.options.hintDelay : 1700);
|
||||
cm.on("cursorActivity", clear);
|
||||
cm.on('blur', clear);
|
||||
cm.on('scroll', clear);
|
||||
var clearActivity = onEditorActivity(cm, clear)
|
||||
}
|
||||
|
||||
function onEditorActivity(cm, f) {
|
||||
cm.on("cursorActivity", f)
|
||||
cm.on("blur", f)
|
||||
cm.on("scroll", f)
|
||||
cm.on("setDoc", f)
|
||||
return function() {
|
||||
cm.off("cursorActivity", f)
|
||||
cm.off("blur", f)
|
||||
cm.off("scroll", f)
|
||||
cm.off("setDoc", f)
|
||||
}
|
||||
}
|
||||
|
||||
function makeTooltip(x, y, content) {
|
||||
|
@ -650,7 +662,11 @@
|
|||
}
|
||||
|
||||
function closeArgHints(ts) {
|
||||
if (ts.activeArgHints) { remove(ts.activeArgHints); ts.activeArgHints = null; }
|
||||
if (ts.activeArgHints) {
|
||||
if (ts.activeArgHints.clear) ts.activeArgHints.clear()
|
||||
remove(ts.activeArgHints)
|
||||
ts.activeArgHints = null
|
||||
}
|
||||
}
|
||||
|
||||
function docValue(ts, doc) {
|
||||
|
|
0
gui/public/codemirror/addon/tern/worker.js
vendored
Executable file → Normal file
0
gui/public/codemirror/addon/tern/worker.js
vendored
Executable file → Normal file
0
gui/public/codemirror/addon/wrap/hardwrap.js
vendored
Executable file → Normal file
0
gui/public/codemirror/addon/wrap/hardwrap.js
vendored
Executable file → Normal file
1872
gui/public/codemirror/lib/codemirror.js
vendored
1872
gui/public/codemirror/lib/codemirror.js
vendored
File diff suppressed because it is too large
Load diff
0
gui/public/codemirror/mode/apl/apl.js
vendored
Executable file → Normal file
0
gui/public/codemirror/mode/apl/apl.js
vendored
Executable file → Normal file
0
gui/public/codemirror/mode/apl/index.html
vendored
Executable file → Normal file
0
gui/public/codemirror/mode/apl/index.html
vendored
Executable file → Normal file
1
gui/public/codemirror/mode/asciiarmor/asciiarmor.js
vendored
Executable file → Normal file
1
gui/public/codemirror/mode/asciiarmor/asciiarmor.js
vendored
Executable file → Normal file
|
@ -68,6 +68,7 @@
|
|||
});
|
||||
|
||||
CodeMirror.defineMIME("application/pgp", "asciiarmor");
|
||||
CodeMirror.defineMIME("application/pgp-encrypted", "asciiarmor");
|
||||
CodeMirror.defineMIME("application/pgp-keys", "asciiarmor");
|
||||
CodeMirror.defineMIME("application/pgp-signature", "asciiarmor");
|
||||
});
|
||||
|
|
2
gui/public/codemirror/mode/asciiarmor/index.html
vendored
Executable file → Normal file
2
gui/public/codemirror/mode/asciiarmor/index.html
vendored
Executable file → Normal file
|
@ -41,6 +41,6 @@ var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
|||
</script>
|
||||
|
||||
<p><strong>MIME types
|
||||
defined:</strong> <code>application/pgp</code>, <code>application/pgp-keys</code>, <code>application/pgp-signature</code></p>
|
||||
defined:</strong> <code>application/pgp</code>, <code>application/pgp-encrypted</code>, <code>application/pgp-keys</code>, <code>application/pgp-signature</code></p>
|
||||
|
||||
</article>
|
||||
|
|
0
gui/public/codemirror/mode/asn.1/asn.1.js
vendored
Executable file → Normal file
0
gui/public/codemirror/mode/asn.1/asn.1.js
vendored
Executable file → Normal file
0
gui/public/codemirror/mode/asn.1/index.html
vendored
Executable file → Normal file
0
gui/public/codemirror/mode/asn.1/index.html
vendored
Executable file → Normal file
0
gui/public/codemirror/mode/asterisk/asterisk.js
vendored
Executable file → Normal file
0
gui/public/codemirror/mode/asterisk/asterisk.js
vendored
Executable file → Normal file
0
gui/public/codemirror/mode/asterisk/index.html
vendored
Executable file → Normal file
0
gui/public/codemirror/mode/asterisk/index.html
vendored
Executable file → Normal file
0
gui/public/codemirror/mode/brainfuck/brainfuck.js
vendored
Executable file → Normal file
0
gui/public/codemirror/mode/brainfuck/brainfuck.js
vendored
Executable file → Normal file
0
gui/public/codemirror/mode/brainfuck/index.html
vendored
Executable file → Normal file
0
gui/public/codemirror/mode/brainfuck/index.html
vendored
Executable file → Normal file
30
gui/public/codemirror/mode/clike/clike.js
vendored
Executable file → Normal file
30
gui/public/codemirror/mode/clike/clike.js
vendored
Executable file → Normal file
|
@ -33,7 +33,7 @@ function popContext(state) {
|
|||
}
|
||||
|
||||
function typeBefore(stream, state, pos) {
|
||||
if (state.prevToken == "variable" || state.prevToken == "variable-3") return true;
|
||||
if (state.prevToken == "variable" || state.prevToken == "type") return true;
|
||||
if (/\S(?:[^- ]>|[*\]])\s*$|\*$/.test(stream.string.slice(0, pos))) return true;
|
||||
if (state.typeAtEndOfLine && stream.column() == stream.indentation()) return true;
|
||||
}
|
||||
|
@ -64,7 +64,8 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
|
|||
isPunctuationChar = parserConfig.isPunctuationChar || /[\[\]{}\(\),;\:\.]/,
|
||||
numberStart = parserConfig.numberStart || /[\d\.]/,
|
||||
number = parserConfig.number || /^(?:0x[a-f\d]+|0b[01]+|(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?)(u|ll?|l|f)?/i,
|
||||
isOperatorChar = parserConfig.isOperatorChar || /[+\-*&%=<>!?|\/]/;
|
||||
isOperatorChar = parserConfig.isOperatorChar || /[+\-*&%=<>!?|\/]/,
|
||||
isIdentifierChar = parserConfig.isIdentifierChar || /[\w\$_\xa1-\uffff]/;
|
||||
|
||||
var curPunc, isDefKeyword;
|
||||
|
||||
|
@ -101,9 +102,9 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
|
|||
while (!stream.match(/^\/[\/*]/, false) && stream.eat(isOperatorChar)) {}
|
||||
return "operator";
|
||||
}
|
||||
stream.eatWhile(/[\w\$_\xa1-\uffff]/);
|
||||
stream.eatWhile(isIdentifierChar);
|
||||
if (namespaceSeparator) while (stream.match(namespaceSeparator))
|
||||
stream.eatWhile(/[\w\$_\xa1-\uffff]/);
|
||||
stream.eatWhile(isIdentifierChar);
|
||||
|
||||
var cur = stream.current();
|
||||
if (contains(keywords, cur)) {
|
||||
|
@ -111,7 +112,7 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
|
|||
if (contains(defKeywords, cur)) isDefKeyword = true;
|
||||
return "keyword";
|
||||
}
|
||||
if (contains(types, cur)) return "variable-3";
|
||||
if (contains(types, cur)) return "type";
|
||||
if (contains(builtin, cur)) {
|
||||
if (contains(blockKeywords, cur)) curPunc = "newstatement";
|
||||
return "builtin";
|
||||
|
@ -243,6 +244,7 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
|
|||
electricInput: indentSwitch ? /^\s*(?:case .*?:|default:|\{\}?|\})$/ : /^\s*[{}]$/,
|
||||
blockCommentStart: "/*",
|
||||
blockCommentEnd: "*/",
|
||||
blockCommentContinue: " * ",
|
||||
lineComment: "//",
|
||||
fold: "brace"
|
||||
};
|
||||
|
@ -280,7 +282,7 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
|
|||
}
|
||||
|
||||
function pointerHook(_stream, state) {
|
||||
if (state.prevToken == "variable-3") return "variable-3";
|
||||
if (state.prevToken == "type") return "type";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -314,7 +316,7 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
|
|||
}
|
||||
|
||||
function cppLooksLikeConstructor(word) {
|
||||
var lastTwo = /(\w+)::(\w+)$/.exec(word);
|
||||
var lastTwo = /(\w+)::~?(\w+)$/.exec(word);
|
||||
return lastTwo && lastTwo[1] == lastTwo[2];
|
||||
}
|
||||
|
||||
|
@ -390,6 +392,7 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
|
|||
typeFirstDefinitions: true,
|
||||
atoms: words("true false null"),
|
||||
dontIndentStatements: /^template$/,
|
||||
isIdentifierChar: /[\w\$_~\xa1-\uffff]/,
|
||||
hooks: {
|
||||
"#": cppHook,
|
||||
"*": pointerHook,
|
||||
|
@ -429,7 +432,7 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
|
|||
types: words("byte short int long float double boolean char void Boolean Byte Character Double Float " +
|
||||
"Integer Long Number Object Short String StringBuffer StringBuilder Void"),
|
||||
blockKeywords: words("catch class do else finally for if switch try while"),
|
||||
defKeywords: words("class interface package enum @interface"),
|
||||
defKeywords: words("class interface enum @interface"),
|
||||
typeFirstDefinitions: true,
|
||||
atoms: words("true false null"),
|
||||
number: /^(?:0x[a-f\d_]+|0b[01_]+|(?:[\d_]+\.?\d*|\.\d+)(?:e[-+]?[\d_]+)?)(u|ll?|l|f)?/i,
|
||||
|
@ -513,8 +516,8 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
|
|||
"StringBuffer System Thread ThreadGroup ThreadLocal Throwable Triple Void"
|
||||
),
|
||||
multiLineStrings: true,
|
||||
blockKeywords: words("catch class do else finally for forSome if match switch try while"),
|
||||
defKeywords: words("class def object package trait type val var"),
|
||||
blockKeywords: words("catch class enum do else finally for forSome if match switch try while"),
|
||||
defKeywords: words("class enum def object package trait type val var"),
|
||||
atoms: words("true false null"),
|
||||
indentStatements: false,
|
||||
indentSwitch: false,
|
||||
|
@ -575,7 +578,7 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
|
|||
"file import where by get set abstract enum open inner override private public internal " +
|
||||
"protected catch finally out final vararg reified dynamic companion constructor init " +
|
||||
"sealed field property receiver param sparam lateinit data inline noinline tailrec " +
|
||||
"external annotation crossinline const operator infix"
|
||||
"external annotation crossinline const operator infix suspend"
|
||||
),
|
||||
types: words(
|
||||
/* package java.lang */
|
||||
|
@ -587,8 +590,9 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
|
|||
intendSwitch: false,
|
||||
indentStatements: false,
|
||||
multiLineStrings: true,
|
||||
number: /^(?:0x[a-f\d_]+|0b[01_]+|(?:[\d_]+\.?\d*|\.\d+)(?:e[-+]?[\d_]+)?)(u|ll?|l|f)?/i,
|
||||
blockKeywords: words("catch class do else finally for if where try while enum"),
|
||||
defKeywords: words("class val var object package interface fun"),
|
||||
defKeywords: words("class val var object interface fun"),
|
||||
atoms: words("true false null this"),
|
||||
hooks: {
|
||||
'"': function(stream, state) {
|
||||
|
@ -771,7 +775,7 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
|
|||
return "atom";
|
||||
},
|
||||
token: function(_stream, state, style) {
|
||||
if ((style == "variable" || style == "variable-3") &&
|
||||
if ((style == "variable" || style == "type") &&
|
||||
state.prevToken == ".") {
|
||||
return "variable-2";
|
||||
}
|
||||
|
|
0
gui/public/codemirror/mode/clike/index.html
vendored
Executable file → Normal file
0
gui/public/codemirror/mode/clike/index.html
vendored
Executable file → Normal file
0
gui/public/codemirror/mode/clike/scala.html
vendored
Executable file → Normal file
0
gui/public/codemirror/mode/clike/scala.html
vendored
Executable file → Normal file
16
gui/public/codemirror/mode/clike/test.js
vendored
Executable file → Normal file
16
gui/public/codemirror/mode/clike/test.js
vendored
Executable file → Normal file
|
@ -6,8 +6,8 @@
|
|||
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
|
||||
|
||||
MT("indent",
|
||||
"[variable-3 void] [def foo]([variable-3 void*] [variable a], [variable-3 int] [variable b]) {",
|
||||
" [variable-3 int] [variable c] [operator =] [variable b] [operator +]",
|
||||
"[type void] [def foo]([type void*] [variable a], [type int] [variable b]) {",
|
||||
" [type int] [variable c] [operator =] [variable b] [operator +]",
|
||||
" [number 1];",
|
||||
" [keyword return] [operator *][variable a];",
|
||||
"}");
|
||||
|
@ -21,9 +21,9 @@
|
|||
"}");
|
||||
|
||||
MT("def",
|
||||
"[variable-3 void] [def foo]() {}",
|
||||
"[type void] [def foo]() {}",
|
||||
"[keyword struct] [def bar]{}",
|
||||
"[variable-3 int] [variable-3 *][def baz]() {}");
|
||||
"[type int] [type *][def baz]() {}");
|
||||
|
||||
MT("def_new_line",
|
||||
"::[variable std]::[variable SomeTerribleType][operator <][variable T][operator >]",
|
||||
|
@ -37,10 +37,10 @@
|
|||
|
||||
MT("preprocessor",
|
||||
"[meta #define FOO 3]",
|
||||
"[variable-3 int] [variable foo];",
|
||||
"[type int] [variable foo];",
|
||||
"[meta #define BAR\\]",
|
||||
"[meta 4]",
|
||||
"[variable-3 unsigned] [variable-3 int] [variable bar] [operator =] [number 8];",
|
||||
"[type unsigned] [type int] [variable bar] [operator =] [number 8];",
|
||||
"[meta #include <baz> ][comment // comment]")
|
||||
|
||||
|
||||
|
@ -52,4 +52,8 @@
|
|||
"[number 0b10'000];",
|
||||
"[number 0x10'000];",
|
||||
"[string '100000'];");
|
||||
|
||||
MTCPP("ctor_dtor",
|
||||
"[def Foo::Foo]() {}",
|
||||
"[def Foo::~Foo]() {}");
|
||||
})();
|
||||
|
|
0
gui/public/codemirror/mode/clojure/clojure.js
vendored
Executable file → Normal file
0
gui/public/codemirror/mode/clojure/clojure.js
vendored
Executable file → Normal file
0
gui/public/codemirror/mode/clojure/index.html
vendored
Executable file → Normal file
0
gui/public/codemirror/mode/clojure/index.html
vendored
Executable file → Normal file
0
gui/public/codemirror/mode/cmake/cmake.js
vendored
Executable file → Normal file
0
gui/public/codemirror/mode/cmake/cmake.js
vendored
Executable file → Normal file
0
gui/public/codemirror/mode/cmake/index.html
vendored
Executable file → Normal file
0
gui/public/codemirror/mode/cmake/index.html
vendored
Executable file → Normal file
0
gui/public/codemirror/mode/cobol/cobol.js
vendored
Executable file → Normal file
0
gui/public/codemirror/mode/cobol/cobol.js
vendored
Executable file → Normal file
0
gui/public/codemirror/mode/cobol/index.html
vendored
Executable file → Normal file
0
gui/public/codemirror/mode/cobol/index.html
vendored
Executable file → Normal file
4
gui/public/codemirror/mode/coffeescript/coffeescript.js
vendored
Executable file → Normal file
4
gui/public/codemirror/mode/coffeescript/coffeescript.js
vendored
Executable file → Normal file
|
@ -349,6 +349,10 @@ CodeMirror.defineMode("coffeescript", function(conf, parserConf) {
|
|||
return external;
|
||||
});
|
||||
|
||||
// IANA registered media type
|
||||
// https://www.iana.org/assignments/media-types/
|
||||
CodeMirror.defineMIME("application/vnd.coffeescript", "coffeescript");
|
||||
|
||||
CodeMirror.defineMIME("text/x-coffeescript", "coffeescript");
|
||||
CodeMirror.defineMIME("text/coffeescript", "coffeescript");
|
||||
|
||||
|
|
2
gui/public/codemirror/mode/coffeescript/index.html
vendored
Executable file → Normal file
2
gui/public/codemirror/mode/coffeescript/index.html
vendored
Executable file → Normal file
|
@ -733,7 +733,7 @@ wrapper::value = -> this._wrapped
|
|||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {});
|
||||
</script>
|
||||
|
||||
<p><strong>MIME types defined:</strong> <code>text/x-coffeescript</code>.</p>
|
||||
<p><strong>MIME types defined:</strong> <code>application/vnd.coffeescript</code>, <code>text/coffeescript</code>, <code>text/x-coffeescript</code>.</p>
|
||||
|
||||
<p>The CoffeeScript mode was written by Jeff Pickhardt.</p>
|
||||
|
||||
|
|
0
gui/public/codemirror/mode/commonlisp/commonlisp.js
vendored
Executable file → Normal file
0
gui/public/codemirror/mode/commonlisp/commonlisp.js
vendored
Executable file → Normal file
0
gui/public/codemirror/mode/commonlisp/index.html
vendored
Executable file → Normal file
0
gui/public/codemirror/mode/commonlisp/index.html
vendored
Executable file → Normal file
0
gui/public/codemirror/mode/crystal/crystal.js
vendored
Executable file → Normal file
0
gui/public/codemirror/mode/crystal/crystal.js
vendored
Executable file → Normal file
0
gui/public/codemirror/mode/crystal/index.html
vendored
Executable file → Normal file
0
gui/public/codemirror/mode/crystal/index.html
vendored
Executable file → Normal file
19
gui/public/codemirror/mode/css/css.js
vendored
Executable file → Normal file
19
gui/public/codemirror/mode/css/css.js
vendored
Executable file → Normal file
|
@ -383,6 +383,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
|||
style = style[0];
|
||||
}
|
||||
override = style;
|
||||
if (type != "comment")
|
||||
state.state = states[state.state](type, stream, state);
|
||||
return override;
|
||||
},
|
||||
|
@ -401,7 +402,6 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
|||
ch == "{" && (cx.type == "at" || cx.type == "atBlock")) {
|
||||
// Dedent relative to current context.
|
||||
indent = Math.max(0, cx.indent - indentUnit);
|
||||
cx = cx.prev;
|
||||
}
|
||||
}
|
||||
return indent;
|
||||
|
@ -410,6 +410,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
|||
electricChars: "}",
|
||||
blockCommentStart: "/*",
|
||||
blockCommentEnd: "*/",
|
||||
blockCommentContinue: " * ",
|
||||
lineComment: lineComment,
|
||||
fold: "brace"
|
||||
};
|
||||
|
@ -472,7 +473,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
|||
"border-top-left-radius", "border-top-right-radius", "border-top-style",
|
||||
"border-top-width", "border-width", "bottom", "box-decoration-break",
|
||||
"box-shadow", "box-sizing", "break-after", "break-before", "break-inside",
|
||||
"caption-side", "clear", "clip", "color", "color-profile", "column-count",
|
||||
"caption-side", "caret-color", "clear", "clip", "color", "color-profile", "column-count",
|
||||
"column-fill", "column-gap", "column-rule", "column-rule-color",
|
||||
"column-rule-style", "column-rule-width", "column-span", "column-width",
|
||||
"columns", "content", "counter-increment", "counter-reset", "crop", "cue",
|
||||
|
@ -493,7 +494,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
|||
"grid-row-start", "grid-template", "grid-template-areas", "grid-template-columns",
|
||||
"grid-template-rows", "hanging-punctuation", "height", "hyphens",
|
||||
"icon", "image-orientation", "image-rendering", "image-resolution",
|
||||
"inline-box-align", "justify-content", "left", "letter-spacing",
|
||||
"inline-box-align", "justify-content", "justify-items", "justify-self", "left", "letter-spacing",
|
||||
"line-break", "line-height", "line-stacking", "line-stacking-ruby",
|
||||
"line-stacking-shift", "line-stacking-strategy", "list-style",
|
||||
"list-style-image", "list-style-position", "list-style-type", "margin",
|
||||
|
@ -508,7 +509,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
|||
"padding", "padding-bottom", "padding-left", "padding-right", "padding-top",
|
||||
"page", "page-break-after", "page-break-before", "page-break-inside",
|
||||
"page-policy", "pause", "pause-after", "pause-before", "perspective",
|
||||
"perspective-origin", "pitch", "pitch-range", "play-during", "position",
|
||||
"perspective-origin", "pitch", "pitch-range", "place-content", "place-items", "place-self", "play-during", "position",
|
||||
"presentation-level", "punctuation-trim", "quotes", "region-break-after",
|
||||
"region-break-before", "region-break-inside", "region-fragment",
|
||||
"rendering-intent", "resize", "rest", "rest-after", "rest-before", "richness",
|
||||
|
@ -659,15 +660,15 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
|||
"s-resize", "sans-serif", "saturation", "scale", "scale3d", "scaleX", "scaleY", "scaleZ", "screen",
|
||||
"scroll", "scrollbar", "scroll-position", "se-resize", "searchfield",
|
||||
"searchfield-cancel-button", "searchfield-decoration",
|
||||
"searchfield-results-button", "searchfield-results-decoration",
|
||||
"searchfield-results-button", "searchfield-results-decoration", "self-start", "self-end",
|
||||
"semi-condensed", "semi-expanded", "separate", "serif", "show", "sidama",
|
||||
"simp-chinese-formal", "simp-chinese-informal", "single",
|
||||
"skew", "skewX", "skewY", "skip-white-space", "slide", "slider-horizontal",
|
||||
"slider-vertical", "sliderthumb-horizontal", "sliderthumb-vertical", "slow",
|
||||
"small", "small-caps", "small-caption", "smaller", "soft-light", "solid", "somali",
|
||||
"source-atop", "source-in", "source-out", "source-over", "space", "space-around", "space-between", "spell-out", "square",
|
||||
"source-atop", "source-in", "source-out", "source-over", "space", "space-around", "space-between", "space-evenly", "spell-out", "square",
|
||||
"square-button", "start", "static", "status-bar", "stretch", "stroke", "sub",
|
||||
"subpixel-antialiased", "super", "sw-resize", "symbolic", "symbols", "table",
|
||||
"subpixel-antialiased", "super", "sw-resize", "symbolic", "symbols", "system-ui", "table",
|
||||
"table-caption", "table-cell", "table-column", "table-column-group",
|
||||
"table-footer-group", "table-header-group", "table-row", "table-row-group",
|
||||
"tamil",
|
||||
|
@ -748,8 +749,8 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
|||
}
|
||||
},
|
||||
":": function(stream) {
|
||||
if (stream.match(/\s*\{/))
|
||||
return [null, "{"];
|
||||
if (stream.match(/\s*\{/, false))
|
||||
return [null, null]
|
||||
return false;
|
||||
},
|
||||
"$": function(stream) {
|
||||
|
|
0
gui/public/codemirror/mode/css/gss.html
vendored
Executable file → Normal file
0
gui/public/codemirror/mode/css/gss.html
vendored
Executable file → Normal file
0
gui/public/codemirror/mode/css/gss_test.js
vendored
Executable file → Normal file
0
gui/public/codemirror/mode/css/gss_test.js
vendored
Executable file → Normal file
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue