updating codemirror to version 5.23.0
This commit is contained in:
parent
9c44c5237b
commit
21ae725979
|
@ -1,4 +1,4 @@
|
|||
Copyright (C) 2015 by Marijn Haverbeke <marijnh@gmail.com> and others
|
||||
Copyright (C) 2017 by Marijn Haverbeke <marijnh@gmail.com> and others
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
51
codemirror/addon/comment/comment.js
vendored
51
codemirror/addon/comment/comment.js
vendored
|
@ -21,26 +21,40 @@
|
|||
}
|
||||
|
||||
CodeMirror.commands.toggleComment = function(cm) {
|
||||
var minLine = Infinity, ranges = cm.listSelections(), mode = null;
|
||||
cm.toggleComment();
|
||||
};
|
||||
|
||||
CodeMirror.defineExtension("toggleComment", function(options) {
|
||||
if (!options) options = noOptions;
|
||||
var cm = this;
|
||||
var minLine = Infinity, ranges = this.listSelections(), mode = null;
|
||||
for (var i = ranges.length - 1; i >= 0; i--) {
|
||||
var from = ranges[i].from(), to = ranges[i].to();
|
||||
if (from.line >= minLine) continue;
|
||||
if (to.line >= minLine) to = Pos(minLine, 0);
|
||||
minLine = from.line;
|
||||
if (mode == null) {
|
||||
if (cm.uncomment(from, to)) mode = "un";
|
||||
else { cm.lineComment(from, to); mode = "line"; }
|
||||
if (cm.uncomment(from, to, options)) mode = "un";
|
||||
else { cm.lineComment(from, to, options); mode = "line"; }
|
||||
} else if (mode == "un") {
|
||||
cm.uncomment(from, to);
|
||||
cm.uncomment(from, to, options);
|
||||
} else {
|
||||
cm.lineComment(from, to);
|
||||
cm.lineComment(from, to, options);
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
// 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)
|
||||
}
|
||||
|
||||
CodeMirror.defineExtension("lineComment", function(from, to, options) {
|
||||
if (!options) options = noOptions;
|
||||
var self = this, mode = self.getModeAt(from);
|
||||
var firstLine = self.getLine(from.line);
|
||||
if (firstLine == null || probablyInsideString(self, from, firstLine)) return;
|
||||
|
||||
var commentString = options.lineComment || mode.lineComment;
|
||||
if (!commentString) {
|
||||
if (options.blockCommentStart || mode.blockCommentStart) {
|
||||
|
@ -49,15 +63,21 @@
|
|||
}
|
||||
return;
|
||||
}
|
||||
var firstLine = self.getLine(from.line);
|
||||
if (firstLine == null) return;
|
||||
|
||||
var end = Math.min(to.ch != 0 || to.line == from.line ? to.line + 1 : to.line, self.lastLine() + 1);
|
||||
var pad = options.padding == null ? " " : options.padding;
|
||||
var blankLines = options.commentBlankLines || from.line == to.line;
|
||||
|
||||
self.operation(function() {
|
||||
if (options.indent) {
|
||||
var baseString = firstLine.slice(0, firstNonWS(firstLine));
|
||||
var baseString = null;
|
||||
for (var i = from.line; i < end; ++i) {
|
||||
var line = self.getLine(i);
|
||||
var whitespace = line.slice(0, firstNonWS(line));
|
||||
if (baseString == null || baseString.length > whitespace.length) {
|
||||
baseString = whitespace;
|
||||
}
|
||||
}
|
||||
for (var i = from.line; i < end; ++i) {
|
||||
var line = self.getLine(i), cut = baseString.length;
|
||||
if (!blankLines && !nonWS.test(line)) continue;
|
||||
|
@ -83,6 +103,7 @@
|
|||
self.lineComment(from, to, options);
|
||||
return;
|
||||
}
|
||||
if (/\bcomment\b/.test(self.getTokenTypeAt(Pos(from.line, 0)))) return
|
||||
|
||||
var end = Math.min(to.line, self.lastLine());
|
||||
if (end != from.line && to.ch == 0 && nonWS.test(self.getLine(end))) --end;
|
||||
|
@ -120,7 +141,7 @@
|
|||
var line = self.getLine(i);
|
||||
var found = line.indexOf(lineString);
|
||||
if (found > -1 && !/comment/.test(self.getTokenTypeAt(Pos(i, found + 1)))) found = -1;
|
||||
if (found == -1 && (i != end || i == start) && nonWS.test(line)) break lineComment;
|
||||
if (found == -1 && nonWS.test(line)) break lineComment;
|
||||
if (found > -1 && nonWS.test(line.slice(0, found))) break lineComment;
|
||||
lines.push(line);
|
||||
}
|
||||
|
@ -142,13 +163,15 @@
|
|||
var endString = options.blockCommentEnd || mode.blockCommentEnd;
|
||||
if (!startString || !endString) return false;
|
||||
var lead = options.blockCommentLead || mode.blockCommentLead;
|
||||
var startLine = self.getLine(start), endLine = end == start ? startLine : self.getLine(end);
|
||||
var open = startLine.indexOf(startString), close = endLine.lastIndexOf(endString);
|
||||
var startLine = self.getLine(start), open = startLine.indexOf(startString)
|
||||
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.lastIndexOf(endString);
|
||||
close = endLine.indexOf(endString);
|
||||
}
|
||||
if (open == -1 || close == -1 ||
|
||||
if (close == -1 ||
|
||||
!/comment/.test(self.getTokenTypeAt(Pos(start, open + 1))) ||
|
||||
!/comment/.test(self.getTokenTypeAt(Pos(end, close + 1))))
|
||||
return false;
|
||||
|
|
85
codemirror/addon/comment/continuecomment.js
vendored
Normal file
85
codemirror/addon/comment/continuecomment.js
vendored
Normal file
|
@ -0,0 +1,85 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror"], mod);
|
||||
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;
|
||||
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) {
|
||||
// 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 = full.indexOf(mode.blockCommentContinue)) != -1 &&
|
||||
found + mode.blockCommentContinue.length > token.start &&
|
||||
/^\s*$/.test(full.slice(0, found))) {
|
||||
insert = full.slice(0, found);
|
||||
}
|
||||
if (insert != null) insert += mode.blockCommentContinue;
|
||||
}
|
||||
if (insert == null && mode.lineComment && continueLineCommentEnabled(cm)) {
|
||||
var line = cm.getLine(pos.line), found = line.indexOf(mode.lineComment);
|
||||
if (found > -1) {
|
||||
insert = line.slice(0, found);
|
||||
if (/\S/.test(insert)) insert = null;
|
||||
else insert += mode.lineComment + line.slice(found + mode.lineComment.length).match(/^\s*/)[0];
|
||||
}
|
||||
}
|
||||
if (insert == null) return CodeMirror.Pass;
|
||||
inserts[i] = "\n" + insert;
|
||||
}
|
||||
|
||||
cm.operation(function() {
|
||||
for (var i = ranges.length - 1; i >= 0; i--)
|
||||
cm.replaceRange(inserts[i], ranges[i].from(), ranges[i].to(), "+insert");
|
||||
});
|
||||
}
|
||||
|
||||
function continueLineCommentEnabled(cm) {
|
||||
var opt = cm.getOption("continueComments");
|
||||
if (opt && typeof opt == "object")
|
||||
return opt.continueLineComment !== false;
|
||||
return true;
|
||||
}
|
||||
|
||||
CodeMirror.defineOption("continueComments", null, function(cm, val, prev) {
|
||||
if (prev && prev != CodeMirror.Init)
|
||||
cm.removeKeyMap("continueComment");
|
||||
if (val) {
|
||||
var key = "Enter";
|
||||
if (typeof val == "string")
|
||||
key = val;
|
||||
else if (typeof val == "object" && val.key)
|
||||
key = val.key;
|
||||
var map = {name: "continueComment"};
|
||||
map[key] = continueComment;
|
||||
cm.addKeyMap(map);
|
||||
}
|
||||
});
|
||||
});
|
4
codemirror/addon/dialog/dialog.js
vendored
4
codemirror/addon/dialog/dialog.js
vendored
|
@ -56,6 +56,8 @@
|
|||
|
||||
var inp = dialog.getElementsByTagName("input")[0], button;
|
||||
if (inp) {
|
||||
inp.focus();
|
||||
|
||||
if (options.value) {
|
||||
inp.value = options.value;
|
||||
if (options.selectValueOnOpen !== false) {
|
||||
|
@ -79,8 +81,6 @@
|
|||
});
|
||||
|
||||
if (options.closeOnBlur !== false) CodeMirror.on(inp, "blur", close);
|
||||
|
||||
inp.focus();
|
||||
} else if (button = dialog.getElementsByTagName("button")[0]) {
|
||||
CodeMirror.on(button, "click", function() {
|
||||
close();
|
||||
|
|
47
codemirror/addon/display/autorefresh.js
vendored
Normal file
47
codemirror/addon/display/autorefresh.js
vendored
Normal file
|
@ -0,0 +1,47 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"))
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror"], mod)
|
||||
else // Plain browser env
|
||||
mod(CodeMirror)
|
||||
})(function(CodeMirror) {
|
||||
"use strict"
|
||||
|
||||
CodeMirror.defineOption("autoRefresh", false, function(cm, val) {
|
||||
if (cm.state.autoRefresh) {
|
||||
stopListening(cm, cm.state.autoRefresh)
|
||||
cm.state.autoRefresh = null
|
||||
}
|
||||
if (val && cm.display.wrapper.offsetHeight == 0)
|
||||
startListening(cm, cm.state.autoRefresh = {delay: val.delay || 250})
|
||||
})
|
||||
|
||||
function startListening(cm, state) {
|
||||
function check() {
|
||||
if (cm.display.wrapper.offsetHeight) {
|
||||
stopListening(cm, state)
|
||||
if (cm.display.lastWrapHeight != cm.display.wrapper.clientHeight)
|
||||
cm.refresh()
|
||||
} else {
|
||||
state.timeout = setTimeout(check, state.delay)
|
||||
}
|
||||
}
|
||||
state.timeout = setTimeout(check, state.delay)
|
||||
state.hurry = function() {
|
||||
clearTimeout(state.timeout)
|
||||
state.timeout = setTimeout(check, 50)
|
||||
}
|
||||
CodeMirror.on(window, "mouseup", state.hurry)
|
||||
CodeMirror.on(window, "keyup", state.hurry)
|
||||
}
|
||||
|
||||
function stopListening(_cm, state) {
|
||||
clearTimeout(state.timeout)
|
||||
CodeMirror.off(window, "mouseup", state.hurry)
|
||||
CodeMirror.off(window, "keyup", state.hurry)
|
||||
}
|
||||
});
|
6
codemirror/addon/display/fullscreen.css
vendored
Normal file
6
codemirror/addon/display/fullscreen.css
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
.CodeMirror-fullscreen {
|
||||
position: fixed;
|
||||
top: 0; left: 0; right: 0; bottom: 0;
|
||||
height: auto;
|
||||
z-index: 9;
|
||||
}
|
41
codemirror/addon/display/fullscreen.js
vendored
Normal file
41
codemirror/addon/display/fullscreen.js
vendored
Normal file
|
@ -0,0 +1,41 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
CodeMirror.defineOption("fullScreen", false, function(cm, val, old) {
|
||||
if (old == CodeMirror.Init) old = false;
|
||||
if (!old == !val) return;
|
||||
if (val) setFullscreen(cm);
|
||||
else setNormal(cm);
|
||||
});
|
||||
|
||||
function setFullscreen(cm) {
|
||||
var wrap = cm.getWrapperElement();
|
||||
cm.state.fullScreenRestore = {scrollTop: window.pageYOffset, scrollLeft: window.pageXOffset,
|
||||
width: wrap.style.width, height: wrap.style.height};
|
||||
wrap.style.width = "";
|
||||
wrap.style.height = "auto";
|
||||
wrap.className += " CodeMirror-fullscreen";
|
||||
document.documentElement.style.overflow = "hidden";
|
||||
cm.refresh();
|
||||
}
|
||||
|
||||
function setNormal(cm) {
|
||||
var wrap = cm.getWrapperElement();
|
||||
wrap.className = wrap.className.replace(/\s*CodeMirror-fullscreen\b/, "");
|
||||
document.documentElement.style.overflow = "";
|
||||
var info = cm.state.fullScreenRestore;
|
||||
wrap.style.width = info.width; wrap.style.height = info.height;
|
||||
window.scrollTo(info.scrollLeft, info.scrollTop);
|
||||
cm.refresh();
|
||||
}
|
||||
});
|
123
codemirror/addon/display/panel.js
vendored
Normal file
123
codemirror/addon/display/panel.js
vendored
Normal file
|
@ -0,0 +1,123 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
CodeMirror.defineExtension("addPanel", function(node, options) {
|
||||
options = options || {};
|
||||
|
||||
if (!this.state.panels) initPanels(this);
|
||||
|
||||
var info = this.state.panels;
|
||||
var wrapper = info.wrapper;
|
||||
var cmWrapper = this.getWrapperElement();
|
||||
|
||||
if (options.after instanceof Panel && !options.after.cleared) {
|
||||
wrapper.insertBefore(node, options.before.node.nextSibling);
|
||||
} else if (options.before instanceof Panel && !options.before.cleared) {
|
||||
wrapper.insertBefore(node, options.before.node);
|
||||
} else if (options.replace instanceof Panel && !options.replace.cleared) {
|
||||
wrapper.insertBefore(node, options.replace.node);
|
||||
options.replace.clear();
|
||||
} else if (options.position == "bottom") {
|
||||
wrapper.appendChild(node);
|
||||
} else if (options.position == "before-bottom") {
|
||||
wrapper.insertBefore(node, cmWrapper.nextSibling);
|
||||
} else if (options.position == "after-top") {
|
||||
wrapper.insertBefore(node, cmWrapper);
|
||||
} else {
|
||||
wrapper.insertBefore(node, wrapper.firstChild);
|
||||
}
|
||||
|
||||
var height = (options && options.height) || node.offsetHeight;
|
||||
this._setSize(null, info.heightLeft -= height);
|
||||
info.panels++;
|
||||
if (options.stable && isAtTop(this, node))
|
||||
this.scrollTo(null, this.getScrollInfo().top + height)
|
||||
|
||||
return new Panel(this, node, options, height);
|
||||
});
|
||||
|
||||
function Panel(cm, node, options, height) {
|
||||
this.cm = cm;
|
||||
this.node = node;
|
||||
this.options = options;
|
||||
this.height = height;
|
||||
this.cleared = false;
|
||||
}
|
||||
|
||||
Panel.prototype.clear = function() {
|
||||
if (this.cleared) return;
|
||||
this.cleared = true;
|
||||
var info = this.cm.state.panels;
|
||||
this.cm._setSize(null, info.heightLeft += this.height);
|
||||
if (this.options.stable && isAtTop(this.cm, this.node))
|
||||
this.cm.scrollTo(null, this.cm.getScrollInfo().top - this.height)
|
||||
info.wrapper.removeChild(this.node);
|
||||
if (--info.panels == 0) removePanels(this.cm);
|
||||
};
|
||||
|
||||
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.height = newHeight;
|
||||
};
|
||||
|
||||
function initPanels(cm) {
|
||||
var wrap = cm.getWrapperElement();
|
||||
var style = window.getComputedStyle ? window.getComputedStyle(wrap) : wrap.currentStyle;
|
||||
var height = parseInt(style.height);
|
||||
var info = cm.state.panels = {
|
||||
setHeight: wrap.style.height,
|
||||
heightLeft: height,
|
||||
panels: 0,
|
||||
wrapper: document.createElement("div")
|
||||
};
|
||||
wrap.parentNode.insertBefore(info.wrapper, wrap);
|
||||
var hasFocus = cm.hasFocus();
|
||||
info.wrapper.appendChild(wrap);
|
||||
if (hasFocus) cm.focus();
|
||||
|
||||
cm._setSize = cm.setSize;
|
||||
if (height != null) cm.setSize = function(width, newHeight) {
|
||||
if (newHeight == null) return this._setSize(width, newHeight);
|
||||
info.setHeight = newHeight;
|
||||
if (typeof newHeight != "number") {
|
||||
var px = /^(\d+\.?\d*)px$/.exec(newHeight);
|
||||
if (px) {
|
||||
newHeight = Number(px[1]);
|
||||
} else {
|
||||
info.wrapper.style.height = newHeight;
|
||||
newHeight = info.wrapper.offsetHeight;
|
||||
info.wrapper.style.height = "";
|
||||
}
|
||||
}
|
||||
cm._setSize(width, info.heightLeft += (newHeight - height));
|
||||
height = newHeight;
|
||||
};
|
||||
}
|
||||
|
||||
function removePanels(cm) {
|
||||
var info = cm.state.panels;
|
||||
cm.state.panels = null;
|
||||
|
||||
var wrap = cm.getWrapperElement();
|
||||
info.wrapper.parentNode.replaceChild(wrap, info.wrapper);
|
||||
wrap.style.height = info.setHeight;
|
||||
cm.setSize = cm._setSize;
|
||||
cm.setSize();
|
||||
}
|
||||
|
||||
function isAtTop(cm, dom) {
|
||||
for (var sibling = dom.nextSibling; sibling; sibling = sibling.nextSibling)
|
||||
if (sibling == cm.getWrapperElement()) return true
|
||||
return false
|
||||
}
|
||||
});
|
62
codemirror/addon/display/placeholder.js
vendored
Normal file
62
codemirror/addon/display/placeholder.js
vendored
Normal file
|
@ -0,0 +1,62 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
CodeMirror.defineOption("placeholder", "", function(cm, val, old) {
|
||||
var prev = old && old != CodeMirror.Init;
|
||||
if (val && !prev) {
|
||||
cm.on("blur", onBlur);
|
||||
cm.on("change", onChange);
|
||||
cm.on("swapDoc", onChange);
|
||||
onChange(cm);
|
||||
} else if (!val && prev) {
|
||||
cm.off("blur", onBlur);
|
||||
cm.off("change", onChange);
|
||||
cm.off("swapDoc", onChange);
|
||||
clearPlaceholder(cm);
|
||||
var wrapper = cm.getWrapperElement();
|
||||
wrapper.className = wrapper.className.replace(" CodeMirror-empty", "");
|
||||
}
|
||||
|
||||
if (val && !cm.hasFocus()) onBlur(cm);
|
||||
});
|
||||
|
||||
function clearPlaceholder(cm) {
|
||||
if (cm.state.placeholder) {
|
||||
cm.state.placeholder.parentNode.removeChild(cm.state.placeholder);
|
||||
cm.state.placeholder = null;
|
||||
}
|
||||
}
|
||||
function setPlaceholder(cm) {
|
||||
clearPlaceholder(cm);
|
||||
var elt = cm.state.placeholder = document.createElement("pre");
|
||||
elt.style.cssText = "height: 0; overflow: visible";
|
||||
elt.className = "CodeMirror-placeholder";
|
||||
var placeHolder = cm.getOption("placeholder")
|
||||
if (typeof placeHolder == "string") placeHolder = document.createTextNode(placeHolder)
|
||||
elt.appendChild(placeHolder)
|
||||
cm.display.lineSpace.insertBefore(elt, cm.display.lineSpace.firstChild);
|
||||
}
|
||||
|
||||
function onBlur(cm) {
|
||||
if (isEmpty(cm)) setPlaceholder(cm);
|
||||
}
|
||||
function onChange(cm) {
|
||||
var wrapper = cm.getWrapperElement(), empty = isEmpty(cm);
|
||||
wrapper.className = wrapper.className.replace(" CodeMirror-empty", "") + (empty ? " CodeMirror-empty" : "");
|
||||
|
||||
if (empty) setPlaceholder(cm);
|
||||
else clearPlaceholder(cm);
|
||||
}
|
||||
|
||||
function isEmpty(cm) {
|
||||
return (cm.lineCount() === 1) && (cm.getLine(0) === "");
|
||||
}
|
||||
});
|
51
codemirror/addon/display/rulers.js
vendored
Normal file
51
codemirror/addon/display/rulers.js
vendored
Normal file
|
@ -0,0 +1,51 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
CodeMirror.defineOption("rulers", false, function(cm, val) {
|
||||
if (cm.state.rulerDiv) {
|
||||
cm.state.rulerDiv.parentElement.removeChild(cm.state.rulerDiv)
|
||||
cm.state.rulerDiv = null
|
||||
cm.off("refresh", drawRulers)
|
||||
}
|
||||
if (val && val.length) {
|
||||
cm.state.rulerDiv = cm.display.lineSpace.parentElement.insertBefore(document.createElement("div"), cm.display.lineSpace)
|
||||
cm.state.rulerDiv.className = "CodeMirror-rulers"
|
||||
drawRulers(cm)
|
||||
cm.on("refresh", drawRulers)
|
||||
}
|
||||
});
|
||||
|
||||
function drawRulers(cm) {
|
||||
cm.state.rulerDiv.textContent = ""
|
||||
var val = cm.getOption("rulers");
|
||||
var cw = cm.defaultCharWidth();
|
||||
var left = cm.charCoords(CodeMirror.Pos(cm.firstLine(), 0), "div").left;
|
||||
cm.state.rulerDiv.style.minHeight = (cm.display.scroller.offsetHeight + 30) + "px";
|
||||
for (var i = 0; i < val.length; i++) {
|
||||
var elt = document.createElement("div");
|
||||
elt.className = "CodeMirror-ruler";
|
||||
var col, conf = val[i];
|
||||
if (typeof conf == "number") {
|
||||
col = conf;
|
||||
} else {
|
||||
col = conf.column;
|
||||
if (conf.className) elt.className += " " + conf.className;
|
||||
if (conf.color) elt.style.borderColor = conf.color;
|
||||
if (conf.lineStyle) elt.style.borderLeftStyle = conf.lineStyle;
|
||||
if (conf.width) elt.style.borderLeftWidth = conf.width;
|
||||
}
|
||||
elt.style.left = (left + col * cw) + "px";
|
||||
cm.state.rulerDiv.appendChild(elt)
|
||||
}
|
||||
}
|
||||
});
|
202
codemirror/addon/edit/closebrackets.js
vendored
Normal file
202
codemirror/addon/edit/closebrackets.js
vendored
Normal file
|
@ -0,0 +1,202 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
var defaults = {
|
||||
pairs: "()[]{}''\"\"",
|
||||
triples: "",
|
||||
explode: "[]{}"
|
||||
};
|
||||
|
||||
var Pos = CodeMirror.Pos;
|
||||
|
||||
CodeMirror.defineOption("autoCloseBrackets", false, function(cm, val, old) {
|
||||
if (old && old != CodeMirror.Init) {
|
||||
cm.removeKeyMap(keyMap);
|
||||
cm.state.closeBrackets = null;
|
||||
}
|
||||
if (val) {
|
||||
cm.state.closeBrackets = val;
|
||||
cm.addKeyMap(keyMap);
|
||||
}
|
||||
});
|
||||
|
||||
function getOption(conf, name) {
|
||||
if (name == "pairs" && typeof conf == "string") return conf;
|
||||
if (typeof conf == "object" && conf[name] != null) return conf[name];
|
||||
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 handler(ch) {
|
||||
return function(cm) { return handleChar(cm, ch); };
|
||||
}
|
||||
|
||||
function getConfig(cm) {
|
||||
var deflt = cm.state.closeBrackets;
|
||||
if (!deflt || deflt.override) return deflt;
|
||||
var mode = cm.getModeAt(cm.getCursor());
|
||||
return mode.closeBrackets || deflt;
|
||||
}
|
||||
|
||||
function handleBackspace(cm) {
|
||||
var conf = getConfig(cm);
|
||||
if (!conf || cm.getOption("disableInput")) return CodeMirror.Pass;
|
||||
|
||||
var pairs = getOption(conf, "pairs");
|
||||
var ranges = cm.listSelections();
|
||||
for (var i = 0; i < ranges.length; i++) {
|
||||
if (!ranges[i].empty()) return CodeMirror.Pass;
|
||||
var around = charsAround(cm, ranges[i].head);
|
||||
if (!around || pairs.indexOf(around) % 2 != 0) return CodeMirror.Pass;
|
||||
}
|
||||
for (var i = ranges.length - 1; i >= 0; i--) {
|
||||
var cur = ranges[i].head;
|
||||
cm.replaceRange("", Pos(cur.line, cur.ch - 1), Pos(cur.line, cur.ch + 1), "+delete");
|
||||
}
|
||||
}
|
||||
|
||||
function handleEnter(cm) {
|
||||
var conf = getConfig(cm);
|
||||
var explode = conf && getOption(conf, "explode");
|
||||
if (!explode || cm.getOption("disableInput")) return CodeMirror.Pass;
|
||||
|
||||
var ranges = cm.listSelections();
|
||||
for (var i = 0; i < ranges.length; i++) {
|
||||
if (!ranges[i].empty()) return CodeMirror.Pass;
|
||||
var around = charsAround(cm, ranges[i].head);
|
||||
if (!around || explode.indexOf(around) % 2 != 0) return CodeMirror.Pass;
|
||||
}
|
||||
cm.operation(function() {
|
||||
cm.replaceSelection("\n\n", null);
|
||||
cm.execCommand("goCharLeft");
|
||||
ranges = cm.listSelections();
|
||||
for (var i = 0; i < ranges.length; i++) {
|
||||
var line = ranges[i].head.line;
|
||||
cm.indentLine(line, null, true);
|
||||
cm.indentLine(line + 1, null, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function contractSelection(sel) {
|
||||
var inverted = CodeMirror.cmpPos(sel.anchor, sel.head) > 0;
|
||||
return {anchor: new Pos(sel.anchor.line, sel.anchor.ch + (inverted ? -1 : 1)),
|
||||
head: new Pos(sel.head.line, sel.head.ch + (inverted ? 1 : -1))};
|
||||
}
|
||||
|
||||
function handleChar(cm, ch) {
|
||||
var conf = getConfig(cm);
|
||||
if (!conf || cm.getOption("disableInput")) return CodeMirror.Pass;
|
||||
|
||||
var pairs = getOption(conf, "pairs");
|
||||
var pos = pairs.indexOf(ch);
|
||||
if (pos == -1) return CodeMirror.Pass;
|
||||
var triples = getOption(conf, "triples");
|
||||
|
||||
var identical = pairs.charAt(pos + 1) == ch;
|
||||
var ranges = cm.listSelections();
|
||||
var opening = pos % 2 == 0;
|
||||
|
||||
var type;
|
||||
for (var i = 0; i < ranges.length; i++) {
|
||||
var range = ranges[i], cur = range.head, curType;
|
||||
var next = cm.getRange(cur, Pos(cur.line, cur.ch + 1));
|
||||
if (opening && !range.empty()) {
|
||||
curType = "surround";
|
||||
} else if ((identical || !opening) && next == ch) {
|
||||
if (identical && stringStartsAfter(cm, cur))
|
||||
curType = "both";
|
||||
else if (triples.indexOf(ch) >= 0 && cm.getRange(cur, Pos(cur.line, cur.ch + 3)) == ch + ch + ch)
|
||||
curType = "skipThree";
|
||||
else
|
||||
curType = "skip";
|
||||
} else if (identical && cur.ch > 1 && triples.indexOf(ch) >= 0 &&
|
||||
cm.getRange(Pos(cur.line, cur.ch - 2), cur) == ch + ch &&
|
||||
(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";
|
||||
else return CodeMirror.Pass;
|
||||
} else if (opening && (cm.getLine(cur.line).length == cur.ch ||
|
||||
isClosingBracket(next, pairs) ||
|
||||
/\s/.test(next))) {
|
||||
curType = "both";
|
||||
} else {
|
||||
return CodeMirror.Pass;
|
||||
}
|
||||
if (!type) type = curType;
|
||||
else if (type != curType) return CodeMirror.Pass;
|
||||
}
|
||||
|
||||
var left = pos % 2 ? pairs.charAt(pos - 1) : ch;
|
||||
var right = pos % 2 ? ch : pairs.charAt(pos + 1);
|
||||
cm.operation(function() {
|
||||
if (type == "skip") {
|
||||
cm.execCommand("goCharRight");
|
||||
} else if (type == "skipThree") {
|
||||
for (var i = 0; i < 3; i++)
|
||||
cm.execCommand("goCharRight");
|
||||
} else if (type == "surround") {
|
||||
var sels = cm.getSelections();
|
||||
for (var i = 0; i < sels.length; i++)
|
||||
sels[i] = left + sels[i] + right;
|
||||
cm.replaceSelections(sels, "around");
|
||||
sels = cm.listSelections().slice();
|
||||
for (var i = 0; i < sels.length; i++)
|
||||
sels[i] = contractSelection(sels[i]);
|
||||
cm.setSelections(sels);
|
||||
} else if (type == "both") {
|
||||
cm.replaceSelection(left + right, null);
|
||||
cm.triggerElectric(left + right);
|
||||
cm.execCommand("goCharLeft");
|
||||
} else if (type == "addFour") {
|
||||
cm.replaceSelection(left + left + left + left, "before");
|
||||
cm.execCommand("goCharRight");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function isClosingBracket(ch, pairs) {
|
||||
var pos = pairs.lastIndexOf(ch);
|
||||
return pos > -1 && pos % 2 == 1;
|
||||
}
|
||||
|
||||
function charsAround(cm, pos) {
|
||||
var str = cm.getRange(Pos(pos.line, pos.ch - 1),
|
||||
Pos(pos.line, pos.ch + 1));
|
||||
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)) 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
|
||||
}
|
||||
});
|
169
codemirror/addon/edit/closetag.js
vendored
Normal file
169
codemirror/addon/edit/closetag.js
vendored
Normal file
|
@ -0,0 +1,169 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
/**
|
||||
* Tag-closer extension for CodeMirror.
|
||||
*
|
||||
* This extension adds an "autoCloseTags" option that can be set to
|
||||
* either true to get the default behavior, or an object to further
|
||||
* configure its behavior.
|
||||
*
|
||||
* These are supported options:
|
||||
*
|
||||
* `whenClosing` (default true)
|
||||
* Whether to autoclose when the '/' of a closing tag is typed.
|
||||
* `whenOpening` (default true)
|
||||
* Whether to autoclose the tag when the final '>' of an opening
|
||||
* tag is typed.
|
||||
* `dontCloseTags` (default is empty tags for HTML, none for XML)
|
||||
* An array of tag names that should not be autoclosed.
|
||||
* `indentTags` (default is block tags for HTML, none for XML)
|
||||
* An array of tag names that should, when opened, cause a
|
||||
* blank line to be added inside the tag, and the blank line and
|
||||
* closing line to be indented.
|
||||
*
|
||||
* See demos/closetag.html for a usage example.
|
||||
*/
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"), require("../fold/xml-fold"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror", "../fold/xml-fold"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
CodeMirror.defineOption("autoCloseTags", false, function(cm, val, old) {
|
||||
if (old != CodeMirror.Init && old)
|
||||
cm.removeKeyMap("autoCloseTags");
|
||||
if (!val) return;
|
||||
var map = {name: "autoCloseTags"};
|
||||
if (typeof val != "object" || val.whenClosing)
|
||||
map["'/'"] = function(cm) { return autoCloseSlash(cm); };
|
||||
if (typeof val != "object" || val.whenOpening)
|
||||
map["'>'"] = function(cm) { return autoCloseGT(cm); };
|
||||
cm.addKeyMap(map);
|
||||
});
|
||||
|
||||
var htmlDontClose = ["area", "base", "br", "col", "command", "embed", "hr", "img", "input", "keygen", "link", "meta", "param",
|
||||
"source", "track", "wbr"];
|
||||
var htmlIndent = ["applet", "blockquote", "body", "button", "div", "dl", "fieldset", "form", "frameset", "h1", "h2", "h3", "h4",
|
||||
"h5", "h6", "head", "html", "iframe", "layer", "legend", "object", "ol", "p", "select", "table", "ul"];
|
||||
|
||||
function autoCloseGT(cm) {
|
||||
if (cm.getOption("disableInput")) return CodeMirror.Pass;
|
||||
var ranges = cm.listSelections(), replacements = [];
|
||||
for (var i = 0; i < ranges.length; i++) {
|
||||
if (!ranges[i].empty()) return CodeMirror.Pass;
|
||||
var pos = ranges[i].head, tok = cm.getTokenAt(pos);
|
||||
var inner = CodeMirror.innerMode(cm.getMode(), tok.state), state = inner.state;
|
||||
if (inner.mode.name != "xml" || !state.tagName) return CodeMirror.Pass;
|
||||
|
||||
var opt = cm.getOption("autoCloseTags"), html = inner.mode.configuration == "html";
|
||||
var dontCloseTags = (typeof opt == "object" && opt.dontCloseTags) || (html && htmlDontClose);
|
||||
var indentTags = (typeof opt == "object" && opt.indentTags) || (html && htmlIndent);
|
||||
|
||||
var tagName = state.tagName;
|
||||
if (tok.end > pos.ch) tagName = tagName.slice(0, tagName.length - tok.end + pos.ch);
|
||||
var lowerTagName = tagName.toLowerCase();
|
||||
// Don't process the '>' at the end of an end-tag or self-closing tag
|
||||
if (!tagName ||
|
||||
tok.type == "string" && (tok.end != pos.ch || !/[\"\']/.test(tok.string.charAt(tok.string.length - 1)) || tok.string.length == 1) ||
|
||||
tok.type == "tag" && state.type == "closeTag" ||
|
||||
tok.string.indexOf("/") == (tok.string.length - 1) || // match something like <someTagName />
|
||||
dontCloseTags && indexOf(dontCloseTags, lowerTagName) > -1 ||
|
||||
closingTagExists(cm, tagName, pos, state, true))
|
||||
return CodeMirror.Pass;
|
||||
|
||||
var indent = indentTags && indexOf(indentTags, lowerTagName) > -1;
|
||||
replacements[i] = {indent: indent,
|
||||
text: ">" + (indent ? "\n\n" : "") + "</" + tagName + ">",
|
||||
newPos: indent ? CodeMirror.Pos(pos.line + 1, 0) : CodeMirror.Pos(pos.line, pos.ch + 1)};
|
||||
}
|
||||
|
||||
for (var i = ranges.length - 1; i >= 0; i--) {
|
||||
var info = replacements[i];
|
||||
cm.replaceRange(info.text, ranges[i].head, ranges[i].anchor, "+insert");
|
||||
var sel = cm.listSelections().slice(0);
|
||||
sel[i] = {head: info.newPos, anchor: info.newPos};
|
||||
cm.setSelections(sel);
|
||||
if (info.indent) {
|
||||
cm.indentLine(info.newPos.line, null, true);
|
||||
cm.indentLine(info.newPos.line + 1, null, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function autoCloseCurrent(cm, typingSlash) {
|
||||
var ranges = cm.listSelections(), replacements = [];
|
||||
var head = typingSlash ? "/" : "</";
|
||||
for (var i = 0; i < ranges.length; i++) {
|
||||
if (!ranges[i].empty()) return CodeMirror.Pass;
|
||||
var pos = ranges[i].head, tok = cm.getTokenAt(pos);
|
||||
var inner = CodeMirror.innerMode(cm.getMode(), tok.state), state = inner.state;
|
||||
if (typingSlash && (tok.type == "string" || tok.string.charAt(0) != "<" ||
|
||||
tok.start != pos.ch - 1))
|
||||
return CodeMirror.Pass;
|
||||
// Kludge to get around the fact that we are not in XML mode
|
||||
// when completing in JS/CSS snippet in htmlmixed mode. Does not
|
||||
// work for other XML embedded languages (there is no general
|
||||
// way to go from a mixed mode to its current XML state).
|
||||
var replacement;
|
||||
if (inner.mode.name != "xml") {
|
||||
if (cm.getMode().name == "htmlmixed" && inner.mode.name == "javascript")
|
||||
replacement = head + "script";
|
||||
else if (cm.getMode().name == "htmlmixed" && inner.mode.name == "css")
|
||||
replacement = head + "style";
|
||||
else
|
||||
return CodeMirror.Pass;
|
||||
} else {
|
||||
if (!state.context || !state.context.tagName ||
|
||||
closingTagExists(cm, state.context.tagName, pos, state))
|
||||
return CodeMirror.Pass;
|
||||
replacement = head + state.context.tagName;
|
||||
}
|
||||
if (cm.getLine(pos.line).charAt(tok.end) != ">") replacement += ">";
|
||||
replacements[i] = replacement;
|
||||
}
|
||||
cm.replaceSelections(replacements);
|
||||
ranges = cm.listSelections();
|
||||
for (var i = 0; i < ranges.length; i++)
|
||||
if (i == ranges.length - 1 || ranges[i].head.line < ranges[i + 1].head.line)
|
||||
cm.indentLine(ranges[i].head.line);
|
||||
}
|
||||
|
||||
function autoCloseSlash(cm) {
|
||||
if (cm.getOption("disableInput")) return CodeMirror.Pass;
|
||||
return autoCloseCurrent(cm, true);
|
||||
}
|
||||
|
||||
CodeMirror.commands.closeTag = function(cm) { return autoCloseCurrent(cm); };
|
||||
|
||||
function indexOf(collection, elt) {
|
||||
if (collection.indexOf) return collection.indexOf(elt);
|
||||
for (var i = 0, e = collection.length; i < e; ++i)
|
||||
if (collection[i] == elt) return i;
|
||||
return -1;
|
||||
}
|
||||
|
||||
// If xml-fold is loaded, we use its functionality to try and verify
|
||||
// whether a given tag is actually unclosed.
|
||||
function closingTagExists(cm, tagName, pos, state, newTag) {
|
||||
if (!CodeMirror.scanForClosingTag) return false;
|
||||
var end = Math.min(cm.lastLine() + 1, pos.line + 500);
|
||||
var nextClose = CodeMirror.scanForClosingTag(cm, pos, null, end);
|
||||
if (!nextClose || nextClose.tag != tagName) return false;
|
||||
var cx = state.context;
|
||||
// If the immediate wrapping context contains onCx instances of
|
||||
// the same tag, a closing tag only exists if there are at least
|
||||
// that many closing tags of that type following.
|
||||
for (var onCx = newTag ? 1 : 0; cx && cx.tagName == tagName; cx = cx.prev) ++onCx;
|
||||
pos = nextClose.to;
|
||||
for (var i = 1; i < onCx; i++) {
|
||||
var next = CodeMirror.scanForClosingTag(cm, pos, null, end);
|
||||
if (!next || next.tag != tagName) return false;
|
||||
pos = next.to;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
51
codemirror/addon/edit/continuelist.js
vendored
Normal file
51
codemirror/addon/edit/continuelist.js
vendored
Normal file
|
@ -0,0 +1,51 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
var listRE = /^(\s*)(>[> ]*|- \[[x ]\]\s|[*+-]\s|(\d+)([.)]))(\s*)/,
|
||||
emptyListRE = /^(\s*)(>[> ]*|- \[[x ]\]|[*+-]|(\d+)[.)])(\s*)$/,
|
||||
unorderedListRE = /[*+-]\s/;
|
||||
|
||||
CodeMirror.commands.newlineAndIndentContinueMarkdownList = function(cm) {
|
||||
if (cm.getOption("disableInput")) return CodeMirror.Pass;
|
||||
var ranges = cm.listSelections(), replacements = [];
|
||||
for (var i = 0; i < ranges.length; i++) {
|
||||
var pos = ranges[i].head;
|
||||
var eolState = cm.getStateAfter(pos.line);
|
||||
var inList = eolState.list !== false;
|
||||
var inQuote = eolState.quote !== 0;
|
||||
|
||||
var line = cm.getLine(pos.line), match = listRE.exec(line);
|
||||
if (!ranges[i].empty() || (!inList && !inQuote) || !match) {
|
||||
cm.execCommand("newlineAndIndent");
|
||||
return;
|
||||
}
|
||||
if (emptyListRE.test(line)) {
|
||||
cm.replaceRange("", {
|
||||
line: pos.line, ch: 0
|
||||
}, {
|
||||
line: pos.line, ch: pos.ch + 1
|
||||
});
|
||||
replacements[i] = "\n";
|
||||
} else {
|
||||
var indent = match[1], after = match[5];
|
||||
var bullet = unorderedListRE.test(match[2]) || match[2].indexOf(">") >= 0
|
||||
? match[2].replace("x", " ")
|
||||
: (parseInt(match[3], 10) + 1) + match[4];
|
||||
|
||||
replacements[i] = "\n" + indent + bullet + after;
|
||||
}
|
||||
}
|
||||
|
||||
cm.replaceSelections(replacements);
|
||||
};
|
||||
});
|
4
codemirror/addon/edit/matchbrackets.js
vendored
4
codemirror/addon/edit/matchbrackets.js
vendored
|
@ -102,8 +102,10 @@
|
|||
}
|
||||
|
||||
CodeMirror.defineOption("matchBrackets", false, function(cm, val, old) {
|
||||
if (old && old != CodeMirror.Init)
|
||||
if (old && old != CodeMirror.Init) {
|
||||
cm.off("cursorActivity", doMatchBrackets);
|
||||
if (currentlyHighlighted) {currentlyHighlighted(); currentlyHighlighted = null;}
|
||||
}
|
||||
if (val) {
|
||||
cm.state.matchBrackets = typeof val == "object" ? val : {};
|
||||
cm.on("cursorActivity", doMatchBrackets);
|
||||
|
|
66
codemirror/addon/edit/matchtags.js
vendored
Normal file
66
codemirror/addon/edit/matchtags.js
vendored
Normal file
|
@ -0,0 +1,66 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"), require("../fold/xml-fold"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror", "../fold/xml-fold"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
CodeMirror.defineOption("matchTags", false, function(cm, val, old) {
|
||||
if (old && old != CodeMirror.Init) {
|
||||
cm.off("cursorActivity", doMatchTags);
|
||||
cm.off("viewportChange", maybeUpdateMatch);
|
||||
clear(cm);
|
||||
}
|
||||
if (val) {
|
||||
cm.state.matchBothTags = typeof val == "object" && val.bothTags;
|
||||
cm.on("cursorActivity", doMatchTags);
|
||||
cm.on("viewportChange", maybeUpdateMatch);
|
||||
doMatchTags(cm);
|
||||
}
|
||||
});
|
||||
|
||||
function clear(cm) {
|
||||
if (cm.state.tagHit) cm.state.tagHit.clear();
|
||||
if (cm.state.tagOther) cm.state.tagOther.clear();
|
||||
cm.state.tagHit = cm.state.tagOther = null;
|
||||
}
|
||||
|
||||
function doMatchTags(cm) {
|
||||
cm.state.failedTagMatch = false;
|
||||
cm.operation(function() {
|
||||
clear(cm);
|
||||
if (cm.somethingSelected()) return;
|
||||
var cur = cm.getCursor(), range = cm.getViewport();
|
||||
range.from = Math.min(range.from, cur.line); range.to = Math.max(cur.line + 1, range.to);
|
||||
var match = CodeMirror.findMatchingTag(cm, cur, range);
|
||||
if (!match) return;
|
||||
if (cm.state.matchBothTags) {
|
||||
var hit = match.at == "open" ? match.open : match.close;
|
||||
if (hit) cm.state.tagHit = cm.markText(hit.from, hit.to, {className: "CodeMirror-matchingtag"});
|
||||
}
|
||||
var other = match.at == "close" ? match.open : match.close;
|
||||
if (other)
|
||||
cm.state.tagOther = cm.markText(other.from, other.to, {className: "CodeMirror-matchingtag"});
|
||||
else
|
||||
cm.state.failedTagMatch = true;
|
||||
});
|
||||
}
|
||||
|
||||
function maybeUpdateMatch(cm) {
|
||||
if (cm.state.failedTagMatch) doMatchTags(cm);
|
||||
}
|
||||
|
||||
CodeMirror.commands.toMatchingTag = function(cm) {
|
||||
var found = CodeMirror.findMatchingTag(cm, cm.getCursor());
|
||||
if (found) {
|
||||
var other = found.at == "close" ? found.open : found.close;
|
||||
if (other) cm.extendSelection(other.to, other.from);
|
||||
}
|
||||
};
|
||||
});
|
27
codemirror/addon/edit/trailingspace.js
vendored
Normal file
27
codemirror/addon/edit/trailingspace.js
vendored
Normal file
|
@ -0,0 +1,27 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
CodeMirror.defineOption("showTrailingSpace", false, function(cm, val, prev) {
|
||||
if (prev == CodeMirror.Init) prev = false;
|
||||
if (prev && !val)
|
||||
cm.removeOverlay("trailingspace");
|
||||
else if (!prev && val)
|
||||
cm.addOverlay({
|
||||
token: function(stream) {
|
||||
for (var l = stream.string.length, i = l; i && /\s/.test(stream.string.charAt(i - 1)); --i) {}
|
||||
if (i > stream.pos) { stream.pos = i; return null; }
|
||||
stream.pos = l;
|
||||
return "trailingspace";
|
||||
},
|
||||
name: "trailingspace"
|
||||
});
|
||||
});
|
||||
});
|
16
codemirror/addon/fold/brace-fold.js
vendored
16
codemirror/addon/fold/brace-fold.js
vendored
|
@ -13,7 +13,7 @@
|
|||
|
||||
CodeMirror.registerHelper("fold", "brace", function(cm, start) {
|
||||
var line = start.line, lineText = cm.getLine(line);
|
||||
var startCh, tokenType;
|
||||
var tokenType;
|
||||
|
||||
function findOpening(openCh) {
|
||||
for (var at = start.ch, pass = 0;;) {
|
||||
|
@ -72,15 +72,15 @@ CodeMirror.registerHelper("fold", "import", function(cm, start) {
|
|||
}
|
||||
}
|
||||
|
||||
var start = start.line, has = hasImport(start), prev;
|
||||
if (!has || hasImport(start - 1) || ((prev = hasImport(start - 2)) && prev.end.line == start - 1))
|
||||
var startLine = start.line, has = hasImport(startLine), prev;
|
||||
if (!has || hasImport(startLine - 1) || ((prev = hasImport(startLine - 2)) && prev.end.line == startLine - 1))
|
||||
return null;
|
||||
for (var end = has.end;;) {
|
||||
var next = hasImport(end.line + 1);
|
||||
if (next == null) break;
|
||||
end = next.end;
|
||||
}
|
||||
return {from: cm.clipPos(CodeMirror.Pos(start, has.startCh + 1)), to: end};
|
||||
return {from: cm.clipPos(CodeMirror.Pos(startLine, has.startCh + 1)), to: end};
|
||||
});
|
||||
|
||||
CodeMirror.registerHelper("fold", "include", function(cm, start) {
|
||||
|
@ -91,14 +91,14 @@ CodeMirror.registerHelper("fold", "include", function(cm, start) {
|
|||
if (start.type == "meta" && start.string.slice(0, 8) == "#include") return start.start + 8;
|
||||
}
|
||||
|
||||
var start = start.line, has = hasInclude(start);
|
||||
if (has == null || hasInclude(start - 1) != null) return null;
|
||||
for (var end = start;;) {
|
||||
var startLine = start.line, has = hasInclude(startLine);
|
||||
if (has == null || hasInclude(startLine - 1) != null) return null;
|
||||
for (var end = startLine;;) {
|
||||
var next = hasInclude(end + 1);
|
||||
if (next == null) break;
|
||||
++end;
|
||||
}
|
||||
return {from: CodeMirror.Pos(start, has + 1),
|
||||
return {from: CodeMirror.Pos(startLine, has + 1),
|
||||
to: cm.clipPos(CodeMirror.Pos(end))};
|
||||
});
|
||||
|
||||
|
|
4
codemirror/addon/fold/comment-fold.js
vendored
4
codemirror/addon/fold/comment-fold.js
vendored
|
@ -28,7 +28,9 @@ CodeMirror.registerGlobalHelper("fold", "comment", function(mode) {
|
|||
continue;
|
||||
}
|
||||
if (pass == 1 && found < start.ch) return;
|
||||
if (/comment/.test(cm.getTokenTypeAt(CodeMirror.Pos(line, found + 1)))) {
|
||||
if (/comment/.test(cm.getTokenTypeAt(CodeMirror.Pos(line, found + 1))) &&
|
||||
(found == 0 || lineText.slice(found - endToken.length, found) == endToken ||
|
||||
!/comment/.test(cm.getTokenTypeAt(CodeMirror.Pos(line, found))))) {
|
||||
startCh = found + startToken.length;
|
||||
break;
|
||||
}
|
||||
|
|
5
codemirror/addon/fold/foldcode.js
vendored
5
codemirror/addon/fold/foldcode.js
vendored
|
@ -49,7 +49,7 @@
|
|||
});
|
||||
var myRange = cm.markText(range.from, range.to, {
|
||||
replacedWith: myWidget,
|
||||
clearOnEnter: true,
|
||||
clearOnEnter: getOption(cm, options, "clearOnEnter"),
|
||||
__isFold: true
|
||||
});
|
||||
myRange.on("clear", function(from, to) {
|
||||
|
@ -129,7 +129,8 @@
|
|||
rangeFinder: CodeMirror.fold.auto,
|
||||
widget: "\u2194",
|
||||
minFoldSize: 0,
|
||||
scanUp: false
|
||||
scanUp: false,
|
||||
clearOnEnter: true
|
||||
};
|
||||
|
||||
CodeMirror.defineOption("foldOptions", null);
|
||||
|
|
6
codemirror/addon/fold/foldgutter.js
vendored
6
codemirror/addon/fold/foldgutter.js
vendored
|
@ -20,7 +20,7 @@
|
|||
cm.off("viewportChange", onViewportChange);
|
||||
cm.off("fold", onFold);
|
||||
cm.off("unfold", onFold);
|
||||
cm.off("swapDoc", updateInViewport);
|
||||
cm.off("swapDoc", onChange);
|
||||
}
|
||||
if (val) {
|
||||
cm.state.foldGutter = new State(parseOptions(val));
|
||||
|
@ -30,7 +30,7 @@
|
|||
cm.on("viewportChange", onViewportChange);
|
||||
cm.on("fold", onFold);
|
||||
cm.on("unfold", onFold);
|
||||
cm.on("swapDoc", updateInViewport);
|
||||
cm.on("swapDoc", onChange);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -50,7 +50,7 @@
|
|||
}
|
||||
|
||||
function isFolded(cm, line) {
|
||||
var marks = cm.findMarksAt(Pos(line));
|
||||
var marks = cm.findMarks(Pos(line, 0), Pos(line + 1, 0));
|
||||
for (var i = 0; i < marks.length; ++i)
|
||||
if (marks[i].__isFold && marks[i].find().from.line == line) return marks[i];
|
||||
}
|
||||
|
|
44
codemirror/addon/fold/indent-fold.js
vendored
Normal file
44
codemirror/addon/fold/indent-fold.js
vendored
Normal file
|
@ -0,0 +1,44 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
CodeMirror.registerHelper("fold", "indent", function(cm, start) {
|
||||
var tabSize = cm.getOption("tabSize"), firstLine = cm.getLine(start.line);
|
||||
if (!/\S/.test(firstLine)) return;
|
||||
var getIndent = function(line) {
|
||||
return CodeMirror.countColumn(line, null, tabSize);
|
||||
};
|
||||
var myIndent = getIndent(firstLine);
|
||||
var lastLineInFold = null;
|
||||
// Go through lines until we find a line that definitely doesn't belong in
|
||||
// the block we're folding, or to the end.
|
||||
for (var i = start.line + 1, end = cm.lastLine(); i <= end; ++i) {
|
||||
var curLine = cm.getLine(i);
|
||||
var curIndent = getIndent(curLine);
|
||||
if (curIndent > myIndent) {
|
||||
// Lines with a greater indent are considered part of the block.
|
||||
lastLineInFold = i;
|
||||
} else if (!/\S/.test(curLine)) {
|
||||
// Empty lines might be breaks within the block we're trying to fold.
|
||||
} else {
|
||||
// A non-empty line at an indent equal to or less than ours marks the
|
||||
// start of another block.
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (lastLineInFold) return {
|
||||
from: CodeMirror.Pos(start.line, firstLine.length),
|
||||
to: CodeMirror.Pos(lastLineInFold, cm.getLine(lastLineInFold).length)
|
||||
};
|
||||
});
|
||||
|
||||
});
|
49
codemirror/addon/fold/markdown-fold.js
vendored
Normal file
49
codemirror/addon/fold/markdown-fold.js
vendored
Normal file
|
@ -0,0 +1,49 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
CodeMirror.registerHelper("fold", "markdown", function(cm, start) {
|
||||
var maxDepth = 100;
|
||||
|
||||
function isHeader(lineNo) {
|
||||
var tokentype = cm.getTokenTypeAt(CodeMirror.Pos(lineNo, 0));
|
||||
return tokentype && /\bheader\b/.test(tokentype);
|
||||
}
|
||||
|
||||
function headerLevel(lineNo, line, nextLine) {
|
||||
var match = line && line.match(/^#+/);
|
||||
if (match && isHeader(lineNo)) return match[0].length;
|
||||
match = nextLine && nextLine.match(/^[=\-]+\s*$/);
|
||||
if (match && isHeader(lineNo + 1)) return nextLine[0] == "=" ? 1 : 2;
|
||||
return maxDepth;
|
||||
}
|
||||
|
||||
var firstLine = cm.getLine(start.line), nextLine = cm.getLine(start.line + 1);
|
||||
var level = headerLevel(start.line, firstLine, nextLine);
|
||||
if (level === maxDepth) return undefined;
|
||||
|
||||
var lastLineNo = cm.lastLine();
|
||||
var end = start.line, nextNextLine = cm.getLine(end + 2);
|
||||
while (end < lastLineNo) {
|
||||
if (headerLevel(end + 1, nextLine, nextNextLine) <= level) break;
|
||||
++end;
|
||||
nextLine = nextNextLine;
|
||||
nextNextLine = cm.getLine(end + 2);
|
||||
}
|
||||
|
||||
return {
|
||||
from: CodeMirror.Pos(start.line, firstLine.length),
|
||||
to: CodeMirror.Pos(end, cm.getLine(end).length)
|
||||
};
|
||||
});
|
||||
|
||||
});
|
182
codemirror/addon/fold/xml-fold.js
vendored
Normal file
182
codemirror/addon/fold/xml-fold.js
vendored
Normal file
|
@ -0,0 +1,182 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
var Pos = CodeMirror.Pos;
|
||||
function cmp(a, b) { return a.line - b.line || a.ch - b.ch; }
|
||||
|
||||
var nameStartChar = "A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD";
|
||||
var nameChar = nameStartChar + "\-\:\.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040";
|
||||
var xmlTagStart = new RegExp("<(/?)([" + nameStartChar + "][" + nameChar + "]*)", "g");
|
||||
|
||||
function Iter(cm, line, ch, range) {
|
||||
this.line = line; this.ch = ch;
|
||||
this.cm = cm; this.text = cm.getLine(line);
|
||||
this.min = range ? Math.max(range.from, cm.firstLine()) : cm.firstLine();
|
||||
this.max = range ? Math.min(range.to - 1, cm.lastLine()) : cm.lastLine();
|
||||
}
|
||||
|
||||
function tagAt(iter, ch) {
|
||||
var type = iter.cm.getTokenTypeAt(Pos(iter.line, ch));
|
||||
return type && /\btag\b/.test(type);
|
||||
}
|
||||
|
||||
function nextLine(iter) {
|
||||
if (iter.line >= iter.max) return;
|
||||
iter.ch = 0;
|
||||
iter.text = iter.cm.getLine(++iter.line);
|
||||
return true;
|
||||
}
|
||||
function prevLine(iter) {
|
||||
if (iter.line <= iter.min) return;
|
||||
iter.text = iter.cm.getLine(--iter.line);
|
||||
iter.ch = iter.text.length;
|
||||
return true;
|
||||
}
|
||||
|
||||
function toTagEnd(iter) {
|
||||
for (;;) {
|
||||
var gt = iter.text.indexOf(">", iter.ch);
|
||||
if (gt == -1) { if (nextLine(iter)) continue; else return; }
|
||||
if (!tagAt(iter, gt + 1)) { iter.ch = gt + 1; continue; }
|
||||
var lastSlash = iter.text.lastIndexOf("/", gt);
|
||||
var selfClose = lastSlash > -1 && !/\S/.test(iter.text.slice(lastSlash + 1, gt));
|
||||
iter.ch = gt + 1;
|
||||
return selfClose ? "selfClose" : "regular";
|
||||
}
|
||||
}
|
||||
function toTagStart(iter) {
|
||||
for (;;) {
|
||||
var lt = iter.ch ? iter.text.lastIndexOf("<", iter.ch - 1) : -1;
|
||||
if (lt == -1) { if (prevLine(iter)) continue; else return; }
|
||||
if (!tagAt(iter, lt + 1)) { iter.ch = lt; continue; }
|
||||
xmlTagStart.lastIndex = lt;
|
||||
iter.ch = lt;
|
||||
var match = xmlTagStart.exec(iter.text);
|
||||
if (match && match.index == lt) return match;
|
||||
}
|
||||
}
|
||||
|
||||
function toNextTag(iter) {
|
||||
for (;;) {
|
||||
xmlTagStart.lastIndex = iter.ch;
|
||||
var found = xmlTagStart.exec(iter.text);
|
||||
if (!found) { if (nextLine(iter)) continue; else return; }
|
||||
if (!tagAt(iter, found.index + 1)) { iter.ch = found.index + 1; continue; }
|
||||
iter.ch = found.index + found[0].length;
|
||||
return found;
|
||||
}
|
||||
}
|
||||
function toPrevTag(iter) {
|
||||
for (;;) {
|
||||
var gt = iter.ch ? iter.text.lastIndexOf(">", iter.ch - 1) : -1;
|
||||
if (gt == -1) { if (prevLine(iter)) continue; else return; }
|
||||
if (!tagAt(iter, gt + 1)) { iter.ch = gt; continue; }
|
||||
var lastSlash = iter.text.lastIndexOf("/", gt);
|
||||
var selfClose = lastSlash > -1 && !/\S/.test(iter.text.slice(lastSlash + 1, gt));
|
||||
iter.ch = gt + 1;
|
||||
return selfClose ? "selfClose" : "regular";
|
||||
}
|
||||
}
|
||||
|
||||
function findMatchingClose(iter, tag) {
|
||||
var stack = [];
|
||||
for (;;) {
|
||||
var next = toNextTag(iter), end, startLine = iter.line, startCh = iter.ch - (next ? next[0].length : 0);
|
||||
if (!next || !(end = toTagEnd(iter))) return;
|
||||
if (end == "selfClose") continue;
|
||||
if (next[1]) { // closing tag
|
||||
for (var i = stack.length - 1; i >= 0; --i) if (stack[i] == next[2]) {
|
||||
stack.length = i;
|
||||
break;
|
||||
}
|
||||
if (i < 0 && (!tag || tag == next[2])) return {
|
||||
tag: next[2],
|
||||
from: Pos(startLine, startCh),
|
||||
to: Pos(iter.line, iter.ch)
|
||||
};
|
||||
} else { // opening tag
|
||||
stack.push(next[2]);
|
||||
}
|
||||
}
|
||||
}
|
||||
function findMatchingOpen(iter, tag) {
|
||||
var stack = [];
|
||||
for (;;) {
|
||||
var prev = toPrevTag(iter);
|
||||
if (!prev) return;
|
||||
if (prev == "selfClose") { toTagStart(iter); continue; }
|
||||
var endLine = iter.line, endCh = iter.ch;
|
||||
var start = toTagStart(iter);
|
||||
if (!start) return;
|
||||
if (start[1]) { // closing tag
|
||||
stack.push(start[2]);
|
||||
} else { // opening tag
|
||||
for (var i = stack.length - 1; i >= 0; --i) if (stack[i] == start[2]) {
|
||||
stack.length = i;
|
||||
break;
|
||||
}
|
||||
if (i < 0 && (!tag || tag == start[2])) return {
|
||||
tag: start[2],
|
||||
from: Pos(iter.line, iter.ch),
|
||||
to: Pos(endLine, endCh)
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CodeMirror.registerHelper("fold", "xml", function(cm, start) {
|
||||
var iter = new Iter(cm, start.line, 0);
|
||||
for (;;) {
|
||||
var openTag = toNextTag(iter), end;
|
||||
if (!openTag || iter.line != start.line || !(end = toTagEnd(iter))) return;
|
||||
if (!openTag[1] && end != "selfClose") {
|
||||
var startPos = Pos(iter.line, iter.ch);
|
||||
var endPos = findMatchingClose(iter, openTag[2]);
|
||||
return endPos && {from: startPos, to: endPos.from};
|
||||
}
|
||||
}
|
||||
});
|
||||
CodeMirror.findMatchingTag = function(cm, pos, range) {
|
||||
var iter = new Iter(cm, pos.line, pos.ch, range);
|
||||
if (iter.text.indexOf(">") == -1 && iter.text.indexOf("<") == -1) return;
|
||||
var end = toTagEnd(iter), to = end && Pos(iter.line, iter.ch);
|
||||
var start = end && toTagStart(iter);
|
||||
if (!end || !start || cmp(iter, pos) > 0) return;
|
||||
var here = {from: Pos(iter.line, iter.ch), to: to, tag: start[2]};
|
||||
if (end == "selfClose") return {open: here, close: null, at: "open"};
|
||||
|
||||
if (start[1]) { // closing tag
|
||||
return {open: findMatchingOpen(iter, start[2]), close: here, at: "close"};
|
||||
} else { // opening tag
|
||||
iter = new Iter(cm, to.line, to.ch, range);
|
||||
return {open: here, close: findMatchingClose(iter, start[2]), at: "open"};
|
||||
}
|
||||
};
|
||||
|
||||
CodeMirror.findEnclosingTag = function(cm, pos, range) {
|
||||
var iter = new Iter(cm, pos.line, pos.ch, range);
|
||||
for (;;) {
|
||||
var open = findMatchingOpen(iter);
|
||||
if (!open) break;
|
||||
var forward = new Iter(cm, pos.line, pos.ch, range);
|
||||
var close = findMatchingClose(forward, open.tag);
|
||||
if (close) return {open: open, close: close};
|
||||
}
|
||||
};
|
||||
|
||||
// Used by addon/edit/closetag.js
|
||||
CodeMirror.scanForClosingTag = function(cm, pos, name, end) {
|
||||
var iter = new Iter(cm, pos.line, pos.ch, end ? {from: 0, to: end} : null);
|
||||
return findMatchingClose(iter, name);
|
||||
};
|
||||
});
|
41
codemirror/addon/hint/anyword-hint.js
vendored
Normal file
41
codemirror/addon/hint/anyword-hint.js
vendored
Normal file
|
@ -0,0 +1,41 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
var WORD = /[\w$]+/, RANGE = 500;
|
||||
|
||||
CodeMirror.registerHelper("hint", "anyword", function(editor, options) {
|
||||
var word = options && options.word || WORD;
|
||||
var range = options && options.range || RANGE;
|
||||
var cur = editor.getCursor(), curLine = editor.getLine(cur.line);
|
||||
var end = cur.ch, start = end;
|
||||
while (start && word.test(curLine.charAt(start - 1))) --start;
|
||||
var curWord = start != end && curLine.slice(start, end);
|
||||
|
||||
var list = options && options.list || [], seen = {};
|
||||
var re = new RegExp(word.source, "g");
|
||||
for (var dir = -1; dir <= 1; dir += 2) {
|
||||
var line = cur.line, endLine = Math.min(Math.max(line + dir * range, editor.firstLine()), editor.lastLine()) + dir;
|
||||
for (; line != endLine; line += dir) {
|
||||
var text = editor.getLine(line), m;
|
||||
while (m = re.exec(text)) {
|
||||
if (line == cur.line && m[0] === curWord) continue;
|
||||
if ((!curWord || m[0].lastIndexOf(curWord, 0) == 0) && !Object.prototype.hasOwnProperty.call(seen, m[0])) {
|
||||
seen[m[0]] = true;
|
||||
list.push(m[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return {list: list, from: CodeMirror.Pos(cur.line, start), to: CodeMirror.Pos(cur.line, end)};
|
||||
});
|
||||
});
|
348
codemirror/addon/hint/html-hint.js
vendored
Normal file
348
codemirror/addon/hint/html-hint.js
vendored
Normal file
|
@ -0,0 +1,348 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"), require("./xml-hint"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror", "./xml-hint"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
var langs = "ab aa af ak sq am ar an hy as av ae ay az bm ba eu be bn bh bi bs br bg my ca ch ce ny zh cv kw co cr hr cs da dv nl dz en eo et ee fo fj fi fr ff gl ka de el gn gu ht ha he hz hi ho hu ia id ie ga ig ik io is it iu ja jv kl kn kr ks kk km ki rw ky kv kg ko ku kj la lb lg li ln lo lt lu lv gv mk mg ms ml mt mi mr mh mn na nv nb nd ne ng nn no ii nr oc oj cu om or os pa pi fa pl ps pt qu rm rn ro ru sa sc sd se sm sg sr gd sn si sk sl so st es su sw ss sv ta te tg th ti bo tk tl tn to tr ts tt tw ty ug uk ur uz ve vi vo wa cy wo fy xh yi yo za zu".split(" ");
|
||||
var targets = ["_blank", "_self", "_top", "_parent"];
|
||||
var charsets = ["ascii", "utf-8", "utf-16", "latin1", "latin1"];
|
||||
var methods = ["get", "post", "put", "delete"];
|
||||
var encs = ["application/x-www-form-urlencoded", "multipart/form-data", "text/plain"];
|
||||
var media = ["all", "screen", "print", "embossed", "braille", "handheld", "print", "projection", "screen", "tty", "tv", "speech",
|
||||
"3d-glasses", "resolution [>][<][=] [X]", "device-aspect-ratio: X/Y", "orientation:portrait",
|
||||
"orientation:landscape", "device-height: [X]", "device-width: [X]"];
|
||||
var s = { attrs: {} }; // Simple tag, reused for a whole lot of tags
|
||||
|
||||
var data = {
|
||||
a: {
|
||||
attrs: {
|
||||
href: null, ping: null, type: null,
|
||||
media: media,
|
||||
target: targets,
|
||||
hreflang: langs
|
||||
}
|
||||
},
|
||||
abbr: s,
|
||||
acronym: s,
|
||||
address: s,
|
||||
applet: s,
|
||||
area: {
|
||||
attrs: {
|
||||
alt: null, coords: null, href: null, target: null, ping: null,
|
||||
media: media, hreflang: langs, type: null,
|
||||
shape: ["default", "rect", "circle", "poly"]
|
||||
}
|
||||
},
|
||||
article: s,
|
||||
aside: s,
|
||||
audio: {
|
||||
attrs: {
|
||||
src: null, mediagroup: null,
|
||||
crossorigin: ["anonymous", "use-credentials"],
|
||||
preload: ["none", "metadata", "auto"],
|
||||
autoplay: ["", "autoplay"],
|
||||
loop: ["", "loop"],
|
||||
controls: ["", "controls"]
|
||||
}
|
||||
},
|
||||
b: s,
|
||||
base: { attrs: { href: null, target: targets } },
|
||||
basefont: s,
|
||||
bdi: s,
|
||||
bdo: s,
|
||||
big: s,
|
||||
blockquote: { attrs: { cite: null } },
|
||||
body: s,
|
||||
br: s,
|
||||
button: {
|
||||
attrs: {
|
||||
form: null, formaction: null, name: null, value: null,
|
||||
autofocus: ["", "autofocus"],
|
||||
disabled: ["", "autofocus"],
|
||||
formenctype: encs,
|
||||
formmethod: methods,
|
||||
formnovalidate: ["", "novalidate"],
|
||||
formtarget: targets,
|
||||
type: ["submit", "reset", "button"]
|
||||
}
|
||||
},
|
||||
canvas: { attrs: { width: null, height: null } },
|
||||
caption: s,
|
||||
center: s,
|
||||
cite: s,
|
||||
code: s,
|
||||
col: { attrs: { span: null } },
|
||||
colgroup: { attrs: { span: null } },
|
||||
command: {
|
||||
attrs: {
|
||||
type: ["command", "checkbox", "radio"],
|
||||
label: null, icon: null, radiogroup: null, command: null, title: null,
|
||||
disabled: ["", "disabled"],
|
||||
checked: ["", "checked"]
|
||||
}
|
||||
},
|
||||
data: { attrs: { value: null } },
|
||||
datagrid: { attrs: { disabled: ["", "disabled"], multiple: ["", "multiple"] } },
|
||||
datalist: { attrs: { data: null } },
|
||||
dd: s,
|
||||
del: { attrs: { cite: null, datetime: null } },
|
||||
details: { attrs: { open: ["", "open"] } },
|
||||
dfn: s,
|
||||
dir: s,
|
||||
div: s,
|
||||
dl: s,
|
||||
dt: s,
|
||||
em: s,
|
||||
embed: { attrs: { src: null, type: null, width: null, height: null } },
|
||||
eventsource: { attrs: { src: null } },
|
||||
fieldset: { attrs: { disabled: ["", "disabled"], form: null, name: null } },
|
||||
figcaption: s,
|
||||
figure: s,
|
||||
font: s,
|
||||
footer: s,
|
||||
form: {
|
||||
attrs: {
|
||||
action: null, name: null,
|
||||
"accept-charset": charsets,
|
||||
autocomplete: ["on", "off"],
|
||||
enctype: encs,
|
||||
method: methods,
|
||||
novalidate: ["", "novalidate"],
|
||||
target: targets
|
||||
}
|
||||
},
|
||||
frame: s,
|
||||
frameset: s,
|
||||
h1: s, h2: s, h3: s, h4: s, h5: s, h6: s,
|
||||
head: {
|
||||
attrs: {},
|
||||
children: ["title", "base", "link", "style", "meta", "script", "noscript", "command"]
|
||||
},
|
||||
header: s,
|
||||
hgroup: s,
|
||||
hr: s,
|
||||
html: {
|
||||
attrs: { manifest: null },
|
||||
children: ["head", "body"]
|
||||
},
|
||||
i: s,
|
||||
iframe: {
|
||||
attrs: {
|
||||
src: null, srcdoc: null, name: null, width: null, height: null,
|
||||
sandbox: ["allow-top-navigation", "allow-same-origin", "allow-forms", "allow-scripts"],
|
||||
seamless: ["", "seamless"]
|
||||
}
|
||||
},
|
||||
img: {
|
||||
attrs: {
|
||||
alt: null, src: null, ismap: null, usemap: null, width: null, height: null,
|
||||
crossorigin: ["anonymous", "use-credentials"]
|
||||
}
|
||||
},
|
||||
input: {
|
||||
attrs: {
|
||||
alt: null, dirname: null, form: null, formaction: null,
|
||||
height: null, list: null, max: null, maxlength: null, min: null,
|
||||
name: null, pattern: null, placeholder: null, size: null, src: null,
|
||||
step: null, value: null, width: null,
|
||||
accept: ["audio/*", "video/*", "image/*"],
|
||||
autocomplete: ["on", "off"],
|
||||
autofocus: ["", "autofocus"],
|
||||
checked: ["", "checked"],
|
||||
disabled: ["", "disabled"],
|
||||
formenctype: encs,
|
||||
formmethod: methods,
|
||||
formnovalidate: ["", "novalidate"],
|
||||
formtarget: targets,
|
||||
multiple: ["", "multiple"],
|
||||
readonly: ["", "readonly"],
|
||||
required: ["", "required"],
|
||||
type: ["hidden", "text", "search", "tel", "url", "email", "password", "datetime", "date", "month",
|
||||
"week", "time", "datetime-local", "number", "range", "color", "checkbox", "radio",
|
||||
"file", "submit", "image", "reset", "button"]
|
||||
}
|
||||
},
|
||||
ins: { attrs: { cite: null, datetime: null } },
|
||||
kbd: s,
|
||||
keygen: {
|
||||
attrs: {
|
||||
challenge: null, form: null, name: null,
|
||||
autofocus: ["", "autofocus"],
|
||||
disabled: ["", "disabled"],
|
||||
keytype: ["RSA"]
|
||||
}
|
||||
},
|
||||
label: { attrs: { "for": null, form: null } },
|
||||
legend: s,
|
||||
li: { attrs: { value: null } },
|
||||
link: {
|
||||
attrs: {
|
||||
href: null, type: null,
|
||||
hreflang: langs,
|
||||
media: media,
|
||||
sizes: ["all", "16x16", "16x16 32x32", "16x16 32x32 64x64"]
|
||||
}
|
||||
},
|
||||
map: { attrs: { name: null } },
|
||||
mark: s,
|
||||
menu: { attrs: { label: null, type: ["list", "context", "toolbar"] } },
|
||||
meta: {
|
||||
attrs: {
|
||||
content: null,
|
||||
charset: charsets,
|
||||
name: ["viewport", "application-name", "author", "description", "generator", "keywords"],
|
||||
"http-equiv": ["content-language", "content-type", "default-style", "refresh"]
|
||||
}
|
||||
},
|
||||
meter: { attrs: { value: null, min: null, low: null, high: null, max: null, optimum: null } },
|
||||
nav: s,
|
||||
noframes: s,
|
||||
noscript: s,
|
||||
object: {
|
||||
attrs: {
|
||||
data: null, type: null, name: null, usemap: null, form: null, width: null, height: null,
|
||||
typemustmatch: ["", "typemustmatch"]
|
||||
}
|
||||
},
|
||||
ol: { attrs: { reversed: ["", "reversed"], start: null, type: ["1", "a", "A", "i", "I"] } },
|
||||
optgroup: { attrs: { disabled: ["", "disabled"], label: null } },
|
||||
option: { attrs: { disabled: ["", "disabled"], label: null, selected: ["", "selected"], value: null } },
|
||||
output: { attrs: { "for": null, form: null, name: null } },
|
||||
p: s,
|
||||
param: { attrs: { name: null, value: null } },
|
||||
pre: s,
|
||||
progress: { attrs: { value: null, max: null } },
|
||||
q: { attrs: { cite: null } },
|
||||
rp: s,
|
||||
rt: s,
|
||||
ruby: s,
|
||||
s: s,
|
||||
samp: s,
|
||||
script: {
|
||||
attrs: {
|
||||
type: ["text/javascript"],
|
||||
src: null,
|
||||
async: ["", "async"],
|
||||
defer: ["", "defer"],
|
||||
charset: charsets
|
||||
}
|
||||
},
|
||||
section: s,
|
||||
select: {
|
||||
attrs: {
|
||||
form: null, name: null, size: null,
|
||||
autofocus: ["", "autofocus"],
|
||||
disabled: ["", "disabled"],
|
||||
multiple: ["", "multiple"]
|
||||
}
|
||||
},
|
||||
small: s,
|
||||
source: { attrs: { src: null, type: null, media: null } },
|
||||
span: s,
|
||||
strike: s,
|
||||
strong: s,
|
||||
style: {
|
||||
attrs: {
|
||||
type: ["text/css"],
|
||||
media: media,
|
||||
scoped: null
|
||||
}
|
||||
},
|
||||
sub: s,
|
||||
summary: s,
|
||||
sup: s,
|
||||
table: s,
|
||||
tbody: s,
|
||||
td: { attrs: { colspan: null, rowspan: null, headers: null } },
|
||||
textarea: {
|
||||
attrs: {
|
||||
dirname: null, form: null, maxlength: null, name: null, placeholder: null,
|
||||
rows: null, cols: null,
|
||||
autofocus: ["", "autofocus"],
|
||||
disabled: ["", "disabled"],
|
||||
readonly: ["", "readonly"],
|
||||
required: ["", "required"],
|
||||
wrap: ["soft", "hard"]
|
||||
}
|
||||
},
|
||||
tfoot: s,
|
||||
th: { attrs: { colspan: null, rowspan: null, headers: null, scope: ["row", "col", "rowgroup", "colgroup"] } },
|
||||
thead: s,
|
||||
time: { attrs: { datetime: null } },
|
||||
title: s,
|
||||
tr: s,
|
||||
track: {
|
||||
attrs: {
|
||||
src: null, label: null, "default": null,
|
||||
kind: ["subtitles", "captions", "descriptions", "chapters", "metadata"],
|
||||
srclang: langs
|
||||
}
|
||||
},
|
||||
tt: s,
|
||||
u: s,
|
||||
ul: s,
|
||||
"var": s,
|
||||
video: {
|
||||
attrs: {
|
||||
src: null, poster: null, width: null, height: null,
|
||||
crossorigin: ["anonymous", "use-credentials"],
|
||||
preload: ["auto", "metadata", "none"],
|
||||
autoplay: ["", "autoplay"],
|
||||
mediagroup: ["movie"],
|
||||
muted: ["", "muted"],
|
||||
controls: ["", "controls"]
|
||||
}
|
||||
},
|
||||
wbr: s
|
||||
};
|
||||
|
||||
var globalAttrs = {
|
||||
accesskey: ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
|
||||
"class": null,
|
||||
contenteditable: ["true", "false"],
|
||||
contextmenu: null,
|
||||
dir: ["ltr", "rtl", "auto"],
|
||||
draggable: ["true", "false", "auto"],
|
||||
dropzone: ["copy", "move", "link", "string:", "file:"],
|
||||
hidden: ["hidden"],
|
||||
id: null,
|
||||
inert: ["inert"],
|
||||
itemid: null,
|
||||
itemprop: null,
|
||||
itemref: null,
|
||||
itemscope: ["itemscope"],
|
||||
itemtype: null,
|
||||
lang: ["en", "es"],
|
||||
spellcheck: ["true", "false"],
|
||||
style: null,
|
||||
tabindex: ["1", "2", "3", "4", "5", "6", "7", "8", "9"],
|
||||
title: null,
|
||||
translate: ["yes", "no"],
|
||||
onclick: null,
|
||||
rel: ["stylesheet", "alternate", "author", "bookmark", "help", "license", "next", "nofollow", "noreferrer", "prefetch", "prev", "search", "tag"]
|
||||
};
|
||||
function populate(obj) {
|
||||
for (var attr in globalAttrs) if (globalAttrs.hasOwnProperty(attr))
|
||||
obj.attrs[attr] = globalAttrs[attr];
|
||||
}
|
||||
|
||||
populate(s);
|
||||
for (var tag in data) if (data.hasOwnProperty(tag) && data[tag] != s)
|
||||
populate(data[tag]);
|
||||
|
||||
CodeMirror.htmlSchema = data;
|
||||
function htmlHint(cm, options) {
|
||||
var local = {schemaInfo: data};
|
||||
if (options) for (var opt in options) local[opt] = options[opt];
|
||||
return CodeMirror.hint.xml(cm, local);
|
||||
}
|
||||
CodeMirror.registerHelper("hint", "html", htmlHint);
|
||||
});
|
155
codemirror/addon/hint/javascript-hint.js
vendored
Normal file
155
codemirror/addon/hint/javascript-hint.js
vendored
Normal file
|
@ -0,0 +1,155 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
var Pos = CodeMirror.Pos;
|
||||
|
||||
function forEach(arr, f) {
|
||||
for (var i = 0, e = arr.length; i < e; ++i) f(arr[i]);
|
||||
}
|
||||
|
||||
function arrayContains(arr, item) {
|
||||
if (!Array.prototype.indexOf) {
|
||||
var i = arr.length;
|
||||
while (i--) {
|
||||
if (arr[i] === item) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return arr.indexOf(item) != -1;
|
||||
}
|
||||
|
||||
function scriptHint(editor, keywords, getToken, options) {
|
||||
// Find the token at the cursor
|
||||
var cur = editor.getCursor(), token = getToken(editor, cur);
|
||||
if (/\b(?:string|comment)\b/.test(token.type)) return;
|
||||
token.state = CodeMirror.innerMode(editor.getMode(), token.state).state;
|
||||
|
||||
// If it's not a 'word-style' token, ignore the token.
|
||||
if (!/^[\w$_]*$/.test(token.string)) {
|
||||
token = {start: cur.ch, end: cur.ch, string: "", state: token.state,
|
||||
type: token.string == "." ? "property" : null};
|
||||
} else if (token.end > cur.ch) {
|
||||
token.end = cur.ch;
|
||||
token.string = token.string.slice(0, cur.ch - token.start);
|
||||
}
|
||||
|
||||
var tprop = token;
|
||||
// If it is a property, find out what it is a property of.
|
||||
while (tprop.type == "property") {
|
||||
tprop = getToken(editor, Pos(cur.line, tprop.start));
|
||||
if (tprop.string != ".") return;
|
||||
tprop = getToken(editor, Pos(cur.line, tprop.start));
|
||||
if (!context) var context = [];
|
||||
context.push(tprop);
|
||||
}
|
||||
return {list: getCompletions(token, context, keywords, options),
|
||||
from: Pos(cur.line, token.start),
|
||||
to: Pos(cur.line, token.end)};
|
||||
}
|
||||
|
||||
function javascriptHint(editor, options) {
|
||||
return scriptHint(editor, javascriptKeywords,
|
||||
function (e, cur) {return e.getTokenAt(cur);},
|
||||
options);
|
||||
};
|
||||
CodeMirror.registerHelper("hint", "javascript", javascriptHint);
|
||||
|
||||
function getCoffeeScriptToken(editor, cur) {
|
||||
// This getToken, it is for coffeescript, imitates the behavior of
|
||||
// getTokenAt method in javascript.js, that is, returning "property"
|
||||
// type and treat "." as indepenent token.
|
||||
var token = editor.getTokenAt(cur);
|
||||
if (cur.ch == token.start + 1 && token.string.charAt(0) == '.') {
|
||||
token.end = token.start;
|
||||
token.string = '.';
|
||||
token.type = "property";
|
||||
}
|
||||
else if (/^\.[\w$_]*$/.test(token.string)) {
|
||||
token.type = "property";
|
||||
token.start++;
|
||||
token.string = token.string.replace(/\./, '');
|
||||
}
|
||||
return token;
|
||||
}
|
||||
|
||||
function coffeescriptHint(editor, options) {
|
||||
return scriptHint(editor, coffeescriptKeywords, getCoffeeScriptToken, options);
|
||||
}
|
||||
CodeMirror.registerHelper("hint", "coffeescript", coffeescriptHint);
|
||||
|
||||
var stringProps = ("charAt charCodeAt indexOf lastIndexOf substring substr slice trim trimLeft trimRight " +
|
||||
"toUpperCase toLowerCase split concat match replace search").split(" ");
|
||||
var arrayProps = ("length concat join splice push pop shift unshift slice reverse sort indexOf " +
|
||||
"lastIndexOf every some filter forEach map reduce reduceRight ").split(" ");
|
||||
var funcProps = "prototype apply call bind".split(" ");
|
||||
var javascriptKeywords = ("break case catch continue debugger default delete do else false finally for function " +
|
||||
"if in instanceof new null return switch throw true try typeof var void while with").split(" ");
|
||||
var coffeescriptKeywords = ("and break catch class continue delete do else extends false finally for " +
|
||||
"if in instanceof isnt new no not null of off on or return switch then throw true try typeof until void while with yes").split(" ");
|
||||
|
||||
function forAllProps(obj, callback) {
|
||||
if (!Object.getOwnPropertyNames || !Object.getPrototypeOf) {
|
||||
for (var name in obj) callback(name)
|
||||
} else {
|
||||
for (var o = obj; o; o = Object.getPrototypeOf(o))
|
||||
Object.getOwnPropertyNames(o).forEach(callback)
|
||||
}
|
||||
}
|
||||
|
||||
function getCompletions(token, context, keywords, options) {
|
||||
var found = [], start = token.string, global = options && options.globalScope || window;
|
||||
function maybeAdd(str) {
|
||||
if (str.lastIndexOf(start, 0) == 0 && !arrayContains(found, str)) found.push(str);
|
||||
}
|
||||
function gatherCompletions(obj) {
|
||||
if (typeof obj == "string") forEach(stringProps, maybeAdd);
|
||||
else if (obj instanceof Array) forEach(arrayProps, maybeAdd);
|
||||
else if (obj instanceof Function) forEach(funcProps, maybeAdd);
|
||||
forAllProps(obj, maybeAdd)
|
||||
}
|
||||
|
||||
if (context && context.length) {
|
||||
// If this is a property, see if it belongs to some object we can
|
||||
// find in the current environment.
|
||||
var obj = context.pop(), base;
|
||||
if (obj.type && obj.type.indexOf("variable") === 0) {
|
||||
if (options && options.additionalContext)
|
||||
base = options.additionalContext[obj.string];
|
||||
if (!options || options.useGlobalScope !== false)
|
||||
base = base || global[obj.string];
|
||||
} else if (obj.type == "string") {
|
||||
base = "";
|
||||
} else if (obj.type == "atom") {
|
||||
base = 1;
|
||||
} else if (obj.type == "function") {
|
||||
if (global.jQuery != null && (obj.string == '$' || obj.string == 'jQuery') &&
|
||||
(typeof global.jQuery == 'function'))
|
||||
base = global.jQuery();
|
||||
else if (global._ != null && (obj.string == '_') && (typeof global._ == 'function'))
|
||||
base = global._();
|
||||
}
|
||||
while (base != null && context.length)
|
||||
base = base[context.pop().string];
|
||||
if (base != null) gatherCompletions(base);
|
||||
} else {
|
||||
// If not, just look in the global object and any local scope
|
||||
// (reading into JS mode internals to get at the local and global variables)
|
||||
for (var v = token.state.localVars; v; v = v.next) maybeAdd(v.name);
|
||||
for (var v = token.state.globalVars; v; v = v.next) maybeAdd(v.name);
|
||||
if (!options || options.useGlobalScope !== false)
|
||||
gatherCompletions(global);
|
||||
forEach(keywords, maybeAdd);
|
||||
}
|
||||
return found;
|
||||
}
|
||||
});
|
2
codemirror/addon/hint/show-hint.css
vendored
2
codemirror/addon/hint/show-hint.css
vendored
|
@ -25,8 +25,6 @@
|
|||
margin: 0;
|
||||
padding: 0 4px;
|
||||
border-radius: 2px;
|
||||
max-width: 19em;
|
||||
overflow: hidden;
|
||||
white-space: pre;
|
||||
color: black;
|
||||
cursor: pointer;
|
||||
|
|
132
codemirror/addon/hint/show-hint.js
vendored
132
codemirror/addon/hint/show-hint.js
vendored
|
@ -25,8 +25,18 @@
|
|||
};
|
||||
|
||||
CodeMirror.defineExtension("showHint", function(options) {
|
||||
// We want a single cursor position.
|
||||
if (this.listSelections().length > 1 || this.somethingSelected()) return;
|
||||
options = parseOptions(this, this.getCursor("start"), options);
|
||||
var selections = this.listSelections()
|
||||
if (selections.length > 1) return;
|
||||
// By default, don't allow completion when something is selected.
|
||||
// A hint function can have a `supportsSelection` property to
|
||||
// indicate that it can handle selections.
|
||||
if (this.somethingSelected()) {
|
||||
if (!options.hint.supportsSelection) return;
|
||||
// Don't try with cross-line selections
|
||||
for (var i = 0; i < selections.length; i++)
|
||||
if (selections[i].head.line != selections[i].anchor.line) return;
|
||||
}
|
||||
|
||||
if (this.state.completionActive) this.state.completionActive.close();
|
||||
var completion = this.state.completionActive = new Completion(this, options);
|
||||
|
@ -38,12 +48,12 @@
|
|||
|
||||
function Completion(cm, options) {
|
||||
this.cm = cm;
|
||||
this.options = this.buildOptions(options);
|
||||
this.options = options;
|
||||
this.widget = null;
|
||||
this.debounce = 0;
|
||||
this.tick = 0;
|
||||
this.startPos = this.cm.getCursor();
|
||||
this.startLen = this.cm.getLine(this.startPos.line).length;
|
||||
this.startPos = this.cm.getCursor("start");
|
||||
this.startLen = this.cm.getLine(this.startPos.line).length - this.cm.getSelection().length;
|
||||
|
||||
var self = this;
|
||||
cm.on("cursorActivity", this.activityFunc = function() { self.cursorActivity(); });
|
||||
|
@ -98,24 +108,22 @@
|
|||
},
|
||||
|
||||
update: function(first) {
|
||||
if (this.tick == null) return;
|
||||
if (!this.options.hint.async) {
|
||||
this.finishUpdate(this.options.hint(this.cm, this.options), first);
|
||||
} else {
|
||||
var myTick = ++this.tick, self = this;
|
||||
this.options.hint(this.cm, function(data) {
|
||||
if (self.tick == myTick) self.finishUpdate(data, first);
|
||||
}, this.options);
|
||||
}
|
||||
if (this.tick == null) return
|
||||
var self = this, myTick = ++this.tick
|
||||
fetchHints(this.options.hint, this.cm, this.options, function(data) {
|
||||
if (self.tick == myTick) self.finishUpdate(data, first)
|
||||
})
|
||||
},
|
||||
|
||||
finishUpdate: function(data, first) {
|
||||
if (this.data) CodeMirror.signal(this.data, "update");
|
||||
if (data && this.data && CodeMirror.cmpPos(data.from, this.data.from)) data = null;
|
||||
this.data = data;
|
||||
|
||||
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) {
|
||||
if (picked && data.list.length == 1) {
|
||||
this.pick(data, 0);
|
||||
|
@ -124,20 +132,26 @@
|
|||
CodeMirror.signal(data, "shown");
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
buildOptions: function(options) {
|
||||
var editor = this.cm.options.hintOptions;
|
||||
var out = {};
|
||||
for (var prop in defaultOptions) out[prop] = defaultOptions[prop];
|
||||
if (editor) for (var prop in editor)
|
||||
if (editor[prop] !== undefined) out[prop] = editor[prop];
|
||||
if (options) for (var prop in options)
|
||||
if (options[prop] !== undefined) out[prop] = options[prop];
|
||||
return out;
|
||||
}
|
||||
};
|
||||
|
||||
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 = {};
|
||||
for (var prop in defaultOptions) out[prop] = defaultOptions[prop];
|
||||
if (editor) for (var prop in editor)
|
||||
if (editor[prop] !== undefined) out[prop] = editor[prop];
|
||||
if (options) for (var prop in options)
|
||||
if (options[prop] !== undefined) out[prop] = options[prop];
|
||||
if (out.hint.resolve) out.hint = out.hint.resolve(cm, pos)
|
||||
return out;
|
||||
}
|
||||
|
||||
function getText(completion) {
|
||||
if (typeof completion == "string") return completion;
|
||||
else return completion.text;
|
||||
|
@ -215,6 +229,9 @@
|
|||
var winH = window.innerHeight || Math.max(document.body.offsetHeight, document.documentElement.offsetHeight);
|
||||
(completion.options.container || document.body).appendChild(hints);
|
||||
var box = hints.getBoundingClientRect(), overlapY = box.bottom - winH;
|
||||
var scrolls = hints.scrollHeight > hints.clientHeight + 1
|
||||
var startScroll = cm.getScrollInfo();
|
||||
|
||||
if (overlapY > 0) {
|
||||
var height = box.bottom - box.top, curTop = pos.top - (pos.bottom - box.top);
|
||||
if (curTop - height > 0) { // Fits above cursor
|
||||
|
@ -239,6 +256,8 @@
|
|||
}
|
||||
hints.style.left = (left = pos.left - overlapX) + "px";
|
||||
}
|
||||
if (scrolls) for (var node = hints.firstChild; node; node = node.nextSibling)
|
||||
node.style.paddingRight = cm.display.nativeBarWidth + "px"
|
||||
|
||||
cm.addKeyMap(this.keyMap = buildKeyMap(completion, {
|
||||
moveFocus: function(n, avoidWrap) { widget.changeActive(widget.selectedHint + n, avoidWrap); },
|
||||
|
@ -256,7 +275,6 @@
|
|||
cm.on("focus", this.onFocus = function() { clearTimeout(closingOnBlur); });
|
||||
}
|
||||
|
||||
var startScroll = cm.getScrollInfo();
|
||||
cm.on("scroll", this.onScroll = function() {
|
||||
var curScroll = cm.getScrollInfo(), editor = cm.getWrapperElement().getBoundingClientRect();
|
||||
var newTop = top + startScroll.top - curScroll.top;
|
||||
|
@ -336,18 +354,52 @@
|
|||
}
|
||||
};
|
||||
|
||||
CodeMirror.registerHelper("hint", "auto", function(cm, options) {
|
||||
var helpers = cm.getHelpers(cm.getCursor(), "hint"), words;
|
||||
if (helpers.length) {
|
||||
for (var i = 0; i < helpers.length; i++) {
|
||||
var cur = helpers[i](cm, options);
|
||||
if (cur && cur.list.length) return cur;
|
||||
}
|
||||
} else if (words = cm.getHelper(cm.getCursor(), "hintWords")) {
|
||||
if (words) return CodeMirror.hint.fromList(cm, {words: words});
|
||||
} else if (CodeMirror.hint.anyword) {
|
||||
return CodeMirror.hint.anyword(cm, options);
|
||||
function applicableHelpers(cm, helpers) {
|
||||
if (!cm.somethingSelected()) return helpers
|
||||
var result = []
|
||||
for (var i = 0; i < helpers.length; i++)
|
||||
if (helpers[i].supportsSelection) result.push(helpers[i])
|
||||
return result
|
||||
}
|
||||
|
||||
function fetchHints(hint, cm, options, callback) {
|
||||
if (hint.async) {
|
||||
hint(cm, callback, options)
|
||||
} else {
|
||||
var result = hint(cm, options)
|
||||
if (result && result.then) result.then(callback)
|
||||
else callback(result)
|
||||
}
|
||||
}
|
||||
|
||||
function resolveAutoHints(cm, pos) {
|
||||
var helpers = cm.getHelpers(pos, "hint"), words
|
||||
if (helpers.length) {
|
||||
var resolved = function(cm, callback, options) {
|
||||
var app = applicableHelpers(cm, helpers);
|
||||
function run(i) {
|
||||
if (i == app.length) return callback(null)
|
||||
fetchHints(app[i], cm, options, function(result) {
|
||||
if (result && result.list.length > 0) callback(result)
|
||||
else run(i + 1)
|
||||
})
|
||||
}
|
||||
run(0)
|
||||
}
|
||||
resolved.async = true
|
||||
resolved.supportsSelection = true
|
||||
return resolved
|
||||
} else if (words = cm.getHelper(cm.getCursor(), "hintWords")) {
|
||||
return function(cm) { return CodeMirror.hint.fromList(cm, {words: words}) }
|
||||
} else if (CodeMirror.hint.anyword) {
|
||||
return function(cm, options) { return CodeMirror.hint.anyword(cm, options) }
|
||||
} else {
|
||||
return function() {}
|
||||
}
|
||||
}
|
||||
|
||||
CodeMirror.registerHelper("hint", "auto", {
|
||||
resolve: resolveAutoHints
|
||||
});
|
||||
|
||||
CodeMirror.registerHelper("hint", "fromList", function(cm, options) {
|
||||
|
@ -376,7 +428,7 @@
|
|||
alignWithWord: true,
|
||||
closeCharacters: /[\s()\[\]{};:>,]/,
|
||||
closeOnUnfocus: true,
|
||||
completeOnSingleClick: false,
|
||||
completeOnSingleClick: true,
|
||||
container: null,
|
||||
customKeys: null,
|
||||
extraKeys: null
|
||||
|
|
271
codemirror/addon/hint/sql-hint.js
vendored
Normal file
271
codemirror/addon/hint/sql-hint.js
vendored
Normal file
|
@ -0,0 +1,271 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"), require("../../mode/sql/sql"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror", "../../mode/sql/sql"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
var tables;
|
||||
var defaultTable;
|
||||
var keywords;
|
||||
var CONS = {
|
||||
QUERY_DIV: ";",
|
||||
ALIAS_KEYWORD: "AS"
|
||||
};
|
||||
var Pos = CodeMirror.Pos, cmpPos = CodeMirror.cmpPos;
|
||||
|
||||
function isArray(val) { return Object.prototype.toString.call(val) == "[object Array]" }
|
||||
|
||||
function getKeywords(editor) {
|
||||
var mode = editor.doc.modeOption;
|
||||
if (mode === "sql") mode = "text/x-sql";
|
||||
return CodeMirror.resolveMode(mode).keywords;
|
||||
}
|
||||
|
||||
function getText(item) {
|
||||
return typeof item == "string" ? item : item.text;
|
||||
}
|
||||
|
||||
function wrapTable(name, value) {
|
||||
if (isArray(value)) value = {columns: value}
|
||||
if (!value.text) value.text = name
|
||||
return value
|
||||
}
|
||||
|
||||
function parseTables(input) {
|
||||
var result = {}
|
||||
if (isArray(input)) {
|
||||
for (var i = input.length - 1; i >= 0; i--) {
|
||||
var item = input[i]
|
||||
result[getText(item).toUpperCase()] = wrapTable(getText(item), item)
|
||||
}
|
||||
} else if (input) {
|
||||
for (var name in input)
|
||||
result[name.toUpperCase()] = wrapTable(name, input[name])
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
function getTable(name) {
|
||||
return tables[name.toUpperCase()]
|
||||
}
|
||||
|
||||
function shallowClone(object) {
|
||||
var result = {};
|
||||
for (var key in object) if (object.hasOwnProperty(key))
|
||||
result[key] = object[key];
|
||||
return result;
|
||||
}
|
||||
|
||||
function match(string, word) {
|
||||
var len = string.length;
|
||||
var sub = getText(word).substr(0, len);
|
||||
return string.toUpperCase() === sub.toUpperCase();
|
||||
}
|
||||
|
||||
function addMatches(result, search, wordlist, formatter) {
|
||||
if (isArray(wordlist)) {
|
||||
for (var i = 0; i < wordlist.length; i++)
|
||||
if (match(search, wordlist[i])) result.push(formatter(wordlist[i]))
|
||||
} else {
|
||||
for (var word in wordlist) if (wordlist.hasOwnProperty(word)) {
|
||||
var val = wordlist[word]
|
||||
if (!val || val === true)
|
||||
val = word
|
||||
else
|
||||
val = val.displayText ? {text: val.text, displayText: val.displayText} : val.text
|
||||
if (match(search, val)) result.push(formatter(val))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function cleanName(name) {
|
||||
// Get rid name from backticks(`) and preceding dot(.)
|
||||
if (name.charAt(0) == ".") {
|
||||
name = name.substr(1);
|
||||
}
|
||||
return name.replace(/`/g, "");
|
||||
}
|
||||
|
||||
function insertBackticks(name) {
|
||||
var nameParts = getText(name).split(".");
|
||||
for (var i = 0; i < nameParts.length; i++)
|
||||
nameParts[i] = "`" + nameParts[i] + "`";
|
||||
var escaped = nameParts.join(".");
|
||||
if (typeof name == "string") return escaped;
|
||||
name = shallowClone(name);
|
||||
name.text = escaped;
|
||||
return name;
|
||||
}
|
||||
|
||||
function nameCompletion(cur, token, result, editor) {
|
||||
// Try to complete table, column names and return start position of completion
|
||||
var useBacktick = false;
|
||||
var nameParts = [];
|
||||
var start = token.start;
|
||||
var cont = true;
|
||||
while (cont) {
|
||||
cont = (token.string.charAt(0) == ".");
|
||||
useBacktick = useBacktick || (token.string.charAt(0) == "`");
|
||||
|
||||
start = token.start;
|
||||
nameParts.unshift(cleanName(token.string));
|
||||
|
||||
token = editor.getTokenAt(Pos(cur.line, token.start));
|
||||
if (token.string == ".") {
|
||||
cont = true;
|
||||
token = editor.getTokenAt(Pos(cur.line, token.start));
|
||||
}
|
||||
}
|
||||
|
||||
// Try to complete table names
|
||||
var string = nameParts.join(".");
|
||||
addMatches(result, string, tables, function(w) {
|
||||
return useBacktick ? insertBackticks(w) : w;
|
||||
});
|
||||
|
||||
// Try to complete columns from defaultTable
|
||||
addMatches(result, string, defaultTable, function(w) {
|
||||
return useBacktick ? insertBackticks(w) : w;
|
||||
});
|
||||
|
||||
// Try to complete columns
|
||||
string = nameParts.pop();
|
||||
var table = nameParts.join(".");
|
||||
|
||||
var alias = false;
|
||||
var aliasTable = table;
|
||||
// Check if table is available. If not, find table by Alias
|
||||
if (!getTable(table)) {
|
||||
var oldTable = table;
|
||||
table = findTableByAlias(table, editor);
|
||||
if (table !== oldTable) alias = true;
|
||||
}
|
||||
|
||||
var columns = getTable(table);
|
||||
if (columns && columns.columns)
|
||||
columns = columns.columns;
|
||||
|
||||
if (columns) {
|
||||
addMatches(result, string, columns, function(w) {
|
||||
var tableInsert = table;
|
||||
if (alias == true) tableInsert = aliasTable;
|
||||
if (typeof w == "string") {
|
||||
w = tableInsert + "." + w;
|
||||
} else {
|
||||
w = shallowClone(w);
|
||||
w.text = tableInsert + "." + w.text;
|
||||
}
|
||||
return useBacktick ? insertBackticks(w) : w;
|
||||
});
|
||||
}
|
||||
|
||||
return start;
|
||||
}
|
||||
|
||||
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, '') : '');
|
||||
}
|
||||
}
|
||||
|
||||
function findTableByAlias(alias, editor) {
|
||||
var doc = editor.doc;
|
||||
var fullQuery = doc.getValue();
|
||||
var aliasUpperCase = alias.toUpperCase();
|
||||
var previousWord = "";
|
||||
var table = "";
|
||||
var separator = [];
|
||||
var validRange = {
|
||||
start: Pos(0, 0),
|
||||
end: Pos(editor.lastLine(), editor.getLineHandle(editor.lastLine()).length)
|
||||
};
|
||||
|
||||
//add separator
|
||||
var indexOfSeparator = fullQuery.indexOf(CONS.QUERY_DIV);
|
||||
while(indexOfSeparator != -1) {
|
||||
separator.push(doc.posFromIndex(indexOfSeparator));
|
||||
indexOfSeparator = fullQuery.indexOf(CONS.QUERY_DIV, indexOfSeparator+1);
|
||||
}
|
||||
separator.unshift(Pos(0, 0));
|
||||
separator.push(Pos(editor.lastLine(), editor.getLineHandle(editor.lastLine()).text.length));
|
||||
|
||||
//find valid range
|
||||
var prevItem = null;
|
||||
var current = editor.getCursor()
|
||||
for (var i = 0; i < separator.length; i++) {
|
||||
if ((prevItem == null || cmpPos(current, prevItem) > 0) && cmpPos(current, separator[i]) <= 0) {
|
||||
validRange = {start: prevItem, end: separator[i]};
|
||||
break;
|
||||
}
|
||||
prevItem = separator[i];
|
||||
}
|
||||
|
||||
var query = doc.getRange(validRange.start, validRange.end, false);
|
||||
|
||||
for (var i = 0; i < query.length; i++) {
|
||||
var lineText = query[i];
|
||||
eachWord(lineText, function(word) {
|
||||
var wordUpperCase = word.toUpperCase();
|
||||
if (wordUpperCase === aliasUpperCase && getTable(previousWord))
|
||||
table = previousWord;
|
||||
if (wordUpperCase !== CONS.ALIAS_KEYWORD)
|
||||
previousWord = word;
|
||||
});
|
||||
if (table) break;
|
||||
}
|
||||
return table;
|
||||
}
|
||||
|
||||
CodeMirror.registerHelper("hint", "sql", function(editor, options) {
|
||||
tables = parseTables(options && options.tables)
|
||||
var defaultTableName = options && options.defaultTable;
|
||||
var disableKeywords = options && options.disableKeywords;
|
||||
defaultTable = defaultTableName && getTable(defaultTableName);
|
||||
keywords = getKeywords(editor);
|
||||
|
||||
if (defaultTableName && !defaultTable)
|
||||
defaultTable = findTableByAlias(defaultTableName, editor);
|
||||
|
||||
defaultTable = defaultTable || [];
|
||||
|
||||
if (defaultTable.columns)
|
||||
defaultTable = defaultTable.columns;
|
||||
|
||||
var cur = editor.getCursor();
|
||||
var result = [];
|
||||
var token = editor.getTokenAt(cur), start, end, search;
|
||||
if (token.end > cur.ch) {
|
||||
token.end = cur.ch;
|
||||
token.string = token.string.slice(0, cur.ch - token.start);
|
||||
}
|
||||
|
||||
if (token.string.match(/^[.`\w@]\w*$/)) {
|
||||
search = token.string;
|
||||
start = token.start;
|
||||
end = token.end;
|
||||
} else {
|
||||
start = end = cur.ch;
|
||||
search = "";
|
||||
}
|
||||
if (search.charAt(0) == "." || search.charAt(0) == "`") {
|
||||
start = nameCompletion(cur, token, result, editor);
|
||||
} else {
|
||||
addMatches(result, search, tables, function(w) {return w;});
|
||||
addMatches(result, search, defaultTable, function(w) {return w;});
|
||||
if (!disableKeywords)
|
||||
addMatches(result, search, keywords, function(w) {return w.toUpperCase();});
|
||||
}
|
||||
|
||||
return {list: result, from: Pos(cur.line, start), to: Pos(cur.line, end)};
|
||||
});
|
||||
});
|
110
codemirror/addon/hint/xml-hint.js
vendored
Normal file
110
codemirror/addon/hint/xml-hint.js
vendored
Normal file
|
@ -0,0 +1,110 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
var Pos = CodeMirror.Pos;
|
||||
|
||||
function getHints(cm, options) {
|
||||
var tags = options && options.schemaInfo;
|
||||
var quote = (options && options.quoteChar) || '"';
|
||||
if (!tags) return;
|
||||
var cur = cm.getCursor(), token = cm.getTokenAt(cur);
|
||||
if (token.end > cur.ch) {
|
||||
token.end = cur.ch;
|
||||
token.string = token.string.slice(0, cur.ch - token.start);
|
||||
}
|
||||
var inner = CodeMirror.innerMode(cm.getMode(), token.state);
|
||||
if (inner.mode.name != "xml") return;
|
||||
var result = [], replaceToken = false, prefix;
|
||||
var tag = /\btag\b/.test(token.type) && !/>$/.test(token.string);
|
||||
var tagName = tag && /^\w/.test(token.string), tagStart;
|
||||
|
||||
if (tagName) {
|
||||
var before = cm.getLine(cur.line).slice(Math.max(0, token.start - 2), token.start);
|
||||
var tagType = /<\/$/.test(before) ? "close" : /<$/.test(before) ? "open" : null;
|
||||
if (tagType) tagStart = token.start - (tagType == "close" ? 2 : 1);
|
||||
} else if (tag && token.string == "<") {
|
||||
tagType = "open";
|
||||
} else if (tag && token.string == "</") {
|
||||
tagType = "close";
|
||||
}
|
||||
|
||||
if (!tag && !inner.state.tagName || tagType) {
|
||||
if (tagName)
|
||||
prefix = token.string;
|
||||
replaceToken = tagType;
|
||||
var cx = inner.state.context, curTag = cx && tags[cx.tagName];
|
||||
var childList = cx ? curTag && curTag.children : tags["!top"];
|
||||
if (childList && tagType != "close") {
|
||||
for (var i = 0; i < childList.length; ++i) if (!prefix || childList[i].lastIndexOf(prefix, 0) == 0)
|
||||
result.push("<" + childList[i]);
|
||||
} else if (tagType != "close") {
|
||||
for (var name in tags)
|
||||
if (tags.hasOwnProperty(name) && name != "!top" && name != "!attrs" && (!prefix || name.lastIndexOf(prefix, 0) == 0))
|
||||
result.push("<" + name);
|
||||
}
|
||||
if (cx && (!prefix || tagType == "close" && cx.tagName.lastIndexOf(prefix, 0) == 0))
|
||||
result.push("</" + cx.tagName + ">");
|
||||
} else {
|
||||
// Attribute completion
|
||||
var curTag = tags[inner.state.tagName], attrs = curTag && curTag.attrs;
|
||||
var globalAttrs = tags["!attrs"];
|
||||
if (!attrs && !globalAttrs) return;
|
||||
if (!attrs) {
|
||||
attrs = globalAttrs;
|
||||
} else if (globalAttrs) { // Combine tag-local and global attributes
|
||||
var set = {};
|
||||
for (var nm in globalAttrs) if (globalAttrs.hasOwnProperty(nm)) set[nm] = globalAttrs[nm];
|
||||
for (var nm in attrs) if (attrs.hasOwnProperty(nm)) set[nm] = attrs[nm];
|
||||
attrs = set;
|
||||
}
|
||||
if (token.type == "string" || token.string == "=") { // A value
|
||||
var before = cm.getRange(Pos(cur.line, Math.max(0, cur.ch - 60)),
|
||||
Pos(cur.line, token.type == "string" ? token.start : token.end));
|
||||
var atName = before.match(/([^\s\u00a0=<>\"\']+)=$/), atValues;
|
||||
if (!atName || !attrs.hasOwnProperty(atName[1]) || !(atValues = attrs[atName[1]])) return;
|
||||
if (typeof atValues == 'function') atValues = atValues.call(this, cm); // Functions can be used to supply values for autocomplete widget
|
||||
if (token.type == "string") {
|
||||
prefix = token.string;
|
||||
var n = 0;
|
||||
if (/['"]/.test(token.string.charAt(0))) {
|
||||
quote = token.string.charAt(0);
|
||||
prefix = token.string.slice(1);
|
||||
n++;
|
||||
}
|
||||
var len = token.string.length;
|
||||
if (/['"]/.test(token.string.charAt(len - 1))) {
|
||||
quote = token.string.charAt(len - 1);
|
||||
prefix = token.string.substr(n, len - 2);
|
||||
}
|
||||
replaceToken = true;
|
||||
}
|
||||
for (var i = 0; i < atValues.length; ++i) if (!prefix || atValues[i].lastIndexOf(prefix, 0) == 0)
|
||||
result.push(quote + atValues[i] + quote);
|
||||
} else { // An attribute name
|
||||
if (token.type == "attribute") {
|
||||
prefix = token.string;
|
||||
replaceToken = true;
|
||||
}
|
||||
for (var attr in attrs) if (attrs.hasOwnProperty(attr) && (!prefix || attr.lastIndexOf(prefix, 0) == 0))
|
||||
result.push(attr);
|
||||
}
|
||||
}
|
||||
return {
|
||||
list: result,
|
||||
from: replaceToken ? Pos(cur.line, tagStart == null ? token.start : tagStart) : cur,
|
||||
to: replaceToken ? Pos(cur.line, token.end) : cur
|
||||
};
|
||||
}
|
||||
|
||||
CodeMirror.registerHelper("hint", "xml", getHints);
|
||||
});
|
41
codemirror/addon/lint/coffeescript-lint.js
vendored
Normal file
41
codemirror/addon/lint/coffeescript-lint.js
vendored
Normal file
|
@ -0,0 +1,41 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
// Depends on coffeelint.js from http://www.coffeelint.org/js/coffeelint.js
|
||||
|
||||
// declare global: coffeelint
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
CodeMirror.registerHelper("lint", "coffeescript", function(text) {
|
||||
var found = [];
|
||||
var parseError = function(err) {
|
||||
var loc = err.lineNumber;
|
||||
found.push({from: CodeMirror.Pos(loc-1, 0),
|
||||
to: CodeMirror.Pos(loc, 0),
|
||||
severity: err.level,
|
||||
message: err.message});
|
||||
};
|
||||
try {
|
||||
var res = coffeelint.lint(text);
|
||||
for(var i = 0; i < res.length; i++) {
|
||||
parseError(res[i]);
|
||||
}
|
||||
} catch(e) {
|
||||
found.push({from: CodeMirror.Pos(e.location.first_line, 0),
|
||||
to: CodeMirror.Pos(e.location.last_line, e.location.last_column),
|
||||
severity: 'error',
|
||||
message: e.message});
|
||||
}
|
||||
return found;
|
||||
});
|
||||
|
||||
});
|
12
codemirror/addon/lint/css-lint.js
vendored
12
codemirror/addon/lint/css-lint.js
vendored
|
@ -18,18 +18,6 @@
|
|||
CodeMirror.registerHelper("lint", "css", function(text) {
|
||||
var found = [];
|
||||
if (!window.CSSLint) return found;
|
||||
|
||||
// STYLISH: hack start
|
||||
var rules = CSSLint.getRules();
|
||||
var allowedRules = ["display-property-grouping", "duplicate-properties", "empty-rules", "errors", "known-properties"];
|
||||
CSSLint.clearRules();
|
||||
rules.forEach(function(rule) {
|
||||
if (allowedRules.indexOf(rule.id) >= 0) {
|
||||
CSSLint.addRule(rule);
|
||||
}
|
||||
});
|
||||
// STYLISH: hack end
|
||||
|
||||
var results = CSSLint.verify(text), messages = results.messages, message = null;
|
||||
for ( var i = 0; i < messages.length; i++) {
|
||||
message = messages[i];
|
||||
|
|
46
codemirror/addon/lint/html-lint.js
vendored
Normal file
46
codemirror/addon/lint/html-lint.js
vendored
Normal file
|
@ -0,0 +1,46 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
// Depends on htmlhint.js from http://htmlhint.com/js/htmlhint.js
|
||||
|
||||
// declare global: HTMLHint
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"), require("htmlhint"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror", "htmlhint"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
var defaultRules = {
|
||||
"tagname-lowercase": true,
|
||||
"attr-lowercase": true,
|
||||
"attr-value-double-quotes": true,
|
||||
"doctype-first": false,
|
||||
"tag-pair": true,
|
||||
"spec-char-escape": true,
|
||||
"id-unique": true,
|
||||
"src-not-empty": true,
|
||||
"attr-no-duplication": true
|
||||
};
|
||||
|
||||
CodeMirror.registerHelper("lint", "html", function(text, options) {
|
||||
var found = [];
|
||||
if (!window.HTMLHint) return found;
|
||||
var messages = HTMLHint.verify(text, options && options.rules || defaultRules);
|
||||
for (var i = 0; i < messages.length; i++) {
|
||||
var message = messages[i];
|
||||
var startLine = message.line - 1, endLine = message.line - 1, startCol = message.col - 1, endCol = message.col;
|
||||
found.push({
|
||||
from: CodeMirror.Pos(startLine, startCol),
|
||||
to: CodeMirror.Pos(endLine, endCol),
|
||||
message: message.message,
|
||||
severity : message.type
|
||||
});
|
||||
}
|
||||
return found;
|
||||
});
|
||||
});
|
136
codemirror/addon/lint/javascript-lint.js
vendored
Normal file
136
codemirror/addon/lint/javascript-lint.js
vendored
Normal file
|
@ -0,0 +1,136 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
// declare global: JSHINT
|
||||
|
||||
var bogus = [ "Dangerous comment" ];
|
||||
|
||||
var warnings = [ [ "Expected '{'",
|
||||
"Statement body should be inside '{ }' braces." ] ];
|
||||
|
||||
var errors = [ "Missing semicolon", "Extra comma", "Missing property name",
|
||||
"Unmatched ", " and instead saw", " is not defined",
|
||||
"Unclosed string", "Stopping, unable to continue" ];
|
||||
|
||||
function validator(text, options) {
|
||||
if (!window.JSHINT) return [];
|
||||
JSHINT(text, options, options.globals);
|
||||
var errors = JSHINT.data().errors, result = [];
|
||||
if (errors) parseErrors(errors, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
CodeMirror.registerHelper("lint", "javascript", validator);
|
||||
|
||||
function cleanup(error) {
|
||||
// All problems are warnings by default
|
||||
fixWith(error, warnings, "warning", true);
|
||||
fixWith(error, errors, "error");
|
||||
|
||||
return isBogus(error) ? null : error;
|
||||
}
|
||||
|
||||
function fixWith(error, fixes, severity, force) {
|
||||
var description, fix, find, replace, found;
|
||||
|
||||
description = error.description;
|
||||
|
||||
for ( var i = 0; i < fixes.length; i++) {
|
||||
fix = fixes[i];
|
||||
find = (typeof fix === "string" ? fix : fix[0]);
|
||||
replace = (typeof fix === "string" ? null : fix[1]);
|
||||
found = description.indexOf(find) !== -1;
|
||||
|
||||
if (force || found) {
|
||||
error.severity = severity;
|
||||
}
|
||||
if (found && replace) {
|
||||
error.description = replace;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function isBogus(error) {
|
||||
var description = error.description;
|
||||
for ( var i = 0; i < bogus.length; i++) {
|
||||
if (description.indexOf(bogus[i]) !== -1) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function parseErrors(errors, output) {
|
||||
for ( var i = 0; i < errors.length; i++) {
|
||||
var error = errors[i];
|
||||
if (error) {
|
||||
var linetabpositions, index;
|
||||
|
||||
linetabpositions = [];
|
||||
|
||||
// This next block is to fix a problem in jshint. Jshint
|
||||
// replaces
|
||||
// all tabs with spaces then performs some checks. The error
|
||||
// positions (character/space) are then reported incorrectly,
|
||||
// not taking the replacement step into account. Here we look
|
||||
// at the evidence line and try to adjust the character position
|
||||
// to the correct value.
|
||||
if (error.evidence) {
|
||||
// Tab positions are computed once per line and cached
|
||||
var tabpositions = linetabpositions[error.line];
|
||||
if (!tabpositions) {
|
||||
var evidence = error.evidence;
|
||||
tabpositions = [];
|
||||
// ugggh phantomjs does not like this
|
||||
// forEachChar(evidence, function(item, index) {
|
||||
Array.prototype.forEach.call(evidence, function(item,
|
||||
index) {
|
||||
if (item === '\t') {
|
||||
// First col is 1 (not 0) to match error
|
||||
// positions
|
||||
tabpositions.push(index + 1);
|
||||
}
|
||||
});
|
||||
linetabpositions[error.line] = tabpositions;
|
||||
}
|
||||
if (tabpositions.length > 0) {
|
||||
var pos = error.character;
|
||||
tabpositions.forEach(function(tabposition) {
|
||||
if (pos > tabposition) pos -= 1;
|
||||
});
|
||||
error.character = pos;
|
||||
}
|
||||
}
|
||||
|
||||
var start = error.character - 1, end = start + 1;
|
||||
if (error.evidence) {
|
||||
index = error.evidence.substring(start).search(/.\b/);
|
||||
if (index > -1) {
|
||||
end += index;
|
||||
}
|
||||
}
|
||||
|
||||
// Convert to format expected by validation service
|
||||
error.description = error.reason;// + "(jshint)";
|
||||
error.start = error.character;
|
||||
error.end = end;
|
||||
error = cleanup(error);
|
||||
|
||||
if (error)
|
||||
output.push({message: error.description,
|
||||
severity: error.severity,
|
||||
from: CodeMirror.Pos(error.line - 1, start),
|
||||
to: CodeMirror.Pos(error.line - 1, end)});
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
31
codemirror/addon/lint/json-lint.js
vendored
Normal file
31
codemirror/addon/lint/json-lint.js
vendored
Normal file
|
@ -0,0 +1,31 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
// Depends on jsonlint.js from https://github.com/zaach/jsonlint
|
||||
|
||||
// declare global: jsonlint
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
CodeMirror.registerHelper("lint", "json", function(text) {
|
||||
var found = [];
|
||||
jsonlint.parseError = function(str, hash) {
|
||||
var loc = hash.loc;
|
||||
found.push({from: CodeMirror.Pos(loc.first_line - 1, loc.first_column),
|
||||
to: CodeMirror.Pos(loc.last_line - 1, loc.last_column),
|
||||
message: str});
|
||||
};
|
||||
try { jsonlint.parse(text); }
|
||||
catch(e) {}
|
||||
return found;
|
||||
});
|
||||
|
||||
});
|
4
codemirror/addon/lint/lint.css
vendored
4
codemirror/addon/lint/lint.css
vendored
|
@ -4,10 +4,10 @@
|
|||
}
|
||||
|
||||
.CodeMirror-lint-tooltip {
|
||||
background-color: infobackground;
|
||||
background-color: #ffd;
|
||||
border: 1px solid black;
|
||||
border-radius: 4px 4px 4px 4px;
|
||||
color: infotext;
|
||||
color: black;
|
||||
font-family: monospace;
|
||||
font-size: 10pt;
|
||||
overflow: hidden;
|
||||
|
|
46
codemirror/addon/lint/lint.js
vendored
46
codemirror/addon/lint/lint.js
vendored
|
@ -61,6 +61,7 @@
|
|||
this.timeout = null;
|
||||
this.hasGutter = hasGutter;
|
||||
this.onMouseOver = function(e) { onMouseOver(cm, e); };
|
||||
this.waitingFor = 0
|
||||
}
|
||||
|
||||
function parseOptions(_cm, options) {
|
||||
|
@ -115,15 +116,32 @@
|
|||
return tip;
|
||||
}
|
||||
|
||||
function lintAsync(cm, getAnnotations, passOptions) {
|
||||
var state = cm.state.lint
|
||||
var id = ++state.waitingFor
|
||||
function abort() {
|
||||
id = -1
|
||||
cm.off("change", abort)
|
||||
}
|
||||
cm.on("change", abort)
|
||||
getAnnotations(cm.getValue(), function(annotations, arg2) {
|
||||
cm.off("change", abort)
|
||||
if (state.waitingFor != id) return
|
||||
if (arg2 && annotations instanceof CodeMirror) annotations = arg2
|
||||
updateLinting(cm, annotations)
|
||||
}, passOptions, cm);
|
||||
}
|
||||
|
||||
function startLinting(cm) {
|
||||
var state = cm.state.lint, options = state.options;
|
||||
var passOptions = options.options || options; // Support deprecated passing of `options` property in options
|
||||
var getAnnotations = options.getAnnotations || cm.getHelper(CodeMirror.Pos(0, 0), "lint");
|
||||
if (!getAnnotations) return;
|
||||
if (options.async || getAnnotations.async)
|
||||
getAnnotations(cm.getValue(), updateLinting, passOptions, cm);
|
||||
else
|
||||
if (options.async || getAnnotations.async) {
|
||||
lintAsync(cm, getAnnotations, passOptions)
|
||||
} else {
|
||||
updateLinting(cm, getAnnotations(cm.getValue(), passOptions, cm));
|
||||
}
|
||||
}
|
||||
|
||||
function updateLinting(cm, annotationsNotSorted) {
|
||||
|
@ -168,9 +186,14 @@
|
|||
state.timeout = setTimeout(function(){startLinting(cm);}, state.options.delay || 500);
|
||||
}
|
||||
|
||||
function popupSpanTooltip(ann, e) {
|
||||
function popupTooltips(annotations, e) {
|
||||
var target = e.target || e.srcElement;
|
||||
showTooltipFor(e, annotationTooltip(ann), target);
|
||||
var tooltip = document.createDocumentFragment();
|
||||
for (var i = 0; i < annotations.length; i++) {
|
||||
var ann = annotations[i];
|
||||
tooltip.appendChild(annotationTooltip(ann));
|
||||
}
|
||||
showTooltipFor(e, tooltip, target);
|
||||
}
|
||||
|
||||
function onMouseOver(cm, e) {
|
||||
|
@ -178,16 +201,19 @@
|
|||
if (!/\bCodeMirror-lint-mark-/.test(target.className)) return;
|
||||
var box = target.getBoundingClientRect(), x = (box.left + box.right) / 2, y = (box.top + box.bottom) / 2;
|
||||
var spans = cm.findMarksAt(cm.coordsChar({left: x, top: y}, "client"));
|
||||
|
||||
var annotations = [];
|
||||
for (var i = 0; i < spans.length; ++i) {
|
||||
var ann = spans[i].__annotation;
|
||||
if (ann) return popupSpanTooltip(ann, e);
|
||||
if (ann) annotations.push(ann);
|
||||
}
|
||||
if (annotations.length) popupTooltips(annotations, e);
|
||||
}
|
||||
|
||||
CodeMirror.defineOption("lint", false, function(cm, val, old) {
|
||||
if (old && old != CodeMirror.Init) {
|
||||
clearMarks(cm);
|
||||
if (!state.options.lintOnChange !== false)
|
||||
if (cm.state.lint.options.lintOnChange !== false)
|
||||
cm.off("change", onChange);
|
||||
CodeMirror.off(cm.getWrapperElement(), "mouseover", cm.state.lint.onMouseOver);
|
||||
clearTimeout(cm.state.lint.timeout);
|
||||
|
@ -198,12 +224,12 @@
|
|||
var gutters = cm.getOption("gutters"), hasLintGutter = false;
|
||||
for (var i = 0; i < gutters.length; ++i) if (gutters[i] == GUTTER_ID) hasLintGutter = true;
|
||||
var state = cm.state.lint = new LintState(cm, parseOptions(cm, val), hasLintGutter);
|
||||
if (!state.options.lintOnChange !== false)
|
||||
if (state.options.lintOnChange !== false)
|
||||
cm.on("change", onChange);
|
||||
if (state.options.tooltips != false)
|
||||
if (state.options.tooltips != false && state.options.tooltips != "gutter")
|
||||
CodeMirror.on(cm.getWrapperElement(), "mouseover", state.onMouseOver);
|
||||
|
||||
state.timeout = setTimeout(function(){startLinting(cm);}, state.options.delay || 500);
|
||||
startLinting(cm);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
28
codemirror/addon/lint/yaml-lint.js
vendored
Normal file
28
codemirror/addon/lint/yaml-lint.js
vendored
Normal file
|
@ -0,0 +1,28 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
// Depends on js-yaml.js from https://github.com/nodeca/js-yaml
|
||||
|
||||
// declare global: jsyaml
|
||||
|
||||
CodeMirror.registerHelper("lint", "yaml", function(text) {
|
||||
var 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 });
|
||||
}
|
||||
return found;
|
||||
});
|
||||
|
||||
});
|
113
codemirror/addon/merge/merge.css
vendored
Normal file
113
codemirror/addon/merge/merge.css
vendored
Normal file
|
@ -0,0 +1,113 @@
|
|||
.CodeMirror-merge {
|
||||
position: relative;
|
||||
border: 1px solid #ddd;
|
||||
white-space: pre;
|
||||
}
|
||||
|
||||
.CodeMirror-merge, .CodeMirror-merge .CodeMirror {
|
||||
height: 350px;
|
||||
}
|
||||
|
||||
.CodeMirror-merge-2pane .CodeMirror-merge-pane { width: 47%; }
|
||||
.CodeMirror-merge-2pane .CodeMirror-merge-gap { width: 6%; }
|
||||
.CodeMirror-merge-3pane .CodeMirror-merge-pane { width: 31%; }
|
||||
.CodeMirror-merge-3pane .CodeMirror-merge-gap { width: 3.5%; }
|
||||
|
||||
.CodeMirror-merge-pane {
|
||||
display: inline-block;
|
||||
white-space: normal;
|
||||
vertical-align: top;
|
||||
}
|
||||
.CodeMirror-merge-pane-rightmost {
|
||||
position: absolute;
|
||||
right: 0px;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.CodeMirror-merge-gap {
|
||||
z-index: 2;
|
||||
display: inline-block;
|
||||
height: 100%;
|
||||
-moz-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
overflow: hidden;
|
||||
border-left: 1px solid #ddd;
|
||||
border-right: 1px solid #ddd;
|
||||
position: relative;
|
||||
background: #f8f8f8;
|
||||
}
|
||||
|
||||
.CodeMirror-merge-scrolllock-wrap {
|
||||
position: absolute;
|
||||
bottom: 0; left: 50%;
|
||||
}
|
||||
.CodeMirror-merge-scrolllock {
|
||||
position: relative;
|
||||
left: -50%;
|
||||
cursor: pointer;
|
||||
color: #555;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.CodeMirror-merge-copybuttons-left, .CodeMirror-merge-copybuttons-right {
|
||||
position: absolute;
|
||||
left: 0; top: 0;
|
||||
right: 0; bottom: 0;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.CodeMirror-merge-copy {
|
||||
position: absolute;
|
||||
cursor: pointer;
|
||||
color: #44c;
|
||||
z-index: 3;
|
||||
}
|
||||
|
||||
.CodeMirror-merge-copy-reverse {
|
||||
position: absolute;
|
||||
cursor: pointer;
|
||||
color: #44c;
|
||||
}
|
||||
|
||||
.CodeMirror-merge-copybuttons-left .CodeMirror-merge-copy { left: 2px; }
|
||||
.CodeMirror-merge-copybuttons-right .CodeMirror-merge-copy { right: 2px; }
|
||||
|
||||
.CodeMirror-merge-r-inserted, .CodeMirror-merge-l-inserted {
|
||||
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAACCAYAAACddGYaAAAAGUlEQVQI12MwuCXy3+CWyH8GBgYGJgYkAABZbAQ9ELXurwAAAABJRU5ErkJggg==);
|
||||
background-position: bottom left;
|
||||
background-repeat: repeat-x;
|
||||
}
|
||||
|
||||
.CodeMirror-merge-r-deleted, .CodeMirror-merge-l-deleted {
|
||||
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAACCAYAAACddGYaAAAAGUlEQVQI12M4Kyb2/6yY2H8GBgYGJgYkAABURgPz6Ks7wQAAAABJRU5ErkJggg==);
|
||||
background-position: bottom left;
|
||||
background-repeat: repeat-x;
|
||||
}
|
||||
|
||||
.CodeMirror-merge-r-chunk { background: #ffffe0; }
|
||||
.CodeMirror-merge-r-chunk-start { border-top: 1px solid #ee8; }
|
||||
.CodeMirror-merge-r-chunk-end { border-bottom: 1px solid #ee8; }
|
||||
.CodeMirror-merge-r-connect { fill: #ffffe0; stroke: #ee8; stroke-width: 1px; }
|
||||
|
||||
.CodeMirror-merge-l-chunk { background: #eef; }
|
||||
.CodeMirror-merge-l-chunk-start { border-top: 1px solid #88e; }
|
||||
.CodeMirror-merge-l-chunk-end { border-bottom: 1px solid #88e; }
|
||||
.CodeMirror-merge-l-connect { fill: #eef; stroke: #88e; stroke-width: 1px; }
|
||||
|
||||
.CodeMirror-merge-l-chunk.CodeMirror-merge-r-chunk { background: #dfd; }
|
||||
.CodeMirror-merge-l-chunk-start.CodeMirror-merge-r-chunk-start { border-top: 1px solid #4e4; }
|
||||
.CodeMirror-merge-l-chunk-end.CodeMirror-merge-r-chunk-end { border-bottom: 1px solid #4e4; }
|
||||
|
||||
.CodeMirror-merge-collapsed-widget:before {
|
||||
content: "(...)";
|
||||
}
|
||||
.CodeMirror-merge-collapsed-widget {
|
||||
cursor: pointer;
|
||||
color: #88b;
|
||||
background: #eef;
|
||||
border: 1px solid #ddf;
|
||||
font-size: 90%;
|
||||
padding: 0 3px;
|
||||
border-radius: 4px;
|
||||
}
|
||||
.CodeMirror-merge-collapsed-line .CodeMirror-gutter-elt { display: none; }
|
795
codemirror/addon/merge/merge.js
vendored
Normal file
795
codemirror/addon/merge/merge.js
vendored
Normal file
|
@ -0,0 +1,795 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
// declare global: diff_match_patch, DIFF_INSERT, DIFF_DELETE, DIFF_EQUAL
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror")); // Note non-packaged dependency diff_match_patch
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror", "diff_match_patch"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
var Pos = CodeMirror.Pos;
|
||||
var svgNS = "http://www.w3.org/2000/svg";
|
||||
|
||||
function DiffView(mv, type) {
|
||||
this.mv = mv;
|
||||
this.type = type;
|
||||
this.classes = type == "left"
|
||||
? {chunk: "CodeMirror-merge-l-chunk",
|
||||
start: "CodeMirror-merge-l-chunk-start",
|
||||
end: "CodeMirror-merge-l-chunk-end",
|
||||
insert: "CodeMirror-merge-l-inserted",
|
||||
del: "CodeMirror-merge-l-deleted",
|
||||
connect: "CodeMirror-merge-l-connect"}
|
||||
: {chunk: "CodeMirror-merge-r-chunk",
|
||||
start: "CodeMirror-merge-r-chunk-start",
|
||||
end: "CodeMirror-merge-r-chunk-end",
|
||||
insert: "CodeMirror-merge-r-inserted",
|
||||
del: "CodeMirror-merge-r-deleted",
|
||||
connect: "CodeMirror-merge-r-connect"};
|
||||
}
|
||||
|
||||
DiffView.prototype = {
|
||||
constructor: DiffView,
|
||||
init: function(pane, orig, options) {
|
||||
this.edit = this.mv.edit;
|
||||
(this.edit.state.diffViews || (this.edit.state.diffViews = [])).push(this);
|
||||
this.orig = CodeMirror(pane, copyObj({value: orig, readOnly: !this.mv.options.allowEditingOriginals}, copyObj(options)));
|
||||
this.orig.state.diffViews = [this];
|
||||
var classLocation = options.chunkClassLocation || "background";
|
||||
if (Object.prototype.toString.call(classLocation) != "[object Array]") classLocation = [classLocation]
|
||||
this.classes.classLocation = classLocation
|
||||
|
||||
this.diff = getDiff(asString(orig), asString(options.value));
|
||||
this.chunks = getChunks(this.diff);
|
||||
this.diffOutOfDate = this.dealigned = false;
|
||||
|
||||
this.showDifferences = options.showDifferences !== false;
|
||||
},
|
||||
registerEvents: function() {
|
||||
this.forceUpdate = registerUpdate(this);
|
||||
setScrollLock(this, true, false);
|
||||
registerScroll(this);
|
||||
},
|
||||
setShowDifferences: function(val) {
|
||||
val = val !== false;
|
||||
if (val != this.showDifferences) {
|
||||
this.showDifferences = val;
|
||||
this.forceUpdate("full");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function ensureDiff(dv) {
|
||||
if (dv.diffOutOfDate) {
|
||||
dv.diff = getDiff(dv.orig.getValue(), dv.edit.getValue());
|
||||
dv.chunks = getChunks(dv.diff);
|
||||
dv.diffOutOfDate = false;
|
||||
CodeMirror.signal(dv.edit, "updateDiff", dv.diff);
|
||||
}
|
||||
}
|
||||
|
||||
var updating = false;
|
||||
function registerUpdate(dv) {
|
||||
var edit = {from: 0, to: 0, marked: []};
|
||||
var orig = {from: 0, to: 0, marked: []};
|
||||
var debounceChange, updatingFast = false;
|
||||
function update(mode) {
|
||||
updating = true;
|
||||
updatingFast = false;
|
||||
if (mode == "full") {
|
||||
if (dv.svg) clear(dv.svg);
|
||||
if (dv.copyButtons) clear(dv.copyButtons);
|
||||
clearMarks(dv.edit, edit.marked, dv.classes);
|
||||
clearMarks(dv.orig, orig.marked, dv.classes);
|
||||
edit.from = edit.to = orig.from = orig.to = 0;
|
||||
}
|
||||
ensureDiff(dv);
|
||||
if (dv.showDifferences) {
|
||||
updateMarks(dv.edit, dv.diff, edit, DIFF_INSERT, dv.classes);
|
||||
updateMarks(dv.orig, dv.diff, orig, DIFF_DELETE, dv.classes);
|
||||
}
|
||||
|
||||
if (dv.mv.options.connect == "align")
|
||||
alignChunks(dv);
|
||||
makeConnections(dv);
|
||||
|
||||
updating = false;
|
||||
}
|
||||
function setDealign(fast) {
|
||||
if (updating) return;
|
||||
dv.dealigned = true;
|
||||
set(fast);
|
||||
}
|
||||
function set(fast) {
|
||||
if (updating || updatingFast) return;
|
||||
clearTimeout(debounceChange);
|
||||
if (fast === true) updatingFast = true;
|
||||
debounceChange = setTimeout(update, fast === true ? 20 : 250);
|
||||
}
|
||||
function change(_cm, change) {
|
||||
if (!dv.diffOutOfDate) {
|
||||
dv.diffOutOfDate = true;
|
||||
edit.from = edit.to = orig.from = orig.to = 0;
|
||||
}
|
||||
// Update faster when a line was added/removed
|
||||
setDealign(change.text.length - 1 != change.to.line - change.from.line);
|
||||
}
|
||||
function swapDoc() {
|
||||
dv.diffOutOfDate = true;
|
||||
update("full");
|
||||
}
|
||||
dv.edit.on("change", change);
|
||||
dv.orig.on("change", change);
|
||||
dv.edit.on("swapDoc", swapDoc);
|
||||
dv.orig.on("swapDoc", swapDoc);
|
||||
dv.edit.on("markerAdded", setDealign);
|
||||
dv.edit.on("markerCleared", setDealign);
|
||||
dv.orig.on("markerAdded", setDealign);
|
||||
dv.orig.on("markerCleared", setDealign);
|
||||
dv.edit.on("viewportChange", function() { set(false); });
|
||||
dv.orig.on("viewportChange", function() { set(false); });
|
||||
update();
|
||||
return update;
|
||||
}
|
||||
|
||||
function registerScroll(dv) {
|
||||
dv.edit.on("scroll", function() {
|
||||
syncScroll(dv, DIFF_INSERT) && makeConnections(dv);
|
||||
});
|
||||
dv.orig.on("scroll", function() {
|
||||
syncScroll(dv, DIFF_DELETE) && makeConnections(dv);
|
||||
});
|
||||
}
|
||||
|
||||
function syncScroll(dv, type) {
|
||||
// Change handler will do a refresh after a timeout when diff is out of date
|
||||
if (dv.diffOutOfDate) return false;
|
||||
if (!dv.lockScroll) return true;
|
||||
var editor, other, now = +new Date;
|
||||
if (type == DIFF_INSERT) { editor = dv.edit; other = dv.orig; }
|
||||
else { editor = dv.orig; other = dv.edit; }
|
||||
// Don't take action if the position of this editor was recently set
|
||||
// (to prevent feedback loops)
|
||||
if (editor.state.scrollSetBy == dv && (editor.state.scrollSetAt || 0) + 50 > now) return false;
|
||||
|
||||
var sInfo = editor.getScrollInfo();
|
||||
if (dv.mv.options.connect == "align") {
|
||||
targetPos = sInfo.top;
|
||||
} else {
|
||||
var halfScreen = .5 * sInfo.clientHeight, midY = sInfo.top + halfScreen;
|
||||
var mid = editor.lineAtHeight(midY, "local");
|
||||
var around = chunkBoundariesAround(dv.chunks, mid, type == DIFF_INSERT);
|
||||
var off = getOffsets(editor, type == DIFF_INSERT ? around.edit : around.orig);
|
||||
var offOther = getOffsets(other, type == DIFF_INSERT ? around.orig : around.edit);
|
||||
var ratio = (midY - off.top) / (off.bot - off.top);
|
||||
var targetPos = (offOther.top - halfScreen) + ratio * (offOther.bot - offOther.top);
|
||||
|
||||
var botDist, mix;
|
||||
// Some careful tweaking to make sure no space is left out of view
|
||||
// when scrolling to top or bottom.
|
||||
if (targetPos > sInfo.top && (mix = sInfo.top / halfScreen) < 1) {
|
||||
targetPos = targetPos * mix + sInfo.top * (1 - mix);
|
||||
} else if ((botDist = sInfo.height - sInfo.clientHeight - sInfo.top) < halfScreen) {
|
||||
var otherInfo = other.getScrollInfo();
|
||||
var botDistOther = otherInfo.height - otherInfo.clientHeight - targetPos;
|
||||
if (botDistOther > botDist && (mix = botDist / halfScreen) < 1)
|
||||
targetPos = targetPos * mix + (otherInfo.height - otherInfo.clientHeight - botDist) * (1 - mix);
|
||||
}
|
||||
}
|
||||
|
||||
other.scrollTo(sInfo.left, targetPos);
|
||||
other.state.scrollSetAt = now;
|
||||
other.state.scrollSetBy = dv;
|
||||
return true;
|
||||
}
|
||||
|
||||
function getOffsets(editor, around) {
|
||||
var bot = around.after;
|
||||
if (bot == null) bot = editor.lastLine() + 1;
|
||||
return {top: editor.heightAtLine(around.before || 0, "local"),
|
||||
bot: editor.heightAtLine(bot, "local")};
|
||||
}
|
||||
|
||||
function setScrollLock(dv, val, action) {
|
||||
dv.lockScroll = val;
|
||||
if (val && action != false) syncScroll(dv, DIFF_INSERT) && makeConnections(dv);
|
||||
dv.lockButton.innerHTML = val ? "\u21db\u21da" : "\u21db \u21da";
|
||||
}
|
||||
|
||||
// Updating the marks for editor content
|
||||
|
||||
function removeClass(editor, line, classes) {
|
||||
var locs = classes.classLocation
|
||||
for (var i = 0; i < locs.length; i++) {
|
||||
editor.removeLineClass(line, locs[i], classes.chunk);
|
||||
editor.removeLineClass(line, locs[i], classes.start);
|
||||
editor.removeLineClass(line, locs[i], classes.end);
|
||||
}
|
||||
}
|
||||
|
||||
function clearMarks(editor, arr, classes) {
|
||||
for (var i = 0; i < arr.length; ++i) {
|
||||
var mark = arr[i];
|
||||
if (mark instanceof CodeMirror.TextMarker)
|
||||
mark.clear();
|
||||
else if (mark.parent)
|
||||
removeClass(editor, mark, classes);
|
||||
}
|
||||
arr.length = 0;
|
||||
}
|
||||
|
||||
// FIXME maybe add a margin around viewport to prevent too many updates
|
||||
function updateMarks(editor, diff, state, type, classes) {
|
||||
var vp = editor.getViewport();
|
||||
editor.operation(function() {
|
||||
if (state.from == state.to || vp.from - state.to > 20 || state.from - vp.to > 20) {
|
||||
clearMarks(editor, state.marked, classes);
|
||||
markChanges(editor, diff, type, state.marked, vp.from, vp.to, classes);
|
||||
state.from = vp.from; state.to = vp.to;
|
||||
} else {
|
||||
if (vp.from < state.from) {
|
||||
markChanges(editor, diff, type, state.marked, vp.from, state.from, classes);
|
||||
state.from = vp.from;
|
||||
}
|
||||
if (vp.to > state.to) {
|
||||
markChanges(editor, diff, type, state.marked, state.to, vp.to, classes);
|
||||
state.to = vp.to;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function addClass(editor, lineNr, classes, main, start, end) {
|
||||
var locs = classes.classLocation, line = editor.getLineHandle(lineNr);
|
||||
for (var i = 0; i < locs.length; i++) {
|
||||
if (main) editor.addLineClass(line, locs[i], classes.chunk);
|
||||
if (start) editor.addLineClass(line, locs[i], classes.start);
|
||||
if (end) editor.addLineClass(line, locs[i], classes.end);
|
||||
}
|
||||
return line;
|
||||
}
|
||||
|
||||
function markChanges(editor, diff, type, marks, from, to, classes) {
|
||||
var pos = Pos(0, 0);
|
||||
var top = Pos(from, 0), bot = editor.clipPos(Pos(to - 1));
|
||||
var cls = type == DIFF_DELETE ? classes.del : classes.insert;
|
||||
function markChunk(start, end) {
|
||||
var bfrom = Math.max(from, start), bto = Math.min(to, end);
|
||||
for (var i = bfrom; i < bto; ++i)
|
||||
marks.push(addClass(editor, i, classes, true, i == start, i == end - 1));
|
||||
// When the chunk is empty, make sure a horizontal line shows up
|
||||
if (start == end && bfrom == end && bto == end) {
|
||||
if (bfrom)
|
||||
marks.push(addClass(editor, bfrom - 1, classes, false, false, true));
|
||||
else
|
||||
marks.push(addClass(editor, bfrom, classes, false, true, false));
|
||||
}
|
||||
}
|
||||
|
||||
var chunkStart = 0;
|
||||
for (var i = 0; i < diff.length; ++i) {
|
||||
var part = diff[i], tp = part[0], str = part[1];
|
||||
if (tp == DIFF_EQUAL) {
|
||||
var cleanFrom = pos.line + (startOfLineClean(diff, i) ? 0 : 1);
|
||||
moveOver(pos, str);
|
||||
var cleanTo = pos.line + (endOfLineClean(diff, i) ? 1 : 0);
|
||||
if (cleanTo > cleanFrom) {
|
||||
if (i) markChunk(chunkStart, cleanFrom);
|
||||
chunkStart = cleanTo;
|
||||
}
|
||||
} else {
|
||||
if (tp == type) {
|
||||
var end = moveOver(pos, str, true);
|
||||
var a = posMax(top, pos), b = posMin(bot, end);
|
||||
if (!posEq(a, b))
|
||||
marks.push(editor.markText(a, b, {className: cls}));
|
||||
pos = end;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (chunkStart <= pos.line) markChunk(chunkStart, pos.line + 1);
|
||||
}
|
||||
|
||||
// Updating the gap between editor and original
|
||||
|
||||
function makeConnections(dv) {
|
||||
if (!dv.showDifferences) return;
|
||||
|
||||
if (dv.svg) {
|
||||
clear(dv.svg);
|
||||
var w = dv.gap.offsetWidth;
|
||||
attrs(dv.svg, "width", w, "height", dv.gap.offsetHeight);
|
||||
}
|
||||
if (dv.copyButtons) clear(dv.copyButtons);
|
||||
|
||||
var vpEdit = dv.edit.getViewport(), vpOrig = dv.orig.getViewport();
|
||||
var outerTop = dv.mv.wrap.getBoundingClientRect().top
|
||||
var sTopEdit = outerTop - dv.edit.getScrollerElement().getBoundingClientRect().top + dv.edit.getScrollInfo().top
|
||||
var sTopOrig = outerTop - dv.orig.getScrollerElement().getBoundingClientRect().top + dv.orig.getScrollInfo().top;
|
||||
for (var i = 0; i < dv.chunks.length; i++) {
|
||||
var ch = dv.chunks[i];
|
||||
if (ch.editFrom <= vpEdit.to && ch.editTo >= vpEdit.from &&
|
||||
ch.origFrom <= vpOrig.to && ch.origTo >= vpOrig.from)
|
||||
drawConnectorsForChunk(dv, ch, sTopOrig, sTopEdit, w);
|
||||
}
|
||||
}
|
||||
|
||||
function getMatchingOrigLine(editLine, chunks) {
|
||||
var editStart = 0, origStart = 0;
|
||||
for (var i = 0; i < chunks.length; i++) {
|
||||
var chunk = chunks[i];
|
||||
if (chunk.editTo > editLine && chunk.editFrom <= editLine) return null;
|
||||
if (chunk.editFrom > editLine) break;
|
||||
editStart = chunk.editTo;
|
||||
origStart = chunk.origTo;
|
||||
}
|
||||
return origStart + (editLine - editStart);
|
||||
}
|
||||
|
||||
function findAlignedLines(dv, other) {
|
||||
var linesToAlign = [];
|
||||
for (var i = 0; i < dv.chunks.length; i++) {
|
||||
var chunk = dv.chunks[i];
|
||||
linesToAlign.push([chunk.origTo, chunk.editTo, other ? getMatchingOrigLine(chunk.editTo, other.chunks) : null]);
|
||||
}
|
||||
if (other) {
|
||||
chunkLoop: for (var i = 0; i < other.chunks.length; i++) {
|
||||
var chunk = other.chunks[i];
|
||||
for (var j = 0; j < linesToAlign.length; j++) {
|
||||
var diff = linesToAlign[j][1] - chunk.editTo;
|
||||
if (diff == 0) continue chunkLoop
|
||||
if (diff > 0) break;
|
||||
}
|
||||
linesToAlign.splice(j, 0, [getMatchingOrigLine(chunk.editTo, dv.chunks), chunk.editTo, chunk.origTo]);
|
||||
}
|
||||
}
|
||||
return linesToAlign;
|
||||
}
|
||||
|
||||
function alignChunks(dv, force) {
|
||||
if (!dv.dealigned && !force) return;
|
||||
if (!dv.orig.curOp) return dv.orig.operation(function() {
|
||||
alignChunks(dv, force);
|
||||
});
|
||||
|
||||
dv.dealigned = false;
|
||||
var other = dv.mv.left == dv ? dv.mv.right : dv.mv.left;
|
||||
if (other) {
|
||||
ensureDiff(other);
|
||||
other.dealigned = false;
|
||||
}
|
||||
var linesToAlign = findAlignedLines(dv, other);
|
||||
|
||||
// Clear old aligners
|
||||
var aligners = dv.mv.aligners;
|
||||
for (var i = 0; i < aligners.length; i++)
|
||||
aligners[i].clear();
|
||||
aligners.length = 0;
|
||||
|
||||
var cm = [dv.orig, dv.edit], scroll = [];
|
||||
if (other) cm.push(other.orig);
|
||||
for (var i = 0; i < cm.length; i++)
|
||||
scroll.push(cm[i].getScrollInfo().top);
|
||||
|
||||
for (var ln = 0; ln < linesToAlign.length; ln++)
|
||||
alignLines(cm, linesToAlign[ln], aligners);
|
||||
|
||||
for (var i = 0; i < cm.length; i++)
|
||||
cm[i].scrollTo(null, scroll[i]);
|
||||
}
|
||||
|
||||
function alignLines(cm, lines, aligners) {
|
||||
var maxOffset = 0, offset = [];
|
||||
for (var i = 0; i < cm.length; i++) if (lines[i] != null) {
|
||||
var off = cm[i].heightAtLine(lines[i], "local");
|
||||
offset[i] = off;
|
||||
maxOffset = Math.max(maxOffset, off);
|
||||
}
|
||||
for (var i = 0; i < cm.length; i++) if (lines[i] != null) {
|
||||
var diff = maxOffset - offset[i];
|
||||
if (diff > 1)
|
||||
aligners.push(padAbove(cm[i], lines[i], diff));
|
||||
}
|
||||
}
|
||||
|
||||
function padAbove(cm, line, size) {
|
||||
var above = true;
|
||||
if (line > cm.lastLine()) {
|
||||
line--;
|
||||
above = false;
|
||||
}
|
||||
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});
|
||||
}
|
||||
|
||||
function drawConnectorsForChunk(dv, chunk, sTopOrig, sTopEdit, w) {
|
||||
var flip = dv.type == "left";
|
||||
var top = dv.orig.heightAtLine(chunk.origFrom, "local", true) - sTopOrig;
|
||||
if (dv.svg) {
|
||||
var topLpx = top;
|
||||
var topRpx = dv.edit.heightAtLine(chunk.editFrom, "local", true) - sTopEdit;
|
||||
if (flip) { var tmp = topLpx; topLpx = topRpx; topRpx = tmp; }
|
||||
var botLpx = dv.orig.heightAtLine(chunk.origTo, "local", true) - sTopOrig;
|
||||
var botRpx = dv.edit.heightAtLine(chunk.editTo, "local", true) - sTopEdit;
|
||||
if (flip) { var tmp = botLpx; botLpx = botRpx; botRpx = tmp; }
|
||||
var curveTop = " C " + w/2 + " " + topRpx + " " + w/2 + " " + topLpx + " " + (w + 2) + " " + topLpx;
|
||||
var curveBot = " C " + w/2 + " " + botLpx + " " + w/2 + " " + botRpx + " -1 " + botRpx;
|
||||
attrs(dv.svg.appendChild(document.createElementNS(svgNS, "path")),
|
||||
"d", "M -1 " + topRpx + curveTop + " L " + (w + 2) + " " + botLpx + curveBot + " z",
|
||||
"class", dv.classes.connect);
|
||||
}
|
||||
if (dv.copyButtons) {
|
||||
var copy = dv.copyButtons.appendChild(elt("div", dv.type == "left" ? "\u21dd" : "\u21dc",
|
||||
"CodeMirror-merge-copy"));
|
||||
var editOriginals = dv.mv.options.allowEditingOriginals;
|
||||
copy.title = editOriginals ? "Push to left" : "Revert chunk";
|
||||
copy.chunk = chunk;
|
||||
copy.style.top = (chunk.origTo > chunk.origFrom ? top : dv.edit.heightAtLine(chunk.editFrom, "local") - sTopEdit) + "px";
|
||||
|
||||
if (editOriginals) {
|
||||
var topReverse = dv.edit.heightAtLine(chunk.editFrom, "local") - sTopEdit;
|
||||
var copyReverse = dv.copyButtons.appendChild(elt("div", dv.type == "right" ? "\u21dd" : "\u21dc",
|
||||
"CodeMirror-merge-copy-reverse"));
|
||||
copyReverse.title = "Push to right";
|
||||
copyReverse.chunk = {editFrom: chunk.origFrom, editTo: chunk.origTo,
|
||||
origFrom: chunk.editFrom, origTo: chunk.editTo};
|
||||
copyReverse.style.top = topReverse + "px";
|
||||
dv.type == "right" ? copyReverse.style.left = "2px" : copyReverse.style.right = "2px";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function copyChunk(dv, to, from, chunk) {
|
||||
if (dv.diffOutOfDate) return;
|
||||
var editStart = chunk.editTo > to.lastLine() ? Pos(chunk.editFrom - 1) : Pos(chunk.editFrom, 0)
|
||||
var origStart = chunk.origTo > from.lastLine() ? Pos(chunk.origFrom - 1) : Pos(chunk.origFrom, 0)
|
||||
to.replaceRange(from.getRange(origStart, Pos(chunk.origTo, 0)), editStart, Pos(chunk.editTo, 0))
|
||||
}
|
||||
|
||||
// Merge view, containing 0, 1, or 2 diff views.
|
||||
|
||||
var MergeView = CodeMirror.MergeView = function(node, options) {
|
||||
if (!(this instanceof MergeView)) return new MergeView(node, options);
|
||||
|
||||
this.options = options;
|
||||
var origLeft = options.origLeft, origRight = options.origRight == null ? options.orig : options.origRight;
|
||||
|
||||
var hasLeft = origLeft != null, hasRight = origRight != null;
|
||||
var panes = 1 + (hasLeft ? 1 : 0) + (hasRight ? 1 : 0);
|
||||
var wrap = [], left = this.left = null, right = this.right = null;
|
||||
var self = this;
|
||||
|
||||
if (hasLeft) {
|
||||
left = this.left = new DiffView(this, "left");
|
||||
var leftPane = elt("div", null, "CodeMirror-merge-pane CodeMirror-merge-left");
|
||||
wrap.push(leftPane);
|
||||
wrap.push(buildGap(left));
|
||||
}
|
||||
|
||||
var editPane = elt("div", null, "CodeMirror-merge-pane CodeMirror-merge-editor");
|
||||
wrap.push(editPane);
|
||||
|
||||
if (hasRight) {
|
||||
right = this.right = new DiffView(this, "right");
|
||||
wrap.push(buildGap(right));
|
||||
var rightPane = elt("div", null, "CodeMirror-merge-pane CodeMirror-merge-right");
|
||||
wrap.push(rightPane);
|
||||
}
|
||||
|
||||
(hasRight ? rightPane : editPane).className += " CodeMirror-merge-pane-rightmost";
|
||||
|
||||
wrap.push(elt("div", null, null, "height: 0; clear: both;"));
|
||||
|
||||
var wrapElt = this.wrap = node.appendChild(elt("div", wrap, "CodeMirror-merge CodeMirror-merge-" + panes + "pane"));
|
||||
this.edit = CodeMirror(editPane, copyObj(options));
|
||||
|
||||
if (left) left.init(leftPane, origLeft, options);
|
||||
if (right) right.init(rightPane, origRight, options);
|
||||
if (options.collapseIdentical)
|
||||
this.editor().operation(function() {
|
||||
collapseIdenticalStretches(self, options.collapseIdentical);
|
||||
});
|
||||
if (options.connect == "align") {
|
||||
this.aligners = [];
|
||||
alignChunks(this.left || this.right, true);
|
||||
}
|
||||
if (left) left.registerEvents()
|
||||
if (right) right.registerEvents()
|
||||
|
||||
|
||||
var onResize = function() {
|
||||
if (left) makeConnections(left);
|
||||
if (right) makeConnections(right);
|
||||
};
|
||||
CodeMirror.on(window, "resize", onResize);
|
||||
var resizeInterval = setInterval(function() {
|
||||
for (var p = wrapElt.parentNode; p && p != document.body; p = p.parentNode) {}
|
||||
if (!p) { clearInterval(resizeInterval); CodeMirror.off(window, "resize", onResize); }
|
||||
}, 5000);
|
||||
};
|
||||
|
||||
function buildGap(dv) {
|
||||
var lock = dv.lockButton = elt("div", null, "CodeMirror-merge-scrolllock");
|
||||
lock.title = "Toggle locked scrolling";
|
||||
var lockWrap = elt("div", [lock], "CodeMirror-merge-scrolllock-wrap");
|
||||
CodeMirror.on(lock, "click", function() { setScrollLock(dv, !dv.lockScroll); });
|
||||
var gapElts = [lockWrap];
|
||||
if (dv.mv.options.revertButtons !== false) {
|
||||
dv.copyButtons = elt("div", null, "CodeMirror-merge-copybuttons-" + dv.type);
|
||||
CodeMirror.on(dv.copyButtons, "click", function(e) {
|
||||
var node = e.target || e.srcElement;
|
||||
if (!node.chunk) return;
|
||||
if (node.className == "CodeMirror-merge-copy-reverse") {
|
||||
copyChunk(dv, dv.orig, dv.edit, node.chunk);
|
||||
return;
|
||||
}
|
||||
copyChunk(dv, dv.edit, dv.orig, node.chunk);
|
||||
});
|
||||
gapElts.unshift(dv.copyButtons);
|
||||
}
|
||||
if (dv.mv.options.connect != "align") {
|
||||
var svg = document.createElementNS && document.createElementNS(svgNS, "svg");
|
||||
if (svg && !svg.createSVGRect) svg = null;
|
||||
dv.svg = svg;
|
||||
if (svg) gapElts.push(svg);
|
||||
}
|
||||
|
||||
return dv.gap = elt("div", gapElts, "CodeMirror-merge-gap");
|
||||
}
|
||||
|
||||
MergeView.prototype = {
|
||||
constructor: MergeView,
|
||||
editor: function() { return this.edit; },
|
||||
rightOriginal: function() { return this.right && this.right.orig; },
|
||||
leftOriginal: function() { return this.left && this.left.orig; },
|
||||
setShowDifferences: function(val) {
|
||||
if (this.right) this.right.setShowDifferences(val);
|
||||
if (this.left) this.left.setShowDifferences(val);
|
||||
},
|
||||
rightChunks: function() {
|
||||
if (this.right) { ensureDiff(this.right); return this.right.chunks; }
|
||||
},
|
||||
leftChunks: function() {
|
||||
if (this.left) { ensureDiff(this.left); return this.left.chunks; }
|
||||
}
|
||||
};
|
||||
|
||||
function asString(obj) {
|
||||
if (typeof obj == "string") return obj;
|
||||
else return obj.getValue();
|
||||
}
|
||||
|
||||
// Operations on diffs
|
||||
|
||||
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]) {
|
||||
diff.splice(i--, 1);
|
||||
} else if (i && diff[i - 1][0] == part[0]) {
|
||||
diff.splice(i--, 1);
|
||||
diff[i][1] += part[1];
|
||||
}
|
||||
}
|
||||
return diff;
|
||||
}
|
||||
|
||||
function getChunks(diff) {
|
||||
var chunks = [];
|
||||
var startEdit = 0, startOrig = 0;
|
||||
var edit = Pos(0, 0), orig = Pos(0, 0);
|
||||
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 cleanFromEdit = edit.line + startOff, cleanFromOrig = orig.line + startOff;
|
||||
moveOver(edit, part[1], null, orig);
|
||||
var endOff = endOfLineClean(diff, i) ? 1 : 0;
|
||||
var cleanToEdit = edit.line + endOff, cleanToOrig = orig.line + endOff;
|
||||
if (cleanToEdit > cleanFromEdit) {
|
||||
if (i) chunks.push({origFrom: startOrig, origTo: cleanFromOrig,
|
||||
editFrom: startEdit, editTo: cleanFromEdit});
|
||||
startEdit = cleanToEdit; startOrig = cleanToOrig;
|
||||
}
|
||||
} else {
|
||||
moveOver(tp == DIFF_INSERT ? edit : orig, part[1]);
|
||||
}
|
||||
}
|
||||
if (startEdit <= edit.line || startOrig <= orig.line)
|
||||
chunks.push({origFrom: startOrig, origTo: orig.line + 1,
|
||||
editFrom: startEdit, editTo: edit.line + 1});
|
||||
return chunks;
|
||||
}
|
||||
|
||||
function endOfLineClean(diff, i) {
|
||||
if (i == diff.length - 1) return true;
|
||||
var next = diff[i + 1][1];
|
||||
if (next.length == 1 || next.charCodeAt(0) != 10) return false;
|
||||
if (i == diff.length - 2) return true;
|
||||
next = diff[i + 2][1];
|
||||
return next.length > 1 && next.charCodeAt(0) == 10;
|
||||
}
|
||||
|
||||
function startOfLineClean(diff, i) {
|
||||
if (i == 0) return true;
|
||||
var last = diff[i - 1][1];
|
||||
if (last.charCodeAt(last.length - 1) != 10) return false;
|
||||
if (i == 1) return true;
|
||||
last = diff[i - 2][1];
|
||||
return last.charCodeAt(last.length - 1) == 10;
|
||||
}
|
||||
|
||||
function chunkBoundariesAround(chunks, n, nInEdit) {
|
||||
var beforeE, afterE, beforeO, afterO;
|
||||
for (var i = 0; i < chunks.length; i++) {
|
||||
var chunk = chunks[i];
|
||||
var fromLocal = nInEdit ? chunk.editFrom : chunk.origFrom;
|
||||
var toLocal = nInEdit ? chunk.editTo : chunk.origTo;
|
||||
if (afterE == null) {
|
||||
if (fromLocal > n) { afterE = chunk.editFrom; afterO = chunk.origFrom; }
|
||||
else if (toLocal > n) { afterE = chunk.editTo; afterO = chunk.origTo; }
|
||||
}
|
||||
if (toLocal <= n) { beforeE = chunk.editTo; beforeO = chunk.origTo; }
|
||||
else if (fromLocal <= n) { beforeE = chunk.editFrom; beforeO = chunk.origFrom; }
|
||||
}
|
||||
return {edit: {before: beforeE, after: afterE}, orig: {before: beforeO, after: afterO}};
|
||||
}
|
||||
|
||||
function collapseSingle(cm, from, to) {
|
||||
cm.addLineClass(from, "wrap", "CodeMirror-merge-collapsed-line");
|
||||
var widget = document.createElement("span");
|
||||
widget.className = "CodeMirror-merge-collapsed-widget";
|
||||
widget.title = "Identical text collapsed. Click to expand.";
|
||||
var mark = cm.markText(Pos(from, 0), Pos(to - 1), {
|
||||
inclusiveLeft: true,
|
||||
inclusiveRight: true,
|
||||
replacedWith: widget,
|
||||
clearOnEnter: true
|
||||
});
|
||||
function clear() {
|
||||
mark.clear();
|
||||
cm.removeLineClass(from, "wrap", "CodeMirror-merge-collapsed-line");
|
||||
}
|
||||
CodeMirror.on(widget, "click", clear);
|
||||
return {mark: mark, clear: clear};
|
||||
}
|
||||
|
||||
function collapseStretch(size, editors) {
|
||||
var marks = [];
|
||||
function clear() {
|
||||
for (var i = 0; i < marks.length; i++) marks[i].clear();
|
||||
}
|
||||
for (var i = 0; i < editors.length; i++) {
|
||||
var editor = editors[i];
|
||||
var mark = collapseSingle(editor.cm, editor.line, editor.line + size);
|
||||
marks.push(mark);
|
||||
mark.mark.on("clear", clear);
|
||||
}
|
||||
return marks[0].mark;
|
||||
}
|
||||
|
||||
function unclearNearChunks(dv, margin, off, clear) {
|
||||
for (var i = 0; i < dv.chunks.length; i++) {
|
||||
var chunk = dv.chunks[i];
|
||||
for (var l = chunk.editFrom - margin; l < chunk.editTo + margin; l++) {
|
||||
var pos = l + off;
|
||||
if (pos >= 0 && pos < clear.length) clear[pos] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function collapseIdenticalStretches(mv, margin) {
|
||||
if (typeof margin != "number") margin = 2;
|
||||
var clear = [], edit = mv.editor(), off = edit.firstLine();
|
||||
for (var l = off, e = edit.lastLine(); l <= e; l++) clear.push(true);
|
||||
if (mv.left) unclearNearChunks(mv.left, margin, off, clear);
|
||||
if (mv.right) unclearNearChunks(mv.right, margin, off, clear);
|
||||
|
||||
for (var i = 0; i < clear.length; i++) {
|
||||
if (clear[i]) {
|
||||
var line = i + off;
|
||||
for (var size = 1; i < clear.length - 1 && clear[i + 1]; i++, size++) {}
|
||||
if (size > margin) {
|
||||
var editors = [{line: line, cm: edit}];
|
||||
if (mv.left) editors.push({line: getMatchingOrigLine(line, mv.left.chunks), cm: mv.left.orig});
|
||||
if (mv.right) editors.push({line: getMatchingOrigLine(line, mv.right.chunks), cm: mv.right.orig});
|
||||
var mark = collapseStretch(size, editors);
|
||||
if (mv.options.onCollapse) mv.options.onCollapse(mv, line, size, mark);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// General utilities
|
||||
|
||||
function elt(tag, content, className, style) {
|
||||
var e = document.createElement(tag);
|
||||
if (className) e.className = className;
|
||||
if (style) e.style.cssText = style;
|
||||
if (typeof content == "string") e.appendChild(document.createTextNode(content));
|
||||
else if (content) for (var i = 0; i < content.length; ++i) e.appendChild(content[i]);
|
||||
return e;
|
||||
}
|
||||
|
||||
function clear(node) {
|
||||
for (var count = node.childNodes.length; count > 0; --count)
|
||||
node.removeChild(node.firstChild);
|
||||
}
|
||||
|
||||
function attrs(elt) {
|
||||
for (var i = 1; i < arguments.length; i += 2)
|
||||
elt.setAttribute(arguments[i], arguments[i+1]);
|
||||
}
|
||||
|
||||
function copyObj(obj, target) {
|
||||
if (!target) target = {};
|
||||
for (var prop in obj) if (obj.hasOwnProperty(prop)) target[prop] = obj[prop];
|
||||
return target;
|
||||
}
|
||||
|
||||
function moveOver(pos, str, copy, other) {
|
||||
var out = copy ? Pos(pos.line, pos.ch) : pos, at = 0;
|
||||
for (;;) {
|
||||
var nl = str.indexOf("\n", at);
|
||||
if (nl == -1) break;
|
||||
++out.line;
|
||||
if (other) ++other.line;
|
||||
at = nl + 1;
|
||||
}
|
||||
out.ch = (at ? 0 : out.ch) + (str.length - at);
|
||||
if (other) other.ch = (at ? 0 : other.ch) + (str.length - at);
|
||||
return out;
|
||||
}
|
||||
|
||||
function posMin(a, b) { return (a.line - b.line || a.ch - b.ch) < 0 ? a : b; }
|
||||
function posMax(a, b) { return (a.line - b.line || a.ch - b.ch) > 0 ? a : b; }
|
||||
function posEq(a, b) { return a.line == b.line && a.ch == b.ch; }
|
||||
|
||||
function findPrevDiff(chunks, start, isOrig) {
|
||||
for (var i = chunks.length - 1; i >= 0; i--) {
|
||||
var chunk = chunks[i];
|
||||
var to = (isOrig ? chunk.origTo : chunk.editTo) - 1;
|
||||
if (to < start) return to;
|
||||
}
|
||||
}
|
||||
|
||||
function findNextDiff(chunks, start, isOrig) {
|
||||
for (var i = 0; i < chunks.length; i++) {
|
||||
var chunk = chunks[i];
|
||||
var from = (isOrig ? chunk.origFrom : chunk.editFrom);
|
||||
if (from > start) return from;
|
||||
}
|
||||
}
|
||||
|
||||
function goNearbyDiff(cm, dir) {
|
||||
var found = null, views = cm.state.diffViews, line = cm.getCursor().line;
|
||||
if (views) for (var i = 0; i < views.length; i++) {
|
||||
var dv = views[i], isOrig = cm == dv.orig;
|
||||
ensureDiff(dv);
|
||||
var pos = dir < 0 ? findPrevDiff(dv.chunks, line, isOrig) : findNextDiff(dv.chunks, line, isOrig);
|
||||
if (pos != null && (found == null || (dir < 0 ? pos > found : pos < found)))
|
||||
found = pos;
|
||||
}
|
||||
if (found != null)
|
||||
cm.setCursor(found, 0);
|
||||
else
|
||||
return CodeMirror.Pass;
|
||||
}
|
||||
|
||||
CodeMirror.commands.goNextDiff = function(cm) {
|
||||
return goNearbyDiff(cm, 1);
|
||||
};
|
||||
CodeMirror.commands.goPrevDiff = function(cm) {
|
||||
return goNearbyDiff(cm, -1);
|
||||
};
|
||||
});
|
64
codemirror/addon/mode/loadmode.js
vendored
Normal file
64
codemirror/addon/mode/loadmode.js
vendored
Normal file
|
@ -0,0 +1,64 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"), "cjs");
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror"], function(CM) { mod(CM, "amd"); });
|
||||
else // Plain browser env
|
||||
mod(CodeMirror, "plain");
|
||||
})(function(CodeMirror, env) {
|
||||
if (!CodeMirror.modeURL) CodeMirror.modeURL = "../mode/%N/%N.js";
|
||||
|
||||
var loading = {};
|
||||
function splitCallback(cont, n) {
|
||||
var countDown = n;
|
||||
return function() { if (--countDown == 0) cont(); };
|
||||
}
|
||||
function ensureDeps(mode, cont) {
|
||||
var deps = CodeMirror.modes[mode].dependencies;
|
||||
if (!deps) return cont();
|
||||
var missing = [];
|
||||
for (var i = 0; i < deps.length; ++i) {
|
||||
if (!CodeMirror.modes.hasOwnProperty(deps[i]))
|
||||
missing.push(deps[i]);
|
||||
}
|
||||
if (!missing.length) return cont();
|
||||
var split = splitCallback(cont, missing.length);
|
||||
for (var i = 0; i < missing.length; ++i)
|
||||
CodeMirror.requireMode(missing[i], split);
|
||||
}
|
||||
|
||||
CodeMirror.requireMode = function(mode, cont) {
|
||||
if (typeof mode != "string") mode = mode.name;
|
||||
if (CodeMirror.modes.hasOwnProperty(mode)) return ensureDeps(mode, cont);
|
||||
if (loading.hasOwnProperty(mode)) return loading[mode].push(cont);
|
||||
|
||||
var file = CodeMirror.modeURL.replace(/%N/g, mode);
|
||||
if (env == "plain") {
|
||||
var script = document.createElement("script");
|
||||
script.src = file;
|
||||
var others = document.getElementsByTagName("script")[0];
|
||||
var list = loading[mode] = [cont];
|
||||
CodeMirror.on(script, "load", function() {
|
||||
ensureDeps(mode, function() {
|
||||
for (var i = 0; i < list.length; ++i) list[i]();
|
||||
});
|
||||
});
|
||||
others.parentNode.insertBefore(script, others);
|
||||
} else if (env == "cjs") {
|
||||
require(file);
|
||||
cont();
|
||||
} else if (env == "amd") {
|
||||
requirejs([file], cont);
|
||||
}
|
||||
};
|
||||
|
||||
CodeMirror.autoLoadMode = function(instance, mode) {
|
||||
if (!CodeMirror.modes.hasOwnProperty(mode))
|
||||
CodeMirror.requireMode(mode, function() {
|
||||
instance.setOption("mode", instance.getOption("mode"));
|
||||
});
|
||||
};
|
||||
});
|
123
codemirror/addon/mode/multiplex.js
vendored
Normal file
123
codemirror/addon/mode/multiplex.js
vendored
Normal file
|
@ -0,0 +1,123 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
CodeMirror.multiplexingMode = function(outer /*, others */) {
|
||||
// Others should be {open, close, mode [, delimStyle] [, innerStyle]} objects
|
||||
var others = Array.prototype.slice.call(arguments, 1);
|
||||
|
||||
function indexOf(string, pattern, from, returnEnd) {
|
||||
if (typeof pattern == "string") {
|
||||
var found = string.indexOf(pattern, from);
|
||||
return returnEnd && found > -1 ? found + pattern.length : found;
|
||||
}
|
||||
var m = pattern.exec(from ? string.slice(from) : string);
|
||||
return m ? m.index + from + (returnEnd ? m[0].length : 0) : -1;
|
||||
}
|
||||
|
||||
return {
|
||||
startState: function() {
|
||||
return {
|
||||
outer: CodeMirror.startState(outer),
|
||||
innerActive: null,
|
||||
inner: null
|
||||
};
|
||||
},
|
||||
|
||||
copyState: function(state) {
|
||||
return {
|
||||
outer: CodeMirror.copyState(outer, state.outer),
|
||||
innerActive: state.innerActive,
|
||||
inner: state.innerActive && CodeMirror.copyState(state.innerActive.mode, state.inner)
|
||||
};
|
||||
},
|
||||
|
||||
token: function(stream, state) {
|
||||
if (!state.innerActive) {
|
||||
var cutOff = Infinity, oldContent = stream.string;
|
||||
for (var i = 0; i < others.length; ++i) {
|
||||
var other = others[i];
|
||||
var found = indexOf(oldContent, other.open, stream.pos);
|
||||
if (found == stream.pos) {
|
||||
if (!other.parseDelimiters) stream.match(other.open);
|
||||
state.innerActive = other;
|
||||
state.inner = CodeMirror.startState(other.mode, outer.indent ? outer.indent(state.outer, "") : 0);
|
||||
return other.delimStyle && (other.delimStyle + " " + other.delimStyle + "-open");
|
||||
} else if (found != -1 && found < cutOff) {
|
||||
cutOff = found;
|
||||
}
|
||||
}
|
||||
if (cutOff != Infinity) stream.string = oldContent.slice(0, cutOff);
|
||||
var outerToken = outer.token(stream, state.outer);
|
||||
if (cutOff != Infinity) stream.string = oldContent;
|
||||
return outerToken;
|
||||
} else {
|
||||
var curInner = state.innerActive, oldContent = stream.string;
|
||||
if (!curInner.close && stream.sol()) {
|
||||
state.innerActive = state.inner = null;
|
||||
return this.token(stream, state);
|
||||
}
|
||||
var found = curInner.close ? indexOf(oldContent, curInner.close, stream.pos, curInner.parseDelimiters) : -1;
|
||||
if (found == stream.pos && !curInner.parseDelimiters) {
|
||||
stream.match(curInner.close);
|
||||
state.innerActive = state.inner = null;
|
||||
return curInner.delimStyle && (curInner.delimStyle + " " + curInner.delimStyle + "-close");
|
||||
}
|
||||
if (found > -1) stream.string = oldContent.slice(0, found);
|
||||
var innerToken = curInner.mode.token(stream, state.inner);
|
||||
if (found > -1) stream.string = oldContent;
|
||||
|
||||
if (found == stream.pos && curInner.parseDelimiters)
|
||||
state.innerActive = state.inner = null;
|
||||
|
||||
if (curInner.innerStyle) {
|
||||
if (innerToken) innerToken = innerToken + " " + curInner.innerStyle;
|
||||
else innerToken = curInner.innerStyle;
|
||||
}
|
||||
|
||||
return innerToken;
|
||||
}
|
||||
},
|
||||
|
||||
indent: function(state, textAfter) {
|
||||
var mode = state.innerActive ? state.innerActive.mode : outer;
|
||||
if (!mode.indent) return CodeMirror.Pass;
|
||||
return mode.indent(state.innerActive ? state.inner : state.outer, textAfter);
|
||||
},
|
||||
|
||||
blankLine: function(state) {
|
||||
var mode = state.innerActive ? state.innerActive.mode : outer;
|
||||
if (mode.blankLine) {
|
||||
mode.blankLine(state.innerActive ? state.inner : state.outer);
|
||||
}
|
||||
if (!state.innerActive) {
|
||||
for (var i = 0; i < others.length; ++i) {
|
||||
var other = others[i];
|
||||
if (other.open === "\n") {
|
||||
state.innerActive = other;
|
||||
state.inner = CodeMirror.startState(other.mode, mode.indent ? mode.indent(state.outer, "") : 0);
|
||||
}
|
||||
}
|
||||
} else if (state.innerActive.close === "\n") {
|
||||
state.innerActive = state.inner = null;
|
||||
}
|
||||
},
|
||||
|
||||
electricChars: outer.electricChars,
|
||||
|
||||
innerMode: function(state) {
|
||||
return state.inner ? {state: state.inner, mode: state.innerActive.mode} : {state: state.outer, mode: outer};
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
});
|
33
codemirror/addon/mode/multiplex_test.js
vendored
Normal file
33
codemirror/addon/mode/multiplex_test.js
vendored
Normal file
|
@ -0,0 +1,33 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function() {
|
||||
CodeMirror.defineMode("markdown_with_stex", function(){
|
||||
var inner = CodeMirror.getMode({}, "stex");
|
||||
var outer = CodeMirror.getMode({}, "markdown");
|
||||
|
||||
var innerOptions = {
|
||||
open: '$',
|
||||
close: '$',
|
||||
mode: inner,
|
||||
delimStyle: 'delim',
|
||||
innerStyle: 'inner'
|
||||
};
|
||||
|
||||
return CodeMirror.multiplexingMode(outer, innerOptions);
|
||||
});
|
||||
|
||||
var mode = CodeMirror.getMode({}, "markdown_with_stex");
|
||||
|
||||
function MT(name) {
|
||||
test.mode(
|
||||
name,
|
||||
mode,
|
||||
Array.prototype.slice.call(arguments, 1),
|
||||
'multiplexing');
|
||||
}
|
||||
|
||||
MT(
|
||||
"stexInsideMarkdown",
|
||||
"[strong **Equation:**] [delim&delim-open $][inner&tag \\pi][delim&delim-close $]");
|
||||
})();
|
90
codemirror/addon/mode/overlay.js
vendored
Normal file
90
codemirror/addon/mode/overlay.js
vendored
Normal file
|
@ -0,0 +1,90 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
// Utility function that allows modes to be combined. The mode given
|
||||
// as the base argument takes care of most of the normal mode
|
||||
// functionality, but a second (typically simple) mode is used, which
|
||||
// can override the style of text. Both modes get to parse all of the
|
||||
// text, but when both assign a non-null style to a piece of code, the
|
||||
// overlay wins, unless the combine argument was true and not overridden,
|
||||
// or state.overlay.combineTokens was true, in which case the styles are
|
||||
// combined.
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
CodeMirror.overlayMode = function(base, overlay, combine) {
|
||||
return {
|
||||
startState: function() {
|
||||
return {
|
||||
base: CodeMirror.startState(base),
|
||||
overlay: CodeMirror.startState(overlay),
|
||||
basePos: 0, baseCur: null,
|
||||
overlayPos: 0, overlayCur: null,
|
||||
streamSeen: null
|
||||
};
|
||||
},
|
||||
copyState: function(state) {
|
||||
return {
|
||||
base: CodeMirror.copyState(base, state.base),
|
||||
overlay: CodeMirror.copyState(overlay, state.overlay),
|
||||
basePos: state.basePos, baseCur: null,
|
||||
overlayPos: state.overlayPos, overlayCur: null
|
||||
};
|
||||
},
|
||||
|
||||
token: function(stream, state) {
|
||||
if (stream != state.streamSeen ||
|
||||
Math.min(state.basePos, state.overlayPos) < stream.start) {
|
||||
state.streamSeen = stream;
|
||||
state.basePos = state.overlayPos = stream.start;
|
||||
}
|
||||
|
||||
if (stream.start == state.basePos) {
|
||||
state.baseCur = base.token(stream, state.base);
|
||||
state.basePos = stream.pos;
|
||||
}
|
||||
if (stream.start == state.overlayPos) {
|
||||
stream.pos = stream.start;
|
||||
state.overlayCur = overlay.token(stream, state.overlay);
|
||||
state.overlayPos = stream.pos;
|
||||
}
|
||||
stream.pos = Math.min(state.basePos, state.overlayPos);
|
||||
|
||||
// state.overlay.combineTokens always takes precedence over combine,
|
||||
// unless set to null
|
||||
if (state.overlayCur == null) return state.baseCur;
|
||||
else if (state.baseCur != null &&
|
||||
state.overlay.combineTokens ||
|
||||
combine && state.overlay.combineTokens == null)
|
||||
return state.baseCur + " " + state.overlayCur;
|
||||
else return state.overlayCur;
|
||||
},
|
||||
|
||||
indent: base.indent && function(state, textAfter) {
|
||||
return base.indent(state.base, textAfter);
|
||||
},
|
||||
electricChars: base.electricChars,
|
||||
|
||||
innerMode: function(state) { return {state: state.base, mode: base}; },
|
||||
|
||||
blankLine: function(state) {
|
||||
var baseToken, overlayToken;
|
||||
if (base.blankLine) baseToken = base.blankLine(state.base);
|
||||
if (overlay.blankLine) overlayToken = overlay.blankLine(state.overlay);
|
||||
|
||||
return overlayToken == null ?
|
||||
baseToken :
|
||||
(combine && baseToken != null ? baseToken + " " + overlayToken : overlayToken);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
});
|
213
codemirror/addon/mode/simple.js
vendored
Normal file
213
codemirror/addon/mode/simple.js
vendored
Normal file
|
@ -0,0 +1,213 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
CodeMirror.defineSimpleMode = function(name, states) {
|
||||
CodeMirror.defineMode(name, function(config) {
|
||||
return CodeMirror.simpleMode(config, states);
|
||||
});
|
||||
};
|
||||
|
||||
CodeMirror.simpleMode = function(config, states) {
|
||||
ensureState(states, "start");
|
||||
var states_ = {}, meta = states.meta || {}, hasIndentation = false;
|
||||
for (var state in states) if (state != meta && states.hasOwnProperty(state)) {
|
||||
var list = states_[state] = [], orig = states[state];
|
||||
for (var i = 0; i < orig.length; i++) {
|
||||
var data = orig[i];
|
||||
list.push(new Rule(data, states));
|
||||
if (data.indent || data.dedent) hasIndentation = true;
|
||||
}
|
||||
}
|
||||
var mode = {
|
||||
startState: function() {
|
||||
return {state: "start", pending: null,
|
||||
local: null, localState: null,
|
||||
indent: hasIndentation ? [] : null};
|
||||
},
|
||||
copyState: function(state) {
|
||||
var s = {state: state.state, pending: state.pending,
|
||||
local: state.local, localState: null,
|
||||
indent: state.indent && state.indent.slice(0)};
|
||||
if (state.localState)
|
||||
s.localState = CodeMirror.copyState(state.local.mode, state.localState);
|
||||
if (state.stack)
|
||||
s.stack = state.stack.slice(0);
|
||||
for (var pers = state.persistentStates; pers; pers = pers.next)
|
||||
s.persistentStates = {mode: pers.mode,
|
||||
spec: pers.spec,
|
||||
state: pers.state == state.localState ? s.localState : CodeMirror.copyState(pers.mode, pers.state),
|
||||
next: s.persistentStates};
|
||||
return s;
|
||||
},
|
||||
token: tokenFunction(states_, config),
|
||||
innerMode: function(state) { return state.local && {mode: state.local.mode, state: state.localState}; },
|
||||
indent: indentFunction(states_, meta)
|
||||
};
|
||||
if (meta) for (var prop in meta) if (meta.hasOwnProperty(prop))
|
||||
mode[prop] = meta[prop];
|
||||
return mode;
|
||||
};
|
||||
|
||||
function ensureState(states, name) {
|
||||
if (!states.hasOwnProperty(name))
|
||||
throw new Error("Undefined state " + name + " in simple mode");
|
||||
}
|
||||
|
||||
function toRegex(val, caret) {
|
||||
if (!val) return /(?:)/;
|
||||
var flags = "";
|
||||
if (val instanceof RegExp) {
|
||||
if (val.ignoreCase) flags = "i";
|
||||
val = val.source;
|
||||
} else {
|
||||
val = String(val);
|
||||
}
|
||||
return new RegExp((caret === false ? "" : "^") + "(?:" + val + ")", flags);
|
||||
}
|
||||
|
||||
function asToken(val) {
|
||||
if (!val) return null;
|
||||
if (typeof val == "string") return val.replace(/\./g, " ");
|
||||
var result = [];
|
||||
for (var i = 0; i < val.length; i++)
|
||||
result.push(val[i] && val[i].replace(/\./g, " "));
|
||||
return result;
|
||||
}
|
||||
|
||||
function Rule(data, states) {
|
||||
if (data.next || data.push) ensureState(states, data.next || data.push);
|
||||
this.regex = toRegex(data.regex);
|
||||
this.token = asToken(data.token);
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
function tokenFunction(states, config) {
|
||||
return function(stream, state) {
|
||||
if (state.pending) {
|
||||
var pend = state.pending.shift();
|
||||
if (state.pending.length == 0) state.pending = null;
|
||||
stream.pos += pend.text.length;
|
||||
return pend.token;
|
||||
}
|
||||
|
||||
if (state.local) {
|
||||
if (state.local.end && stream.match(state.local.end)) {
|
||||
var tok = state.local.endToken || null;
|
||||
state.local = state.localState = null;
|
||||
return tok;
|
||||
} else {
|
||||
var tok = state.local.mode.token(stream, state.localState), m;
|
||||
if (state.local.endScan && (m = state.local.endScan.exec(stream.current())))
|
||||
stream.pos = stream.start + m.index;
|
||||
return tok;
|
||||
}
|
||||
}
|
||||
|
||||
var curState = states[state.state];
|
||||
for (var i = 0; i < curState.length; i++) {
|
||||
var rule = curState[i];
|
||||
var matches = (!rule.data.sol || stream.sol()) && stream.match(rule.regex);
|
||||
if (matches) {
|
||||
if (rule.data.next) {
|
||||
state.state = rule.data.next;
|
||||
} else if (rule.data.push) {
|
||||
(state.stack || (state.stack = [])).push(state.state);
|
||||
state.state = rule.data.push;
|
||||
} else if (rule.data.pop && state.stack && state.stack.length) {
|
||||
state.state = state.stack.pop();
|
||||
}
|
||||
|
||||
if (rule.data.mode)
|
||||
enterLocalMode(config, state, rule.data.mode, rule.token);
|
||||
if (rule.data.indent)
|
||||
state.indent.push(stream.indentation() + config.indentUnit);
|
||||
if (rule.data.dedent)
|
||||
state.indent.pop();
|
||||
if (matches.length > 2) {
|
||||
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];
|
||||
} else {
|
||||
return rule.token;
|
||||
}
|
||||
}
|
||||
}
|
||||
stream.next();
|
||||
return null;
|
||||
};
|
||||
}
|
||||
|
||||
function cmp(a, b) {
|
||||
if (a === b) return true;
|
||||
if (!a || typeof a != "object" || !b || typeof b != "object") return false;
|
||||
var props = 0;
|
||||
for (var prop in a) if (a.hasOwnProperty(prop)) {
|
||||
if (!b.hasOwnProperty(prop) || !cmp(a[prop], b[prop])) return false;
|
||||
props++;
|
||||
}
|
||||
for (var prop in b) if (b.hasOwnProperty(prop)) props--;
|
||||
return props == 0;
|
||||
}
|
||||
|
||||
function enterLocalMode(config, state, spec, token) {
|
||||
var pers;
|
||||
if (spec.persistent) for (var p = state.persistentStates; p && !pers; p = p.next)
|
||||
if (spec.spec ? cmp(spec.spec, p.spec) : spec.mode == p.mode) pers = p;
|
||||
var mode = pers ? pers.mode : spec.mode || CodeMirror.getMode(config, spec.spec);
|
||||
var lState = pers ? pers.state : CodeMirror.startState(mode);
|
||||
if (spec.persistent && !pers)
|
||||
state.persistentStates = {mode: mode, spec: spec.spec, state: lState, next: state.persistentStates};
|
||||
|
||||
state.localState = lState;
|
||||
state.local = {mode: mode,
|
||||
end: spec.end && toRegex(spec.end),
|
||||
endScan: spec.end && spec.forceEnd !== false && toRegex(spec.end, false),
|
||||
endToken: token && token.join ? token[token.length - 1] : token};
|
||||
}
|
||||
|
||||
function indexOf(val, arr) {
|
||||
for (var i = 0; i < arr.length; i++) if (arr[i] === val) return true;
|
||||
}
|
||||
|
||||
function indentFunction(states, meta) {
|
||||
return function(state, textAfter, line) {
|
||||
if (state.local && state.local.mode.indent)
|
||||
return state.local.mode.indent(state.localState, textAfter, line);
|
||||
if (state.indent == null || state.local || meta.dontIndentStates && indexOf(state.state, meta.dontIndentStates) > -1)
|
||||
return CodeMirror.Pass;
|
||||
|
||||
var pos = state.indent.length - 1, rules = states[state.state];
|
||||
scan: for (;;) {
|
||||
for (var i = 0; i < rules.length; i++) {
|
||||
var rule = rules[i];
|
||||
if (rule.data.dedent && rule.data.dedentIfLineStart !== false) {
|
||||
var m = rule.regex.exec(textAfter);
|
||||
if (m && m[0]) {
|
||||
pos--;
|
||||
if (rule.next || rule.push) rules = states[rule.next || rule.push];
|
||||
textAfter = textAfter.slice(m[0].length);
|
||||
continue scan;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
return pos < 0 ? 0 : state.indent[pos];
|
||||
};
|
||||
}
|
||||
});
|
40
codemirror/addon/runmode/colorize.js
vendored
Normal file
40
codemirror/addon/runmode/colorize.js
vendored
Normal file
|
@ -0,0 +1,40 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"), require("./runmode"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror", "./runmode"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
var isBlock = /^(p|li|div|h\\d|pre|blockquote|td)$/;
|
||||
|
||||
function textContent(node, out) {
|
||||
if (node.nodeType == 3) return out.push(node.nodeValue);
|
||||
for (var ch = node.firstChild; ch; ch = ch.nextSibling) {
|
||||
textContent(ch, out);
|
||||
if (isBlock.test(node.nodeType)) out.push("\n");
|
||||
}
|
||||
}
|
||||
|
||||
CodeMirror.colorize = function(collection, defaultMode) {
|
||||
if (!collection) collection = document.body.getElementsByTagName("pre");
|
||||
|
||||
for (var i = 0; i < collection.length; ++i) {
|
||||
var node = collection[i];
|
||||
var mode = node.getAttribute("data-lang") || defaultMode;
|
||||
if (!mode) continue;
|
||||
|
||||
var text = [];
|
||||
textContent(node, text);
|
||||
node.innerHTML = "";
|
||||
CodeMirror.runMode(text.join(""), mode, node);
|
||||
|
||||
node.className += " cm-s-default";
|
||||
}
|
||||
};
|
||||
});
|
157
codemirror/addon/runmode/runmode-standalone.js
vendored
Normal file
157
codemirror/addon/runmode/runmode-standalone.js
vendored
Normal file
|
@ -0,0 +1,157 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
window.CodeMirror = {};
|
||||
|
||||
(function() {
|
||||
"use strict";
|
||||
|
||||
function splitLines(string){ return string.split(/\r?\n|\r/); };
|
||||
|
||||
function StringStream(string) {
|
||||
this.pos = this.start = 0;
|
||||
this.string = string;
|
||||
this.lineStart = 0;
|
||||
}
|
||||
StringStream.prototype = {
|
||||
eol: function() {return this.pos >= this.string.length;},
|
||||
sol: function() {return this.pos == 0;},
|
||||
peek: function() {return this.string.charAt(this.pos) || null;},
|
||||
next: function() {
|
||||
if (this.pos < this.string.length)
|
||||
return this.string.charAt(this.pos++);
|
||||
},
|
||||
eat: function(match) {
|
||||
var ch = this.string.charAt(this.pos);
|
||||
if (typeof match == "string") var ok = ch == match;
|
||||
else var ok = ch && (match.test ? match.test(ch) : match(ch));
|
||||
if (ok) {++this.pos; return ch;}
|
||||
},
|
||||
eatWhile: function(match) {
|
||||
var start = this.pos;
|
||||
while (this.eat(match)){}
|
||||
return this.pos > start;
|
||||
},
|
||||
eatSpace: function() {
|
||||
var start = this.pos;
|
||||
while (/[\s\u00a0]/.test(this.string.charAt(this.pos))) ++this.pos;
|
||||
return this.pos > start;
|
||||
},
|
||||
skipToEnd: function() {this.pos = this.string.length;},
|
||||
skipTo: function(ch) {
|
||||
var found = this.string.indexOf(ch, this.pos);
|
||||
if (found > -1) {this.pos = found; return true;}
|
||||
},
|
||||
backUp: function(n) {this.pos -= n;},
|
||||
column: function() {return this.start - this.lineStart;},
|
||||
indentation: function() {return 0;},
|
||||
match: function(pattern, consume, caseInsensitive) {
|
||||
if (typeof pattern == "string") {
|
||||
var cased = function(str) {return caseInsensitive ? str.toLowerCase() : str;};
|
||||
var substr = this.string.substr(this.pos, pattern.length);
|
||||
if (cased(substr) == cased(pattern)) {
|
||||
if (consume !== false) this.pos += pattern.length;
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
var match = this.string.slice(this.pos).match(pattern);
|
||||
if (match && match.index > 0) return null;
|
||||
if (match && consume !== false) this.pos += match[0].length;
|
||||
return match;
|
||||
}
|
||||
},
|
||||
current: function(){return this.string.slice(this.start, this.pos);},
|
||||
hideFirstChars: function(n, inner) {
|
||||
this.lineStart += n;
|
||||
try { return inner(); }
|
||||
finally { this.lineStart -= n; }
|
||||
}
|
||||
};
|
||||
CodeMirror.StringStream = StringStream;
|
||||
|
||||
CodeMirror.startState = function (mode, a1, a2) {
|
||||
return mode.startState ? mode.startState(a1, a2) : true;
|
||||
};
|
||||
|
||||
var modes = CodeMirror.modes = {}, mimeModes = CodeMirror.mimeModes = {};
|
||||
CodeMirror.defineMode = function (name, mode) {
|
||||
if (arguments.length > 2)
|
||||
mode.dependencies = Array.prototype.slice.call(arguments, 2);
|
||||
modes[name] = mode;
|
||||
};
|
||||
CodeMirror.defineMIME = function (mime, spec) { mimeModes[mime] = spec; };
|
||||
CodeMirror.resolveMode = function(spec) {
|
||||
if (typeof spec == "string" && mimeModes.hasOwnProperty(spec)) {
|
||||
spec = mimeModes[spec];
|
||||
} else if (spec && typeof spec.name == "string" && mimeModes.hasOwnProperty(spec.name)) {
|
||||
spec = mimeModes[spec.name];
|
||||
}
|
||||
if (typeof spec == "string") return {name: spec};
|
||||
else return spec || {name: "null"};
|
||||
};
|
||||
CodeMirror.getMode = function (options, spec) {
|
||||
spec = CodeMirror.resolveMode(spec);
|
||||
var mfactory = modes[spec.name];
|
||||
if (!mfactory) throw new Error("Unknown mode: " + spec);
|
||||
return mfactory(options, spec);
|
||||
};
|
||||
CodeMirror.registerHelper = CodeMirror.registerGlobalHelper = Math.min;
|
||||
CodeMirror.defineMode("null", function() {
|
||||
return {token: function(stream) {stream.skipToEnd();}};
|
||||
});
|
||||
CodeMirror.defineMIME("text/plain", "null");
|
||||
|
||||
CodeMirror.runMode = function (string, modespec, callback, options) {
|
||||
var mode = CodeMirror.getMode({ indentUnit: 2 }, modespec);
|
||||
|
||||
if (callback.nodeType == 1) {
|
||||
var tabSize = (options && options.tabSize) || 4;
|
||||
var node = callback, col = 0;
|
||||
node.innerHTML = "";
|
||||
callback = function (text, style) {
|
||||
if (text == "\n") {
|
||||
node.appendChild(document.createElement("br"));
|
||||
col = 0;
|
||||
return;
|
||||
}
|
||||
var content = "";
|
||||
// replace tabs
|
||||
for (var pos = 0; ;) {
|
||||
var idx = text.indexOf("\t", pos);
|
||||
if (idx == -1) {
|
||||
content += text.slice(pos);
|
||||
col += text.length - pos;
|
||||
break;
|
||||
} else {
|
||||
col += idx - pos;
|
||||
content += text.slice(pos, idx);
|
||||
var size = tabSize - col % tabSize;
|
||||
col += size;
|
||||
for (var i = 0; i < size; ++i) content += " ";
|
||||
pos = idx + 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (style) {
|
||||
var sp = node.appendChild(document.createElement("span"));
|
||||
sp.className = "cm-" + style.replace(/ +/g, " cm-");
|
||||
sp.appendChild(document.createTextNode(content));
|
||||
} else {
|
||||
node.appendChild(document.createTextNode(content));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
var lines = splitLines(string), state = (options && options.state) || CodeMirror.startState(mode);
|
||||
for (var i = 0, e = lines.length; i < e; ++i) {
|
||||
if (i) callback("\n");
|
||||
var stream = new CodeMirror.StringStream(lines[i]);
|
||||
if (!stream.string && mode.blankLine) mode.blankLine(state);
|
||||
while (!stream.eol()) {
|
||||
var style = mode.token(stream, state);
|
||||
callback(stream.current(), style, i, stream.start, state);
|
||||
stream.start = stream.pos;
|
||||
}
|
||||
}
|
||||
};
|
||||
})();
|
72
codemirror/addon/runmode/runmode.js
vendored
Normal file
72
codemirror/addon/runmode/runmode.js
vendored
Normal file
|
@ -0,0 +1,72 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
CodeMirror.runMode = function(string, modespec, callback, options) {
|
||||
var mode = CodeMirror.getMode(CodeMirror.defaults, modespec);
|
||||
var ie = /MSIE \d/.test(navigator.userAgent);
|
||||
var ie_lt9 = ie && (document.documentMode == null || document.documentMode < 9);
|
||||
|
||||
if (callback.appendChild) {
|
||||
var tabSize = (options && options.tabSize) || CodeMirror.defaults.tabSize;
|
||||
var node = callback, col = 0;
|
||||
node.innerHTML = "";
|
||||
callback = function(text, style) {
|
||||
if (text == "\n") {
|
||||
// Emitting LF or CRLF on IE8 or earlier results in an incorrect display.
|
||||
// Emitting a carriage return makes everything ok.
|
||||
node.appendChild(document.createTextNode(ie_lt9 ? '\r' : text));
|
||||
col = 0;
|
||||
return;
|
||||
}
|
||||
var content = "";
|
||||
// replace tabs
|
||||
for (var pos = 0;;) {
|
||||
var idx = text.indexOf("\t", pos);
|
||||
if (idx == -1) {
|
||||
content += text.slice(pos);
|
||||
col += text.length - pos;
|
||||
break;
|
||||
} else {
|
||||
col += idx - pos;
|
||||
content += text.slice(pos, idx);
|
||||
var size = tabSize - col % tabSize;
|
||||
col += size;
|
||||
for (var i = 0; i < size; ++i) content += " ";
|
||||
pos = idx + 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (style) {
|
||||
var sp = node.appendChild(document.createElement("span"));
|
||||
sp.className = "cm-" + style.replace(/ +/g, " cm-");
|
||||
sp.appendChild(document.createTextNode(content));
|
||||
} else {
|
||||
node.appendChild(document.createTextNode(content));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
var lines = CodeMirror.splitLines(string), state = (options && options.state) || CodeMirror.startState(mode);
|
||||
for (var i = 0, e = lines.length; i < e; ++i) {
|
||||
if (i) callback("\n");
|
||||
var stream = new CodeMirror.StringStream(lines[i]);
|
||||
if (!stream.string && mode.blankLine) mode.blankLine(state);
|
||||
while (!stream.eol()) {
|
||||
var style = mode.token(stream, state);
|
||||
callback(stream.current(), style, i, stream.start, state);
|
||||
stream.start = stream.pos;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
});
|
179
codemirror/addon/runmode/runmode.node.js
vendored
Normal file
179
codemirror/addon/runmode/runmode.node.js
vendored
Normal file
|
@ -0,0 +1,179 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
/* Just enough of CodeMirror to run runMode under node.js */
|
||||
|
||||
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) {
|
||||
if (end == null) {
|
||||
end = string.search(/[^\s\u00a0]/);
|
||||
if (end == -1) end = string.length;
|
||||
}
|
||||
for (var i = startIndex || 0, n = startValue || 0;;) {
|
||||
var nextTab = string.indexOf("\t", i);
|
||||
if (nextTab < 0 || nextTab >= end)
|
||||
return n + (end - i);
|
||||
n += nextTab - i;
|
||||
n += tabSize - (n % tabSize);
|
||||
i = nextTab + 1;
|
||||
}
|
||||
};
|
||||
|
||||
function StringStream(string, tabSize) {
|
||||
this.pos = this.start = 0;
|
||||
this.string = string;
|
||||
this.tabSize = tabSize || 8;
|
||||
this.lastColumnPos = this.lastColumnValue = 0;
|
||||
this.lineStart = 0;
|
||||
};
|
||||
|
||||
StringStream.prototype = {
|
||||
eol: function() {return this.pos >= this.string.length;},
|
||||
sol: function() {return this.pos == this.lineStart;},
|
||||
peek: function() {return this.string.charAt(this.pos) || undefined;},
|
||||
next: function() {
|
||||
if (this.pos < this.string.length)
|
||||
return this.string.charAt(this.pos++);
|
||||
},
|
||||
eat: function(match) {
|
||||
var ch = this.string.charAt(this.pos);
|
||||
if (typeof match == "string") var ok = ch == match;
|
||||
else var ok = ch && (match.test ? match.test(ch) : match(ch));
|
||||
if (ok) {++this.pos; return ch;}
|
||||
},
|
||||
eatWhile: function(match) {
|
||||
var start = this.pos;
|
||||
while (this.eat(match)){}
|
||||
return this.pos > start;
|
||||
},
|
||||
eatSpace: function() {
|
||||
var start = this.pos;
|
||||
while (/[\s\u00a0]/.test(this.string.charAt(this.pos))) ++this.pos;
|
||||
return this.pos > start;
|
||||
},
|
||||
skipToEnd: function() {this.pos = this.string.length;},
|
||||
skipTo: function(ch) {
|
||||
var found = this.string.indexOf(ch, this.pos);
|
||||
if (found > -1) {this.pos = found; return true;}
|
||||
},
|
||||
backUp: function(n) {this.pos -= n;},
|
||||
column: function() {
|
||||
if (this.lastColumnPos < this.start) {
|
||||
this.lastColumnValue = countColumn(this.string, this.start, this.tabSize, this.lastColumnPos, this.lastColumnValue);
|
||||
this.lastColumnPos = this.start;
|
||||
}
|
||||
return this.lastColumnValue - (this.lineStart ? countColumn(this.string, this.lineStart, this.tabSize) : 0);
|
||||
},
|
||||
indentation: function() {
|
||||
return countColumn(this.string, null, this.tabSize) -
|
||||
(this.lineStart ? countColumn(this.string, this.lineStart, this.tabSize) : 0);
|
||||
},
|
||||
match: function(pattern, consume, caseInsensitive) {
|
||||
if (typeof pattern == "string") {
|
||||
var cased = function(str) {return caseInsensitive ? str.toLowerCase() : str;};
|
||||
var substr = this.string.substr(this.pos, pattern.length);
|
||||
if (cased(substr) == cased(pattern)) {
|
||||
if (consume !== false) this.pos += pattern.length;
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
var match = this.string.slice(this.pos).match(pattern);
|
||||
if (match && match.index > 0) return null;
|
||||
if (match && consume !== false) this.pos += match[0].length;
|
||||
return match;
|
||||
}
|
||||
},
|
||||
current: function(){return this.string.slice(this.start, this.pos);},
|
||||
hideFirstChars: function(n, inner) {
|
||||
this.lineStart += n;
|
||||
try { return inner(); }
|
||||
finally { this.lineStart -= n; }
|
||||
}
|
||||
};
|
||||
exports.StringStream = StringStream;
|
||||
|
||||
exports.startState = function(mode, a1, a2) {
|
||||
return mode.startState ? mode.startState(a1, a2) : true;
|
||||
};
|
||||
|
||||
var modes = exports.modes = {}, mimeModes = exports.mimeModes = {};
|
||||
exports.defineMode = function(name, mode) {
|
||||
if (arguments.length > 2)
|
||||
mode.dependencies = Array.prototype.slice.call(arguments, 2);
|
||||
modes[name] = mode;
|
||||
};
|
||||
exports.defineMIME = function(mime, spec) { mimeModes[mime] = spec; };
|
||||
|
||||
exports.defineMode("null", function() {
|
||||
return {token: function(stream) {stream.skipToEnd();}};
|
||||
});
|
||||
exports.defineMIME("text/plain", "null");
|
||||
|
||||
exports.resolveMode = function(spec) {
|
||||
if (typeof spec == "string" && mimeModes.hasOwnProperty(spec)) {
|
||||
spec = mimeModes[spec];
|
||||
} else if (spec && typeof spec.name == "string" && mimeModes.hasOwnProperty(spec.name)) {
|
||||
spec = mimeModes[spec.name];
|
||||
}
|
||||
if (typeof spec == "string") return {name: spec};
|
||||
else return spec || {name: "null"};
|
||||
};
|
||||
|
||||
function copyObj(obj, target, overwrite) {
|
||||
if (!target) target = {};
|
||||
for (var prop in obj)
|
||||
if (obj.hasOwnProperty(prop) && (overwrite !== false || !target.hasOwnProperty(prop)))
|
||||
target[prop] = obj[prop];
|
||||
return target;
|
||||
}
|
||||
|
||||
// This can be used to attach properties to mode objects from
|
||||
// outside the actual mode definition.
|
||||
var modeExtensions = exports.modeExtensions = {};
|
||||
exports.extendMode = function(mode, properties) {
|
||||
var exts = modeExtensions.hasOwnProperty(mode) ? modeExtensions[mode] : (modeExtensions[mode] = {});
|
||||
copyObj(properties, exts);
|
||||
};
|
||||
|
||||
exports.getMode = function(options, spec) {
|
||||
var spec = exports.resolveMode(spec);
|
||||
var mfactory = modes[spec.name];
|
||||
if (!mfactory) return exports.getMode(options, "text/plain");
|
||||
var modeObj = mfactory(options, spec);
|
||||
if (modeExtensions.hasOwnProperty(spec.name)) {
|
||||
var exts = modeExtensions[spec.name];
|
||||
for (var prop in exts) {
|
||||
if (!exts.hasOwnProperty(prop)) continue;
|
||||
if (modeObj.hasOwnProperty(prop)) modeObj["_" + prop] = modeObj[prop];
|
||||
modeObj[prop] = exts[prop];
|
||||
}
|
||||
}
|
||||
modeObj.name = spec.name;
|
||||
if (spec.helperType) modeObj.helperType = spec.helperType;
|
||||
if (spec.modeProps) for (var prop in spec.modeProps)
|
||||
modeObj[prop] = spec.modeProps[prop];
|
||||
|
||||
return modeObj;
|
||||
};
|
||||
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) {
|
||||
if (i) callback("\n");
|
||||
var stream = new exports.StringStream(lines[i]);
|
||||
if (!stream.string && mode.blankLine) mode.blankLine(state);
|
||||
while (!stream.eol()) {
|
||||
var style = mode.token(stream, state);
|
||||
callback(stream.current(), style, i, stream.start, state);
|
||||
stream.start = stream.pos;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
require.cache[require.resolve("../../lib/codemirror")] = require.cache[require.resolve("./runmode.node")];
|
||||
require.cache[require.resolve("../../addon/runmode/runmode")] = require.cache[require.resolve("./runmode.node")];
|
5
codemirror/addon/scroll/annotatescrollbar.js
vendored
5
codemirror/addon/scroll/annotatescrollbar.js
vendored
|
@ -51,7 +51,7 @@
|
|||
Annotation.prototype.computeScale = function() {
|
||||
var cm = this.cm;
|
||||
var hScale = (cm.getWrapperElement().clientHeight - cm.display.barHeight - this.buttonHeight * 2) /
|
||||
cm.heightAtLine(cm.lastLine() + 1, "local");
|
||||
cm.getScrollerElement().scrollHeight
|
||||
if (hScale != this.hScale) {
|
||||
this.hScale = hScale;
|
||||
return true;
|
||||
|
@ -100,6 +100,9 @@
|
|||
elt.style.cssText = "position: absolute; right: 0px; width: " + Math.max(cm.display.barWidth - 1, 2) + "px; top: "
|
||||
+ (top + this.buttonHeight) + "px; height: " + height + "px";
|
||||
elt.className = this.options.className;
|
||||
if (ann.id) {
|
||||
elt.setAttribute("annotation-id", ann.id);
|
||||
}
|
||||
}
|
||||
this.div.textContent = "";
|
||||
this.div.appendChild(frag);
|
||||
|
|
48
codemirror/addon/scroll/scrollpastend.js
vendored
Normal file
48
codemirror/addon/scroll/scrollpastend.js
vendored
Normal file
|
@ -0,0 +1,48 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
CodeMirror.defineOption("scrollPastEnd", false, function(cm, val, old) {
|
||||
if (old && old != CodeMirror.Init) {
|
||||
cm.off("change", onChange);
|
||||
cm.off("refresh", updateBottomMargin);
|
||||
cm.display.lineSpace.parentNode.style.paddingBottom = "";
|
||||
cm.state.scrollPastEndPadding = null;
|
||||
}
|
||||
if (val) {
|
||||
cm.on("change", onChange);
|
||||
cm.on("refresh", updateBottomMargin);
|
||||
updateBottomMargin(cm);
|
||||
}
|
||||
});
|
||||
|
||||
function onChange(cm, change) {
|
||||
if (CodeMirror.changeEnd(change).line == cm.lastLine())
|
||||
updateBottomMargin(cm);
|
||||
}
|
||||
|
||||
function updateBottomMargin(cm) {
|
||||
var padding = "";
|
||||
if (cm.lineCount() > 1) {
|
||||
var totalH = cm.display.scroller.clientHeight - 30,
|
||||
lastLineH = cm.getLineHandle(cm.lastLine()).height;
|
||||
padding = (totalH - lastLineH) + "px";
|
||||
}
|
||||
if (cm.state.scrollPastEndPadding != padding) {
|
||||
cm.state.scrollPastEndPadding = padding;
|
||||
cm.display.lineSpace.parentNode.style.paddingBottom = padding;
|
||||
cm.off("refresh", updateBottomMargin);
|
||||
cm.setSize();
|
||||
cm.on("refresh", updateBottomMargin);
|
||||
}
|
||||
}
|
||||
});
|
66
codemirror/addon/scroll/simplescrollbars.css
vendored
Normal file
66
codemirror/addon/scroll/simplescrollbars.css
vendored
Normal file
|
@ -0,0 +1,66 @@
|
|||
.CodeMirror-simplescroll-horizontal div, .CodeMirror-simplescroll-vertical div {
|
||||
position: absolute;
|
||||
background: #ccc;
|
||||
-moz-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
border: 1px solid #bbb;
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
||||
.CodeMirror-simplescroll-horizontal, .CodeMirror-simplescroll-vertical {
|
||||
position: absolute;
|
||||
z-index: 6;
|
||||
background: #eee;
|
||||
}
|
||||
|
||||
.CodeMirror-simplescroll-horizontal {
|
||||
bottom: 0; left: 0;
|
||||
height: 8px;
|
||||
}
|
||||
.CodeMirror-simplescroll-horizontal div {
|
||||
bottom: 0;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.CodeMirror-simplescroll-vertical {
|
||||
right: 0; top: 0;
|
||||
width: 8px;
|
||||
}
|
||||
.CodeMirror-simplescroll-vertical div {
|
||||
right: 0;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
|
||||
.CodeMirror-overlayscroll .CodeMirror-scrollbar-filler, .CodeMirror-overlayscroll .CodeMirror-gutter-filler {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.CodeMirror-overlayscroll-horizontal div, .CodeMirror-overlayscroll-vertical div {
|
||||
position: absolute;
|
||||
background: #bcd;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
.CodeMirror-overlayscroll-horizontal, .CodeMirror-overlayscroll-vertical {
|
||||
position: absolute;
|
||||
z-index: 6;
|
||||
}
|
||||
|
||||
.CodeMirror-overlayscroll-horizontal {
|
||||
bottom: 0; left: 0;
|
||||
height: 6px;
|
||||
}
|
||||
.CodeMirror-overlayscroll-horizontal div {
|
||||
bottom: 0;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.CodeMirror-overlayscroll-vertical {
|
||||
right: 0; top: 0;
|
||||
width: 6px;
|
||||
}
|
||||
.CodeMirror-overlayscroll-vertical div {
|
||||
right: 0;
|
||||
width: 100%;
|
||||
}
|
152
codemirror/addon/scroll/simplescrollbars.js
vendored
Normal file
152
codemirror/addon/scroll/simplescrollbars.js
vendored
Normal file
|
@ -0,0 +1,152 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
function Bar(cls, orientation, scroll) {
|
||||
this.orientation = orientation;
|
||||
this.scroll = scroll;
|
||||
this.screen = this.total = this.size = 1;
|
||||
this.pos = 0;
|
||||
|
||||
this.node = document.createElement("div");
|
||||
this.node.className = cls + "-" + orientation;
|
||||
this.inner = this.node.appendChild(document.createElement("div"));
|
||||
|
||||
var self = this;
|
||||
CodeMirror.on(this.inner, "mousedown", function(e) {
|
||||
if (e.which != 1) return;
|
||||
CodeMirror.e_preventDefault(e);
|
||||
var axis = self.orientation == "horizontal" ? "pageX" : "pageY";
|
||||
var start = e[axis], startpos = self.pos;
|
||||
function done() {
|
||||
CodeMirror.off(document, "mousemove", move);
|
||||
CodeMirror.off(document, "mouseup", done);
|
||||
}
|
||||
function move(e) {
|
||||
if (e.which != 1) return done();
|
||||
self.moveTo(startpos + (e[axis] - start) * (self.total / self.size));
|
||||
}
|
||||
CodeMirror.on(document, "mousemove", move);
|
||||
CodeMirror.on(document, "mouseup", done);
|
||||
});
|
||||
|
||||
CodeMirror.on(this.node, "click", function(e) {
|
||||
CodeMirror.e_preventDefault(e);
|
||||
var innerBox = self.inner.getBoundingClientRect(), where;
|
||||
if (self.orientation == "horizontal")
|
||||
where = e.clientX < innerBox.left ? -1 : e.clientX > innerBox.right ? 1 : 0;
|
||||
else
|
||||
where = e.clientY < innerBox.top ? -1 : e.clientY > innerBox.bottom ? 1 : 0;
|
||||
self.moveTo(self.pos + where * self.screen);
|
||||
});
|
||||
|
||||
function onWheel(e) {
|
||||
var moved = CodeMirror.wheelEventPixels(e)[self.orientation == "horizontal" ? "x" : "y"];
|
||||
var oldPos = self.pos;
|
||||
self.moveTo(self.pos + moved);
|
||||
if (self.pos != oldPos) CodeMirror.e_preventDefault(e);
|
||||
}
|
||||
CodeMirror.on(this.node, "mousewheel", onWheel);
|
||||
CodeMirror.on(this.node, "DOMMouseScroll", onWheel);
|
||||
}
|
||||
|
||||
Bar.prototype.setPos = function(pos, force) {
|
||||
if (pos < 0) pos = 0;
|
||||
if (pos > this.total - this.screen) pos = this.total - this.screen;
|
||||
if (!force && pos == this.pos) return false;
|
||||
this.pos = pos;
|
||||
this.inner.style[this.orientation == "horizontal" ? "left" : "top"] =
|
||||
(pos * (this.size / this.total)) + "px";
|
||||
return true
|
||||
};
|
||||
|
||||
Bar.prototype.moveTo = function(pos) {
|
||||
if (this.setPos(pos)) this.scroll(pos, this.orientation);
|
||||
}
|
||||
|
||||
var minButtonSize = 10;
|
||||
|
||||
Bar.prototype.update = function(scrollSize, clientSize, barSize) {
|
||||
var sizeChanged = this.screen != clientSize || this.total != scrollSize || this.size != barSize
|
||||
if (sizeChanged) {
|
||||
this.screen = clientSize;
|
||||
this.total = scrollSize;
|
||||
this.size = barSize;
|
||||
}
|
||||
|
||||
var buttonSize = this.screen * (this.size / this.total);
|
||||
if (buttonSize < minButtonSize) {
|
||||
this.size -= minButtonSize - buttonSize;
|
||||
buttonSize = minButtonSize;
|
||||
}
|
||||
this.inner.style[this.orientation == "horizontal" ? "width" : "height"] =
|
||||
buttonSize + "px";
|
||||
this.setPos(this.pos, sizeChanged);
|
||||
};
|
||||
|
||||
function SimpleScrollbars(cls, place, scroll) {
|
||||
this.addClass = cls;
|
||||
this.horiz = new Bar(cls, "horizontal", scroll);
|
||||
place(this.horiz.node);
|
||||
this.vert = new Bar(cls, "vertical", scroll);
|
||||
place(this.vert.node);
|
||||
this.width = null;
|
||||
}
|
||||
|
||||
SimpleScrollbars.prototype.update = function(measure) {
|
||||
if (this.width == null) {
|
||||
var style = window.getComputedStyle ? window.getComputedStyle(this.horiz.node) : this.horiz.node.currentStyle;
|
||||
if (style) this.width = parseInt(style.height);
|
||||
}
|
||||
var width = this.width || 0;
|
||||
|
||||
var needsH = measure.scrollWidth > measure.clientWidth + 1;
|
||||
var needsV = measure.scrollHeight > measure.clientHeight + 1;
|
||||
this.vert.node.style.display = needsV ? "block" : "none";
|
||||
this.horiz.node.style.display = needsH ? "block" : "none";
|
||||
|
||||
if (needsV) {
|
||||
this.vert.update(measure.scrollHeight, measure.clientHeight,
|
||||
measure.viewHeight - (needsH ? width : 0));
|
||||
this.vert.node.style.bottom = needsH ? width + "px" : "0";
|
||||
}
|
||||
if (needsH) {
|
||||
this.horiz.update(measure.scrollWidth, measure.clientWidth,
|
||||
measure.viewWidth - (needsV ? width : 0) - measure.barLeft);
|
||||
this.horiz.node.style.right = needsV ? width + "px" : "0";
|
||||
this.horiz.node.style.left = measure.barLeft + "px";
|
||||
}
|
||||
|
||||
return {right: needsV ? width : 0, bottom: needsH ? width : 0};
|
||||
};
|
||||
|
||||
SimpleScrollbars.prototype.setScrollTop = function(pos) {
|
||||
this.vert.setPos(pos);
|
||||
};
|
||||
|
||||
SimpleScrollbars.prototype.setScrollLeft = function(pos) {
|
||||
this.horiz.setPos(pos);
|
||||
};
|
||||
|
||||
SimpleScrollbars.prototype.clear = function() {
|
||||
var parent = this.horiz.node.parentNode;
|
||||
parent.removeChild(this.horiz.node);
|
||||
parent.removeChild(this.vert.node);
|
||||
};
|
||||
|
||||
CodeMirror.scrollbarModel.simple = function(place, scroll) {
|
||||
return new SimpleScrollbars("CodeMirror-simplescroll", place, scroll);
|
||||
};
|
||||
CodeMirror.scrollbarModel.overlay = function(place, scroll) {
|
||||
return new SimpleScrollbars("CodeMirror-overlayscroll", place, scroll);
|
||||
};
|
||||
});
|
49
codemirror/addon/search/jump-to-line.js
vendored
Normal file
49
codemirror/addon/search/jump-to-line.js
vendored
Normal file
|
@ -0,0 +1,49 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
// Defines jumpToLine command. Uses dialog.js if present.
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"), require("../dialog/dialog"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror", "../dialog/dialog"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
function dialog(cm, text, shortText, deflt, f) {
|
||||
if (cm.openDialog) cm.openDialog(text, f, {value: deflt, selectValueOnOpen: true});
|
||||
else f(prompt(shortText, deflt));
|
||||
}
|
||||
|
||||
var jumpDialog =
|
||||
'Jump to line: <input type="text" style="width: 10em" class="CodeMirror-search-field"/> <span style="color: #888" class="CodeMirror-search-hint">(Use line:column or scroll% syntax)</span>';
|
||||
|
||||
function interpretLine(cm, string) {
|
||||
var num = Number(string)
|
||||
if (/^[-+]/.test(string)) return cm.getCursor().line + num
|
||||
else return num - 1
|
||||
}
|
||||
|
||||
CodeMirror.commands.jumpToLine = function(cm) {
|
||||
var cur = cm.getCursor();
|
||||
dialog(cm, jumpDialog, "Jump to line:", (cur.line + 1) + ":" + cur.ch, function(posStr) {
|
||||
if (!posStr) return;
|
||||
|
||||
var match;
|
||||
if (match = /^\s*([\+\-]?\d+)\s*\:\s*(\d+)\s*$/.exec(posStr)) {
|
||||
cm.setCursor(interpretLine(cm, match[1]), Number(match[2]))
|
||||
} else if (match = /^\s*([\+\-]?\d+(\.\d+)?)\%\s*/.exec(posStr)) {
|
||||
var line = Math.round(cm.lineCount() * Number(match[1]) / 100);
|
||||
if (/^[-+]/.test(match[1])) line = cur.line + line + 1;
|
||||
cm.setCursor(line - 1, cur.ch);
|
||||
} else if (match = /^\s*\:?\s*([\+\-]?\d+)\s*/.exec(posStr)) {
|
||||
cm.setCursor(interpretLine(cm, match[1]), cur.ch);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
CodeMirror.keyMap["default"]["Alt-G"] = "jumpToLine";
|
||||
});
|
165
codemirror/addon/search/match-highlighter.js
vendored
Normal file
165
codemirror/addon/search/match-highlighter.js
vendored
Normal file
|
@ -0,0 +1,165 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
// Highlighting text that matches the selection
|
||||
//
|
||||
// Defines an option highlightSelectionMatches, which, when enabled,
|
||||
// will style strings that match the selection throughout the
|
||||
// document.
|
||||
//
|
||||
// The option can be set to true to simply enable it, or to a
|
||||
// {minChars, style, wordsOnly, showToken, delay} object to explicitly
|
||||
// configure it. minChars is the minimum amount of characters that should be
|
||||
// selected for the behavior to occur, and style is the token style to
|
||||
// apply to the matches. This will be prefixed by "cm-" to create an
|
||||
// actual CSS class name. If wordsOnly is enabled, the matches will be
|
||||
// highlighted only if the selected text is a word. showToken, when enabled,
|
||||
// will cause the current token to be highlighted when nothing is selected.
|
||||
// delay is used to specify how much time to wait, in milliseconds, before
|
||||
// highlighting the matches. If annotateScrollbar is enabled, the occurences
|
||||
// will be highlighted on the scrollbar via the matchesonscrollbar addon.
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"), require("./matchesonscrollbar"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror", "./matchesonscrollbar"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
var defaults = {
|
||||
style: "matchhighlight",
|
||||
minChars: 2,
|
||||
delay: 100,
|
||||
wordsOnly: false,
|
||||
annotateScrollbar: false,
|
||||
showToken: false,
|
||||
trim: true
|
||||
}
|
||||
|
||||
function State(options) {
|
||||
this.options = {}
|
||||
for (var name in defaults)
|
||||
this.options[name] = (options && options.hasOwnProperty(name) ? options : defaults)[name]
|
||||
this.overlay = this.timeout = null;
|
||||
this.matchesonscroll = null;
|
||||
this.active = false;
|
||||
}
|
||||
|
||||
CodeMirror.defineOption("highlightSelectionMatches", false, function(cm, val, old) {
|
||||
if (old && old != CodeMirror.Init) {
|
||||
removeOverlay(cm);
|
||||
clearTimeout(cm.state.matchHighlighter.timeout);
|
||||
cm.state.matchHighlighter = null;
|
||||
cm.off("cursorActivity", cursorActivity);
|
||||
cm.off("focus", onFocus)
|
||||
}
|
||||
if (val) {
|
||||
var state = cm.state.matchHighlighter = new State(val);
|
||||
if (cm.hasFocus()) {
|
||||
state.active = true
|
||||
highlightMatches(cm)
|
||||
} else {
|
||||
cm.on("focus", onFocus)
|
||||
}
|
||||
cm.on("cursorActivity", cursorActivity);
|
||||
}
|
||||
});
|
||||
|
||||
function cursorActivity(cm) {
|
||||
var state = cm.state.matchHighlighter;
|
||||
if (state.active || cm.hasFocus()) scheduleHighlight(cm, state)
|
||||
}
|
||||
|
||||
function onFocus(cm) {
|
||||
var state = cm.state.matchHighlighter
|
||||
if (!state.active) {
|
||||
state.active = true
|
||||
scheduleHighlight(cm, state)
|
||||
}
|
||||
}
|
||||
|
||||
function scheduleHighlight(cm, state) {
|
||||
clearTimeout(state.timeout);
|
||||
state.timeout = setTimeout(function() {highlightMatches(cm);}, state.options.delay);
|
||||
}
|
||||
|
||||
function addOverlay(cm, query, hasBoundary, style) {
|
||||
var state = cm.state.matchHighlighter;
|
||||
cm.addOverlay(state.overlay = makeOverlay(query, hasBoundary, style));
|
||||
if (state.options.annotateScrollbar && cm.showMatchesOnScrollbar) {
|
||||
var searchFor = hasBoundary ? new RegExp("\\b" + query + "\\b") : query;
|
||||
state.matchesonscroll = cm.showMatchesOnScrollbar(searchFor, false,
|
||||
{className: "CodeMirror-selection-highlight-scrollbar"});
|
||||
}
|
||||
}
|
||||
|
||||
function removeOverlay(cm) {
|
||||
var state = cm.state.matchHighlighter;
|
||||
if (state.overlay) {
|
||||
cm.removeOverlay(state.overlay);
|
||||
state.overlay = null;
|
||||
if (state.matchesonscroll) {
|
||||
state.matchesonscroll.clear();
|
||||
state.matchesonscroll = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function highlightMatches(cm) {
|
||||
cm.operation(function() {
|
||||
var state = cm.state.matchHighlighter;
|
||||
removeOverlay(cm);
|
||||
if (!cm.somethingSelected() && state.options.showToken) {
|
||||
var re = state.options.showToken === true ? /[\w$]/ : state.options.showToken;
|
||||
var cur = cm.getCursor(), line = cm.getLine(cur.line), start = cur.ch, end = start;
|
||||
while (start && re.test(line.charAt(start - 1))) --start;
|
||||
while (end < line.length && re.test(line.charAt(end))) ++end;
|
||||
if (start < end)
|
||||
addOverlay(cm, line.slice(start, end), re, state.options.style);
|
||||
return;
|
||||
}
|
||||
var from = cm.getCursor("from"), to = cm.getCursor("to");
|
||||
if (from.line != to.line) return;
|
||||
if (state.options.wordsOnly && !isWord(cm, from, to)) return;
|
||||
var selection = cm.getRange(from, to)
|
||||
if (state.options.trim) selection = selection.replace(/^\s+|\s+$/g, "")
|
||||
if (selection.length >= state.options.minChars)
|
||||
addOverlay(cm, selection, false, state.options.style);
|
||||
});
|
||||
}
|
||||
|
||||
function isWord(cm, from, to) {
|
||||
var str = cm.getRange(from, to);
|
||||
if (str.match(/^\w+$/) !== null) {
|
||||
if (from.ch > 0) {
|
||||
var pos = {line: from.line, ch: from.ch - 1};
|
||||
var chr = cm.getRange(pos, from);
|
||||
if (chr.match(/\W/) === null) return false;
|
||||
}
|
||||
if (to.ch < cm.getLine(from.line).length) {
|
||||
var pos = {line: to.line, ch: to.ch + 1};
|
||||
var chr = cm.getRange(to, pos);
|
||||
if (chr.match(/\W/) === null) return false;
|
||||
}
|
||||
return true;
|
||||
} else return false;
|
||||
}
|
||||
|
||||
function boundariesAround(stream, re) {
|
||||
return (!stream.start || !re.test(stream.string.charAt(stream.start - 1))) &&
|
||||
(stream.pos == stream.string.length || !re.test(stream.string.charAt(stream.pos)));
|
||||
}
|
||||
|
||||
function makeOverlay(query, hasBoundary, style) {
|
||||
return {token: function(stream) {
|
||||
if (stream.match(query) &&
|
||||
(!hasBoundary || boundariesAround(stream, hasBoundary)))
|
||||
return style;
|
||||
stream.next();
|
||||
stream.skipTo(query.charAt(0)) || stream.skipToEnd();
|
||||
}};
|
||||
}
|
||||
});
|
94
codemirror/addon/search/search.js
vendored
94
codemirror/addon/search/search.js
vendored
|
@ -29,7 +29,7 @@
|
|||
query.lastIndex = stream.pos;
|
||||
var match = query.exec(stream.string);
|
||||
if (match && match.index == stream.pos) {
|
||||
stream.pos += match[0].length;
|
||||
stream.pos += match[0].length || 1;
|
||||
return "searching";
|
||||
} else if (match) {
|
||||
stream.pos = match.index;
|
||||
|
@ -57,12 +57,13 @@
|
|||
return cm.getSearchCursor(query, pos, queryCaseInsensitive(query));
|
||||
}
|
||||
|
||||
function persistentDialog(cm, text, deflt, f) {
|
||||
cm.openDialog(text, f, {
|
||||
function persistentDialog(cm, text, deflt, onEnter, onKeyDown) {
|
||||
cm.openDialog(text, onEnter, {
|
||||
value: deflt,
|
||||
selectValueOnOpen: true,
|
||||
closeOnEnter: false,
|
||||
onClose: function() { clearSearch(cm); }
|
||||
onClose: function() { clearSearch(cm); },
|
||||
onKeyDown: onKeyDown
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -76,11 +77,21 @@
|
|||
else if (confirm(shortText)) fs[0]();
|
||||
}
|
||||
|
||||
function parseString(string) {
|
||||
return string.replace(/\\(.)/g, function(_, ch) {
|
||||
if (ch == "n") return "\n"
|
||||
if (ch == "r") return "\r"
|
||||
return ch
|
||||
})
|
||||
}
|
||||
|
||||
function parseQuery(query) {
|
||||
var isRE = query.match(/^\/(.*)\/([a-z]*)$/);
|
||||
if (isRE) {
|
||||
try { query = new RegExp(isRE[1], isRE[2].indexOf("i") == -1 ? "" : "i"); }
|
||||
catch(e) {} // Not a regular expression after all, do a string search
|
||||
} else {
|
||||
query = parseString(query)
|
||||
}
|
||||
if (typeof query == "string" ? query == "" : query.test(""))
|
||||
query = /x^/;
|
||||
|
@ -102,17 +113,46 @@
|
|||
}
|
||||
}
|
||||
|
||||
function doSearch(cm, rev, persistent) {
|
||||
function doSearch(cm, rev, persistent, immediate) {
|
||||
var state = getSearchState(cm);
|
||||
if (state.query) return findNext(cm, rev);
|
||||
var q = cm.getSelection() || state.lastQuery;
|
||||
if (persistent && cm.openDialog) {
|
||||
persistentDialog(cm, queryDialog, q, function(query, event) {
|
||||
var hiding = null
|
||||
var searchNext = function(query, event) {
|
||||
CodeMirror.e_stop(event);
|
||||
if (!query) return;
|
||||
if (query != state.queryText) startSearch(cm, state, query);
|
||||
findNext(cm, event.shiftKey);
|
||||
if (query != state.queryText) {
|
||||
startSearch(cm, state, query);
|
||||
state.posFrom = state.posTo = cm.getCursor();
|
||||
}
|
||||
if (hiding) hiding.style.opacity = 1
|
||||
findNext(cm, event.shiftKey, function(_, to) {
|
||||
var dialog
|
||||
if (to.line < 3 && document.querySelector &&
|
||||
(dialog = cm.display.wrapper.querySelector(".CodeMirror-dialog")) &&
|
||||
dialog.getBoundingClientRect().bottom - 4 > cm.cursorCoords(to, "window").top)
|
||||
(hiding = dialog).style.opacity = .4
|
||||
})
|
||||
};
|
||||
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]
|
||||
if (cmd == "findNext" || cmd == "findPrev" ||
|
||||
cmd == "findPersistentNext" || cmd == "findPersistentPrev") {
|
||||
CodeMirror.e_stop(event);
|
||||
startSearch(cm, getSearchState(cm), query);
|
||||
cm.execCommand(cmd);
|
||||
} else if (cmd == "find" || cmd == "findPersistent") {
|
||||
CodeMirror.e_stop(event);
|
||||
searchNext(query, event);
|
||||
}
|
||||
});
|
||||
if (immediate && q) {
|
||||
startSearch(cm, state, q);
|
||||
findNext(cm, rev);
|
||||
}
|
||||
} else {
|
||||
dialog(cm, queryDialog, "Search for:", q, function(query) {
|
||||
if (query && !state.query) cm.operation(function() {
|
||||
|
@ -124,7 +164,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
function findNext(cm, rev) {cm.operation(function() {
|
||||
function findNext(cm, rev, callback) {cm.operation(function() {
|
||||
var state = getSearchState(cm);
|
||||
var cursor = getSearchCursor(cm, state.query, rev ? state.posFrom : state.posTo);
|
||||
if (!cursor.find(rev)) {
|
||||
|
@ -134,6 +174,7 @@
|
|||
cm.setSelection(cursor.from(), cursor.to());
|
||||
cm.scrollIntoView({from: cursor.from(), to: cursor.to()}, 20);
|
||||
state.posFrom = cursor.from(); state.posTo = cursor.to();
|
||||
if (callback) callback(cursor.from(), cursor.to())
|
||||
});}
|
||||
|
||||
function clearSearch(cm) {cm.operation(function() {
|
||||
|
@ -146,29 +187,35 @@
|
|||
});}
|
||||
|
||||
var replaceQueryDialog =
|
||||
'Replace: <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>';
|
||||
' <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>Stop</button>";
|
||||
var doReplaceConfirm = "Replace? <button>Yes</button> <button>No</button> <button>All</button> <button>Stop</button>";
|
||||
|
||||
function replaceAll(cm, query, text) {
|
||||
cm.operation(function() {
|
||||
for (var cursor = getSearchCursor(cm, query); cursor.findNext();) {
|
||||
if (typeof query != "string") {
|
||||
var match = cm.getRange(cursor.from(), cursor.to()).match(query);
|
||||
cursor.replace(text.replace(/\$(\d)/g, function(_, i) {return match[i];}));
|
||||
} else cursor.replace(text);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function replace(cm, all) {
|
||||
if (cm.getOption("readOnly")) return;
|
||||
var query = cm.getSelection() || getSearchState(cm).lastQuery;
|
||||
dialog(cm, replaceQueryDialog, "Replace:", query, function(query) {
|
||||
var dialogText = all ? "Replace all:" : "Replace:"
|
||||
dialog(cm, dialogText + replaceQueryDialog, dialogText, query, function(query) {
|
||||
if (!query) return;
|
||||
query = parseQuery(query);
|
||||
dialog(cm, replacementQueryDialog, "Replace with:", "", function(text) {
|
||||
text = parseString(text)
|
||||
if (all) {
|
||||
cm.operation(function() {
|
||||
for (var cursor = getSearchCursor(cm, query); cursor.findNext();) {
|
||||
if (typeof query != "string") {
|
||||
var match = cm.getRange(cursor.from(), cursor.to()).match(query);
|
||||
cursor.replace(text.replace(/\$(\d)/g, function(_, i) {return match[i];}));
|
||||
} else cursor.replace(text);
|
||||
}
|
||||
});
|
||||
replaceAll(cm, query, text)
|
||||
} else {
|
||||
clearSearch(cm);
|
||||
var cursor = getSearchCursor(cm, query, cm.getCursor());
|
||||
var cursor = getSearchCursor(cm, query, cm.getCursor("from"));
|
||||
var advance = function() {
|
||||
var start = cursor.from(), match;
|
||||
if (!(match = cursor.findNext())) {
|
||||
|
@ -179,7 +226,8 @@
|
|||
cm.setSelection(cursor.from(), cursor.to());
|
||||
cm.scrollIntoView({from: cursor.from(), to: cursor.to()});
|
||||
confirmDialog(cm, doReplaceConfirm, "Replace?",
|
||||
[function() {doReplace(match);}, advance]);
|
||||
[function() {doReplace(match);}, advance,
|
||||
function() {replaceAll(cm, query, text)}]);
|
||||
};
|
||||
var doReplace = function(match) {
|
||||
cursor.replace(typeof query == "string" ? text :
|
||||
|
@ -194,6 +242,8 @@
|
|||
|
||||
CodeMirror.commands.find = function(cm) {clearSearch(cm); doSearch(cm);};
|
||||
CodeMirror.commands.findPersistent = function(cm) {clearSearch(cm); doSearch(cm, false, true);};
|
||||
CodeMirror.commands.findPersistentNext = function(cm) {doSearch(cm, false, true, true);};
|
||||
CodeMirror.commands.findPersistentPrev = function(cm) {doSearch(cm, true, true, true);};
|
||||
CodeMirror.commands.findNext = doSearch;
|
||||
CodeMirror.commands.findPrev = function(cm) {doSearch(cm, true);};
|
||||
CodeMirror.commands.clearSearch = clearSearch;
|
||||
|
|
27
codemirror/addon/selection/active-line.js
vendored
27
codemirror/addon/selection/active-line.js
vendored
|
@ -1,12 +1,6 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
// Because sometimes you need to style the cursor's line.
|
||||
//
|
||||
// Adds an option 'styleActiveLine' which, when enabled, gives the
|
||||
// active line's wrapping <div> the CSS class "CodeMirror-activeline",
|
||||
// and gives its background <div> the class "CodeMirror-activeline-background".
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"));
|
||||
|
@ -18,24 +12,28 @@
|
|||
"use strict";
|
||||
var WRAP_CLASS = "CodeMirror-activeline";
|
||||
var BACK_CLASS = "CodeMirror-activeline-background";
|
||||
var GUTT_CLASS = "CodeMirror-activeline-gutter";
|
||||
|
||||
CodeMirror.defineOption("styleActiveLine", false, function(cm, val, old) {
|
||||
var prev = old && old != CodeMirror.Init;
|
||||
if (val && !prev) {
|
||||
cm.state.activeLines = [];
|
||||
updateActiveLines(cm, cm.listSelections());
|
||||
cm.on("beforeSelectionChange", selectionChange);
|
||||
} else if (!val && prev) {
|
||||
var prev = old == CodeMirror.Init ? false : old;
|
||||
if (val == prev) return
|
||||
if (prev) {
|
||||
cm.off("beforeSelectionChange", selectionChange);
|
||||
clearActiveLines(cm);
|
||||
delete cm.state.activeLines;
|
||||
}
|
||||
if (val) {
|
||||
cm.state.activeLines = [];
|
||||
updateActiveLines(cm, cm.listSelections());
|
||||
cm.on("beforeSelectionChange", selectionChange);
|
||||
}
|
||||
});
|
||||
|
||||
function clearActiveLines(cm) {
|
||||
for (var i = 0; i < cm.state.activeLines.length; i++) {
|
||||
cm.removeLineClass(cm.state.activeLines[i], "wrap", WRAP_CLASS);
|
||||
cm.removeLineClass(cm.state.activeLines[i], "background", BACK_CLASS);
|
||||
cm.removeLineClass(cm.state.activeLines[i], "gutter", GUTT_CLASS);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -50,7 +48,9 @@
|
|||
var active = [];
|
||||
for (var i = 0; i < ranges.length; i++) {
|
||||
var range = ranges[i];
|
||||
if (!range.empty()) continue;
|
||||
var option = cm.getOption("styleActiveLine");
|
||||
if (typeof option == "object" && option.nonEmpty ? range.anchor.line != range.head.line : !range.empty())
|
||||
continue
|
||||
var line = cm.getLineHandleVisualStart(range.head.line);
|
||||
if (active[active.length - 1] != line) active.push(line);
|
||||
}
|
||||
|
@ -60,6 +60,7 @@
|
|||
for (var i = 0; i < active.length; i++) {
|
||||
cm.addLineClass(active[i], "wrap", WRAP_CLASS);
|
||||
cm.addLineClass(active[i], "background", BACK_CLASS);
|
||||
cm.addLineClass(active[i], "gutter", GUTT_CLASS);
|
||||
}
|
||||
cm.state.activeLines = active;
|
||||
});
|
||||
|
|
118
codemirror/addon/selection/mark-selection.js
vendored
Normal file
118
codemirror/addon/selection/mark-selection.js
vendored
Normal file
|
@ -0,0 +1,118 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
// Because sometimes you need to mark the selected *text*.
|
||||
//
|
||||
// Adds an option 'styleSelectedText' which, when enabled, gives
|
||||
// selected text the CSS class given as option value, or
|
||||
// "CodeMirror-selectedtext" when the value is not a string.
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
CodeMirror.defineOption("styleSelectedText", false, function(cm, val, old) {
|
||||
var prev = old && old != CodeMirror.Init;
|
||||
if (val && !prev) {
|
||||
cm.state.markedSelection = [];
|
||||
cm.state.markedSelectionStyle = typeof val == "string" ? val : "CodeMirror-selectedtext";
|
||||
reset(cm);
|
||||
cm.on("cursorActivity", onCursorActivity);
|
||||
cm.on("change", onChange);
|
||||
} else if (!val && prev) {
|
||||
cm.off("cursorActivity", onCursorActivity);
|
||||
cm.off("change", onChange);
|
||||
clear(cm);
|
||||
cm.state.markedSelection = cm.state.markedSelectionStyle = null;
|
||||
}
|
||||
});
|
||||
|
||||
function onCursorActivity(cm) {
|
||||
cm.operation(function() { update(cm); });
|
||||
}
|
||||
|
||||
function onChange(cm) {
|
||||
if (cm.state.markedSelection.length)
|
||||
cm.operation(function() { clear(cm); });
|
||||
}
|
||||
|
||||
var CHUNK_SIZE = 8;
|
||||
var Pos = CodeMirror.Pos;
|
||||
var cmp = CodeMirror.cmpPos;
|
||||
|
||||
function coverRange(cm, from, to, addAt) {
|
||||
if (cmp(from, to) == 0) return;
|
||||
var array = cm.state.markedSelection;
|
||||
var cls = cm.state.markedSelectionStyle;
|
||||
for (var line = from.line;;) {
|
||||
var start = line == from.line ? from : Pos(line, 0);
|
||||
var endLine = line + CHUNK_SIZE, atEnd = endLine >= to.line;
|
||||
var end = atEnd ? to : Pos(endLine, 0);
|
||||
var mark = cm.markText(start, end, {className: cls});
|
||||
if (addAt == null) array.push(mark);
|
||||
else array.splice(addAt++, 0, mark);
|
||||
if (atEnd) break;
|
||||
line = endLine;
|
||||
}
|
||||
}
|
||||
|
||||
function clear(cm) {
|
||||
var array = cm.state.markedSelection;
|
||||
for (var i = 0; i < array.length; ++i) array[i].clear();
|
||||
array.length = 0;
|
||||
}
|
||||
|
||||
function reset(cm) {
|
||||
clear(cm);
|
||||
var ranges = cm.listSelections();
|
||||
for (var i = 0; i < ranges.length; i++)
|
||||
coverRange(cm, ranges[i].from(), ranges[i].to());
|
||||
}
|
||||
|
||||
function update(cm) {
|
||||
if (!cm.somethingSelected()) return clear(cm);
|
||||
if (cm.listSelections().length > 1) return reset(cm);
|
||||
|
||||
var from = cm.getCursor("start"), to = cm.getCursor("end");
|
||||
|
||||
var array = cm.state.markedSelection;
|
||||
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 ||
|
||||
cmp(from, coverEnd.to) >= 0 || cmp(to, coverStart.from) <= 0)
|
||||
return reset(cm);
|
||||
|
||||
while (cmp(from, coverStart.from) > 0) {
|
||||
array.shift().clear();
|
||||
coverStart = array[0].find();
|
||||
}
|
||||
if (cmp(from, coverStart.from) < 0) {
|
||||
if (coverStart.to.line - from.line < CHUNK_SIZE) {
|
||||
array.shift().clear();
|
||||
coverRange(cm, from, coverStart.to, 0);
|
||||
} else {
|
||||
coverRange(cm, from, coverStart.from, 0);
|
||||
}
|
||||
}
|
||||
|
||||
while (cmp(to, coverEnd.to) < 0) {
|
||||
array.pop().clear();
|
||||
coverEnd = array[array.length - 1].find();
|
||||
}
|
||||
if (cmp(to, coverEnd.to) > 0) {
|
||||
if (to.line - coverEnd.from.line < CHUNK_SIZE) {
|
||||
array.pop().clear();
|
||||
coverRange(cm, coverEnd.from, to);
|
||||
} else {
|
||||
coverRange(cm, coverEnd.to, to);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
98
codemirror/addon/selection/selection-pointer.js
vendored
Normal file
98
codemirror/addon/selection/selection-pointer.js
vendored
Normal file
|
@ -0,0 +1,98 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
CodeMirror.defineOption("selectionPointer", false, function(cm, val) {
|
||||
var data = cm.state.selectionPointer;
|
||||
if (data) {
|
||||
CodeMirror.off(cm.getWrapperElement(), "mousemove", data.mousemove);
|
||||
CodeMirror.off(cm.getWrapperElement(), "mouseout", data.mouseout);
|
||||
CodeMirror.off(window, "scroll", data.windowScroll);
|
||||
cm.off("cursorActivity", reset);
|
||||
cm.off("scroll", reset);
|
||||
cm.state.selectionPointer = null;
|
||||
cm.display.lineDiv.style.cursor = "";
|
||||
}
|
||||
if (val) {
|
||||
data = cm.state.selectionPointer = {
|
||||
value: typeof val == "string" ? val : "default",
|
||||
mousemove: function(event) { mousemove(cm, event); },
|
||||
mouseout: function(event) { mouseout(cm, event); },
|
||||
windowScroll: function() { reset(cm); },
|
||||
rects: null,
|
||||
mouseX: null, mouseY: null,
|
||||
willUpdate: false
|
||||
};
|
||||
CodeMirror.on(cm.getWrapperElement(), "mousemove", data.mousemove);
|
||||
CodeMirror.on(cm.getWrapperElement(), "mouseout", data.mouseout);
|
||||
CodeMirror.on(window, "scroll", data.windowScroll);
|
||||
cm.on("cursorActivity", reset);
|
||||
cm.on("scroll", reset);
|
||||
}
|
||||
});
|
||||
|
||||
function mousemove(cm, event) {
|
||||
var data = cm.state.selectionPointer;
|
||||
if (event.buttons == null ? event.which : event.buttons) {
|
||||
data.mouseX = data.mouseY = null;
|
||||
} else {
|
||||
data.mouseX = event.clientX;
|
||||
data.mouseY = event.clientY;
|
||||
}
|
||||
scheduleUpdate(cm);
|
||||
}
|
||||
|
||||
function mouseout(cm, event) {
|
||||
if (!cm.getWrapperElement().contains(event.relatedTarget)) {
|
||||
var data = cm.state.selectionPointer;
|
||||
data.mouseX = data.mouseY = null;
|
||||
scheduleUpdate(cm);
|
||||
}
|
||||
}
|
||||
|
||||
function reset(cm) {
|
||||
cm.state.selectionPointer.rects = null;
|
||||
scheduleUpdate(cm);
|
||||
}
|
||||
|
||||
function scheduleUpdate(cm) {
|
||||
if (!cm.state.selectionPointer.willUpdate) {
|
||||
cm.state.selectionPointer.willUpdate = true;
|
||||
setTimeout(function() {
|
||||
update(cm);
|
||||
cm.state.selectionPointer.willUpdate = false;
|
||||
}, 50);
|
||||
}
|
||||
}
|
||||
|
||||
function update(cm) {
|
||||
var data = cm.state.selectionPointer;
|
||||
if (!data) return;
|
||||
if (data.rects == null && data.mouseX != null) {
|
||||
data.rects = [];
|
||||
if (cm.somethingSelected()) {
|
||||
for (var sel = cm.display.selectionDiv.firstChild; sel; sel = sel.nextSibling)
|
||||
data.rects.push(sel.getBoundingClientRect());
|
||||
}
|
||||
}
|
||||
var inside = false;
|
||||
if (data.mouseX != null) for (var i = 0; i < data.rects.length; i++) {
|
||||
var rect = data.rects[i];
|
||||
if (rect.left <= data.mouseX && rect.right >= data.mouseX &&
|
||||
rect.top <= data.mouseY && rect.bottom >= data.mouseY)
|
||||
inside = true;
|
||||
}
|
||||
var cursor = inside ? data.value : "";
|
||||
if (cm.display.lineDiv.style.cursor != cursor)
|
||||
cm.display.lineDiv.style.cursor = cursor;
|
||||
}
|
||||
});
|
87
codemirror/addon/tern/tern.css
vendored
Normal file
87
codemirror/addon/tern/tern.css
vendored
Normal file
|
@ -0,0 +1,87 @@
|
|||
.CodeMirror-Tern-completion {
|
||||
padding-left: 22px;
|
||||
position: relative;
|
||||
line-height: 1.5;
|
||||
}
|
||||
.CodeMirror-Tern-completion:before {
|
||||
position: absolute;
|
||||
left: 2px;
|
||||
bottom: 2px;
|
||||
border-radius: 50%;
|
||||
font-size: 12px;
|
||||
font-weight: bold;
|
||||
height: 15px;
|
||||
width: 15px;
|
||||
line-height: 16px;
|
||||
text-align: center;
|
||||
color: white;
|
||||
-moz-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.CodeMirror-Tern-completion-unknown:before {
|
||||
content: "?";
|
||||
background: #4bb;
|
||||
}
|
||||
.CodeMirror-Tern-completion-object:before {
|
||||
content: "O";
|
||||
background: #77c;
|
||||
}
|
||||
.CodeMirror-Tern-completion-fn:before {
|
||||
content: "F";
|
||||
background: #7c7;
|
||||
}
|
||||
.CodeMirror-Tern-completion-array:before {
|
||||
content: "A";
|
||||
background: #c66;
|
||||
}
|
||||
.CodeMirror-Tern-completion-number:before {
|
||||
content: "1";
|
||||
background: #999;
|
||||
}
|
||||
.CodeMirror-Tern-completion-string:before {
|
||||
content: "S";
|
||||
background: #999;
|
||||
}
|
||||
.CodeMirror-Tern-completion-bool:before {
|
||||
content: "B";
|
||||
background: #999;
|
||||
}
|
||||
|
||||
.CodeMirror-Tern-completion-guess {
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.CodeMirror-Tern-tooltip {
|
||||
border: 1px solid silver;
|
||||
border-radius: 3px;
|
||||
color: #444;
|
||||
padding: 2px 5px;
|
||||
font-size: 90%;
|
||||
font-family: monospace;
|
||||
background-color: white;
|
||||
white-space: pre-wrap;
|
||||
|
||||
max-width: 40em;
|
||||
position: absolute;
|
||||
z-index: 10;
|
||||
-webkit-box-shadow: 2px 3px 5px rgba(0,0,0,.2);
|
||||
-moz-box-shadow: 2px 3px 5px rgba(0,0,0,.2);
|
||||
box-shadow: 2px 3px 5px rgba(0,0,0,.2);
|
||||
|
||||
transition: opacity 1s;
|
||||
-moz-transition: opacity 1s;
|
||||
-webkit-transition: opacity 1s;
|
||||
-o-transition: opacity 1s;
|
||||
-ms-transition: opacity 1s;
|
||||
}
|
||||
|
||||
.CodeMirror-Tern-hint-doc {
|
||||
max-width: 25em;
|
||||
margin-top: -3px;
|
||||
}
|
||||
|
||||
.CodeMirror-Tern-fname { color: black; }
|
||||
.CodeMirror-Tern-farg { color: #70a; }
|
||||
.CodeMirror-Tern-farg-current { text-decoration: underline; }
|
||||
.CodeMirror-Tern-type { color: #07c; }
|
||||
.CodeMirror-Tern-fhint-guess { opacity: .7; }
|
701
codemirror/addon/tern/tern.js
vendored
Normal file
701
codemirror/addon/tern/tern.js
vendored
Normal file
|
@ -0,0 +1,701 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
// Glue code between CodeMirror and Tern.
|
||||
//
|
||||
// Create a CodeMirror.TernServer to wrap an actual Tern server,
|
||||
// register open documents (CodeMirror.Doc instances) with it, and
|
||||
// call its methods to activate the assisting functions that Tern
|
||||
// provides.
|
||||
//
|
||||
// Options supported (all optional):
|
||||
// * defs: An array of JSON definition data structures.
|
||||
// * plugins: An object mapping plugin names to configuration
|
||||
// options.
|
||||
// * getFile: A function(name, c) that can be used to access files in
|
||||
// the project that haven't been loaded yet. Simply do c(null) to
|
||||
// indicate that a file is not available.
|
||||
// * fileFilter: A function(value, docName, doc) that will be applied
|
||||
// to documents before passing them on to Tern.
|
||||
// * switchToDoc: A function(name, doc) that should, when providing a
|
||||
// multi-file view, switch the view or focus to the named file.
|
||||
// * showError: A function(editor, message) that can be used to
|
||||
// override the way errors are displayed.
|
||||
// * completionTip: Customize the content in tooltips for completions.
|
||||
// Is passed a single argument—the completion's data as returned by
|
||||
// Tern—and may return a string, DOM node, or null to indicate that
|
||||
// no tip should be shown. By default the docstring is shown.
|
||||
// * typeTip: Like completionTip, but for the tooltips shown for type
|
||||
// queries.
|
||||
// * responseFilter: A function(doc, query, request, error, data) that
|
||||
// will be applied to the Tern responses before treating them
|
||||
//
|
||||
//
|
||||
// It is possible to run the Tern server in a web worker by specifying
|
||||
// these additional options:
|
||||
// * useWorker: Set to true to enable web worker mode. You'll probably
|
||||
// want to feature detect the actual value you use here, for example
|
||||
// !!window.Worker.
|
||||
// * workerScript: The main script of the worker. Point this to
|
||||
// wherever you are hosting worker.js from this directory.
|
||||
// * workerDeps: An array of paths pointing (relative to workerScript)
|
||||
// to the Acorn and Tern libraries and any Tern plugins you want to
|
||||
// load. Or, if you minified those into a single script and included
|
||||
// them in the workerScript, simply leave this undefined.
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
// declare global: tern
|
||||
|
||||
CodeMirror.TernServer = function(options) {
|
||||
var self = this;
|
||||
this.options = options || {};
|
||||
var plugins = this.options.plugins || (this.options.plugins = {});
|
||||
if (!plugins.doc_comment) plugins.doc_comment = true;
|
||||
this.docs = Object.create(null);
|
||||
if (this.options.useWorker) {
|
||||
this.server = new WorkerServer(this);
|
||||
} else {
|
||||
this.server = new tern.Server({
|
||||
getFile: function(name, c) { return getFile(self, name, c); },
|
||||
async: true,
|
||||
defs: this.options.defs || [],
|
||||
plugins: plugins
|
||||
});
|
||||
}
|
||||
this.trackChange = function(doc, change) { trackChange(self, doc, change); };
|
||||
|
||||
this.cachedArgHints = null;
|
||||
this.activeArgHints = null;
|
||||
this.jumpStack = [];
|
||||
|
||||
this.getHint = function(cm, c) { return hint(self, cm, c); };
|
||||
this.getHint.async = true;
|
||||
};
|
||||
|
||||
CodeMirror.TernServer.prototype = {
|
||||
addDoc: function(name, doc) {
|
||||
var data = {doc: doc, name: name, changed: null};
|
||||
this.server.addFile(name, docValue(this, data));
|
||||
CodeMirror.on(doc, "change", this.trackChange);
|
||||
return this.docs[name] = data;
|
||||
},
|
||||
|
||||
delDoc: function(id) {
|
||||
var found = resolveDoc(this, id);
|
||||
if (!found) return;
|
||||
CodeMirror.off(found.doc, "change", this.trackChange);
|
||||
delete this.docs[found.name];
|
||||
this.server.delFile(found.name);
|
||||
},
|
||||
|
||||
hideDoc: function(id) {
|
||||
closeArgHints(this);
|
||||
var found = resolveDoc(this, id);
|
||||
if (found && found.changed) sendDoc(this, found);
|
||||
},
|
||||
|
||||
complete: function(cm) {
|
||||
cm.showHint({hint: this.getHint});
|
||||
},
|
||||
|
||||
showType: function(cm, pos, c) { showContextInfo(this, cm, pos, "type", c); },
|
||||
|
||||
showDocs: function(cm, pos, c) { showContextInfo(this, cm, pos, "documentation", c); },
|
||||
|
||||
updateArgHints: function(cm) { updateArgHints(this, cm); },
|
||||
|
||||
jumpToDef: function(cm) { jumpToDef(this, cm); },
|
||||
|
||||
jumpBack: function(cm) { jumpBack(this, cm); },
|
||||
|
||||
rename: function(cm) { rename(this, cm); },
|
||||
|
||||
selectName: function(cm) { selectName(this, cm); },
|
||||
|
||||
request: function (cm, query, c, pos) {
|
||||
var self = this;
|
||||
var doc = findDoc(this, cm.getDoc());
|
||||
var request = buildRequest(this, doc, query, pos);
|
||||
var extraOptions = request.query && this.options.queryOptions && this.options.queryOptions[request.query.type]
|
||||
if (extraOptions) for (var prop in extraOptions) request.query[prop] = extraOptions[prop];
|
||||
|
||||
this.server.request(request, function (error, data) {
|
||||
if (!error && self.options.responseFilter)
|
||||
data = self.options.responseFilter(doc, query, request, error, data);
|
||||
c(error, data);
|
||||
});
|
||||
},
|
||||
|
||||
destroy: function () {
|
||||
closeArgHints(this)
|
||||
if (this.worker) {
|
||||
this.worker.terminate();
|
||||
this.worker = null;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var Pos = CodeMirror.Pos;
|
||||
var cls = "CodeMirror-Tern-";
|
||||
var bigDoc = 250;
|
||||
|
||||
function getFile(ts, name, c) {
|
||||
var buf = ts.docs[name];
|
||||
if (buf)
|
||||
c(docValue(ts, buf));
|
||||
else if (ts.options.getFile)
|
||||
ts.options.getFile(name, c);
|
||||
else
|
||||
c(null);
|
||||
}
|
||||
|
||||
function findDoc(ts, doc, name) {
|
||||
for (var n in ts.docs) {
|
||||
var cur = ts.docs[n];
|
||||
if (cur.doc == doc) return cur;
|
||||
}
|
||||
if (!name) for (var i = 0;; ++i) {
|
||||
n = "[doc" + (i || "") + "]";
|
||||
if (!ts.docs[n]) { name = n; break; }
|
||||
}
|
||||
return ts.addDoc(name, doc);
|
||||
}
|
||||
|
||||
function resolveDoc(ts, id) {
|
||||
if (typeof id == "string") return ts.docs[id];
|
||||
if (id instanceof CodeMirror) id = id.getDoc();
|
||||
if (id instanceof CodeMirror.Doc) return findDoc(ts, id);
|
||||
}
|
||||
|
||||
function trackChange(ts, doc, change) {
|
||||
var data = findDoc(ts, doc);
|
||||
|
||||
var argHints = ts.cachedArgHints;
|
||||
if (argHints && argHints.doc == doc && cmpPos(argHints.start, change.to) >= 0)
|
||||
ts.cachedArgHints = null;
|
||||
|
||||
var changed = data.changed;
|
||||
if (changed == null)
|
||||
data.changed = changed = {from: change.from.line, to: change.from.line};
|
||||
var end = change.from.line + (change.text.length - 1);
|
||||
if (change.from.line < changed.to) changed.to = changed.to - (change.to.line - end);
|
||||
if (end >= changed.to) changed.to = end + 1;
|
||||
if (changed.from > change.from.line) changed.from = change.from.line;
|
||||
|
||||
if (doc.lineCount() > bigDoc && change.to - changed.from > 100) setTimeout(function() {
|
||||
if (data.changed && data.changed.to - data.changed.from > 100) sendDoc(ts, data);
|
||||
}, 200);
|
||||
}
|
||||
|
||||
function sendDoc(ts, doc) {
|
||||
ts.server.request({files: [{type: "full", name: doc.name, text: docValue(ts, doc)}]}, function(error) {
|
||||
if (error) window.console.error(error);
|
||||
else doc.changed = null;
|
||||
});
|
||||
}
|
||||
|
||||
// Completion
|
||||
|
||||
function hint(ts, cm, c) {
|
||||
ts.request(cm, {type: "completions", types: true, docs: true, urls: true}, function(error, data) {
|
||||
if (error) return showError(ts, cm, error);
|
||||
var completions = [], after = "";
|
||||
var from = data.start, to = data.end;
|
||||
if (cm.getRange(Pos(from.line, from.ch - 2), from) == "[\"" &&
|
||||
cm.getRange(to, Pos(to.line, to.ch + 2)) != "\"]")
|
||||
after = "\"]";
|
||||
|
||||
for (var i = 0; i < data.completions.length; ++i) {
|
||||
var completion = data.completions[i], className = typeToIcon(completion.type);
|
||||
if (data.guess) className += " " + cls + "guess";
|
||||
completions.push({text: completion.name + after,
|
||||
displayText: completion.displayName || completion.name,
|
||||
className: className,
|
||||
data: completion});
|
||||
}
|
||||
|
||||
var obj = {from: from, to: to, list: completions};
|
||||
var tooltip = null;
|
||||
CodeMirror.on(obj, "close", function() { remove(tooltip); });
|
||||
CodeMirror.on(obj, "update", function() { remove(tooltip); });
|
||||
CodeMirror.on(obj, "select", function(cur, node) {
|
||||
remove(tooltip);
|
||||
var content = ts.options.completionTip ? ts.options.completionTip(cur.data) : cur.data.doc;
|
||||
if (content) {
|
||||
tooltip = makeTooltip(node.parentNode.getBoundingClientRect().right + window.pageXOffset,
|
||||
node.getBoundingClientRect().top + window.pageYOffset, content);
|
||||
tooltip.className += " " + cls + "hint-doc";
|
||||
}
|
||||
});
|
||||
c(obj);
|
||||
});
|
||||
}
|
||||
|
||||
function typeToIcon(type) {
|
||||
var suffix;
|
||||
if (type == "?") suffix = "unknown";
|
||||
else if (type == "number" || type == "string" || type == "bool") suffix = type;
|
||||
else if (/^fn\(/.test(type)) suffix = "fn";
|
||||
else if (/^\[/.test(type)) suffix = "array";
|
||||
else suffix = "object";
|
||||
return cls + "completion " + cls + "completion-" + suffix;
|
||||
}
|
||||
|
||||
// Type queries
|
||||
|
||||
function showContextInfo(ts, cm, pos, queryName, c) {
|
||||
ts.request(cm, queryName, function(error, data) {
|
||||
if (error) return showError(ts, cm, error);
|
||||
if (ts.options.typeTip) {
|
||||
var tip = ts.options.typeTip(data);
|
||||
} else {
|
||||
var tip = elt("span", null, elt("strong", null, data.type || "not found"));
|
||||
if (data.doc)
|
||||
tip.appendChild(document.createTextNode(" — " + data.doc));
|
||||
if (data.url) {
|
||||
tip.appendChild(document.createTextNode(" "));
|
||||
var child = tip.appendChild(elt("a", null, "[docs]"));
|
||||
child.href = data.url;
|
||||
child.target = "_blank";
|
||||
}
|
||||
}
|
||||
tempTooltip(cm, tip, ts);
|
||||
if (c) c();
|
||||
}, pos);
|
||||
}
|
||||
|
||||
// Maintaining argument hints
|
||||
|
||||
function updateArgHints(ts, cm) {
|
||||
closeArgHints(ts);
|
||||
|
||||
if (cm.somethingSelected()) return;
|
||||
var state = cm.getTokenAt(cm.getCursor()).state;
|
||||
var inner = CodeMirror.innerMode(cm.getMode(), state);
|
||||
if (inner.mode.name != "javascript") return;
|
||||
var lex = inner.state.lexical;
|
||||
if (lex.info != "call") return;
|
||||
|
||||
var ch, argPos = lex.pos || 0, tabSize = cm.getOption("tabSize");
|
||||
for (var line = cm.getCursor().line, e = Math.max(0, line - 9), found = false; line >= e; --line) {
|
||||
var str = cm.getLine(line), extra = 0;
|
||||
for (var pos = 0;;) {
|
||||
var tab = str.indexOf("\t", pos);
|
||||
if (tab == -1) break;
|
||||
extra += tabSize - (tab + extra) % tabSize - 1;
|
||||
pos = tab + 1;
|
||||
}
|
||||
ch = lex.column - extra;
|
||||
if (str.charAt(ch) == "(") {found = true; break;}
|
||||
}
|
||||
if (!found) return;
|
||||
|
||||
var start = Pos(line, ch);
|
||||
var cache = ts.cachedArgHints;
|
||||
if (cache && cache.doc == cm.getDoc() && cmpPos(start, cache.start) == 0)
|
||||
return showArgHints(ts, cm, argPos);
|
||||
|
||||
ts.request(cm, {type: "type", preferFunction: true, end: start}, function(error, data) {
|
||||
if (error || !data.type || !(/^fn\(/).test(data.type)) return;
|
||||
ts.cachedArgHints = {
|
||||
start: start,
|
||||
type: parseFnType(data.type),
|
||||
name: data.exprName || data.name || "fn",
|
||||
guess: data.guess,
|
||||
doc: cm.getDoc()
|
||||
};
|
||||
showArgHints(ts, cm, argPos);
|
||||
});
|
||||
}
|
||||
|
||||
function showArgHints(ts, cm, pos) {
|
||||
closeArgHints(ts);
|
||||
|
||||
var cache = ts.cachedArgHints, tp = cache.type;
|
||||
var tip = elt("span", cache.guess ? cls + "fhint-guess" : null,
|
||||
elt("span", cls + "fname", cache.name), "(");
|
||||
for (var i = 0; i < tp.args.length; ++i) {
|
||||
if (i) tip.appendChild(document.createTextNode(", "));
|
||||
var arg = tp.args[i];
|
||||
tip.appendChild(elt("span", cls + "farg" + (i == pos ? " " + cls + "farg-current" : ""), arg.name || "?"));
|
||||
if (arg.type != "?") {
|
||||
tip.appendChild(document.createTextNode(":\u00a0"));
|
||||
tip.appendChild(elt("span", cls + "type", arg.type));
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
function parseFnType(text) {
|
||||
var args = [], pos = 3;
|
||||
|
||||
function skipMatching(upto) {
|
||||
var depth = 0, start = pos;
|
||||
for (;;) {
|
||||
var next = text.charAt(pos);
|
||||
if (upto.test(next) && !depth) return text.slice(start, pos);
|
||||
if (/[{\[\(]/.test(next)) ++depth;
|
||||
else if (/[}\]\)]/.test(next)) --depth;
|
||||
++pos;
|
||||
}
|
||||
}
|
||||
|
||||
// Parse arguments
|
||||
if (text.charAt(pos) != ")") for (;;) {
|
||||
var name = text.slice(pos).match(/^([^, \(\[\{]+): /);
|
||||
if (name) {
|
||||
pos += name[0].length;
|
||||
name = name[1];
|
||||
}
|
||||
args.push({name: name, type: skipMatching(/[\),]/)});
|
||||
if (text.charAt(pos) == ")") break;
|
||||
pos += 2;
|
||||
}
|
||||
|
||||
var rettype = text.slice(pos).match(/^\) -> (.*)$/);
|
||||
|
||||
return {args: args, rettype: rettype && rettype[1]};
|
||||
}
|
||||
|
||||
// Moving to the definition of something
|
||||
|
||||
function jumpToDef(ts, cm) {
|
||||
function inner(varName) {
|
||||
var req = {type: "definition", variable: varName || null};
|
||||
var doc = findDoc(ts, cm.getDoc());
|
||||
ts.server.request(buildRequest(ts, doc, req), function(error, data) {
|
||||
if (error) return showError(ts, cm, error);
|
||||
if (!data.file && data.url) { window.open(data.url); return; }
|
||||
|
||||
if (data.file) {
|
||||
var localDoc = ts.docs[data.file], found;
|
||||
if (localDoc && (found = findContext(localDoc.doc, data))) {
|
||||
ts.jumpStack.push({file: doc.name,
|
||||
start: cm.getCursor("from"),
|
||||
end: cm.getCursor("to")});
|
||||
moveTo(ts, doc, localDoc, found.start, found.end);
|
||||
return;
|
||||
}
|
||||
}
|
||||
showError(ts, cm, "Could not find a definition.");
|
||||
});
|
||||
}
|
||||
|
||||
if (!atInterestingExpression(cm))
|
||||
dialog(cm, "Jump to variable", function(name) { if (name) inner(name); });
|
||||
else
|
||||
inner();
|
||||
}
|
||||
|
||||
function jumpBack(ts, cm) {
|
||||
var pos = ts.jumpStack.pop(), doc = pos && ts.docs[pos.file];
|
||||
if (!doc) return;
|
||||
moveTo(ts, findDoc(ts, cm.getDoc()), doc, pos.start, pos.end);
|
||||
}
|
||||
|
||||
function moveTo(ts, curDoc, doc, start, end) {
|
||||
doc.doc.setSelection(start, end);
|
||||
if (curDoc != doc && ts.options.switchToDoc) {
|
||||
closeArgHints(ts);
|
||||
ts.options.switchToDoc(doc.name, doc.doc);
|
||||
}
|
||||
}
|
||||
|
||||
// The {line,ch} representation of positions makes this rather awkward.
|
||||
function findContext(doc, data) {
|
||||
var before = data.context.slice(0, data.contextOffset).split("\n");
|
||||
var startLine = data.start.line - (before.length - 1);
|
||||
var start = Pos(startLine, (before.length == 1 ? data.start.ch : doc.getLine(startLine).length) - before[0].length);
|
||||
|
||||
var text = doc.getLine(startLine).slice(start.ch);
|
||||
for (var cur = startLine + 1; cur < doc.lineCount() && text.length < data.context.length; ++cur)
|
||||
text += "\n" + doc.getLine(cur);
|
||||
if (text.slice(0, data.context.length) == data.context) return data;
|
||||
|
||||
var cursor = doc.getSearchCursor(data.context, 0, false);
|
||||
var nearest, nearestDist = Infinity;
|
||||
while (cursor.findNext()) {
|
||||
var from = cursor.from(), dist = Math.abs(from.line - start.line) * 10000;
|
||||
if (!dist) dist = Math.abs(from.ch - start.ch);
|
||||
if (dist < nearestDist) { nearest = from; nearestDist = dist; }
|
||||
}
|
||||
if (!nearest) return null;
|
||||
|
||||
if (before.length == 1)
|
||||
nearest.ch += before[0].length;
|
||||
else
|
||||
nearest = Pos(nearest.line + (before.length - 1), before[before.length - 1].length);
|
||||
if (data.start.line == data.end.line)
|
||||
var end = Pos(nearest.line, nearest.ch + (data.end.ch - data.start.ch));
|
||||
else
|
||||
var end = Pos(nearest.line + (data.end.line - data.start.line), data.end.ch);
|
||||
return {start: nearest, end: end};
|
||||
}
|
||||
|
||||
function atInterestingExpression(cm) {
|
||||
var pos = cm.getCursor("end"), tok = cm.getTokenAt(pos);
|
||||
if (tok.start < pos.ch && tok.type == "comment") return false;
|
||||
return /[\w)\]]/.test(cm.getLine(pos.line).slice(Math.max(pos.ch - 1, 0), pos.ch + 1));
|
||||
}
|
||||
|
||||
// Variable renaming
|
||||
|
||||
function rename(ts, cm) {
|
||||
var token = cm.getTokenAt(cm.getCursor());
|
||||
if (!/\w/.test(token.string)) return showError(ts, cm, "Not at a variable");
|
||||
dialog(cm, "New name for " + token.string, function(newName) {
|
||||
ts.request(cm, {type: "rename", newName: newName, fullDocs: true}, function(error, data) {
|
||||
if (error) return showError(ts, cm, error);
|
||||
applyChanges(ts, data.changes);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function selectName(ts, cm) {
|
||||
var name = findDoc(ts, cm.doc).name;
|
||||
ts.request(cm, {type: "refs"}, function(error, data) {
|
||||
if (error) return showError(ts, cm, error);
|
||||
var ranges = [], cur = 0;
|
||||
var curPos = cm.getCursor();
|
||||
for (var i = 0; i < data.refs.length; i++) {
|
||||
var ref = data.refs[i];
|
||||
if (ref.file == name) {
|
||||
ranges.push({anchor: ref.start, head: ref.end});
|
||||
if (cmpPos(curPos, ref.start) >= 0 && cmpPos(curPos, ref.end) <= 0)
|
||||
cur = ranges.length - 1;
|
||||
}
|
||||
}
|
||||
cm.setSelections(ranges, cur);
|
||||
});
|
||||
}
|
||||
|
||||
var nextChangeOrig = 0;
|
||||
function applyChanges(ts, changes) {
|
||||
var perFile = Object.create(null);
|
||||
for (var i = 0; i < changes.length; ++i) {
|
||||
var ch = changes[i];
|
||||
(perFile[ch.file] || (perFile[ch.file] = [])).push(ch);
|
||||
}
|
||||
for (var file in perFile) {
|
||||
var known = ts.docs[file], chs = perFile[file];;
|
||||
if (!known) continue;
|
||||
chs.sort(function(a, b) { return cmpPos(b.start, a.start); });
|
||||
var origin = "*rename" + (++nextChangeOrig);
|
||||
for (var i = 0; i < chs.length; ++i) {
|
||||
var ch = chs[i];
|
||||
known.doc.replaceRange(ch.text, ch.start, ch.end, origin);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Generic request-building helper
|
||||
|
||||
function buildRequest(ts, doc, query, pos) {
|
||||
var files = [], offsetLines = 0, allowFragments = !query.fullDocs;
|
||||
if (!allowFragments) delete query.fullDocs;
|
||||
if (typeof query == "string") query = {type: query};
|
||||
query.lineCharPositions = true;
|
||||
if (query.end == null) {
|
||||
query.end = pos || doc.doc.getCursor("end");
|
||||
if (doc.doc.somethingSelected())
|
||||
query.start = doc.doc.getCursor("start");
|
||||
}
|
||||
var startPos = query.start || query.end;
|
||||
|
||||
if (doc.changed) {
|
||||
if (doc.doc.lineCount() > bigDoc && allowFragments !== false &&
|
||||
doc.changed.to - doc.changed.from < 100 &&
|
||||
doc.changed.from <= startPos.line && doc.changed.to > query.end.line) {
|
||||
files.push(getFragmentAround(doc, startPos, query.end));
|
||||
query.file = "#0";
|
||||
var offsetLines = files[0].offsetLines;
|
||||
if (query.start != null) query.start = Pos(query.start.line - -offsetLines, query.start.ch);
|
||||
query.end = Pos(query.end.line - offsetLines, query.end.ch);
|
||||
} else {
|
||||
files.push({type: "full",
|
||||
name: doc.name,
|
||||
text: docValue(ts, doc)});
|
||||
query.file = doc.name;
|
||||
doc.changed = null;
|
||||
}
|
||||
} else {
|
||||
query.file = doc.name;
|
||||
}
|
||||
for (var name in ts.docs) {
|
||||
var cur = ts.docs[name];
|
||||
if (cur.changed && cur != doc) {
|
||||
files.push({type: "full", name: cur.name, text: docValue(ts, cur)});
|
||||
cur.changed = null;
|
||||
}
|
||||
}
|
||||
|
||||
return {query: query, files: files};
|
||||
}
|
||||
|
||||
function getFragmentAround(data, start, end) {
|
||||
var doc = data.doc;
|
||||
var minIndent = null, minLine = null, endLine, tabSize = 4;
|
||||
for (var p = start.line - 1, min = Math.max(0, p - 50); p >= min; --p) {
|
||||
var line = doc.getLine(p), fn = line.search(/\bfunction\b/);
|
||||
if (fn < 0) continue;
|
||||
var indent = CodeMirror.countColumn(line, null, tabSize);
|
||||
if (minIndent != null && minIndent <= indent) continue;
|
||||
minIndent = indent;
|
||||
minLine = p;
|
||||
}
|
||||
if (minLine == null) minLine = min;
|
||||
var max = Math.min(doc.lastLine(), end.line + 20);
|
||||
if (minIndent == null || minIndent == CodeMirror.countColumn(doc.getLine(start.line), null, tabSize))
|
||||
endLine = max;
|
||||
else for (endLine = end.line + 1; endLine < max; ++endLine) {
|
||||
var indent = CodeMirror.countColumn(doc.getLine(endLine), null, tabSize);
|
||||
if (indent <= minIndent) break;
|
||||
}
|
||||
var from = Pos(minLine, 0);
|
||||
|
||||
return {type: "part",
|
||||
name: data.name,
|
||||
offsetLines: from.line,
|
||||
text: doc.getRange(from, Pos(endLine, 0))};
|
||||
}
|
||||
|
||||
// Generic utilities
|
||||
|
||||
var cmpPos = CodeMirror.cmpPos;
|
||||
|
||||
function elt(tagname, cls /*, ... elts*/) {
|
||||
var e = document.createElement(tagname);
|
||||
if (cls) e.className = cls;
|
||||
for (var i = 2; i < arguments.length; ++i) {
|
||||
var elt = arguments[i];
|
||||
if (typeof elt == "string") elt = document.createTextNode(elt);
|
||||
e.appendChild(elt);
|
||||
}
|
||||
return e;
|
||||
}
|
||||
|
||||
function dialog(cm, text, f) {
|
||||
if (cm.openDialog)
|
||||
cm.openDialog(text + ": <input type=text>", f);
|
||||
else
|
||||
f(prompt(text, ""));
|
||||
}
|
||||
|
||||
// Tooltips
|
||||
|
||||
function tempTooltip(cm, content, ts) {
|
||||
if (cm.state.ternTooltip) remove(cm.state.ternTooltip);
|
||||
var where = cm.cursorCoords();
|
||||
var tip = cm.state.ternTooltip = makeTooltip(where.right + 1, where.bottom, content);
|
||||
function maybeClear() {
|
||||
old = true;
|
||||
if (!mouseOnTip) clear();
|
||||
}
|
||||
function clear() {
|
||||
cm.state.ternTooltip = null;
|
||||
if (!tip.parentNode) return;
|
||||
cm.off("cursorActivity", clear);
|
||||
cm.off('blur', clear);
|
||||
cm.off('scroll', clear);
|
||||
fadeOut(tip);
|
||||
}
|
||||
var mouseOnTip = false, old = false;
|
||||
CodeMirror.on(tip, "mousemove", function() { mouseOnTip = true; });
|
||||
CodeMirror.on(tip, "mouseout", function(e) {
|
||||
if (!CodeMirror.contains(tip, e.relatedTarget || e.toElement)) {
|
||||
if (old) clear();
|
||||
else mouseOnTip = false;
|
||||
}
|
||||
});
|
||||
setTimeout(maybeClear, ts.options.hintDelay ? ts.options.hintDelay : 1700);
|
||||
cm.on("cursorActivity", clear);
|
||||
cm.on('blur', clear);
|
||||
cm.on('scroll', clear);
|
||||
}
|
||||
|
||||
function makeTooltip(x, y, content) {
|
||||
var node = elt("div", cls + "tooltip", content);
|
||||
node.style.left = x + "px";
|
||||
node.style.top = y + "px";
|
||||
document.body.appendChild(node);
|
||||
return node;
|
||||
}
|
||||
|
||||
function remove(node) {
|
||||
var p = node && node.parentNode;
|
||||
if (p) p.removeChild(node);
|
||||
}
|
||||
|
||||
function fadeOut(tooltip) {
|
||||
tooltip.style.opacity = "0";
|
||||
setTimeout(function() { remove(tooltip); }, 1100);
|
||||
}
|
||||
|
||||
function showError(ts, cm, msg) {
|
||||
if (ts.options.showError)
|
||||
ts.options.showError(cm, msg);
|
||||
else
|
||||
tempTooltip(cm, String(msg), ts);
|
||||
}
|
||||
|
||||
function closeArgHints(ts) {
|
||||
if (ts.activeArgHints) { remove(ts.activeArgHints); ts.activeArgHints = null; }
|
||||
}
|
||||
|
||||
function docValue(ts, doc) {
|
||||
var val = doc.doc.getValue();
|
||||
if (ts.options.fileFilter) val = ts.options.fileFilter(val, doc.name, doc.doc);
|
||||
return val;
|
||||
}
|
||||
|
||||
// Worker wrapper
|
||||
|
||||
function WorkerServer(ts) {
|
||||
var worker = ts.worker = new Worker(ts.options.workerScript);
|
||||
worker.postMessage({type: "init",
|
||||
defs: ts.options.defs,
|
||||
plugins: ts.options.plugins,
|
||||
scripts: ts.options.workerDeps});
|
||||
var msgId = 0, pending = {};
|
||||
|
||||
function send(data, c) {
|
||||
if (c) {
|
||||
data.id = ++msgId;
|
||||
pending[msgId] = c;
|
||||
}
|
||||
worker.postMessage(data);
|
||||
}
|
||||
worker.onmessage = function(e) {
|
||||
var data = e.data;
|
||||
if (data.type == "getFile") {
|
||||
getFile(ts, data.name, function(err, text) {
|
||||
send({type: "getFile", err: String(err), text: text, id: data.id});
|
||||
});
|
||||
} else if (data.type == "debug") {
|
||||
window.console.log(data.message);
|
||||
} else if (data.id && pending[data.id]) {
|
||||
pending[data.id](data.err, data.body);
|
||||
delete pending[data.id];
|
||||
}
|
||||
};
|
||||
worker.onerror = function(e) {
|
||||
for (var id in pending) pending[id](e);
|
||||
pending = {};
|
||||
};
|
||||
|
||||
this.addFile = function(name, text) { send({type: "add", name: name, text: text}); };
|
||||
this.delFile = function(name) { send({type: "del", name: name}); };
|
||||
this.request = function(body, c) { send({type: "req", body: body}, c); };
|
||||
}
|
||||
});
|
44
codemirror/addon/tern/worker.js
vendored
Normal file
44
codemirror/addon/tern/worker.js
vendored
Normal file
|
@ -0,0 +1,44 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
// declare global: tern, server
|
||||
|
||||
var server;
|
||||
|
||||
this.onmessage = function(e) {
|
||||
var data = e.data;
|
||||
switch (data.type) {
|
||||
case "init": return startServer(data.defs, data.plugins, data.scripts);
|
||||
case "add": return server.addFile(data.name, data.text);
|
||||
case "del": return server.delFile(data.name);
|
||||
case "req": return server.request(data.body, function(err, reqData) {
|
||||
postMessage({id: data.id, body: reqData, err: err && String(err)});
|
||||
});
|
||||
case "getFile":
|
||||
var c = pending[data.id];
|
||||
delete pending[data.id];
|
||||
return c(data.err, data.text);
|
||||
default: throw new Error("Unknown message type: " + data.type);
|
||||
}
|
||||
};
|
||||
|
||||
var nextId = 0, pending = {};
|
||||
function getFile(file, c) {
|
||||
postMessage({type: "getFile", name: file, id: ++nextId});
|
||||
pending[nextId] = c;
|
||||
}
|
||||
|
||||
function startServer(defs, plugins, scripts) {
|
||||
if (scripts) importScripts.apply(null, scripts);
|
||||
|
||||
server = new tern.Server({
|
||||
getFile: getFile,
|
||||
async: true,
|
||||
defs: defs,
|
||||
plugins: plugins
|
||||
});
|
||||
}
|
||||
|
||||
this.console = {
|
||||
log: function(v) { postMessage({type: "debug", message: v}); }
|
||||
};
|
144
codemirror/addon/wrap/hardwrap.js
vendored
Normal file
144
codemirror/addon/wrap/hardwrap.js
vendored
Normal file
|
@ -0,0 +1,144 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
var Pos = CodeMirror.Pos;
|
||||
|
||||
function findParagraph(cm, pos, options) {
|
||||
var startRE = options.paragraphStart || cm.getHelper(pos, "paragraphStart");
|
||||
for (var start = pos.line, first = cm.firstLine(); start > first; --start) {
|
||||
var line = cm.getLine(start);
|
||||
if (startRE && startRE.test(line)) break;
|
||||
if (!/\S/.test(line)) { ++start; break; }
|
||||
}
|
||||
var endRE = options.paragraphEnd || cm.getHelper(pos, "paragraphEnd");
|
||||
for (var end = pos.line + 1, last = cm.lastLine(); end <= last; ++end) {
|
||||
var line = cm.getLine(end);
|
||||
if (endRE && endRE.test(line)) { ++end; break; }
|
||||
if (!/\S/.test(line)) break;
|
||||
}
|
||||
return {from: start, to: end};
|
||||
}
|
||||
|
||||
function findBreakPoint(text, column, wrapOn, killTrailingSpace) {
|
||||
var at = column
|
||||
while (at < text.length && text.charAt(at) == " ") at++
|
||||
for (; at > 0; --at)
|
||||
if (wrapOn.test(text.slice(at - 1, at + 1))) break;
|
||||
for (var first = true;; first = false) {
|
||||
var endOfText = at;
|
||||
if (killTrailingSpace)
|
||||
while (text.charAt(endOfText - 1) == " ") --endOfText;
|
||||
if (endOfText == 0 && first) at = column;
|
||||
else return {from: endOfText, to: at};
|
||||
}
|
||||
}
|
||||
|
||||
function wrapRange(cm, from, to, options) {
|
||||
from = cm.clipPos(from); to = cm.clipPos(to);
|
||||
var column = options.column || 80;
|
||||
var wrapOn = options.wrapOn || /\s\S|-[^\.\d]/;
|
||||
var killTrailing = options.killTrailingSpace !== false;
|
||||
var changes = [], curLine = "", curNo = from.line;
|
||||
var lines = cm.getRange(from, to, false);
|
||||
if (!lines.length) return null;
|
||||
var leadingSpace = lines[0].match(/^[ \t]*/)[0];
|
||||
|
||||
for (var i = 0; i < lines.length; ++i) {
|
||||
var text = lines[i], oldLen = curLine.length, spaceInserted = 0;
|
||||
if (curLine && text && !wrapOn.test(curLine.charAt(curLine.length - 1) + text.charAt(0))) {
|
||||
curLine += " ";
|
||||
spaceInserted = 1;
|
||||
}
|
||||
var spaceTrimmed = "";
|
||||
if (i) {
|
||||
spaceTrimmed = text.match(/^\s*/)[0];
|
||||
text = text.slice(spaceTrimmed.length);
|
||||
}
|
||||
curLine += text;
|
||||
if (i) {
|
||||
var firstBreak = curLine.length > column && leadingSpace == spaceTrimmed &&
|
||||
findBreakPoint(curLine, column, wrapOn, killTrailing);
|
||||
// If this isn't broken, or is broken at a different point, remove old break
|
||||
if (!firstBreak || firstBreak.from != oldLen || firstBreak.to != oldLen + spaceInserted) {
|
||||
changes.push({text: [spaceInserted ? " " : ""],
|
||||
from: Pos(curNo, oldLen),
|
||||
to: Pos(curNo + 1, spaceTrimmed.length)});
|
||||
} else {
|
||||
curLine = leadingSpace + text;
|
||||
++curNo;
|
||||
}
|
||||
}
|
||||
while (curLine.length > column) {
|
||||
var bp = findBreakPoint(curLine, column, wrapOn, killTrailing);
|
||||
changes.push({text: ["", leadingSpace],
|
||||
from: Pos(curNo, bp.from),
|
||||
to: Pos(curNo, bp.to)});
|
||||
curLine = leadingSpace + curLine.slice(bp.to);
|
||||
++curNo;
|
||||
}
|
||||
}
|
||||
if (changes.length) cm.operation(function() {
|
||||
for (var i = 0; i < changes.length; ++i) {
|
||||
var change = changes[i];
|
||||
if (change.text || CodeMirror.cmpPos(change.from, change.to))
|
||||
cm.replaceRange(change.text, change.from, change.to);
|
||||
}
|
||||
});
|
||||
return changes.length ? {from: changes[0].from, to: CodeMirror.changeEnd(changes[changes.length - 1])} : null;
|
||||
}
|
||||
|
||||
CodeMirror.defineExtension("wrapParagraph", function(pos, options) {
|
||||
options = options || {};
|
||||
if (!pos) pos = this.getCursor();
|
||||
var para = findParagraph(this, pos, options);
|
||||
return wrapRange(this, Pos(para.from, 0), Pos(para.to - 1), options);
|
||||
});
|
||||
|
||||
CodeMirror.commands.wrapLines = function(cm) {
|
||||
cm.operation(function() {
|
||||
var ranges = cm.listSelections(), at = cm.lastLine() + 1;
|
||||
for (var i = ranges.length - 1; i >= 0; i--) {
|
||||
var range = ranges[i], span;
|
||||
if (range.empty()) {
|
||||
var para = findParagraph(cm, range.head, {});
|
||||
span = {from: Pos(para.from, 0), to: Pos(para.to - 1)};
|
||||
} else {
|
||||
span = {from: range.from(), to: range.to()};
|
||||
}
|
||||
if (span.to.line >= at) continue;
|
||||
at = span.from.line;
|
||||
wrapRange(cm, span.from, span.to, {});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
CodeMirror.defineExtension("wrapRange", function(from, to, options) {
|
||||
return wrapRange(this, from, to, options || {});
|
||||
});
|
||||
|
||||
CodeMirror.defineExtension("wrapParagraphsInRange", function(from, to, options) {
|
||||
options = options || {};
|
||||
var cm = this, paras = [];
|
||||
for (var line = from.line; line <= to.line;) {
|
||||
var para = findParagraph(cm, Pos(line, 0), options);
|
||||
paras.push(para);
|
||||
line = para.to;
|
||||
}
|
||||
var madeChange = false;
|
||||
if (paras.length) cm.operation(function() {
|
||||
for (var i = paras.length - 1; i >= 0; --i)
|
||||
madeChange = madeChange || wrapRange(cm, Pos(paras[i].from, 0), Pos(paras[i].to - 1), options);
|
||||
});
|
||||
return madeChange;
|
||||
});
|
||||
});
|
2
codemirror/keymap/emacs.js
vendored
2
codemirror/keymap/emacs.js
vendored
|
@ -271,6 +271,8 @@
|
|||
clearMark(cm);
|
||||
}
|
||||
|
||||
CodeMirror.emacs = {kill: kill, killRegion: killRegion, repeated: repeated};
|
||||
|
||||
// Actual keymap
|
||||
|
||||
var keyMap = CodeMirror.keyMap.emacs = CodeMirror.normalizeKeyMap({
|
||||
|
|
90
codemirror/keymap/sublime.js
vendored
90
codemirror/keymap/sublime.js
vendored
|
@ -52,8 +52,12 @@
|
|||
});
|
||||
}
|
||||
|
||||
cmds[map["Alt-Left"] = "goSubwordLeft"] = function(cm) { moveSubword(cm, -1); };
|
||||
cmds[map["Alt-Right"] = "goSubwordRight"] = function(cm) { moveSubword(cm, 1); };
|
||||
var goSubwordCombo = mac ? "Ctrl-" : "Alt-";
|
||||
|
||||
cmds[map[goSubwordCombo + "Left"] = "goSubwordLeft"] = function(cm) { moveSubword(cm, -1); };
|
||||
cmds[map[goSubwordCombo + "Right"] = "goSubwordRight"] = function(cm) { moveSubword(cm, 1); };
|
||||
|
||||
if (mac) map["Cmd-Left"] = "goLineStartSmart";
|
||||
|
||||
var scrollLineCombo = mac ? "Ctrl-Alt-" : "Ctrl-";
|
||||
|
||||
|
@ -105,9 +109,10 @@
|
|||
cm.setSelections(extended);
|
||||
};
|
||||
|
||||
map["Shift-" + ctrl + "K"] = "deleteLine";
|
||||
map["Shift-Ctrl-K"] = "deleteLine";
|
||||
|
||||
function insertLine(cm, above) {
|
||||
if (cm.isReadOnly()) return CodeMirror.Pass
|
||||
cm.operation(function() {
|
||||
var len = cm.listSelections().length, newSelection = [], last = -1;
|
||||
for (var i = 0; i < len; i++) {
|
||||
|
@ -121,11 +126,12 @@
|
|||
}
|
||||
cm.setSelections(newSelection);
|
||||
});
|
||||
cm.execCommand("indentAuto");
|
||||
}
|
||||
|
||||
cmds[map[ctrl + "Enter"] = "insertLineAfter"] = function(cm) { insertLine(cm, false); };
|
||||
cmds[map[ctrl + "Enter"] = "insertLineAfter"] = function(cm) { return insertLine(cm, false); };
|
||||
|
||||
cmds[map["Shift-" + ctrl + "Enter"] = "insertLineBefore"] = function(cm) { insertLine(cm, true); };
|
||||
cmds[map["Shift-" + ctrl + "Enter"] = "insertLineBefore"] = function(cm) { return insertLine(cm, true); };
|
||||
|
||||
function wordAt(cm, pos) {
|
||||
var start = pos.ch, end = start, line = cm.getLine(pos.line);
|
||||
|
@ -160,17 +166,23 @@
|
|||
|
||||
var mirror = "(){}[]";
|
||||
function selectBetweenBrackets(cm) {
|
||||
var pos = cm.getCursor(), opening = cm.scanForBracket(pos, -1);
|
||||
if (!opening) return;
|
||||
for (;;) {
|
||||
var closing = cm.scanForBracket(pos, 1);
|
||||
if (!closing) return;
|
||||
if (closing.ch == mirror.charAt(mirror.indexOf(opening.ch) + 1)) {
|
||||
cm.setSelection(Pos(opening.pos.line, opening.pos.ch + 1), closing.pos, false);
|
||||
return true;
|
||||
var ranges = cm.listSelections(), newRanges = []
|
||||
for (var i = 0; i < ranges.length; i++) {
|
||||
var range = ranges[i], pos = range.head, opening = cm.scanForBracket(pos, -1);
|
||||
if (!opening) return false;
|
||||
for (;;) {
|
||||
var closing = cm.scanForBracket(pos, 1);
|
||||
if (!closing) return false;
|
||||
if (closing.ch == mirror.charAt(mirror.indexOf(opening.ch) + 1)) {
|
||||
newRanges.push({anchor: Pos(opening.pos.line, opening.pos.ch + 1),
|
||||
head: closing.pos});
|
||||
break;
|
||||
}
|
||||
pos = Pos(closing.pos.line, closing.pos.ch + 1);
|
||||
}
|
||||
pos = Pos(closing.pos.line, closing.pos.ch + 1);
|
||||
}
|
||||
cm.setSelections(newRanges);
|
||||
return true;
|
||||
}
|
||||
|
||||
cmds[map["Shift-" + ctrl + "Space"] = "selectScope"] = function(cm) {
|
||||
|
@ -192,6 +204,7 @@
|
|||
var swapLineCombo = mac ? "Cmd-Ctrl-" : "Shift-Ctrl-";
|
||||
|
||||
cmds[map[swapLineCombo + "Up"] = "swapLineUp"] = function(cm) {
|
||||
if (cm.isReadOnly()) return CodeMirror.Pass
|
||||
var ranges = cm.listSelections(), linesToMove = [], at = cm.firstLine() - 1, newSels = [];
|
||||
for (var i = 0; i < ranges.length; i++) {
|
||||
var range = ranges[i], from = range.from().line - 1, to = range.to().line;
|
||||
|
@ -218,6 +231,7 @@
|
|||
};
|
||||
|
||||
cmds[map[swapLineCombo + "Down"] = "swapLineDown"] = function(cm) {
|
||||
if (cm.isReadOnly()) return CodeMirror.Pass
|
||||
var ranges = cm.listSelections(), linesToMove = [], at = cm.lastLine() + 1;
|
||||
for (var i = ranges.length - 1; i >= 0; i--) {
|
||||
var range = ranges[i], from = range.to().line + 1, to = range.from().line;
|
||||
|
@ -240,7 +254,9 @@
|
|||
});
|
||||
};
|
||||
|
||||
map[ctrl + "/"] = "toggleComment";
|
||||
cmds[map[ctrl + "/"] = "toggleCommentIndented"] = function(cm) {
|
||||
cm.toggleComment({ indent: true });
|
||||
}
|
||||
|
||||
cmds[map[ctrl + "J"] = "joinLines"] = function(cm) {
|
||||
var ranges = cm.listSelections(), joined = [];
|
||||
|
@ -284,16 +300,18 @@
|
|||
});
|
||||
};
|
||||
|
||||
map[ctrl + "T"] = "transposeChars";
|
||||
if (!mac) map[ctrl + "T"] = "transposeChars";
|
||||
|
||||
function sortLines(cm, caseSensitive) {
|
||||
if (cm.isReadOnly()) return CodeMirror.Pass
|
||||
var ranges = cm.listSelections(), toSort = [], selected;
|
||||
for (var i = 0; i < ranges.length; i++) {
|
||||
var range = ranges[i];
|
||||
if (range.empty()) continue;
|
||||
var from = range.from().line, to = range.to().line;
|
||||
while (i < ranges.length - 1 && ranges[i + 1].from().line == to)
|
||||
to = range[++i].to().line;
|
||||
to = ranges[++i].to().line;
|
||||
if (!ranges[i].to().ch) to--;
|
||||
toSort.push(from, to);
|
||||
}
|
||||
if (toSort.length) selected = true;
|
||||
|
@ -314,7 +332,7 @@
|
|||
return a < b ? -1 : a == b ? 0 : 1;
|
||||
});
|
||||
cm.replaceRange(lines, start, end);
|
||||
if (selected) ranges.push({anchor: start, head: end});
|
||||
if (selected) ranges.push({anchor: start, head: Pos(to + 1, 0)});
|
||||
}
|
||||
if (selected) cm.setSelections(ranges, 0);
|
||||
});
|
||||
|
@ -414,14 +432,29 @@
|
|||
cmds[map["Backspace"] = "smartBackspace"] = function(cm) {
|
||||
if (cm.somethingSelected()) return CodeMirror.Pass;
|
||||
|
||||
var cursor = cm.getCursor();
|
||||
var toStartOfLine = cm.getRange({line: cursor.line, ch: 0}, cursor);
|
||||
var column = CodeMirror.countColumn(toStartOfLine, null, cm.getOption("tabSize"));
|
||||
cm.operation(function() {
|
||||
var cursors = cm.listSelections();
|
||||
var indentUnit = cm.getOption("indentUnit");
|
||||
|
||||
if (toStartOfLine && !/\S/.test(toStartOfLine) && column % cm.getOption("indentUnit") == 0)
|
||||
return cm.indentSelection("subtract");
|
||||
else
|
||||
return CodeMirror.Pass;
|
||||
for (var i = cursors.length - 1; i >= 0; i--) {
|
||||
var cursor = cursors[i].head;
|
||||
var toStartOfLine = cm.getRange({line: cursor.line, ch: 0}, cursor);
|
||||
var column = CodeMirror.countColumn(toStartOfLine, null, cm.getOption("tabSize"));
|
||||
|
||||
// Delete by one character by default
|
||||
var deletePos = cm.findPosH(cursor, -1, "char", false);
|
||||
|
||||
if (toStartOfLine && !/\S/.test(toStartOfLine) && column % indentUnit == 0) {
|
||||
var prevIndent = new Pos(cursor.line,
|
||||
CodeMirror.findColumn(toStartOfLine, column - indentUnit, indentUnit));
|
||||
|
||||
// Smart delete only if we found a valid prevIndent location
|
||||
if (prevIndent.ch != cursor.ch) deletePos = prevIndent;
|
||||
}
|
||||
|
||||
cm.replaceRange("", deletePos, cursor, "+delete");
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
cmds[map[cK + ctrl + "K"] = "delLineRight"] = function(cm) {
|
||||
|
@ -476,7 +509,8 @@
|
|||
cm.scrollTo(null, (pos.top + pos.bottom) / 2 - cm.getScrollInfo().clientHeight / 2);
|
||||
};
|
||||
|
||||
cmds[map["Shift-Alt-Up"] = "selectLinesUpward"] = function(cm) {
|
||||
var selectLinesCombo = mac ? "Ctrl-Shift-" : "Ctrl-Alt-";
|
||||
cmds[map[selectLinesCombo + "Up"] = "selectLinesUpward"] = function(cm) {
|
||||
cm.operation(function() {
|
||||
var ranges = cm.listSelections();
|
||||
for (var i = 0; i < ranges.length; i++) {
|
||||
|
@ -486,7 +520,7 @@
|
|||
}
|
||||
});
|
||||
};
|
||||
cmds[map["Shift-Alt-Down"] = "selectLinesDownward"] = function(cm) {
|
||||
cmds[map[selectLinesCombo + "Down"] = "selectLinesDownward"] = function(cm) {
|
||||
cm.operation(function() {
|
||||
var ranges = cm.listSelections();
|
||||
for (var i = 0; i < ranges.length; i++) {
|
||||
|
@ -543,7 +577,7 @@
|
|||
|
||||
map["Shift-" + ctrl + "["] = "fold";
|
||||
map["Shift-" + ctrl + "]"] = "unfold";
|
||||
map[cK + ctrl + "0"] = map[cK + ctrl + "j"] = "unfoldAll";
|
||||
map[cK + ctrl + "0"] = map[cK + ctrl + "J"] = "unfoldAll";
|
||||
|
||||
map[ctrl + "I"] = "findIncremental";
|
||||
map["Shift-" + ctrl + "I"] = "findIncrementalReverse";
|
||||
|
|
150
codemirror/keymap/vim.js
vendored
150
codemirror/keymap/vim.js
vendored
|
@ -26,7 +26,7 @@
|
|||
* 2. Variable declarations and short basic helpers
|
||||
* 3. Instance (External API) implementation
|
||||
* 4. Internal state tracking objects (input state, counter) implementation
|
||||
* and instanstiation
|
||||
* and instantiation
|
||||
* 5. Key handler (the main command dispatcher) implementation
|
||||
* 6. Motion, operator, and action implementations
|
||||
* 7. Helper functions for the key handler, motions, operators, and actions
|
||||
|
@ -64,14 +64,15 @@
|
|||
{ keys: '<C-[>', type: 'keyToKey', toKeys: '<Esc>', context: 'insert' },
|
||||
{ keys: '<C-c>', type: 'keyToKey', toKeys: '<Esc>', context: 'insert' },
|
||||
{ keys: 's', type: 'keyToKey', toKeys: 'cl', context: 'normal' },
|
||||
{ keys: 's', type: 'keyToKey', toKeys: 'xi', context: 'visual'},
|
||||
{ keys: 's', type: 'keyToKey', toKeys: 'c', context: 'visual'},
|
||||
{ keys: 'S', type: 'keyToKey', toKeys: 'cc', context: 'normal' },
|
||||
{ keys: 'S', type: 'keyToKey', toKeys: 'dcc', context: 'visual' },
|
||||
{ keys: 'S', type: 'keyToKey', toKeys: 'VdO', context: 'visual' },
|
||||
{ keys: '<Home>', type: 'keyToKey', toKeys: '0' },
|
||||
{ keys: '<End>', type: 'keyToKey', toKeys: '$' },
|
||||
{ keys: '<PageUp>', type: 'keyToKey', toKeys: '<C-b>' },
|
||||
{ keys: '<PageDown>', type: 'keyToKey', toKeys: '<C-f>' },
|
||||
{ keys: '<CR>', type: 'keyToKey', toKeys: 'j^', context: 'normal' },
|
||||
{ keys: '<Ins>', type: 'action', action: 'toggleOverwrite', context: 'insert' },
|
||||
// Motions
|
||||
{ keys: 'H', type: 'motion', motion: 'moveToTopLine', motionArgs: { linewise: true, toJumplist: true }},
|
||||
{ keys: 'M', type: 'motion', motion: 'moveToMiddleLine', motionArgs: { linewise: true, toJumplist: true }},
|
||||
|
@ -164,6 +165,7 @@
|
|||
{ keys: 'v', type: 'action', action: 'toggleVisualMode' },
|
||||
{ keys: 'V', type: 'action', action: 'toggleVisualMode', actionArgs: { linewise: true }},
|
||||
{ keys: '<C-v>', type: 'action', action: 'toggleVisualMode', actionArgs: { blockwise: true }},
|
||||
{ keys: '<C-q>', type: 'action', action: 'toggleVisualMode', actionArgs: { blockwise: true }},
|
||||
{ keys: 'gv', type: 'action', action: 'reselectLastSelection' },
|
||||
{ keys: 'J', type: 'action', action: 'joinLines', isEdit: true },
|
||||
{ keys: 'p', type: 'action', action: 'paste', isEdit: true, actionArgs: { after: true, isEdit: true }},
|
||||
|
@ -188,6 +190,8 @@
|
|||
{ keys: '.', type: 'action', action: 'repeatLastEdit' },
|
||||
{ keys: '<C-a>', type: 'action', action: 'incrementNumberToken', isEdit: true, actionArgs: {increase: true, backtrack: false}},
|
||||
{ keys: '<C-x>', type: 'action', action: 'incrementNumberToken', isEdit: true, actionArgs: {increase: false, backtrack: false}},
|
||||
{ keys: '<C-t>', type: 'action', action: 'indent', actionArgs: { indentRight: true }, context: 'insert' },
|
||||
{ keys: '<C-d>', type: 'action', action: 'indent', actionArgs: { indentRight: false }, context: 'insert' },
|
||||
// Text object motions
|
||||
{ keys: 'a<character>', type: 'motion', motion: 'textObjectManipulation' },
|
||||
{ keys: 'i<character>', type: 'motion', motion: 'textObjectManipulation', motionArgs: { textObjectInner: true }},
|
||||
|
@ -225,6 +229,7 @@
|
|||
{ name: 'sort', shortName: 'sor' },
|
||||
{ name: 'substitute', shortName: 's', possiblyAsync: true },
|
||||
{ name: 'nohlsearch', shortName: 'noh' },
|
||||
{ name: 'yank', shortName: 'y' },
|
||||
{ name: 'delmarks', shortName: 'delm' },
|
||||
{ name: 'registers', shortName: 'reg', excludeFromCommandHistory: true },
|
||||
{ name: 'global', shortName: 'g' }
|
||||
|
@ -274,6 +279,7 @@
|
|||
|
||||
function cmKey(key, cm) {
|
||||
if (!cm) { return undefined; }
|
||||
if (this[key]) { return this[key]; }
|
||||
var vimKey = cmKeyToVimKey(key);
|
||||
if (!vimKey) {
|
||||
return false;
|
||||
|
@ -286,18 +292,13 @@
|
|||
}
|
||||
|
||||
var modifiers = {'Shift': 'S', 'Ctrl': 'C', 'Alt': 'A', 'Cmd': 'D', 'Mod': 'A'};
|
||||
var specialKeys = {Enter:'CR',Backspace:'BS',Delete:'Del'};
|
||||
var specialKeys = {Enter:'CR',Backspace:'BS',Delete:'Del',Insert:'Ins'};
|
||||
function cmKeyToVimKey(key) {
|
||||
if (key.charAt(0) == '\'') {
|
||||
// Keypress character binding of format "'a'"
|
||||
return key.charAt(1);
|
||||
}
|
||||
var pieces = key.split('-');
|
||||
if (/-$/.test(key)) {
|
||||
// If the - key was typed, split will result in 2 extra empty strings
|
||||
// in the array. Replace them with 1 '-'.
|
||||
pieces.splice(-2, 2, '-');
|
||||
}
|
||||
var pieces = key.split(/-(?!$)/);
|
||||
var lastPiece = pieces[pieces.length - 1];
|
||||
if (pieces.length == 1 && pieces[0].length == 1) {
|
||||
// No-modifier bindings use literal character bindings above. Skip.
|
||||
|
@ -645,7 +646,7 @@
|
|||
jumpList: createCircularJumpList(),
|
||||
macroModeState: new MacroModeState,
|
||||
// Recording latest f, t, F or T motion command.
|
||||
lastChararacterSearch: {increment:0, forward:true, selectedCharacter:''},
|
||||
lastCharacterSearch: {increment:0, forward:true, selectedCharacter:''},
|
||||
registerController: new RegisterController({}),
|
||||
// search history buffer
|
||||
searchHistoryController: new HistoryController({}),
|
||||
|
@ -686,6 +687,9 @@
|
|||
// Add user defined key bindings.
|
||||
exCommandDispatcher.map(lhs, rhs, ctx);
|
||||
},
|
||||
unmap: function(lhs, ctx) {
|
||||
exCommandDispatcher.unmap(lhs, ctx);
|
||||
},
|
||||
// TODO: Expose setOption and getOption as instance methods. Need to decide how to namespace
|
||||
// them, or somehow make them work with the existing CodeMirror setOption/getOption API.
|
||||
setOption: setOption,
|
||||
|
@ -778,8 +782,12 @@
|
|||
|
||||
if (lastInsertModeKeyTimer) { window.clearTimeout(lastInsertModeKeyTimer); }
|
||||
if (keysAreChars) {
|
||||
var here = cm.getCursor();
|
||||
cm.replaceRange('', offsetCursor(here, 0, -(keys.length - 1)), here, '+input');
|
||||
var selections = cm.listSelections();
|
||||
for (var i = 0; i < selections.length; i++) {
|
||||
var here = selections[i].head;
|
||||
cm.replaceRange('', offsetCursor(here, 0, -(keys.length - 1)), here, '+input');
|
||||
}
|
||||
vimGlobalState.macroModeState.lastInsertModeChanges.changes.pop();
|
||||
}
|
||||
clearInputState(cm);
|
||||
return match.command;
|
||||
|
@ -816,7 +824,7 @@
|
|||
// TODO: Look into using CodeMirror's multi-key handling.
|
||||
// Return no-op since we are caching the key. Counts as handled, but
|
||||
// don't want act on it just yet.
|
||||
return function() {};
|
||||
return function() { return true; };
|
||||
} else {
|
||||
return function() {
|
||||
return cm.operation(function() {
|
||||
|
@ -1048,7 +1056,7 @@
|
|||
};
|
||||
function HistoryController() {
|
||||
this.historyBuffer = [];
|
||||
this.iterator;
|
||||
this.iterator = 0;
|
||||
this.initialPrefix = null;
|
||||
}
|
||||
HistoryController.prototype = {
|
||||
|
@ -1373,7 +1381,7 @@
|
|||
}
|
||||
},
|
||||
evalInput: function(cm, vim) {
|
||||
// If the motion comand is set, execute both the operator and motion.
|
||||
// If the motion command is set, execute both the operator and motion.
|
||||
// Otherwise return.
|
||||
var inputState = vim.inputState;
|
||||
var motion = inputState.motion;
|
||||
|
@ -1697,11 +1705,12 @@
|
|||
var line = motionArgs.forward ? cur.line + repeat : cur.line - repeat;
|
||||
var first = cm.firstLine();
|
||||
var last = cm.lastLine();
|
||||
// Vim cancels linewise motions that start on an edge and move beyond
|
||||
// that edge. It does not cancel motions that do not start on an edge.
|
||||
if ((line < first && cur.line == first) ||
|
||||
(line > last && cur.line == last)) {
|
||||
return;
|
||||
// Vim go to line begin or line end when cursor at first/last line and
|
||||
// move to previous/next line is triggered.
|
||||
if (line < first && cur.line == first){
|
||||
return this.moveToStartOfLine(cm, head, motionArgs, vim);
|
||||
}else if (line > last && cur.line == last){
|
||||
return this.moveToEol(cm, head, motionArgs, vim);
|
||||
}
|
||||
if (motionArgs.toFirstChar){
|
||||
endCh=findFirstNonWhiteSpaceCharacter(cm.getLine(line));
|
||||
|
@ -1909,7 +1918,7 @@
|
|||
},
|
||||
|
||||
repeatLastCharacterSearch: function(cm, head, motionArgs) {
|
||||
var lastSearch = vimGlobalState.lastChararacterSearch;
|
||||
var lastSearch = vimGlobalState.lastCharacterSearch;
|
||||
var repeat = motionArgs.repeat;
|
||||
var forward = motionArgs.forward === lastSearch.forward;
|
||||
var increment = (lastSearch.increment ? 1 : 0) * (forward ? -1 : 1);
|
||||
|
@ -1959,13 +1968,21 @@
|
|||
text = text.slice(0, - match[0].length);
|
||||
}
|
||||
}
|
||||
var wasLastLine = head.line - 1 == cm.lastLine();
|
||||
cm.replaceRange('', anchor, head);
|
||||
if (args.linewise && !wasLastLine) {
|
||||
var prevLineEnd = new Pos(anchor.line - 1, Number.MAX_VALUE);
|
||||
var wasLastLine = cm.firstLine() == cm.lastLine();
|
||||
if (head.line > cm.lastLine() && args.linewise && !wasLastLine) {
|
||||
cm.replaceRange('', prevLineEnd, head);
|
||||
} else {
|
||||
cm.replaceRange('', anchor, head);
|
||||
}
|
||||
if (args.linewise) {
|
||||
// Push the next line back down, if there is a next line.
|
||||
CodeMirror.commands.newlineAndIndent(cm);
|
||||
// null ch so setCursor moves to end of line.
|
||||
anchor.ch = null;
|
||||
if (!wasLastLine) {
|
||||
cm.setCursor(prevLineEnd);
|
||||
CodeMirror.commands.newlineAndIndent(cm);
|
||||
}
|
||||
// make sure cursor ends up at the end of the line.
|
||||
anchor.ch = Number.MAX_VALUE;
|
||||
}
|
||||
finalHead = anchor;
|
||||
} else {
|
||||
|
@ -2144,9 +2161,7 @@
|
|||
switch (actionArgs.position) {
|
||||
case 'center': y = y - (height / 2) + lineHeight;
|
||||
break;
|
||||
case 'bottom': y = y - height + lineHeight*1.4;
|
||||
break;
|
||||
case 'top': y = y + lineHeight*0.4;
|
||||
case 'bottom': y = y - height + lineHeight;
|
||||
break;
|
||||
}
|
||||
cm.scrollTo(null, y);
|
||||
|
@ -2167,6 +2182,17 @@
|
|||
var registerName = actionArgs.selectedCharacter;
|
||||
macroModeState.enterMacroRecordMode(cm, registerName);
|
||||
},
|
||||
toggleOverwrite: function(cm) {
|
||||
if (!cm.state.overwrite) {
|
||||
cm.toggleOverwrite(true);
|
||||
cm.setOption('keyMap', 'vim-replace');
|
||||
CodeMirror.signal(cm, "vim-mode-change", {mode: "replace"});
|
||||
} else {
|
||||
cm.toggleOverwrite(false);
|
||||
cm.setOption('keyMap', 'vim-insert');
|
||||
CodeMirror.signal(cm, "vim-mode-change", {mode: "insert"});
|
||||
}
|
||||
},
|
||||
enterInsertMode: function(cm, actionArgs, vim) {
|
||||
if (cm.getOption('readOnly')) { return; }
|
||||
vim.insertMode = true;
|
||||
|
@ -2212,7 +2238,6 @@
|
|||
return;
|
||||
}
|
||||
}
|
||||
cm.setOption('keyMap', 'vim-insert');
|
||||
cm.setOption('disableInput', false);
|
||||
if (actionArgs && actionArgs.replace) {
|
||||
// Handle Replace-mode as a special case of insert mode.
|
||||
|
@ -2220,6 +2245,7 @@
|
|||
cm.setOption('keyMap', 'vim-replace');
|
||||
CodeMirror.signal(cm, "vim-mode-change", {mode: "replace"});
|
||||
} else {
|
||||
cm.toggleOverwrite(false);
|
||||
cm.setOption('keyMap', 'vim-insert');
|
||||
CodeMirror.signal(cm, "vim-mode-change", {mode: "insert"});
|
||||
}
|
||||
|
@ -2592,6 +2618,9 @@
|
|||
}
|
||||
repeatLastEdit(cm, vim, repeat, false /** repeatForInsert */);
|
||||
},
|
||||
indent: function(cm, actionArgs) {
|
||||
cm.indentLine(cm.getCursor().line, actionArgs.indentRight);
|
||||
},
|
||||
exitInsertMode: exitInsertMode
|
||||
};
|
||||
|
||||
|
@ -2996,7 +3025,7 @@
|
|||
// Only clip if the selection ends with trailing newline + whitespace
|
||||
if (/\n\s*$/.test(selection)) {
|
||||
var lines = selection.split('\n');
|
||||
// We know this is all whitepsace.
|
||||
// We know this is all whitespace.
|
||||
lines.pop();
|
||||
|
||||
// Cases:
|
||||
|
@ -3082,9 +3111,9 @@
|
|||
}
|
||||
|
||||
function recordLastCharacterSearch(increment, args) {
|
||||
vimGlobalState.lastChararacterSearch.increment = increment;
|
||||
vimGlobalState.lastChararacterSearch.forward = args.forward;
|
||||
vimGlobalState.lastChararacterSearch.selectedCharacter = args.selectedCharacter;
|
||||
vimGlobalState.lastCharacterSearch.increment = increment;
|
||||
vimGlobalState.lastCharacterSearch.forward = args.forward;
|
||||
vimGlobalState.lastCharacterSearch.selectedCharacter = args.selectedCharacter;
|
||||
}
|
||||
|
||||
var symbolToMode = {
|
||||
|
@ -3208,7 +3237,7 @@
|
|||
return cur;
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* Returns the boundaries of the next word. If the cursor in the middle of
|
||||
* the word, then returns the boundaries of the current word, starting at
|
||||
* the cursor. If the cursor is at the start/end of a word, and we are going
|
||||
|
@ -3283,8 +3312,6 @@
|
|||
line = cm.getLine(lineNum);
|
||||
pos = (dir > 0) ? 0 : line.length;
|
||||
}
|
||||
// Should never get here.
|
||||
throw new Error('The impossible happened.');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3446,7 +3473,7 @@
|
|||
}
|
||||
|
||||
// TODO: perhaps this finagling of start and end positions belonds
|
||||
// in codmirror/replaceRange?
|
||||
// in codemirror/replaceRange?
|
||||
function selectCompanionObject(cm, head, symb, inclusive) {
|
||||
var cur = head, start, end;
|
||||
|
||||
|
@ -3777,17 +3804,10 @@
|
|||
}
|
||||
}
|
||||
function makePrompt(prefix, desc) {
|
||||
var raw = '';
|
||||
if (prefix) {
|
||||
raw += '<span style="font-family: monospace">' + prefix + '</span>';
|
||||
}
|
||||
raw += '<input type="text"/> ' +
|
||||
'<span style="color: #888">';
|
||||
if (desc) {
|
||||
raw += '<span style="color: #888">';
|
||||
raw += desc;
|
||||
raw += '</span>';
|
||||
}
|
||||
var raw = '<span style="font-family: monospace; white-space: pre">' +
|
||||
(prefix || "") + '<input type="text"></span>';
|
||||
if (desc)
|
||||
raw += ' <span style="color: #888">' + desc + '</span>';
|
||||
return raw;
|
||||
}
|
||||
var searchPromptDesc = '(Javascript regexp)';
|
||||
|
@ -4508,14 +4528,21 @@
|
|||
if (CodeMirror.commands.save) {
|
||||
// If a save command is defined, call it.
|
||||
CodeMirror.commands.save(cm);
|
||||
} else {
|
||||
// Saves to text area if no save command is defined.
|
||||
} else if (cm.save) {
|
||||
// Saves to text area if no save command is defined and cm.save() is available.
|
||||
cm.save();
|
||||
}
|
||||
},
|
||||
nohlsearch: function(cm) {
|
||||
clearSearchHighlight(cm);
|
||||
},
|
||||
yank: function (cm) {
|
||||
var cur = copyCursor(cm.getCursor());
|
||||
var line = cur.line;
|
||||
var lineText = cm.getLine(line);
|
||||
vimGlobalState.registerController.pushText(
|
||||
'0', 'yank', lineText, true, true);
|
||||
},
|
||||
delmarks: function(cm, params) {
|
||||
if (!params.argString || !trim(params.argString)) {
|
||||
showConfirm(cm, 'Argument required');
|
||||
|
@ -4766,13 +4793,6 @@
|
|||
CodeMirror.keyMap['vim-insert'] = {
|
||||
// TODO: override navigation keys so that Esc will cancel automatic
|
||||
// indentation from o, O, i_<CR>
|
||||
'Ctrl-N': 'autocomplete',
|
||||
'Ctrl-P': 'autocomplete',
|
||||
'Enter': function(cm) {
|
||||
var fn = CodeMirror.commands.newlineAndIndentContinueComment ||
|
||||
CodeMirror.commands.newlineAndIndent;
|
||||
fn(cm);
|
||||
},
|
||||
fallthrough: ['default'],
|
||||
attach: attachVimMap,
|
||||
detach: detachVimMap,
|
||||
|
@ -4863,6 +4883,10 @@
|
|||
if (changeObj.origin == '+input' || changeObj.origin == 'paste'
|
||||
|| changeObj.origin === undefined /* only in testing */) {
|
||||
var text = changeObj.text.join('\n');
|
||||
if (lastChange.maybeReset) {
|
||||
lastChange.changes = [];
|
||||
lastChange.maybeReset = false;
|
||||
}
|
||||
lastChange.changes.push(text);
|
||||
}
|
||||
// Change objects may be chained with next.
|
||||
|
@ -4885,7 +4909,7 @@
|
|||
lastChange.expectCursorActivityForChange = false;
|
||||
} else {
|
||||
// Cursor moved outside the context of an edit. Reset the change.
|
||||
lastChange.changes = [];
|
||||
lastChange.maybeReset = true;
|
||||
}
|
||||
} else if (!cm.curOp.isVimOp) {
|
||||
handleExternalSelection(cm, vim);
|
||||
|
@ -4949,6 +4973,10 @@
|
|||
var keyName = CodeMirror.keyName(e);
|
||||
if (!keyName) { return; }
|
||||
function onKeyFound() {
|
||||
if (lastChange.maybeReset) {
|
||||
lastChange.changes = [];
|
||||
lastChange.maybeReset = false;
|
||||
}
|
||||
lastChange.changes.push(new InsertModeKey(keyName));
|
||||
return true;
|
||||
}
|
||||
|
|
41
codemirror/lib/codemirror.css
vendored
41
codemirror/lib/codemirror.css
vendored
|
@ -41,19 +41,21 @@
|
|||
|
||||
/* CURSOR */
|
||||
|
||||
.CodeMirror div.CodeMirror-cursor {
|
||||
.CodeMirror-cursor {
|
||||
border-left: 1px solid black;
|
||||
border-right: none;
|
||||
width: 0;
|
||||
}
|
||||
/* Shown when moving in bi-directional text */
|
||||
.CodeMirror div.CodeMirror-secondarycursor {
|
||||
border-left: 1px solid silver;
|
||||
}
|
||||
.CodeMirror.cm-fat-cursor div.CodeMirror-cursor {
|
||||
.cm-fat-cursor .CodeMirror-cursor {
|
||||
width: auto;
|
||||
border: 0;
|
||||
border: 0 !important;
|
||||
background: #7e7;
|
||||
}
|
||||
.CodeMirror.cm-fat-cursor div.CodeMirror-cursors {
|
||||
.cm-fat-cursor div.CodeMirror-cursors {
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
|
@ -82,12 +84,18 @@
|
|||
}
|
||||
|
||||
/* Can style cursor different in overwrite (non-insert) mode */
|
||||
div.CodeMirror-overwrite div.CodeMirror-cursor {}
|
||||
.CodeMirror-overwrite .CodeMirror-cursor {}
|
||||
|
||||
.cm-tab { display: inline-block; text-decoration: inherit; }
|
||||
|
||||
.CodeMirror-rulers {
|
||||
position: absolute;
|
||||
left: 0; right: 0; top: -50px; bottom: -20px;
|
||||
overflow: hidden;
|
||||
}
|
||||
.CodeMirror-ruler {
|
||||
border-left: 1px solid #ccc;
|
||||
top: 0; bottom: 0;
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
|
@ -163,7 +171,7 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
|
|||
}
|
||||
|
||||
/* The fake, visible scrollbars. Used to force redraw during scrolling
|
||||
before actuall scrolling happens, thus preventing shaking and
|
||||
before actual scrolling happens, thus preventing shaking and
|
||||
flickering artifacts. */
|
||||
.CodeMirror-vscrollbar, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
|
||||
position: absolute;
|
||||
|
@ -189,16 +197,15 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
|
|||
|
||||
.CodeMirror-gutters {
|
||||
position: absolute; left: 0; top: 0;
|
||||
min-height: 100%;
|
||||
z-index: 3;
|
||||
}
|
||||
.CodeMirror-gutter {
|
||||
white-space: normal;
|
||||
height: 100%;
|
||||
display: inline-block;
|
||||
vertical-align: top;
|
||||
margin-bottom: -30px;
|
||||
/* Hack to make IE7 behave */
|
||||
*zoom:1;
|
||||
*display:inline;
|
||||
}
|
||||
.CodeMirror-gutter-wrapper {
|
||||
position: absolute;
|
||||
|
@ -242,6 +249,8 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
|
|||
position: relative;
|
||||
overflow: visible;
|
||||
-webkit-tap-highlight-color: transparent;
|
||||
-webkit-font-variant-ligatures: contextual;
|
||||
font-variant-ligatures: contextual;
|
||||
}
|
||||
.CodeMirror-wrap pre {
|
||||
word-wrap: break-word;
|
||||
|
@ -284,19 +293,22 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
|
|||
overflow: hidden;
|
||||
visibility: hidden;
|
||||
}
|
||||
.CodeMirror-measure pre { position: static; }
|
||||
|
||||
.CodeMirror div.CodeMirror-cursor {
|
||||
.CodeMirror-cursor {
|
||||
position: absolute;
|
||||
border-right: none;
|
||||
width: 0;
|
||||
pointer-events: none;
|
||||
}
|
||||
.CodeMirror-measure pre { position: static; }
|
||||
|
||||
div.CodeMirror-cursors {
|
||||
visibility: hidden;
|
||||
position: relative;
|
||||
z-index: 3;
|
||||
}
|
||||
div.CodeMirror-dragcursors {
|
||||
visibility: visible;
|
||||
}
|
||||
|
||||
.CodeMirror-focused div.CodeMirror-cursors {
|
||||
visibility: visible;
|
||||
}
|
||||
|
@ -312,9 +324,6 @@ div.CodeMirror-cursors {
|
|||
background: rgba(255, 255, 0, .4);
|
||||
}
|
||||
|
||||
/* IE7 hack to prevent it from returning funny offsetTops on the spans */
|
||||
.CodeMirror span { *vertical-align: text-bottom; }
|
||||
|
||||
/* Used to force a border model for a node */
|
||||
.cm-force-border { padding-right: .1px; }
|
||||
|
||||
|
|
16956
codemirror/lib/codemirror.js
vendored
16956
codemirror/lib/codemirror.js
vendored
File diff suppressed because it is too large
Load Diff
175
codemirror/mode/css/css.js
vendored
175
codemirror/mode/css/css.js
vendored
|
@ -12,6 +12,7 @@
|
|||
"use strict";
|
||||
|
||||
CodeMirror.defineMode("css", function(config, parserConfig) {
|
||||
var inline = parserConfig.inline
|
||||
if (!parserConfig.propertyKeywords) parserConfig = CodeMirror.resolveMode("text/css");
|
||||
|
||||
var indentUnit = config.indentUnit,
|
||||
|
@ -19,13 +20,15 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
|||
documentTypes = parserConfig.documentTypes || {},
|
||||
mediaTypes = parserConfig.mediaTypes || {},
|
||||
mediaFeatures = parserConfig.mediaFeatures || {},
|
||||
mediaValueKeywords = parserConfig.mediaValueKeywords || {},
|
||||
propertyKeywords = parserConfig.propertyKeywords || {},
|
||||
nonStandardPropertyKeywords = parserConfig.nonStandardPropertyKeywords || {},
|
||||
fontProperties = parserConfig.fontProperties || {},
|
||||
counterDescriptors = parserConfig.counterDescriptors || {},
|
||||
colorKeywords = parserConfig.colorKeywords || {},
|
||||
valueKeywords = parserConfig.valueKeywords || {},
|
||||
allowNested = parserConfig.allowNested;
|
||||
allowNested = parserConfig.allowNested,
|
||||
supportsAtComponent = parserConfig.supportsAtComponent === true;
|
||||
|
||||
var type, override;
|
||||
function ret(style, tp) { type = tp; return style; }
|
||||
|
@ -119,13 +122,14 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
|||
this.prev = prev;
|
||||
}
|
||||
|
||||
function pushContext(state, stream, type) {
|
||||
state.context = new Context(type, stream.indentation() + indentUnit, state.context);
|
||||
function pushContext(state, stream, type, indent) {
|
||||
state.context = new Context(type, stream.indentation() + (indent === false ? 0 : indentUnit), state.context);
|
||||
return type;
|
||||
}
|
||||
|
||||
function popContext(state) {
|
||||
state.context = state.context.prev;
|
||||
if (state.context.prev)
|
||||
state.context = state.context.prev;
|
||||
return state.context.type;
|
||||
}
|
||||
|
||||
|
@ -157,9 +161,13 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
|||
return pushContext(state, stream, "block");
|
||||
} else if (type == "}" && state.context.prev) {
|
||||
return popContext(state);
|
||||
} else if (/@(media|supports|(-moz-)?document)/.test(type)) {
|
||||
} else if (supportsAtComponent && /@component/.test(type)) {
|
||||
return pushContext(state, stream, "atComponentBlock");
|
||||
} else if (/^@(-moz-)?document$/.test(type)) {
|
||||
return pushContext(state, stream, "documentTypes");
|
||||
} else if (/^@(media|supports|(-moz-)?document|import)$/.test(type)) {
|
||||
return pushContext(state, stream, "atBlock");
|
||||
} else if (/@(font-face|counter-style)/.test(type)) {
|
||||
} else if (/^@(font-face|counter-style)/.test(type)) {
|
||||
state.stateArg = type;
|
||||
return "restricted_atBlock_before";
|
||||
} else if (/^@(-(moz|ms|o|webkit)-)?keyframes$/.test(type)) {
|
||||
|
@ -219,7 +227,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
|||
if (type == "}" || type == "{") return popAndPass(type, stream, state);
|
||||
if (type == "(") return pushContext(state, stream, "parens");
|
||||
|
||||
if (type == "hash" && !/^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/.test(stream.current())) {
|
||||
if (type == "hash" && !/^#([0-9a-fA-f]{3,4}|[0-9a-fA-f]{6}|[0-9a-fA-f]{8})$/.test(stream.current())) {
|
||||
override += " error";
|
||||
} else if (type == "word") {
|
||||
wordAsValue(stream);
|
||||
|
@ -252,21 +260,32 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
|||
return pass(type, stream, state);
|
||||
};
|
||||
|
||||
states.documentTypes = function(type, stream, state) {
|
||||
if (type == "word" && documentTypes.hasOwnProperty(stream.current())) {
|
||||
override = "tag";
|
||||
return state.context.type;
|
||||
} else {
|
||||
return states.atBlock(type, stream, state);
|
||||
}
|
||||
};
|
||||
|
||||
states.atBlock = function(type, stream, state) {
|
||||
if (type == "(") return pushContext(state, stream, "atBlock_parens");
|
||||
if (type == "}") return popAndPass(type, stream, state);
|
||||
if (type == "}" || type == ";") return popAndPass(type, stream, state);
|
||||
if (type == "{") return popContext(state) && pushContext(state, stream, allowNested ? "block" : "top");
|
||||
|
||||
if (type == "interpolation") return pushContext(state, stream, "interpolation");
|
||||
|
||||
if (type == "word") {
|
||||
var word = stream.current().toLowerCase();
|
||||
if (word == "only" || word == "not" || word == "and" || word == "or")
|
||||
override = "keyword";
|
||||
else if (documentTypes.hasOwnProperty(word))
|
||||
override = "tag";
|
||||
else if (mediaTypes.hasOwnProperty(word))
|
||||
override = "attribute";
|
||||
else if (mediaFeatures.hasOwnProperty(word))
|
||||
override = "property";
|
||||
else if (mediaValueKeywords.hasOwnProperty(word))
|
||||
override = "keyword";
|
||||
else if (propertyKeywords.hasOwnProperty(word))
|
||||
override = "property";
|
||||
else if (nonStandardPropertyKeywords.hasOwnProperty(word))
|
||||
|
@ -281,6 +300,16 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
|||
return state.context.type;
|
||||
};
|
||||
|
||||
states.atComponentBlock = function(type, stream, state) {
|
||||
if (type == "}")
|
||||
return popAndPass(type, stream, state);
|
||||
if (type == "{")
|
||||
return popContext(state) && pushContext(state, stream, allowNested ? "block" : "top", false);
|
||||
if (type == "word")
|
||||
override = "error";
|
||||
return state.context.type;
|
||||
};
|
||||
|
||||
states.atBlock_parens = function(type, stream, state) {
|
||||
if (type == ")") return popContext(state);
|
||||
if (type == "{" || type == "}") return popAndPass(type, stream, state, 2);
|
||||
|
@ -338,9 +367,9 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
|||
return {
|
||||
startState: function(base) {
|
||||
return {tokenize: null,
|
||||
state: "top",
|
||||
state: inline ? "block" : "top",
|
||||
stateArg: null,
|
||||
context: new Context("top", base || 0, null)};
|
||||
context: new Context(inline ? "block" : "top", base || 0, null)};
|
||||
},
|
||||
|
||||
token: function(stream, state) {
|
||||
|
@ -359,12 +388,18 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
|||
var cx = state.context, ch = textAfter && textAfter.charAt(0);
|
||||
var indent = cx.indent;
|
||||
if (cx.type == "prop" && (ch == "}" || ch == ")")) cx = cx.prev;
|
||||
if (cx.prev &&
|
||||
(ch == "}" && (cx.type == "block" || cx.type == "top" || cx.type == "interpolation" || cx.type == "restricted_atBlock") ||
|
||||
ch == ")" && (cx.type == "parens" || cx.type == "atBlock_parens") ||
|
||||
ch == "{" && (cx.type == "at" || cx.type == "atBlock"))) {
|
||||
indent = cx.indent - indentUnit;
|
||||
cx = cx.prev;
|
||||
if (cx.prev) {
|
||||
if (ch == "}" && (cx.type == "block" || cx.type == "top" ||
|
||||
cx.type == "interpolation" || cx.type == "restricted_atBlock")) {
|
||||
// Resume indentation from parent context.
|
||||
cx = cx.prev;
|
||||
indent = cx.indent;
|
||||
} else if (ch == ")" && (cx.type == "parens" || cx.type == "atBlock_parens") ||
|
||||
ch == "{" && (cx.type == "at" || cx.type == "atBlock")) {
|
||||
// Dedent relative to current context.
|
||||
indent = Math.max(0, cx.indent - indentUnit);
|
||||
cx = cx.prev;
|
||||
}
|
||||
}
|
||||
return indent;
|
||||
},
|
||||
|
@ -379,7 +414,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
|||
function keySet(array) {
|
||||
var keys = {};
|
||||
for (var i = 0; i < array.length; ++i) {
|
||||
keys[array[i]] = true;
|
||||
keys[array[i].toLowerCase()] = true;
|
||||
}
|
||||
return keys;
|
||||
}
|
||||
|
@ -401,17 +436,24 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
|||
"min-device-aspect-ratio", "max-device-aspect-ratio", "color", "min-color",
|
||||
"max-color", "color-index", "min-color-index", "max-color-index",
|
||||
"monochrome", "min-monochrome", "max-monochrome", "resolution",
|
||||
"min-resolution", "max-resolution", "scan", "grid"
|
||||
"min-resolution", "max-resolution", "scan", "grid", "orientation",
|
||||
"device-pixel-ratio", "min-device-pixel-ratio", "max-device-pixel-ratio",
|
||||
"pointer", "any-pointer", "hover", "any-hover"
|
||||
], mediaFeatures = keySet(mediaFeatures_);
|
||||
|
||||
var mediaValueKeywords_ = [
|
||||
"landscape", "portrait", "none", "coarse", "fine", "on-demand", "hover",
|
||||
"interlace", "progressive"
|
||||
], mediaValueKeywords = keySet(mediaValueKeywords_);
|
||||
|
||||
var propertyKeywords_ = [
|
||||
"align-content", "align-items", "align-self", "alignment-adjust",
|
||||
"alignment-baseline", "anchor-point", "animation", "animation-delay",
|
||||
"animation-direction", "animation-duration", "animation-fill-mode",
|
||||
"animation-iteration-count", "animation-name", "animation-play-state",
|
||||
"animation-timing-function", "appearance", "azimuth", "backface-visibility",
|
||||
"background", "background-attachment", "background-clip", "background-color",
|
||||
"background-image", "background-origin", "background-position",
|
||||
"background", "background-attachment", "background-blend-mode", "background-clip",
|
||||
"background-color", "background-image", "background-origin", "background-position",
|
||||
"background-repeat", "background-size", "baseline-shift", "binding",
|
||||
"bleed", "bookmark-label", "bookmark-level", "bookmark-state",
|
||||
"bookmark-target", "border", "border-bottom", "border-bottom-color",
|
||||
|
@ -442,9 +484,9 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
|||
"font-variant-alternates", "font-variant-caps", "font-variant-east-asian",
|
||||
"font-variant-ligatures", "font-variant-numeric", "font-variant-position",
|
||||
"font-weight", "grid", "grid-area", "grid-auto-columns", "grid-auto-flow",
|
||||
"grid-auto-position", "grid-auto-rows", "grid-column", "grid-column-end",
|
||||
"grid-column-start", "grid-row", "grid-row-end", "grid-row-start",
|
||||
"grid-template", "grid-template-areas", "grid-template-columns",
|
||||
"grid-auto-rows", "grid-column", "grid-column-end", "grid-column-gap",
|
||||
"grid-column-start", "grid-gap", "grid-row", "grid-row-end", "grid-row-gap",
|
||||
"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",
|
||||
|
@ -452,7 +494,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
|||
"line-stacking-shift", "line-stacking-strategy", "list-style",
|
||||
"list-style-image", "list-style-position", "list-style-type", "margin",
|
||||
"margin-bottom", "margin-left", "margin-right", "margin-top",
|
||||
"marker-offset", "marks", "marquee-direction", "marquee-loop",
|
||||
"marks", "marquee-direction", "marquee-loop",
|
||||
"marquee-play-count", "marquee-speed", "marquee-style", "max-height",
|
||||
"max-width", "min-height", "min-width", "move-to", "nav-down", "nav-index",
|
||||
"nav-left", "nav-right", "nav-up", "object-fit", "object-position",
|
||||
|
@ -480,9 +522,9 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
|||
"text-wrap", "top", "transform", "transform-origin", "transform-style",
|
||||
"transition", "transition-delay", "transition-duration",
|
||||
"transition-property", "transition-timing-function", "unicode-bidi",
|
||||
"vertical-align", "visibility", "voice-balance", "voice-duration",
|
||||
"user-select", "vertical-align", "visibility", "voice-balance", "voice-duration",
|
||||
"voice-family", "voice-pitch", "voice-range", "voice-rate", "voice-stress",
|
||||
"voice-volume", "volume", "white-space", "widows", "width", "word-break",
|
||||
"voice-volume", "volume", "white-space", "widows", "width", "will-change", "word-break",
|
||||
"word-spacing", "word-wrap", "z-index",
|
||||
// SVG-specific
|
||||
"clip-path", "clip-rule", "mask", "enable-background", "filter", "flood-color",
|
||||
|
@ -547,7 +589,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
|||
"above", "absolute", "activeborder", "additive", "activecaption", "afar",
|
||||
"after-white-space", "ahead", "alias", "all", "all-scroll", "alphabetic", "alternate",
|
||||
"always", "amharic", "amharic-abegede", "antialiased", "appworkspace",
|
||||
"arabic-indic", "armenian", "asterisks", "attr", "auto", "avoid", "avoid-column", "avoid-page",
|
||||
"arabic-indic", "armenian", "asterisks", "attr", "auto", "auto-flow", "avoid", "avoid-column", "avoid-page",
|
||||
"avoid-region", "background", "backwards", "baseline", "below", "bidi-override", "binary",
|
||||
"bengali", "blink", "block", "block-axis", "bold", "bolder", "border", "border-box",
|
||||
"both", "bottom", "break", "break-all", "break-word", "bullets", "button", "button-bevel",
|
||||
|
@ -555,11 +597,12 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
|||
"capitalize", "caps-lock-indicator", "caption", "captiontext", "caret",
|
||||
"cell", "center", "checkbox", "circle", "cjk-decimal", "cjk-earthly-branch",
|
||||
"cjk-heavenly-stem", "cjk-ideographic", "clear", "clip", "close-quote",
|
||||
"col-resize", "collapse", "column", "compact", "condensed", "contain", "content",
|
||||
"col-resize", "collapse", "color", "color-burn", "color-dodge", "column", "column-reverse",
|
||||
"compact", "condensed", "contain", "content", "contents",
|
||||
"content-box", "context-menu", "continuous", "copy", "counter", "counters", "cover", "crop",
|
||||
"cross", "crosshair", "currentcolor", "cursive", "cyclic", "dashed", "decimal",
|
||||
"decimal-leading-zero", "default", "default-button", "destination-atop",
|
||||
"destination-in", "destination-out", "destination-over", "devanagari",
|
||||
"cross", "crosshair", "currentcolor", "cursive", "cyclic", "darken", "dashed", "decimal",
|
||||
"decimal-leading-zero", "default", "default-button", "dense", "destination-atop",
|
||||
"destination-in", "destination-out", "destination-over", "devanagari", "difference",
|
||||
"disc", "discard", "disclosure-closed", "disclosure-open", "document",
|
||||
"dot-dash", "dot-dot-dash",
|
||||
"dotted", "double", "down", "e-resize", "ease", "ease-in", "ease-in-out", "ease-out",
|
||||
|
@ -570,23 +613,23 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
|||
"ethiopic-halehame-gez", "ethiopic-halehame-om-et",
|
||||
"ethiopic-halehame-sid-et", "ethiopic-halehame-so-et",
|
||||
"ethiopic-halehame-ti-er", "ethiopic-halehame-ti-et", "ethiopic-halehame-tig",
|
||||
"ethiopic-numeric", "ew-resize", "expanded", "extends", "extra-condensed",
|
||||
"extra-expanded", "fantasy", "fast", "fill", "fixed", "flat", "flex", "footnotes",
|
||||
"forwards", "from", "geometricPrecision", "georgian", "graytext", "groove",
|
||||
"gujarati", "gurmukhi", "hand", "hangul", "hangul-consonant", "hebrew",
|
||||
"ethiopic-numeric", "ew-resize", "exclusion", "expanded", "extends", "extra-condensed",
|
||||
"extra-expanded", "fantasy", "fast", "fill", "fixed", "flat", "flex", "flex-end", "flex-start", "footnotes",
|
||||
"forwards", "from", "geometricPrecision", "georgian", "graytext", "grid", "groove",
|
||||
"gujarati", "gurmukhi", "hand", "hangul", "hangul-consonant", "hard-light", "hebrew",
|
||||
"help", "hidden", "hide", "higher", "highlight", "highlighttext",
|
||||
"hiragana", "hiragana-iroha", "horizontal", "hsl", "hsla", "icon", "ignore",
|
||||
"hiragana", "hiragana-iroha", "horizontal", "hsl", "hsla", "hue", "icon", "ignore",
|
||||
"inactiveborder", "inactivecaption", "inactivecaptiontext", "infinite",
|
||||
"infobackground", "infotext", "inherit", "initial", "inline", "inline-axis",
|
||||
"inline-block", "inline-flex", "inline-table", "inset", "inside", "intrinsic", "invert",
|
||||
"inline-block", "inline-flex", "inline-grid", "inline-table", "inset", "inside", "intrinsic", "invert",
|
||||
"italic", "japanese-formal", "japanese-informal", "justify", "kannada",
|
||||
"katakana", "katakana-iroha", "keep-all", "khmer",
|
||||
"korean-hangul-formal", "korean-hanja-formal", "korean-hanja-informal",
|
||||
"landscape", "lao", "large", "larger", "left", "level", "lighter",
|
||||
"landscape", "lao", "large", "larger", "left", "level", "lighter", "lighten",
|
||||
"line-through", "linear", "linear-gradient", "lines", "list-item", "listbox", "listitem",
|
||||
"local", "logical", "loud", "lower", "lower-alpha", "lower-armenian",
|
||||
"lower-greek", "lower-hexadecimal", "lower-latin", "lower-norwegian",
|
||||
"lower-roman", "lowercase", "ltr", "malayalam", "match", "matrix", "matrix3d",
|
||||
"lower-roman", "lowercase", "ltr", "luminosity", "malayalam", "match", "matrix", "matrix3d",
|
||||
"media-controls-background", "media-current-time-display",
|
||||
"media-fullscreen-button", "media-mute-button", "media-play-button",
|
||||
"media-return-to-realtime-button", "media-rewind-button",
|
||||
|
@ -595,10 +638,10 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
|||
"media-volume-slider-container", "media-volume-sliderthumb", "medium",
|
||||
"menu", "menulist", "menulist-button", "menulist-text",
|
||||
"menulist-textfield", "menutext", "message-box", "middle", "min-intrinsic",
|
||||
"mix", "mongolian", "monospace", "move", "multiple", "myanmar", "n-resize",
|
||||
"mix", "mongolian", "monospace", "move", "multiple", "multiply", "myanmar", "n-resize",
|
||||
"narrower", "ne-resize", "nesw-resize", "no-close-quote", "no-drop",
|
||||
"no-open-quote", "no-repeat", "none", "normal", "not-allowed", "nowrap",
|
||||
"ns-resize", "numbers", "numeric", "nw-resize", "nwse-resize", "oblique", "octal", "open-quote",
|
||||
"ns-resize", "numbers", "numeric", "nw-resize", "nwse-resize", "oblique", "octal", "opacity", "open-quote",
|
||||
"optimizeLegibility", "optimizeSpeed", "oriya", "oromo", "outset",
|
||||
"outside", "outside-shape", "overlay", "overline", "padding", "padding-box",
|
||||
"painted", "page", "paused", "persian", "perspective", "plus-darker", "plus-lighter",
|
||||
|
@ -608,17 +651,17 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
|||
"relative", "repeat", "repeating-linear-gradient",
|
||||
"repeating-radial-gradient", "repeat-x", "repeat-y", "reset", "reverse",
|
||||
"rgb", "rgba", "ridge", "right", "rotate", "rotate3d", "rotateX", "rotateY",
|
||||
"rotateZ", "round", "row-resize", "rtl", "run-in", "running",
|
||||
"s-resize", "sans-serif", "scale", "scale3d", "scaleX", "scaleY", "scaleZ",
|
||||
"scroll", "scrollbar", "se-resize", "searchfield",
|
||||
"rotateZ", "round", "row", "row-resize", "row-reverse", "rtl", "run-in", "running",
|
||||
"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",
|
||||
"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", "solid", "somali",
|
||||
"source-atop", "source-in", "source-out", "source-over", "space", "spell-out", "square",
|
||||
"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",
|
||||
"square-button", "start", "static", "status-bar", "stretch", "stroke", "sub",
|
||||
"subpixel-antialiased", "super", "sw-resize", "symbolic", "symbols", "table",
|
||||
"table-caption", "table-cell", "table-column", "table-column-group",
|
||||
|
@ -628,19 +671,20 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
|||
"thick", "thin", "threeddarkshadow", "threedface", "threedhighlight",
|
||||
"threedlightshadow", "threedshadow", "tibetan", "tigre", "tigrinya-er",
|
||||
"tigrinya-er-abegede", "tigrinya-et", "tigrinya-et-abegede", "to", "top",
|
||||
"trad-chinese-formal", "trad-chinese-informal",
|
||||
"trad-chinese-formal", "trad-chinese-informal", "transform",
|
||||
"translate", "translate3d", "translateX", "translateY", "translateZ",
|
||||
"transparent", "ultra-condensed", "ultra-expanded", "underline", "up",
|
||||
"transparent", "ultra-condensed", "ultra-expanded", "underline", "unset", "up",
|
||||
"upper-alpha", "upper-armenian", "upper-greek", "upper-hexadecimal",
|
||||
"upper-latin", "upper-norwegian", "upper-roman", "uppercase", "urdu", "url",
|
||||
"var", "vertical", "vertical-text", "visible", "visibleFill", "visiblePainted",
|
||||
"visibleStroke", "visual", "w-resize", "wait", "wave", "wider",
|
||||
"window", "windowframe", "windowtext", "words", "x-large", "x-small", "xor",
|
||||
"window", "windowframe", "windowtext", "words", "wrap", "wrap-reverse", "x-large", "x-small", "xor",
|
||||
"xx-large", "xx-small"
|
||||
], valueKeywords = keySet(valueKeywords_);
|
||||
|
||||
var allWords = documentTypes_.concat(mediaTypes_).concat(mediaFeatures_).concat(propertyKeywords_)
|
||||
.concat(nonStandardPropertyKeywords_).concat(colorKeywords_).concat(valueKeywords_);
|
||||
var allWords = documentTypes_.concat(mediaTypes_).concat(mediaFeatures_).concat(mediaValueKeywords_)
|
||||
.concat(propertyKeywords_).concat(nonStandardPropertyKeywords_).concat(colorKeywords_)
|
||||
.concat(valueKeywords_);
|
||||
CodeMirror.registerHelper("hintWords", "css", allWords);
|
||||
|
||||
function tokenCComment(stream, state) {
|
||||
|
@ -659,6 +703,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
|||
documentTypes: documentTypes,
|
||||
mediaTypes: mediaTypes,
|
||||
mediaFeatures: mediaFeatures,
|
||||
mediaValueKeywords: mediaValueKeywords,
|
||||
propertyKeywords: propertyKeywords,
|
||||
nonStandardPropertyKeywords: nonStandardPropertyKeywords,
|
||||
fontProperties: fontProperties,
|
||||
|
@ -678,6 +723,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
|||
CodeMirror.defineMIME("text/x-scss", {
|
||||
mediaTypes: mediaTypes,
|
||||
mediaFeatures: mediaFeatures,
|
||||
mediaValueKeywords: mediaValueKeywords,
|
||||
propertyKeywords: propertyKeywords,
|
||||
nonStandardPropertyKeywords: nonStandardPropertyKeywords,
|
||||
colorKeywords: colorKeywords,
|
||||
|
@ -719,6 +765,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
|||
CodeMirror.defineMIME("text/x-less", {
|
||||
mediaTypes: mediaTypes,
|
||||
mediaFeatures: mediaFeatures,
|
||||
mediaValueKeywords: mediaValueKeywords,
|
||||
propertyKeywords: propertyKeywords,
|
||||
nonStandardPropertyKeywords: nonStandardPropertyKeywords,
|
||||
colorKeywords: colorKeywords,
|
||||
|
@ -753,4 +800,26 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
|||
helperType: "less"
|
||||
});
|
||||
|
||||
CodeMirror.defineMIME("text/x-gss", {
|
||||
documentTypes: documentTypes,
|
||||
mediaTypes: mediaTypes,
|
||||
mediaFeatures: mediaFeatures,
|
||||
propertyKeywords: propertyKeywords,
|
||||
nonStandardPropertyKeywords: nonStandardPropertyKeywords,
|
||||
fontProperties: fontProperties,
|
||||
counterDescriptors: counterDescriptors,
|
||||
colorKeywords: colorKeywords,
|
||||
valueKeywords: valueKeywords,
|
||||
supportsAtComponent: true,
|
||||
tokenHooks: {
|
||||
"/": function(stream, state) {
|
||||
if (!stream.eat("*")) return false;
|
||||
state.tokenize = tokenCComment;
|
||||
return tokenCComment(stream, state);
|
||||
}
|
||||
},
|
||||
name: "css",
|
||||
helperType: "gss"
|
||||
});
|
||||
|
||||
});
|
||||
|
|
103
codemirror/mode/css/gss.html
vendored
Normal file
103
codemirror/mode/css/gss.html
vendored
Normal file
|
@ -0,0 +1,103 @@
|
|||
<!doctype html>
|
||||
|
||||
<title>CodeMirror: Closure Stylesheets (GSS) mode</title>
|
||||
<meta charset="utf-8"/>
|
||||
<link rel=stylesheet href="../../doc/docs.css">
|
||||
|
||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
||||
<link rel="stylesheet" href="../../addon/hint/show-hint.css">
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="css.js"></script>
|
||||
<script src="../../addon/hint/show-hint.js"></script>
|
||||
<script src="../../addon/hint/css-hint.js"></script>
|
||||
<style>.CodeMirror {background: #f8f8f8;}</style>
|
||||
<div id=nav>
|
||||
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
|
||||
|
||||
<ul>
|
||||
<li><a href="../../index.html">Home</a>
|
||||
<li><a href="../../doc/manual.html">Manual</a>
|
||||
<li><a href="https://github.com/codemirror/codemirror">Code</a>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><a href="../index.html">Language modes</a>
|
||||
<li><a class=active href="#">Closure Stylesheets (GSS)</a>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<article>
|
||||
<h2>Closure Stylesheets (GSS) mode</h2>
|
||||
<form><textarea id="code" name="code">
|
||||
/* Some example Closure Stylesheets */
|
||||
|
||||
@provide 'some.styles';
|
||||
|
||||
@require 'other.styles';
|
||||
|
||||
@component {
|
||||
|
||||
@def FONT_FAMILY "Times New Roman", Georgia, Serif;
|
||||
@def FONT_SIZE_NORMAL 15px;
|
||||
@def FONT_NORMAL normal FONT_SIZE_NORMAL FONT_FAMILY;
|
||||
|
||||
@def BG_COLOR rgb(235, 239, 249);
|
||||
|
||||
@def DIALOG_BORDER_COLOR rgb(107, 144, 218);
|
||||
@def DIALOG_BG_COLOR BG_COLOR;
|
||||
|
||||
@def LEFT_HAND_NAV_WIDTH 180px;
|
||||
@def LEFT_HAND_NAV_PADDING 3px;
|
||||
|
||||
@defmixin size(WIDTH, HEIGHT) {
|
||||
width: WIDTH;
|
||||
height: HEIGHT;
|
||||
}
|
||||
|
||||
body {
|
||||
background-color: BG_COLOR;
|
||||
margin: 0;
|
||||
padding: 3em 6em;
|
||||
font: FONT_NORMAL;
|
||||
color: #000;
|
||||
}
|
||||
|
||||
#navigation a {
|
||||
font-weight: bold;
|
||||
text-decoration: none !important;
|
||||
}
|
||||
|
||||
.dialog {
|
||||
background-color: DIALOG_BG_COLOR;
|
||||
border: 1px solid DIALOG_BORDER_COLOR;
|
||||
}
|
||||
|
||||
.content {
|
||||
position: absolute;
|
||||
margin-left: add(LEFT_HAND_NAV_PADDING, /* padding left */
|
||||
LEFT_HAND_NAV_WIDTH,
|
||||
LEFT_HAND_NAV_PADDING); /* padding right */
|
||||
|
||||
}
|
||||
|
||||
.logo {
|
||||
@mixin size(150px, 55px);
|
||||
background-image: url('http://www.google.com/images/logo_sm.gif');
|
||||
}
|
||||
|
||||
}
|
||||
</textarea></form>
|
||||
<script>
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
||||
extraKeys: {"Ctrl-Space": "autocomplete"},
|
||||
lineNumbers: true,
|
||||
matchBrackets: "text/x-less",
|
||||
mode: "text/x-gss"
|
||||
});
|
||||
</script>
|
||||
|
||||
<p>A mode for <a href="https://github.com/google/closure-stylesheets">Closure Stylesheets</a> (GSS).</p>
|
||||
<p><strong>MIME type defined:</strong> <code>text/x-gss</code>.</p>
|
||||
|
||||
<p><strong>Parsing/Highlighting Tests:</strong> <a href="../../test/index.html#gss_*">normal</a>, <a href="../../test/index.html#verbose,gss_*">verbose</a>.</p>
|
||||
|
||||
</article>
|
17
codemirror/mode/css/gss_test.js
vendored
Normal file
17
codemirror/mode/css/gss_test.js
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function() {
|
||||
"use strict";
|
||||
|
||||
var mode = CodeMirror.getMode({indentUnit: 2}, "text/x-gss");
|
||||
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1), "gss"); }
|
||||
|
||||
MT("atComponent",
|
||||
"[def @component] {",
|
||||
"[tag foo] {",
|
||||
" [property color]: [keyword black];",
|
||||
"}",
|
||||
"}");
|
||||
|
||||
})();
|
75
codemirror/mode/css/index.html
vendored
Normal file
75
codemirror/mode/css/index.html
vendored
Normal file
|
@ -0,0 +1,75 @@
|
|||
<!doctype html>
|
||||
|
||||
<title>CodeMirror: CSS mode</title>
|
||||
<meta charset="utf-8"/>
|
||||
<link rel=stylesheet href="../../doc/docs.css">
|
||||
|
||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
||||
<link rel="stylesheet" href="../../addon/hint/show-hint.css">
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="css.js"></script>
|
||||
<script src="../../addon/hint/show-hint.js"></script>
|
||||
<script src="../../addon/hint/css-hint.js"></script>
|
||||
<style>.CodeMirror {background: #f8f8f8;}</style>
|
||||
<div id=nav>
|
||||
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
|
||||
|
||||
<ul>
|
||||
<li><a href="../../index.html">Home</a>
|
||||
<li><a href="../../doc/manual.html">Manual</a>
|
||||
<li><a href="https://github.com/codemirror/codemirror">Code</a>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><a href="../index.html">Language modes</a>
|
||||
<li><a class=active href="#">CSS</a>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<article>
|
||||
<h2>CSS mode</h2>
|
||||
<form><textarea id="code" name="code">
|
||||
/* Some example CSS */
|
||||
|
||||
@import url("something.css");
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 3em 6em;
|
||||
font-family: tahoma, arial, sans-serif;
|
||||
color: #000;
|
||||
}
|
||||
|
||||
#navigation a {
|
||||
font-weight: bold;
|
||||
text-decoration: none !important;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 2.5em;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 1.7em;
|
||||
}
|
||||
|
||||
h1:before, h2:before {
|
||||
content: "::";
|
||||
}
|
||||
|
||||
code {
|
||||
font-family: courier, monospace;
|
||||
font-size: 80%;
|
||||
color: #418A8A;
|
||||
}
|
||||
</textarea></form>
|
||||
<script>
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
||||
extraKeys: {"Ctrl-Space": "autocomplete"},
|
||||
});
|
||||
</script>
|
||||
|
||||
<p><strong>MIME types defined:</strong> <code>text/css</code>, <code>text/x-scss</code> (<a href="scss.html">demo</a>), <code>text/x-less</code> (<a href="less.html">demo</a>).</p>
|
||||
|
||||
<p><strong>Parsing/Highlighting Tests:</strong> <a href="../../test/index.html#css_*">normal</a>, <a href="../../test/index.html#verbose,css_*">verbose</a>.</p>
|
||||
|
||||
</article>
|
152
codemirror/mode/css/less.html
vendored
Normal file
152
codemirror/mode/css/less.html
vendored
Normal file
|
@ -0,0 +1,152 @@
|
|||
<!doctype html>
|
||||
|
||||
<title>CodeMirror: LESS mode</title>
|
||||
<meta charset="utf-8"/>
|
||||
<link rel=stylesheet href="../../doc/docs.css">
|
||||
|
||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="../../addon/edit/matchbrackets.js"></script>
|
||||
<script src="css.js"></script>
|
||||
<style>.CodeMirror {border: 1px solid #ddd; line-height: 1.2;}</style>
|
||||
<div id=nav>
|
||||
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
|
||||
|
||||
<ul>
|
||||
<li><a href="../../index.html">Home</a>
|
||||
<li><a href="../../doc/manual.html">Manual</a>
|
||||
<li><a href="https://github.com/codemirror/codemirror">Code</a>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><a href="../index.html">Language modes</a>
|
||||
<li><a class=active href="#">LESS</a>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<article>
|
||||
<h2>LESS mode</h2>
|
||||
<form><textarea id="code" name="code">@media screen and (device-aspect-ratio: 16/9) { … }
|
||||
@media screen and (device-aspect-ratio: 1280/720) { … }
|
||||
@media screen and (device-aspect-ratio: 2560/1440) { … }
|
||||
|
||||
html:lang(fr-be)
|
||||
|
||||
tr:nth-child(2n+1) /* represents every odd row of an HTML table */
|
||||
|
||||
img:nth-of-type(2n+1) { float: right; }
|
||||
img:nth-of-type(2n) { float: left; }
|
||||
|
||||
body > h2:not(:first-of-type):not(:last-of-type)
|
||||
|
||||
html|*:not(:link):not(:visited)
|
||||
*|*:not(:hover)
|
||||
p::first-line { text-transform: uppercase }
|
||||
|
||||
@namespace foo url(http://www.example.com);
|
||||
foo|h1 { color: blue } /* first rule */
|
||||
|
||||
span[hello="Ocean"][goodbye="Land"]
|
||||
|
||||
E[foo]{
|
||||
padding:65px;
|
||||
}
|
||||
|
||||
input[type="search"]::-webkit-search-decoration,
|
||||
input[type="search"]::-webkit-search-cancel-button {
|
||||
-webkit-appearance: none; // Inner-padding issues in Chrome OSX, Safari 5
|
||||
}
|
||||
button::-moz-focus-inner,
|
||||
input::-moz-focus-inner { // Inner padding and border oddities in FF3/4
|
||||
padding: 0;
|
||||
border: 0;
|
||||
}
|
||||
.btn {
|
||||
// reset here as of 2.0.3 due to Recess property order
|
||||
border-color: #ccc;
|
||||
border-color: rgba(0,0,0,.1) rgba(0,0,0,.1) rgba(0,0,0,.25);
|
||||
}
|
||||
fieldset span button, fieldset span input[type="file"] {
|
||||
font-size:12px;
|
||||
font-family:Arial, Helvetica, sans-serif;
|
||||
}
|
||||
|
||||
.rounded-corners (@radius: 5px) {
|
||||
border-radius: @radius;
|
||||
-webkit-border-radius: @radius;
|
||||
-moz-border-radius: @radius;
|
||||
}
|
||||
|
||||
@import url("something.css");
|
||||
|
||||
@light-blue: hsl(190, 50%, 65%);
|
||||
|
||||
#menu {
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
z-index: 3;
|
||||
clear: both;
|
||||
display: block;
|
||||
background-color: @blue;
|
||||
height: 42px;
|
||||
border-top: 2px solid lighten(@alpha-blue, 20%);
|
||||
border-bottom: 2px solid darken(@alpha-blue, 25%);
|
||||
.box-shadow(0, 1px, 8px, 0.6);
|
||||
-moz-box-shadow: 0 0 0 #000; // Because firefox sucks.
|
||||
|
||||
&.docked {
|
||||
background-color: hsla(210, 60%, 40%, 0.4);
|
||||
}
|
||||
&:hover {
|
||||
background-color: @blue;
|
||||
}
|
||||
|
||||
#dropdown {
|
||||
margin: 0 0 0 117px;
|
||||
padding: 0;
|
||||
padding-top: 5px;
|
||||
display: none;
|
||||
width: 190px;
|
||||
border-top: 2px solid @medium;
|
||||
color: @highlight;
|
||||
border: 2px solid darken(@medium, 25%);
|
||||
border-left-color: darken(@medium, 15%);
|
||||
border-right-color: darken(@medium, 15%);
|
||||
border-top-width: 0;
|
||||
background-color: darken(@medium, 10%);
|
||||
ul {
|
||||
padding: 0px;
|
||||
}
|
||||
li {
|
||||
font-size: 14px;
|
||||
display: block;
|
||||
text-align: left;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
a {
|
||||
display: block;
|
||||
padding: 0px 15px;
|
||||
text-decoration: none;
|
||||
color: white;
|
||||
&:hover {
|
||||
background-color: darken(@medium, 15%);
|
||||
text-decoration: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
.border-radius(5px, bottom);
|
||||
.box-shadow(0, 6px, 8px, 0.5);
|
||||
}
|
||||
}
|
||||
</textarea></form>
|
||||
<script>
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
||||
lineNumbers : true,
|
||||
matchBrackets : true,
|
||||
mode: "text/x-less"
|
||||
});
|
||||
</script>
|
||||
|
||||
<p>The LESS mode is a sub-mode of the <a href="index.html">CSS mode</a> (defined in <code>css.js</code>).</p>
|
||||
|
||||
<p><strong>Parsing/Highlighting Tests:</strong> <a href="../../test/index.html#less_*">normal</a>, <a href="../../test/index.html#verbose,less_*">verbose</a>.</p>
|
||||
</article>
|
54
codemirror/mode/css/less_test.js
vendored
Normal file
54
codemirror/mode/css/less_test.js
vendored
Normal file
|
@ -0,0 +1,54 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function() {
|
||||
"use strict";
|
||||
|
||||
var mode = CodeMirror.getMode({indentUnit: 2}, "text/x-less");
|
||||
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1), "less"); }
|
||||
|
||||
MT("variable",
|
||||
"[variable-2 @base]: [atom #f04615];",
|
||||
"[qualifier .class] {",
|
||||
" [property width]: [variable percentage]([number 0.5]); [comment // returns `50%`]",
|
||||
" [property color]: [variable saturate]([variable-2 @base], [number 5%]);",
|
||||
"}");
|
||||
|
||||
MT("amp",
|
||||
"[qualifier .child], [qualifier .sibling] {",
|
||||
" [qualifier .parent] [atom &] {",
|
||||
" [property color]: [keyword black];",
|
||||
" }",
|
||||
" [atom &] + [atom &] {",
|
||||
" [property color]: [keyword red];",
|
||||
" }",
|
||||
"}");
|
||||
|
||||
MT("mixin",
|
||||
"[qualifier .mixin] ([variable dark]; [variable-2 @color]) {",
|
||||
" [property color]: [atom darken]([variable-2 @color], [number 10%]);",
|
||||
"}",
|
||||
"[qualifier .mixin] ([variable light]; [variable-2 @color]) {",
|
||||
" [property color]: [atom lighten]([variable-2 @color], [number 10%]);",
|
||||
"}",
|
||||
"[qualifier .mixin] ([variable-2 @_]; [variable-2 @color]) {",
|
||||
" [property display]: [atom block];",
|
||||
"}",
|
||||
"[variable-2 @switch]: [variable light];",
|
||||
"[qualifier .class] {",
|
||||
" [qualifier .mixin]([variable-2 @switch]; [atom #888]);",
|
||||
"}");
|
||||
|
||||
MT("nest",
|
||||
"[qualifier .one] {",
|
||||
" [def @media] ([property width]: [number 400px]) {",
|
||||
" [property font-size]: [number 1.2em];",
|
||||
" [def @media] [attribute print] [keyword and] [property color] {",
|
||||
" [property color]: [keyword blue];",
|
||||
" }",
|
||||
" }",
|
||||
"}");
|
||||
|
||||
|
||||
MT("interpolation", ".@{[variable foo]} { [property font-weight]: [atom bold]; }");
|
||||
})();
|
157
codemirror/mode/css/scss.html
vendored
Normal file
157
codemirror/mode/css/scss.html
vendored
Normal file
|
@ -0,0 +1,157 @@
|
|||
<!doctype html>
|
||||
|
||||
<title>CodeMirror: SCSS mode</title>
|
||||
<meta charset="utf-8"/>
|
||||
<link rel=stylesheet href="../../doc/docs.css">
|
||||
|
||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="css.js"></script>
|
||||
<style>.CodeMirror {background: #f8f8f8;}</style>
|
||||
<div id=nav>
|
||||
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
|
||||
|
||||
<ul>
|
||||
<li><a href="../../index.html">Home</a>
|
||||
<li><a href="../../doc/manual.html">Manual</a>
|
||||
<li><a href="https://github.com/codemirror/codemirror">Code</a>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><a href="../index.html">Language modes</a>
|
||||
<li><a class=active href="#">SCSS</a>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<article>
|
||||
<h2>SCSS mode</h2>
|
||||
<form><textarea id="code" name="code">
|
||||
/* Some example SCSS */
|
||||
|
||||
@import "compass/css3";
|
||||
$variable: #333;
|
||||
|
||||
$blue: #3bbfce;
|
||||
$margin: 16px;
|
||||
|
||||
.content-navigation {
|
||||
#nested {
|
||||
background-color: black;
|
||||
}
|
||||
border-color: $blue;
|
||||
color:
|
||||
darken($blue, 9%);
|
||||
}
|
||||
|
||||
.border {
|
||||
padding: $margin / 2;
|
||||
margin: $margin / 2;
|
||||
border-color: $blue;
|
||||
}
|
||||
|
||||
@mixin table-base {
|
||||
th {
|
||||
text-align: center;
|
||||
font-weight: bold;
|
||||
}
|
||||
td, th {padding: 2px}
|
||||
}
|
||||
|
||||
table.hl {
|
||||
margin: 2em 0;
|
||||
td.ln {
|
||||
text-align: right;
|
||||
}
|
||||
}
|
||||
|
||||
li {
|
||||
font: {
|
||||
family: serif;
|
||||
weight: bold;
|
||||
size: 1.2em;
|
||||
}
|
||||
}
|
||||
|
||||
@mixin left($dist) {
|
||||
float: left;
|
||||
margin-left: $dist;
|
||||
}
|
||||
|
||||
#data {
|
||||
@include left(10px);
|
||||
@include table-base;
|
||||
}
|
||||
|
||||
.source {
|
||||
@include flow-into(target);
|
||||
border: 10px solid green;
|
||||
margin: 20px;
|
||||
width: 200px; }
|
||||
|
||||
.new-container {
|
||||
@include flow-from(target);
|
||||
border: 10px solid red;
|
||||
margin: 20px;
|
||||
width: 200px; }
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 3em 6em;
|
||||
font-family: tahoma, arial, sans-serif;
|
||||
color: #000;
|
||||
}
|
||||
|
||||
@mixin yellow() {
|
||||
background: yellow;
|
||||
}
|
||||
|
||||
.big {
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.nested {
|
||||
@include border-radius(3px);
|
||||
@extend .big;
|
||||
p {
|
||||
background: whitesmoke;
|
||||
a {
|
||||
color: red;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#navigation a {
|
||||
font-weight: bold;
|
||||
text-decoration: none !important;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 2.5em;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 1.7em;
|
||||
}
|
||||
|
||||
h1:before, h2:before {
|
||||
content: "::";
|
||||
}
|
||||
|
||||
code {
|
||||
font-family: courier, monospace;
|
||||
font-size: 80%;
|
||||
color: #418A8A;
|
||||
}
|
||||
</textarea></form>
|
||||
<script>
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
||||
lineNumbers: true,
|
||||
matchBrackets: true,
|
||||
mode: "text/x-scss"
|
||||
});
|
||||
</script>
|
||||
|
||||
<p>The SCSS mode is a sub-mode of the <a href="index.html">CSS mode</a> (defined in <code>css.js</code>).</p>
|
||||
|
||||
<p><strong>Parsing/Highlighting Tests:</strong> <a href="../../test/index.html#scss_*">normal</a>, <a href="../../test/index.html#verbose,scss_*">verbose</a>.</p>
|
||||
|
||||
</article>
|
110
codemirror/mode/css/scss_test.js
vendored
Normal file
110
codemirror/mode/css/scss_test.js
vendored
Normal file
|
@ -0,0 +1,110 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function() {
|
||||
var mode = CodeMirror.getMode({indentUnit: 2}, "text/x-scss");
|
||||
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1), "scss"); }
|
||||
|
||||
MT('url_with_quotation',
|
||||
"[tag foo] { [property background]:[atom url]([string test.jpg]) }");
|
||||
|
||||
MT('url_with_double_quotes',
|
||||
"[tag foo] { [property background]:[atom url]([string \"test.jpg\"]) }");
|
||||
|
||||
MT('url_with_single_quotes',
|
||||
"[tag foo] { [property background]:[atom url]([string \'test.jpg\']) }");
|
||||
|
||||
MT('string',
|
||||
"[def @import] [string \"compass/css3\"]");
|
||||
|
||||
MT('important_keyword',
|
||||
"[tag foo] { [property background]:[atom url]([string \'test.jpg\']) [keyword !important] }");
|
||||
|
||||
MT('variable',
|
||||
"[variable-2 $blue]:[atom #333]");
|
||||
|
||||
MT('variable_as_attribute',
|
||||
"[tag foo] { [property color]:[variable-2 $blue] }");
|
||||
|
||||
MT('numbers',
|
||||
"[tag foo] { [property padding]:[number 10px] [number 10] [number 10em] [number 8in] }");
|
||||
|
||||
MT('number_percentage',
|
||||
"[tag foo] { [property width]:[number 80%] }");
|
||||
|
||||
MT('selector',
|
||||
"[builtin #hello][qualifier .world]{}");
|
||||
|
||||
MT('singleline_comment',
|
||||
"[comment // this is a comment]");
|
||||
|
||||
MT('multiline_comment',
|
||||
"[comment /*foobar*/]");
|
||||
|
||||
MT('attribute_with_hyphen',
|
||||
"[tag foo] { [property font-size]:[number 10px] }");
|
||||
|
||||
MT('string_after_attribute',
|
||||
"[tag foo] { [property content]:[string \"::\"] }");
|
||||
|
||||
MT('directives',
|
||||
"[def @include] [qualifier .mixin]");
|
||||
|
||||
MT('basic_structure',
|
||||
"[tag p] { [property background]:[keyword red]; }");
|
||||
|
||||
MT('nested_structure',
|
||||
"[tag p] { [tag a] { [property color]:[keyword red]; } }");
|
||||
|
||||
MT('mixin',
|
||||
"[def @mixin] [tag table-base] {}");
|
||||
|
||||
MT('number_without_semicolon',
|
||||
"[tag p] {[property width]:[number 12]}",
|
||||
"[tag a] {[property color]:[keyword red];}");
|
||||
|
||||
MT('atom_in_nested_block',
|
||||
"[tag p] { [tag a] { [property color]:[atom #000]; } }");
|
||||
|
||||
MT('interpolation_in_property',
|
||||
"[tag foo] { #{[variable-2 $hello]}:[number 2]; }");
|
||||
|
||||
MT('interpolation_in_selector',
|
||||
"[tag foo]#{[variable-2 $hello]} { [property color]:[atom #000]; }");
|
||||
|
||||
MT('interpolation_error',
|
||||
"[tag foo]#{[variable foo]} { [property color]:[atom #000]; }");
|
||||
|
||||
MT("divide_operator",
|
||||
"[tag foo] { [property width]:[number 4] [operator /] [number 2] }");
|
||||
|
||||
MT('nested_structure_with_id_selector',
|
||||
"[tag p] { [builtin #hello] { [property color]:[keyword red]; } }");
|
||||
|
||||
MT('indent_mixin',
|
||||
"[def @mixin] [tag container] (",
|
||||
" [variable-2 $a]: [number 10],",
|
||||
" [variable-2 $b]: [number 10])",
|
||||
"{}");
|
||||
|
||||
MT('indent_nested',
|
||||
"[tag foo] {",
|
||||
" [tag bar] {",
|
||||
" }",
|
||||
"}");
|
||||
|
||||
MT('indent_parentheses',
|
||||
"[tag foo] {",
|
||||
" [property color]: [atom darken]([variable-2 $blue],",
|
||||
" [number 9%]);",
|
||||
"}");
|
||||
|
||||
MT('indent_vardef',
|
||||
"[variable-2 $name]:",
|
||||
" [string 'val'];",
|
||||
"[tag tag] {",
|
||||
" [tag inner] {",
|
||||
" [property margin]: [number 3px];",
|
||||
" }",
|
||||
"}");
|
||||
})();
|
200
codemirror/mode/css/test.js
vendored
Normal file
200
codemirror/mode/css/test.js
vendored
Normal file
|
@ -0,0 +1,200 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function() {
|
||||
var mode = CodeMirror.getMode({indentUnit: 2}, "css");
|
||||
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
|
||||
|
||||
// Error, because "foobarhello" is neither a known type or property, but
|
||||
// property was expected (after "and"), and it should be in parentheses.
|
||||
MT("atMediaUnknownType",
|
||||
"[def @media] [attribute screen] [keyword and] [error foobarhello] { }");
|
||||
|
||||
// Soft error, because "foobarhello" is not a known property or type.
|
||||
MT("atMediaUnknownProperty",
|
||||
"[def @media] [attribute screen] [keyword and] ([error foobarhello]) { }");
|
||||
|
||||
// Make sure nesting works with media queries
|
||||
MT("atMediaMaxWidthNested",
|
||||
"[def @media] [attribute screen] [keyword and] ([property max-width]: [number 25px]) { [tag foo] { } }");
|
||||
|
||||
MT("atMediaFeatureValueKeyword",
|
||||
"[def @media] ([property orientation]: [keyword landscape]) { }");
|
||||
|
||||
MT("atMediaUnknownFeatureValueKeyword",
|
||||
"[def @media] ([property orientation]: [error upsidedown]) { }");
|
||||
|
||||
MT("tagSelector",
|
||||
"[tag foo] { }");
|
||||
|
||||
MT("classSelector",
|
||||
"[qualifier .foo-bar_hello] { }");
|
||||
|
||||
MT("idSelector",
|
||||
"[builtin #foo] { [error #foo] }");
|
||||
|
||||
MT("tagSelectorUnclosed",
|
||||
"[tag foo] { [property margin]: [number 0] } [tag bar] { }");
|
||||
|
||||
MT("tagStringNoQuotes",
|
||||
"[tag foo] { [property font-family]: [variable hello] [variable world]; }");
|
||||
|
||||
MT("tagStringDouble",
|
||||
"[tag foo] { [property font-family]: [string \"hello world\"]; }");
|
||||
|
||||
MT("tagStringSingle",
|
||||
"[tag foo] { [property font-family]: [string 'hello world']; }");
|
||||
|
||||
MT("tagColorKeyword",
|
||||
"[tag foo] {",
|
||||
" [property color]: [keyword black];",
|
||||
" [property color]: [keyword navy];",
|
||||
" [property color]: [keyword yellow];",
|
||||
"}");
|
||||
|
||||
MT("tagColorHex3",
|
||||
"[tag foo] { [property background]: [atom #fff]; }");
|
||||
|
||||
MT("tagColorHex4",
|
||||
"[tag foo] { [property background]: [atom #ffff]; }");
|
||||
|
||||
MT("tagColorHex6",
|
||||
"[tag foo] { [property background]: [atom #ffffff]; }");
|
||||
|
||||
MT("tagColorHex8",
|
||||
"[tag foo] { [property background]: [atom #ffffffff]; }");
|
||||
|
||||
MT("tagColorHex5Invalid",
|
||||
"[tag foo] { [property background]: [atom&error #fffff]; }");
|
||||
|
||||
MT("tagColorHexInvalid",
|
||||
"[tag foo] { [property background]: [atom&error #ffg]; }");
|
||||
|
||||
MT("tagNegativeNumber",
|
||||
"[tag foo] { [property margin]: [number -5px]; }");
|
||||
|
||||
MT("tagPositiveNumber",
|
||||
"[tag foo] { [property padding]: [number 5px]; }");
|
||||
|
||||
MT("tagVendor",
|
||||
"[tag foo] { [meta -foo-][property box-sizing]: [meta -foo-][atom border-box]; }");
|
||||
|
||||
MT("tagBogusProperty",
|
||||
"[tag foo] { [property&error barhelloworld]: [number 0]; }");
|
||||
|
||||
MT("tagTwoProperties",
|
||||
"[tag foo] { [property margin]: [number 0]; [property padding]: [number 0]; }");
|
||||
|
||||
MT("tagTwoPropertiesURL",
|
||||
"[tag foo] { [property background]: [atom url]([string //example.com/foo.png]); [property padding]: [number 0]; }");
|
||||
|
||||
MT("indent_tagSelector",
|
||||
"[tag strong], [tag em] {",
|
||||
" [property background]: [atom rgba](",
|
||||
" [number 255], [number 255], [number 0], [number .2]",
|
||||
" );",
|
||||
"}");
|
||||
|
||||
MT("indent_atMedia",
|
||||
"[def @media] {",
|
||||
" [tag foo] {",
|
||||
" [property color]:",
|
||||
" [keyword yellow];",
|
||||
" }",
|
||||
"}");
|
||||
|
||||
MT("indent_comma",
|
||||
"[tag foo] {",
|
||||
" [property font-family]: [variable verdana],",
|
||||
" [atom sans-serif];",
|
||||
"}");
|
||||
|
||||
MT("indent_parentheses",
|
||||
"[tag foo]:[variable-3 before] {",
|
||||
" [property background]: [atom url](",
|
||||
"[string blahblah]",
|
||||
"[string etc]",
|
||||
"[string ]) [keyword !important];",
|
||||
"}");
|
||||
|
||||
MT("font_face",
|
||||
"[def @font-face] {",
|
||||
" [property font-family]: [string 'myfont'];",
|
||||
" [error nonsense]: [string 'abc'];",
|
||||
" [property src]: [atom url]([string http://blah]),",
|
||||
" [atom url]([string http://foo]);",
|
||||
"}");
|
||||
|
||||
MT("empty_url",
|
||||
"[def @import] [atom url]() [attribute screen];");
|
||||
|
||||
MT("parens",
|
||||
"[qualifier .foo] {",
|
||||
" [property background-image]: [variable fade]([atom #000], [number 20%]);",
|
||||
" [property border-image]: [atom linear-gradient](",
|
||||
" [atom to] [atom bottom],",
|
||||
" [variable fade]([atom #000], [number 20%]) [number 0%],",
|
||||
" [variable fade]([atom #000], [number 20%]) [number 100%]",
|
||||
" );",
|
||||
"}");
|
||||
|
||||
MT("css_variable",
|
||||
":[variable-3 root] {",
|
||||
" [variable-2 --main-color]: [atom #06c];",
|
||||
"}",
|
||||
"[tag h1][builtin #foo] {",
|
||||
" [property color]: [atom var]([variable-2 --main-color]);",
|
||||
"}");
|
||||
|
||||
MT("supports",
|
||||
"[def @supports] ([keyword not] (([property text-align-last]: [atom justify]) [keyword or] ([meta -moz-][property text-align-last]: [atom justify])) {",
|
||||
" [property text-align-last]: [atom justify];",
|
||||
"}");
|
||||
|
||||
MT("document",
|
||||
"[def @document] [tag url]([string http://blah]),",
|
||||
" [tag url-prefix]([string https://]),",
|
||||
" [tag domain]([string blah.com]),",
|
||||
" [tag regexp]([string \".*blah.+\"]) {",
|
||||
" [builtin #id] {",
|
||||
" [property background-color]: [keyword white];",
|
||||
" }",
|
||||
" [tag foo] {",
|
||||
" [property font-family]: [variable Verdana], [atom sans-serif];",
|
||||
" }",
|
||||
"}");
|
||||
|
||||
MT("document_url",
|
||||
"[def @document] [tag url]([string http://blah]) { [qualifier .class] { } }");
|
||||
|
||||
MT("document_urlPrefix",
|
||||
"[def @document] [tag url-prefix]([string https://]) { [builtin #id] { } }");
|
||||
|
||||
MT("document_domain",
|
||||
"[def @document] [tag domain]([string blah.com]) { [tag foo] { } }");
|
||||
|
||||
MT("document_regexp",
|
||||
"[def @document] [tag regexp]([string \".*blah.+\"]) { [builtin #id] { } }");
|
||||
|
||||
MT("counter-style",
|
||||
"[def @counter-style] [variable binary] {",
|
||||
" [property system]: [atom numeric];",
|
||||
" [property symbols]: [number 0] [number 1];",
|
||||
" [property suffix]: [string \".\"];",
|
||||
" [property range]: [atom infinite];",
|
||||
" [property speak-as]: [atom numeric];",
|
||||
"}");
|
||||
|
||||
MT("counter-style-additive-symbols",
|
||||
"[def @counter-style] [variable simple-roman] {",
|
||||
" [property system]: [atom additive];",
|
||||
" [property additive-symbols]: [number 10] [variable X], [number 5] [variable V], [number 1] [variable I];",
|
||||
" [property range]: [number 1] [number 49];",
|
||||
"}");
|
||||
|
||||
MT("counter-style-use",
|
||||
"[tag ol][qualifier .roman] { [property list-style]: [variable simple-roman]; }");
|
||||
|
||||
MT("counter-style-symbols",
|
||||
"[tag ol] { [property list-style]: [atom symbols]([atom cyclic] [string \"*\"] [string \"\\2020\"] [string \"\\2021\"] [string \"\\A7\"]); }");
|
||||
})();
|
40
codemirror/theme/3024-day.css
vendored
40
codemirror/theme/3024-day.css
vendored
|
@ -8,34 +8,34 @@
|
|||
|
||||
*/
|
||||
|
||||
.cm-s-3024-day.CodeMirror {background: #f7f7f7; color: #3a3432;}
|
||||
.cm-s-3024-day div.CodeMirror-selected {background: #d6d5d4 !important;}
|
||||
.cm-s-3024-day.CodeMirror { background: #f7f7f7; color: #3a3432; }
|
||||
.cm-s-3024-day div.CodeMirror-selected { background: #d6d5d4; }
|
||||
|
||||
.cm-s-3024-day .CodeMirror-line::selection, .cm-s-3024-day .CodeMirror-line > span::selection, .cm-s-3024-day .CodeMirror-line > span > span::selection { background: #d6d5d4; }
|
||||
.cm-s-3024-day .CodeMirror-line::-moz-selection, .cm-s-3024-day .CodeMirror-line > span::-moz-selection, .cm-s-3024-day .CodeMirror-line > span > span::selection { background: #d9d9d9; }
|
||||
|
||||
.cm-s-3024-day .CodeMirror-gutters {background: #f7f7f7; border-right: 0px;}
|
||||
.cm-s-3024-day .CodeMirror-gutters { background: #f7f7f7; border-right: 0px; }
|
||||
.cm-s-3024-day .CodeMirror-guttermarker { color: #db2d20; }
|
||||
.cm-s-3024-day .CodeMirror-guttermarker-subtle { color: #807d7c; }
|
||||
.cm-s-3024-day .CodeMirror-linenumber {color: #807d7c;}
|
||||
.cm-s-3024-day .CodeMirror-linenumber { color: #807d7c; }
|
||||
|
||||
.cm-s-3024-day .CodeMirror-cursor {border-left: 1px solid #5c5855 !important;}
|
||||
.cm-s-3024-day .CodeMirror-cursor { border-left: 1px solid #5c5855; }
|
||||
|
||||
.cm-s-3024-day span.cm-comment {color: #cdab53;}
|
||||
.cm-s-3024-day span.cm-atom {color: #a16a94;}
|
||||
.cm-s-3024-day span.cm-number {color: #a16a94;}
|
||||
.cm-s-3024-day span.cm-comment { color: #cdab53; }
|
||||
.cm-s-3024-day span.cm-atom { color: #a16a94; }
|
||||
.cm-s-3024-day span.cm-number { color: #a16a94; }
|
||||
|
||||
.cm-s-3024-day span.cm-property, .cm-s-3024-day span.cm-attribute {color: #01a252;}
|
||||
.cm-s-3024-day span.cm-keyword {color: #db2d20;}
|
||||
.cm-s-3024-day span.cm-string {color: #fded02;}
|
||||
.cm-s-3024-day span.cm-property, .cm-s-3024-day span.cm-attribute { color: #01a252; }
|
||||
.cm-s-3024-day span.cm-keyword { color: #db2d20; }
|
||||
.cm-s-3024-day span.cm-string { color: #fded02; }
|
||||
|
||||
.cm-s-3024-day span.cm-variable {color: #01a252;}
|
||||
.cm-s-3024-day span.cm-variable-2 {color: #01a0e4;}
|
||||
.cm-s-3024-day span.cm-def {color: #e8bbd0;}
|
||||
.cm-s-3024-day span.cm-bracket {color: #3a3432;}
|
||||
.cm-s-3024-day span.cm-tag {color: #db2d20;}
|
||||
.cm-s-3024-day span.cm-link {color: #a16a94;}
|
||||
.cm-s-3024-day span.cm-error {background: #db2d20; color: #5c5855;}
|
||||
.cm-s-3024-day span.cm-variable { color: #01a252; }
|
||||
.cm-s-3024-day span.cm-variable-2 { color: #01a0e4; }
|
||||
.cm-s-3024-day span.cm-def { color: #e8bbd0; }
|
||||
.cm-s-3024-day span.cm-bracket { color: #3a3432; }
|
||||
.cm-s-3024-day span.cm-tag { color: #db2d20; }
|
||||
.cm-s-3024-day span.cm-link { color: #a16a94; }
|
||||
.cm-s-3024-day span.cm-error { background: #db2d20; color: #5c5855; }
|
||||
|
||||
.cm-s-3024-day .CodeMirror-activeline-background {background: #e8f2ff !important;}
|
||||
.cm-s-3024-day .CodeMirror-matchingbracket { text-decoration: underline; color: #a16a94 !important;}
|
||||
.cm-s-3024-day .CodeMirror-activeline-background { background: #e8f2ff; }
|
||||
.cm-s-3024-day .CodeMirror-matchingbracket { text-decoration: underline; color: #a16a94 !important; }
|
||||
|
|
40
codemirror/theme/3024-night.css
vendored
40
codemirror/theme/3024-night.css
vendored
|
@ -8,32 +8,32 @@
|
|||
|
||||
*/
|
||||
|
||||
.cm-s-3024-night.CodeMirror {background: #090300; color: #d6d5d4;}
|
||||
.cm-s-3024-night div.CodeMirror-selected {background: #3a3432 !important;}
|
||||
.cm-s-3024-night.CodeMirror { background: #090300; color: #d6d5d4; }
|
||||
.cm-s-3024-night div.CodeMirror-selected { background: #3a3432; }
|
||||
.cm-s-3024-night .CodeMirror-line::selection, .cm-s-3024-night .CodeMirror-line > span::selection, .cm-s-3024-night .CodeMirror-line > span > span::selection { background: rgba(58, 52, 50, .99); }
|
||||
.cm-s-3024-night .CodeMirror-line::-moz-selection, .cm-s-3024-night .CodeMirror-line > span::-moz-selection, .cm-s-3024-night .CodeMirror-line > span > span::-moz-selection { background: rgba(58, 52, 50, .99); }
|
||||
.cm-s-3024-night .CodeMirror-gutters {background: #090300; border-right: 0px;}
|
||||
.cm-s-3024-night .CodeMirror-gutters { background: #090300; border-right: 0px; }
|
||||
.cm-s-3024-night .CodeMirror-guttermarker { color: #db2d20; }
|
||||
.cm-s-3024-night .CodeMirror-guttermarker-subtle { color: #5c5855; }
|
||||
.cm-s-3024-night .CodeMirror-linenumber {color: #5c5855;}
|
||||
.cm-s-3024-night .CodeMirror-linenumber { color: #5c5855; }
|
||||
|
||||
.cm-s-3024-night .CodeMirror-cursor {border-left: 1px solid #807d7c !important;}
|
||||
.cm-s-3024-night .CodeMirror-cursor { border-left: 1px solid #807d7c; }
|
||||
|
||||
.cm-s-3024-night span.cm-comment {color: #cdab53;}
|
||||
.cm-s-3024-night span.cm-atom {color: #a16a94;}
|
||||
.cm-s-3024-night span.cm-number {color: #a16a94;}
|
||||
.cm-s-3024-night span.cm-comment { color: #cdab53; }
|
||||
.cm-s-3024-night span.cm-atom { color: #a16a94; }
|
||||
.cm-s-3024-night span.cm-number { color: #a16a94; }
|
||||
|
||||
.cm-s-3024-night span.cm-property, .cm-s-3024-night span.cm-attribute {color: #01a252;}
|
||||
.cm-s-3024-night span.cm-keyword {color: #db2d20;}
|
||||
.cm-s-3024-night span.cm-string {color: #fded02;}
|
||||
.cm-s-3024-night span.cm-property, .cm-s-3024-night span.cm-attribute { color: #01a252; }
|
||||
.cm-s-3024-night span.cm-keyword { color: #db2d20; }
|
||||
.cm-s-3024-night span.cm-string { color: #fded02; }
|
||||
|
||||
.cm-s-3024-night span.cm-variable {color: #01a252;}
|
||||
.cm-s-3024-night span.cm-variable-2 {color: #01a0e4;}
|
||||
.cm-s-3024-night span.cm-def {color: #e8bbd0;}
|
||||
.cm-s-3024-night span.cm-bracket {color: #d6d5d4;}
|
||||
.cm-s-3024-night span.cm-tag {color: #db2d20;}
|
||||
.cm-s-3024-night span.cm-link {color: #a16a94;}
|
||||
.cm-s-3024-night span.cm-error {background: #db2d20; color: #807d7c;}
|
||||
.cm-s-3024-night span.cm-variable { color: #01a252; }
|
||||
.cm-s-3024-night span.cm-variable-2 { color: #01a0e4; }
|
||||
.cm-s-3024-night span.cm-def { color: #e8bbd0; }
|
||||
.cm-s-3024-night span.cm-bracket { color: #d6d5d4; }
|
||||
.cm-s-3024-night span.cm-tag { color: #db2d20; }
|
||||
.cm-s-3024-night span.cm-link { color: #a16a94; }
|
||||
.cm-s-3024-night span.cm-error { background: #db2d20; color: #807d7c; }
|
||||
|
||||
.cm-s-3024-night .CodeMirror-activeline-background {background: #2F2F2F !important;}
|
||||
.cm-s-3024-night .CodeMirror-matchingbracket { text-decoration: underline; color: white !important;}
|
||||
.cm-s-3024-night .CodeMirror-activeline-background { background: #2F2F2F; }
|
||||
.cm-s-3024-night .CodeMirror-matchingbracket { text-decoration: underline; color: white !important; }
|
||||
|
|
32
codemirror/theme/abcdef.css
vendored
Normal file
32
codemirror/theme/abcdef.css
vendored
Normal file
|
@ -0,0 +1,32 @@
|
|||
.cm-s-abcdef.CodeMirror { background: #0f0f0f; color: #defdef; }
|
||||
.cm-s-abcdef div.CodeMirror-selected { background: #515151; }
|
||||
.cm-s-abcdef .CodeMirror-line::selection, .cm-s-abcdef .CodeMirror-line > span::selection, .cm-s-abcdef .CodeMirror-line > span > span::selection { background: rgba(56, 56, 56, 0.99); }
|
||||
.cm-s-abcdef .CodeMirror-line::-moz-selection, .cm-s-abcdef .CodeMirror-line > span::-moz-selection, .cm-s-abcdef .CodeMirror-line > span > span::-moz-selection { background: rgba(56, 56, 56, 0.99); }
|
||||
.cm-s-abcdef .CodeMirror-gutters { background: #555; border-right: 2px solid #314151; }
|
||||
.cm-s-abcdef .CodeMirror-guttermarker { color: #222; }
|
||||
.cm-s-abcdef .CodeMirror-guttermarker-subtle { color: azure; }
|
||||
.cm-s-abcdef .CodeMirror-linenumber { color: #FFFFFF; }
|
||||
.cm-s-abcdef .CodeMirror-cursor { border-left: 1px solid #00FF00; }
|
||||
|
||||
.cm-s-abcdef span.cm-keyword { color: darkgoldenrod; font-weight: bold; }
|
||||
.cm-s-abcdef span.cm-atom { color: #77F; }
|
||||
.cm-s-abcdef span.cm-number { color: violet; }
|
||||
.cm-s-abcdef span.cm-def { color: #fffabc; }
|
||||
.cm-s-abcdef span.cm-variable { color: #abcdef; }
|
||||
.cm-s-abcdef span.cm-variable-2 { color: #cacbcc; }
|
||||
.cm-s-abcdef span.cm-variable-3 { color: #def; }
|
||||
.cm-s-abcdef span.cm-property { color: #fedcba; }
|
||||
.cm-s-abcdef span.cm-operator { color: #ff0; }
|
||||
.cm-s-abcdef span.cm-comment { color: #7a7b7c; font-style: italic;}
|
||||
.cm-s-abcdef span.cm-string { color: #2b4; }
|
||||
.cm-s-abcdef span.cm-meta { color: #C9F; }
|
||||
.cm-s-abcdef span.cm-qualifier { color: #FFF700; }
|
||||
.cm-s-abcdef span.cm-builtin { color: #30aabc; }
|
||||
.cm-s-abcdef span.cm-bracket { color: #8a8a8a; }
|
||||
.cm-s-abcdef span.cm-tag { color: #FFDD44; }
|
||||
.cm-s-abcdef span.cm-attribute { color: #DDFF00; }
|
||||
.cm-s-abcdef span.cm-error { color: #FF0000; }
|
||||
.cm-s-abcdef span.cm-header { color: aquamarine; font-weight: bold; }
|
||||
.cm-s-abcdef span.cm-link { color: blueviolet; }
|
||||
|
||||
.cm-s-abcdef .CodeMirror-activeline-background { background: #314151; }
|
16
codemirror/theme/ambiance.css
vendored
16
codemirror/theme/ambiance.css
vendored
|
@ -2,7 +2,7 @@
|
|||
|
||||
/* Color scheme */
|
||||
|
||||
.cm-s-ambiance .cm-header {color: blue;}
|
||||
.cm-s-ambiance .cm-header { color: blue; }
|
||||
.cm-s-ambiance .cm-quote { color: #24C2C7; }
|
||||
|
||||
.cm-s-ambiance .cm-keyword { color: #cda869; }
|
||||
|
@ -13,7 +13,7 @@
|
|||
.cm-s-ambiance .cm-variable-2 { color: #eed1b3; }
|
||||
.cm-s-ambiance .cm-variable-3 { color: #faded3; }
|
||||
.cm-s-ambiance .cm-property { color: #eed1b3; }
|
||||
.cm-s-ambiance .cm-operator {color: #fa8d6a;}
|
||||
.cm-s-ambiance .cm-operator { color: #fa8d6a; }
|
||||
.cm-s-ambiance .cm-comment { color: #555; font-style:italic; }
|
||||
.cm-s-ambiance .cm-string { color: #8f9d6a; }
|
||||
.cm-s-ambiance .cm-string-2 { color: #9d937c; }
|
||||
|
@ -21,8 +21,8 @@
|
|||
.cm-s-ambiance .cm-qualifier { color: yellow; }
|
||||
.cm-s-ambiance .cm-builtin { color: #9999cc; }
|
||||
.cm-s-ambiance .cm-bracket { color: #24C2C7; }
|
||||
.cm-s-ambiance .cm-tag { color: #fee4ff }
|
||||
.cm-s-ambiance .cm-attribute { color: #9B859D; }
|
||||
.cm-s-ambiance .cm-tag { color: #fee4ff; }
|
||||
.cm-s-ambiance .cm-attribute { color: #9B859D; }
|
||||
.cm-s-ambiance .cm-hr { color: pink; }
|
||||
.cm-s-ambiance .cm-link { color: #F4C20B; }
|
||||
.cm-s-ambiance .cm-special { color: #FF9D00; }
|
||||
|
@ -31,8 +31,8 @@
|
|||
.cm-s-ambiance .CodeMirror-matchingbracket { color: #0f0; }
|
||||
.cm-s-ambiance .CodeMirror-nonmatchingbracket { color: #f22; }
|
||||
|
||||
.cm-s-ambiance .CodeMirror-selected { background: rgba(255, 255, 255, 0.15); }
|
||||
.cm-s-ambiance.CodeMirror-focused .CodeMirror-selected { background: rgba(255, 255, 255, 0.10); }
|
||||
.cm-s-ambiance div.CodeMirror-selected { background: rgba(255, 255, 255, 0.15); }
|
||||
.cm-s-ambiance.CodeMirror-focused div.CodeMirror-selected { background: rgba(255, 255, 255, 0.10); }
|
||||
.cm-s-ambiance .CodeMirror-line::selection, .cm-s-ambiance .CodeMirror-line > span::selection, .cm-s-ambiance .CodeMirror-line > span > span::selection { background: rgba(255, 255, 255, 0.10); }
|
||||
.cm-s-ambiance .CodeMirror-line::-moz-selection, .cm-s-ambiance .CodeMirror-line > span::-moz-selection, .cm-s-ambiance .CodeMirror-line > span > span::-moz-selection { background: rgba(255, 255, 255, 0.10); }
|
||||
|
||||
|
@ -62,9 +62,7 @@
|
|||
.cm-s-ambiance .CodeMirror-guttermarker { color: #aaa; }
|
||||
.cm-s-ambiance .CodeMirror-guttermarker-subtle { color: #111; }
|
||||
|
||||
.cm-s-ambiance .CodeMirror-lines .CodeMirror-cursor {
|
||||
border-left: 1px solid #7991E8;
|
||||
}
|
||||
.cm-s-ambiance .CodeMirror-cursor { border-left: 1px solid #7991E8; }
|
||||
|
||||
.cm-s-ambiance .CodeMirror-activeline-background {
|
||||
background: none repeat scroll 0% 0% rgba(255, 255, 255, 0.031);
|
||||
|
|
42
codemirror/theme/base16-dark.css
vendored
42
codemirror/theme/base16-dark.css
vendored
|
@ -3,36 +3,36 @@
|
|||
Name: Base16 Default Dark
|
||||
Author: Chris Kempson (http://chriskempson.com)
|
||||
|
||||
CodeMirror template by Jan T. Sott (https://github.com/idleberg/base16-chrome-devtools)
|
||||
CodeMirror template by Jan T. Sott (https://github.com/idleberg/base16-codemirror)
|
||||
Original Base16 color scheme by Chris Kempson (https://github.com/chriskempson/base16)
|
||||
|
||||
*/
|
||||
|
||||
.cm-s-base16-dark.CodeMirror {background: #151515; color: #e0e0e0;}
|
||||
.cm-s-base16-dark div.CodeMirror-selected {background: #303030 !important;}
|
||||
.cm-s-base16-dark.CodeMirror { background: #151515; color: #e0e0e0; }
|
||||
.cm-s-base16-dark div.CodeMirror-selected { background: #303030; }
|
||||
.cm-s-base16-dark .CodeMirror-line::selection, .cm-s-base16-dark .CodeMirror-line > span::selection, .cm-s-base16-dark .CodeMirror-line > span > span::selection { background: rgba(48, 48, 48, .99); }
|
||||
.cm-s-base16-dark .CodeMirror-line::-moz-selection, .cm-s-base16-dark .CodeMirror-line > span::-moz-selection, .cm-s-base16-dark .CodeMirror-line > span > span::-moz-selection { background: rgba(48, 48, 48, .99); }
|
||||
.cm-s-base16-dark .CodeMirror-gutters {background: #151515; border-right: 0px;}
|
||||
.cm-s-base16-dark .CodeMirror-gutters { background: #151515; border-right: 0px; }
|
||||
.cm-s-base16-dark .CodeMirror-guttermarker { color: #ac4142; }
|
||||
.cm-s-base16-dark .CodeMirror-guttermarker-subtle { color: #505050; }
|
||||
.cm-s-base16-dark .CodeMirror-linenumber {color: #505050;}
|
||||
.cm-s-base16-dark .CodeMirror-cursor {border-left: 1px solid #b0b0b0 !important;}
|
||||
.cm-s-base16-dark .CodeMirror-linenumber { color: #505050; }
|
||||
.cm-s-base16-dark .CodeMirror-cursor { border-left: 1px solid #b0b0b0; }
|
||||
|
||||
.cm-s-base16-dark span.cm-comment {color: #8f5536;}
|
||||
.cm-s-base16-dark span.cm-atom {color: #aa759f;}
|
||||
.cm-s-base16-dark span.cm-number {color: #aa759f;}
|
||||
.cm-s-base16-dark span.cm-comment { color: #8f5536; }
|
||||
.cm-s-base16-dark span.cm-atom { color: #aa759f; }
|
||||
.cm-s-base16-dark span.cm-number { color: #aa759f; }
|
||||
|
||||
.cm-s-base16-dark span.cm-property, .cm-s-base16-dark span.cm-attribute {color: #90a959;}
|
||||
.cm-s-base16-dark span.cm-keyword {color: #ac4142;}
|
||||
.cm-s-base16-dark span.cm-string {color: #f4bf75;}
|
||||
.cm-s-base16-dark span.cm-property, .cm-s-base16-dark span.cm-attribute { color: #90a959; }
|
||||
.cm-s-base16-dark span.cm-keyword { color: #ac4142; }
|
||||
.cm-s-base16-dark span.cm-string { color: #f4bf75; }
|
||||
|
||||
.cm-s-base16-dark span.cm-variable {color: #90a959;}
|
||||
.cm-s-base16-dark span.cm-variable-2 {color: #6a9fb5;}
|
||||
.cm-s-base16-dark span.cm-def {color: #d28445;}
|
||||
.cm-s-base16-dark span.cm-bracket {color: #e0e0e0;}
|
||||
.cm-s-base16-dark span.cm-tag {color: #ac4142;}
|
||||
.cm-s-base16-dark span.cm-link {color: #aa759f;}
|
||||
.cm-s-base16-dark span.cm-error {background: #ac4142; color: #b0b0b0;}
|
||||
.cm-s-base16-dark span.cm-variable { color: #90a959; }
|
||||
.cm-s-base16-dark span.cm-variable-2 { color: #6a9fb5; }
|
||||
.cm-s-base16-dark span.cm-def { color: #d28445; }
|
||||
.cm-s-base16-dark span.cm-bracket { color: #e0e0e0; }
|
||||
.cm-s-base16-dark span.cm-tag { color: #ac4142; }
|
||||
.cm-s-base16-dark span.cm-link { color: #aa759f; }
|
||||
.cm-s-base16-dark span.cm-error { background: #ac4142; color: #b0b0b0; }
|
||||
|
||||
.cm-s-base16-dark .CodeMirror-activeline-background {background: #202020 !important;}
|
||||
.cm-s-base16-dark .CodeMirror-matchingbracket { text-decoration: underline; color: white !important;}
|
||||
.cm-s-base16-dark .CodeMirror-activeline-background { background: #202020; }
|
||||
.cm-s-base16-dark .CodeMirror-matchingbracket { text-decoration: underline; color: white !important; }
|
||||
|
|
42
codemirror/theme/base16-light.css
vendored
42
codemirror/theme/base16-light.css
vendored
|
@ -3,36 +3,36 @@
|
|||
Name: Base16 Default Light
|
||||
Author: Chris Kempson (http://chriskempson.com)
|
||||
|
||||
CodeMirror template by Jan T. Sott (https://github.com/idleberg/base16-chrome-devtools)
|
||||
CodeMirror template by Jan T. Sott (https://github.com/idleberg/base16-codemirror)
|
||||
Original Base16 color scheme by Chris Kempson (https://github.com/chriskempson/base16)
|
||||
|
||||
*/
|
||||
|
||||
.cm-s-base16-light.CodeMirror {background: #f5f5f5; color: #202020;}
|
||||
.cm-s-base16-light div.CodeMirror-selected {background: #e0e0e0 !important;}
|
||||
.cm-s-base16-light.CodeMirror { background: #f5f5f5; color: #202020; }
|
||||
.cm-s-base16-light div.CodeMirror-selected { background: #e0e0e0; }
|
||||
.cm-s-base16-light .CodeMirror-line::selection, .cm-s-base16-light .CodeMirror-line > span::selection, .cm-s-base16-light .CodeMirror-line > span > span::selection { background: #e0e0e0; }
|
||||
.cm-s-base16-light .CodeMirror-line::-moz-selection, .cm-s-base16-light .CodeMirror-line > span::-moz-selection, .cm-s-base16-light .CodeMirror-line > span > span::-moz-selection { background: #e0e0e0; }
|
||||
.cm-s-base16-light .CodeMirror-gutters {background: #f5f5f5; border-right: 0px;}
|
||||
.cm-s-base16-light .CodeMirror-gutters { background: #f5f5f5; border-right: 0px; }
|
||||
.cm-s-base16-light .CodeMirror-guttermarker { color: #ac4142; }
|
||||
.cm-s-base16-light .CodeMirror-guttermarker-subtle { color: #b0b0b0; }
|
||||
.cm-s-base16-light .CodeMirror-linenumber {color: #b0b0b0;}
|
||||
.cm-s-base16-light .CodeMirror-cursor {border-left: 1px solid #505050 !important;}
|
||||
.cm-s-base16-light .CodeMirror-linenumber { color: #b0b0b0; }
|
||||
.cm-s-base16-light .CodeMirror-cursor { border-left: 1px solid #505050; }
|
||||
|
||||
.cm-s-base16-light span.cm-comment {color: #8f5536;}
|
||||
.cm-s-base16-light span.cm-atom {color: #aa759f;}
|
||||
.cm-s-base16-light span.cm-number {color: #aa759f;}
|
||||
.cm-s-base16-light span.cm-comment { color: #8f5536; }
|
||||
.cm-s-base16-light span.cm-atom { color: #aa759f; }
|
||||
.cm-s-base16-light span.cm-number { color: #aa759f; }
|
||||
|
||||
.cm-s-base16-light span.cm-property, .cm-s-base16-light span.cm-attribute {color: #90a959;}
|
||||
.cm-s-base16-light span.cm-keyword {color: #ac4142;}
|
||||
.cm-s-base16-light span.cm-string {color: #f4bf75;}
|
||||
.cm-s-base16-light span.cm-property, .cm-s-base16-light span.cm-attribute { color: #90a959; }
|
||||
.cm-s-base16-light span.cm-keyword { color: #ac4142; }
|
||||
.cm-s-base16-light span.cm-string { color: #f4bf75; }
|
||||
|
||||
.cm-s-base16-light span.cm-variable {color: #90a959;}
|
||||
.cm-s-base16-light span.cm-variable-2 {color: #6a9fb5;}
|
||||
.cm-s-base16-light span.cm-def {color: #d28445;}
|
||||
.cm-s-base16-light span.cm-bracket {color: #202020;}
|
||||
.cm-s-base16-light span.cm-tag {color: #ac4142;}
|
||||
.cm-s-base16-light span.cm-link {color: #aa759f;}
|
||||
.cm-s-base16-light span.cm-error {background: #ac4142; color: #505050;}
|
||||
.cm-s-base16-light span.cm-variable { color: #90a959; }
|
||||
.cm-s-base16-light span.cm-variable-2 { color: #6a9fb5; }
|
||||
.cm-s-base16-light span.cm-def { color: #d28445; }
|
||||
.cm-s-base16-light span.cm-bracket { color: #202020; }
|
||||
.cm-s-base16-light span.cm-tag { color: #ac4142; }
|
||||
.cm-s-base16-light span.cm-link { color: #aa759f; }
|
||||
.cm-s-base16-light span.cm-error { background: #ac4142; color: #505050; }
|
||||
|
||||
.cm-s-base16-light .CodeMirror-activeline-background {background: #DDDCDC !important;}
|
||||
.cm-s-base16-light .CodeMirror-matchingbracket { text-decoration: underline; color: white !important;}
|
||||
.cm-s-base16-light .CodeMirror-activeline-background { background: #DDDCDC; }
|
||||
.cm-s-base16-light .CodeMirror-matchingbracket { text-decoration: underline; color: white !important; }
|
||||
|
|
34
codemirror/theme/bespin.css
vendored
Normal file
34
codemirror/theme/bespin.css
vendored
Normal file
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
|
||||
Name: Bespin
|
||||
Author: Mozilla / Jan T. Sott
|
||||
|
||||
CodeMirror template by Jan T. Sott (https://github.com/idleberg/base16-codemirror)
|
||||
Original Base16 color scheme by Chris Kempson (https://github.com/chriskempson/base16)
|
||||
|
||||
*/
|
||||
|
||||
.cm-s-bespin.CodeMirror {background: #28211c; color: #9d9b97;}
|
||||
.cm-s-bespin div.CodeMirror-selected {background: #36312e !important;}
|
||||
.cm-s-bespin .CodeMirror-gutters {background: #28211c; border-right: 0px;}
|
||||
.cm-s-bespin .CodeMirror-linenumber {color: #666666;}
|
||||
.cm-s-bespin .CodeMirror-cursor {border-left: 1px solid #797977 !important;}
|
||||
|
||||
.cm-s-bespin span.cm-comment {color: #937121;}
|
||||
.cm-s-bespin span.cm-atom {color: #9b859d;}
|
||||
.cm-s-bespin span.cm-number {color: #9b859d;}
|
||||
|
||||
.cm-s-bespin span.cm-property, .cm-s-bespin span.cm-attribute {color: #54be0d;}
|
||||
.cm-s-bespin span.cm-keyword {color: #cf6a4c;}
|
||||
.cm-s-bespin span.cm-string {color: #f9ee98;}
|
||||
|
||||
.cm-s-bespin span.cm-variable {color: #54be0d;}
|
||||
.cm-s-bespin span.cm-variable-2 {color: #5ea6ea;}
|
||||
.cm-s-bespin span.cm-def {color: #cf7d34;}
|
||||
.cm-s-bespin span.cm-error {background: #cf6a4c; color: #797977;}
|
||||
.cm-s-bespin span.cm-bracket {color: #9d9b97;}
|
||||
.cm-s-bespin span.cm-tag {color: #cf6a4c;}
|
||||
.cm-s-bespin span.cm-link {color: #9b859d;}
|
||||
|
||||
.cm-s-bespin .CodeMirror-matchingbracket { text-decoration: underline; color: white !important;}
|
||||
.cm-s-bespin .CodeMirror-activeline-background { background: #404040; }
|
10
codemirror/theme/blackboard.css
vendored
10
codemirror/theme/blackboard.css
vendored
|
@ -1,21 +1,21 @@
|
|||
/* Port of TextMate's Blackboard theme */
|
||||
|
||||
.cm-s-blackboard.CodeMirror { background: #0C1021; color: #F8F8F8; }
|
||||
.cm-s-blackboard .CodeMirror-selected { background: #253B76 !important; }
|
||||
.cm-s-blackboard div.CodeMirror-selected { background: #253B76; }
|
||||
.cm-s-blackboard .CodeMirror-line::selection, .cm-s-blackboard .CodeMirror-line > span::selection, .cm-s-blackboard .CodeMirror-line > span > span::selection { background: rgba(37, 59, 118, .99); }
|
||||
.cm-s-blackboard .CodeMirror-line::-moz-selection, .cm-s-blackboard .CodeMirror-line > span::-moz-selection, .cm-s-blackboard .CodeMirror-line > span > span::-moz-selection { background: rgba(37, 59, 118, .99); }
|
||||
.cm-s-blackboard .CodeMirror-gutters { background: #0C1021; border-right: 0; }
|
||||
.cm-s-blackboard .CodeMirror-guttermarker { color: #FBDE2D; }
|
||||
.cm-s-blackboard .CodeMirror-guttermarker-subtle { color: #888; }
|
||||
.cm-s-blackboard .CodeMirror-linenumber { color: #888; }
|
||||
.cm-s-blackboard .CodeMirror-cursor { border-left: 1px solid #A7A7A7 !important; }
|
||||
.cm-s-blackboard .CodeMirror-cursor { border-left: 1px solid #A7A7A7; }
|
||||
|
||||
.cm-s-blackboard .cm-keyword { color: #FBDE2D; }
|
||||
.cm-s-blackboard .cm-atom { color: #D8FA3C; }
|
||||
.cm-s-blackboard .cm-number { color: #D8FA3C; }
|
||||
.cm-s-blackboard .cm-def { color: #8DA6CE; }
|
||||
.cm-s-blackboard .cm-variable { color: #FF6400; }
|
||||
.cm-s-blackboard .cm-operator { color: #FBDE2D;}
|
||||
.cm-s-blackboard .cm-operator { color: #FBDE2D; }
|
||||
.cm-s-blackboard .cm-comment { color: #AEAEAE; }
|
||||
.cm-s-blackboard .cm-string { color: #61CE3C; }
|
||||
.cm-s-blackboard .cm-string-2 { color: #61CE3C; }
|
||||
|
@ -28,5 +28,5 @@
|
|||
.cm-s-blackboard .cm-link { color: #8DA6CE; }
|
||||
.cm-s-blackboard .cm-error { background: #9D1E15; color: #F8F8F8; }
|
||||
|
||||
.cm-s-blackboard .CodeMirror-activeline-background {background: #3C3636 !important;}
|
||||
.cm-s-blackboard .CodeMirror-matchingbracket {outline:1px solid grey;color:white !important}
|
||||
.cm-s-blackboard .CodeMirror-activeline-background { background: #3C3636; }
|
||||
.cm-s-blackboard .CodeMirror-matchingbracket { outline:1px solid grey;color:white !important; }
|
||||
|
|
8
codemirror/theme/cobalt.css
vendored
8
codemirror/theme/cobalt.css
vendored
|
@ -1,12 +1,12 @@
|
|||
.cm-s-cobalt.CodeMirror { background: #002240; color: white; }
|
||||
.cm-s-cobalt div.CodeMirror-selected { background: #b36539 !important; }
|
||||
.cm-s-cobalt div.CodeMirror-selected { background: #b36539; }
|
||||
.cm-s-cobalt .CodeMirror-line::selection, .cm-s-cobalt .CodeMirror-line > span::selection, .cm-s-cobalt .CodeMirror-line > span > span::selection { background: rgba(179, 101, 57, .99); }
|
||||
.cm-s-cobalt .CodeMirror-line::-moz-selection, .cm-s-cobalt .CodeMirror-line > span::-moz-selection, .cm-s-cobalt .CodeMirror-line > span > span::-moz-selection { background: rgba(179, 101, 57, .99); }
|
||||
.cm-s-cobalt .CodeMirror-gutters { background: #002240; border-right: 1px solid #aaa; }
|
||||
.cm-s-cobalt .CodeMirror-guttermarker { color: #ffee80; }
|
||||
.cm-s-cobalt .CodeMirror-guttermarker-subtle { color: #d0d0d0; }
|
||||
.cm-s-cobalt .CodeMirror-linenumber { color: #d0d0d0; }
|
||||
.cm-s-cobalt .CodeMirror-cursor { border-left: 1px solid white !important; }
|
||||
.cm-s-cobalt .CodeMirror-cursor { border-left: 1px solid white; }
|
||||
|
||||
.cm-s-cobalt span.cm-comment { color: #08f; }
|
||||
.cm-s-cobalt span.cm-atom { color: #845dc4; }
|
||||
|
@ -21,5 +21,5 @@
|
|||
.cm-s-cobalt span.cm-link { color: #845dc4; }
|
||||
.cm-s-cobalt span.cm-error { color: #9d1e15; }
|
||||
|
||||
.cm-s-cobalt .CodeMirror-activeline-background {background: #002D57 !important;}
|
||||
.cm-s-cobalt .CodeMirror-matchingbracket {outline:1px solid grey;color:white !important}
|
||||
.cm-s-cobalt .CodeMirror-activeline-background { background: #002D57; }
|
||||
.cm-s-cobalt .CodeMirror-matchingbracket { outline:1px solid grey;color:white !important; }
|
||||
|
|
6
codemirror/theme/colorforth.css
vendored
6
codemirror/theme/colorforth.css
vendored
|
@ -3,7 +3,7 @@
|
|||
.cm-s-colorforth .CodeMirror-guttermarker { color: #FFBD40; }
|
||||
.cm-s-colorforth .CodeMirror-guttermarker-subtle { color: #78846f; }
|
||||
.cm-s-colorforth .CodeMirror-linenumber { color: #bababa; }
|
||||
.cm-s-colorforth .CodeMirror-cursor { border-left: 1px solid white !important; }
|
||||
.cm-s-colorforth .CodeMirror-cursor { border-left: 1px solid white; }
|
||||
|
||||
.cm-s-colorforth span.cm-comment { color: #ededed; }
|
||||
.cm-s-colorforth span.cm-def { color: #ff1c1c; font-weight:bold; }
|
||||
|
@ -26,8 +26,8 @@
|
|||
.cm-s-colorforth span.cm-attribute { color: #FFF700; }
|
||||
.cm-s-colorforth span.cm-error { color: #f00; }
|
||||
|
||||
.cm-s-colorforth .CodeMirror-selected { background: #333d53 !important; }
|
||||
.cm-s-colorforth div.CodeMirror-selected { background: #333d53; }
|
||||
|
||||
.cm-s-colorforth span.cm-compilation { background: rgba(255, 255, 255, 0.12); }
|
||||
|
||||
.cm-s-colorforth .CodeMirror-activeline-background {background: #253540 !important;}
|
||||
.cm-s-colorforth .CodeMirror-activeline-background { background: #253540; }
|
||||
|
|
40
codemirror/theme/dracula.css
vendored
Normal file
40
codemirror/theme/dracula.css
vendored
Normal file
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
|
||||
Name: dracula
|
||||
Author: Michael Kaminsky (http://github.com/mkaminsky11)
|
||||
|
||||
Original dracula color scheme by Zeno Rocha (https://github.com/zenorocha/dracula-theme)
|
||||
|
||||
*/
|
||||
|
||||
|
||||
.cm-s-dracula.CodeMirror, .cm-s-dracula .CodeMirror-gutters {
|
||||
background-color: #282a36 !important;
|
||||
color: #f8f8f2 !important;
|
||||
border: none;
|
||||
}
|
||||
.cm-s-dracula .CodeMirror-gutters { color: #282a36; }
|
||||
.cm-s-dracula .CodeMirror-cursor { border-left: solid thin #f8f8f0; }
|
||||
.cm-s-dracula .CodeMirror-linenumber { color: #6D8A88; }
|
||||
.cm-s-dracula .CodeMirror-selected { background: rgba(255, 255, 255, 0.10); }
|
||||
.cm-s-dracula .CodeMirror-line::selection, .cm-s-dracula .CodeMirror-line > span::selection, .cm-s-dracula .CodeMirror-line > span > span::selection { background: rgba(255, 255, 255, 0.10); }
|
||||
.cm-s-dracula .CodeMirror-line::-moz-selection, .cm-s-dracula .CodeMirror-line > span::-moz-selection, .cm-s-dracula .CodeMirror-line > span > span::-moz-selection { background: rgba(255, 255, 255, 0.10); }
|
||||
.cm-s-dracula span.cm-comment { color: #6272a4; }
|
||||
.cm-s-dracula span.cm-string, .cm-s-dracula span.cm-string-2 { color: #f1fa8c; }
|
||||
.cm-s-dracula span.cm-number { color: #bd93f9; }
|
||||
.cm-s-dracula span.cm-variable { color: #50fa7b; }
|
||||
.cm-s-dracula span.cm-variable-2 { color: white; }
|
||||
.cm-s-dracula span.cm-def { color: #50fa7b; }
|
||||
.cm-s-dracula span.cm-operator { color: #ff79c6; }
|
||||
.cm-s-dracula span.cm-keyword { color: #ff79c6; }
|
||||
.cm-s-dracula span.cm-atom { color: #bd93f9; }
|
||||
.cm-s-dracula span.cm-meta { color: #f8f8f2; }
|
||||
.cm-s-dracula span.cm-tag { color: #ff79c6; }
|
||||
.cm-s-dracula span.cm-attribute { color: #50fa7b; }
|
||||
.cm-s-dracula span.cm-qualifier { color: #50fa7b; }
|
||||
.cm-s-dracula span.cm-property { color: #66d9ef; }
|
||||
.cm-s-dracula span.cm-builtin { color: #50fa7b; }
|
||||
.cm-s-dracula span.cm-variable-3 { color: #ffb86c; }
|
||||
|
||||
.cm-s-dracula .CodeMirror-activeline-background { background: rgba(255,255,255,0.1); }
|
||||
.cm-s-dracula .CodeMirror-matchingbracket { text-decoration: underline; color: white !important; }
|
35
codemirror/theme/duotone-dark.css
vendored
Normal file
35
codemirror/theme/duotone-dark.css
vendored
Normal file
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
Name: DuoTone-Dark
|
||||
Author: by Bram de Haan, adapted from DuoTone themes by Simurai (http://simurai.com/projects/2016/01/01/duotone-themes)
|
||||
|
||||
CodeMirror template by Jan T. Sott (https://github.com/idleberg), adapted by Bram de Haan (https://github.com/atelierbram/)
|
||||
*/
|
||||
|
||||
.cm-s-duotone-dark.CodeMirror { background: #2a2734; color: #6c6783; }
|
||||
.cm-s-duotone-dark div.CodeMirror-selected { background: #545167!important; }
|
||||
.cm-s-duotone-dark .CodeMirror-gutters { background: #2a2734; border-right: 0px; }
|
||||
.cm-s-duotone-dark .CodeMirror-linenumber { color: #545167; }
|
||||
|
||||
/* begin cursor */
|
||||
.cm-s-duotone-dark .CodeMirror-cursor { border-left: 1px solid #ffad5c; /* border-left: 1px solid #ffad5c80; */ border-right: .5em solid #ffad5c; /* border-right: .5em solid #ffad5c80; */ opacity: .5; }
|
||||
.cm-s-duotone-dark .CodeMirror-activeline-background { background: #363342; /* background: #36334280; */ opacity: .5;}
|
||||
.cm-s-duotone-dark .cm-fat-cursor .CodeMirror-cursor { background: #ffad5c; /* background: #ffad5c80; */ opacity: .5;}
|
||||
/* end cursor */
|
||||
|
||||
.cm-s-duotone-dark span.cm-atom, .cm-s-duotone-dark span.cm-number, .cm-s-duotone-dark span.cm-keyword, .cm-s-duotone-dark span.cm-variable, .cm-s-duotone-dark span.cm-attribute, .cm-s-duotone-dark span.cm-quote, .cm-s-duotone-dark span.cm-hr, .cm-s-duotone-dark span.cm-link { color: #ffcc99; }
|
||||
|
||||
.cm-s-duotone-dark span.cm-property { color: #9a86fd; }
|
||||
.cm-s-duotone-dark span.cm-punctuation, .cm-s-duotone-dark span.cm-unit, .cm-s-duotone-dark span.cm-negative { color: #e09142; }
|
||||
.cm-s-duotone-dark span.cm-string { color: #ffb870; }
|
||||
.cm-s-duotone-dark span.cm-operator { color: #ffad5c; }
|
||||
.cm-s-duotone-dark span.cm-positive { color: #6a51e6; }
|
||||
|
||||
.cm-s-duotone-dark span.cm-variable-2, .cm-s-duotone-dark span.cm-variable-3, .cm-s-duotone-dark span.cm-string-2, .cm-s-duotone-dark span.cm-url { color: #7a63ee; }
|
||||
.cm-s-duotone-dark span.cm-def, .cm-s-duotone-dark span.cm-tag, .cm-s-duotone-dark span.cm-builtin, .cm-s-duotone-dark span.cm-qualifier, .cm-s-duotone-dark span.cm-header, .cm-s-duotone-dark span.cm-em { color: #eeebff; }
|
||||
.cm-s-duotone-dark span.cm-bracket, .cm-s-duotone-dark span.cm-comment { color: #6c6783; }
|
||||
|
||||
/* using #f00 red for errors, don't think any of the colorscheme variables will stand out enough, ... maybe by giving it a background-color ... */
|
||||
.cm-s-duotone-dark span.cm-error, .cm-s-duotone-dark span.cm-invalidchar { color: #f00; }
|
||||
|
||||
.cm-s-duotone-dark span.cm-header { font-weight: normal; }
|
||||
.cm-s-duotone-dark .CodeMirror-matchingbracket { text-decoration: underline; color: #eeebff !important; }
|
36
codemirror/theme/duotone-light.css
vendored
Normal file
36
codemirror/theme/duotone-light.css
vendored
Normal file
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
Name: DuoTone-Light
|
||||
Author: by Bram de Haan, adapted from DuoTone themes by Simurai (http://simurai.com/projects/2016/01/01/duotone-themes)
|
||||
|
||||
CodeMirror template by Jan T. Sott (https://github.com/idleberg), adapted by Bram de Haan (https://github.com/atelierbram/)
|
||||
*/
|
||||
|
||||
.cm-s-duotone-light.CodeMirror { background: #faf8f5; color: #b29762; }
|
||||
.cm-s-duotone-light div.CodeMirror-selected { background: #e3dcce !important; }
|
||||
.cm-s-duotone-light .CodeMirror-gutters { background: #faf8f5; border-right: 0px; }
|
||||
.cm-s-duotone-light .CodeMirror-linenumber { color: #cdc4b1; }
|
||||
|
||||
/* begin cursor */
|
||||
.cm-s-duotone-light .CodeMirror-cursor { border-left: 1px solid #93abdc; /* border-left: 1px solid #93abdc80; */ border-right: .5em solid #93abdc; /* border-right: .5em solid #93abdc80; */ opacity: .5; }
|
||||
.cm-s-duotone-light .CodeMirror-activeline-background { background: #e3dcce; /* background: #e3dcce80; */ opacity: .5; }
|
||||
.cm-s-duotone-light .cm-fat-cursor .CodeMirror-cursor { background: #93abdc; /* #93abdc80; */ opacity: .5; }
|
||||
/* end cursor */
|
||||
|
||||
.cm-s-duotone-light span.cm-atom, .cm-s-duotone-light span.cm-number, .cm-s-duotone-light span.cm-keyword, .cm-s-duotone-light span.cm-variable, .cm-s-duotone-light span.cm-attribute, .cm-s-duotone-light span.cm-quote, .cm-s-duotone-light-light span.cm-hr, .cm-s-duotone-light-light span.cm-link { color: #063289; }
|
||||
|
||||
.cm-s-duotone-light span.cm-property { color: #b29762; }
|
||||
.cm-s-duotone-light span.cm-punctuation, .cm-s-duotone-light span.cm-unit, .cm-s-duotone-light span.cm-negative { color: #063289; }
|
||||
.cm-s-duotone-light span.cm-string, .cm-s-duotone-light span.cm-operator { color: #1659df; }
|
||||
.cm-s-duotone-light span.cm-positive { color: #896724; }
|
||||
|
||||
.cm-s-duotone-light span.cm-variable-2, .cm-s-duotone-light span.cm-variable-3, .cm-s-duotone-light span.cm-string-2, .cm-s-duotone-light span.cm-url { color: #896724; }
|
||||
.cm-s-duotone-light span.cm-def, .cm-s-duotone-light span.cm-tag, .cm-s-duotone-light span.cm-builtin, .cm-s-duotone-light span.cm-qualifier, .cm-s-duotone-light span.cm-header, .cm-s-duotone-light span.cm-em { color: #2d2006; }
|
||||
.cm-s-duotone-light span.cm-bracket, .cm-s-duotone-light span.cm-comment { color: #b6ad9a; }
|
||||
|
||||
/* using #f00 red for errors, don't think any of the colorscheme variables will stand out enough, ... maybe by giving it a background-color ... */
|
||||
/* .cm-s-duotone-light span.cm-error { background: #896724; color: #728fcb; } */
|
||||
.cm-s-duotone-light span.cm-error, .cm-s-duotone-light span.cm-invalidchar { color: #f00; }
|
||||
|
||||
.cm-s-duotone-light span.cm-header { font-weight: normal; }
|
||||
.cm-s-duotone-light .CodeMirror-matchingbracket { text-decoration: underline; color: #faf8f5 !important; }
|
||||
|
42
codemirror/theme/eclipse.css
vendored
42
codemirror/theme/eclipse.css
vendored
|
@ -1,23 +1,23 @@
|
|||
.cm-s-eclipse span.cm-meta {color: #FF1717;}
|
||||
.cm-s-eclipse span.cm-meta { color: #FF1717; }
|
||||
.cm-s-eclipse span.cm-keyword { line-height: 1em; font-weight: bold; color: #7F0055; }
|
||||
.cm-s-eclipse span.cm-atom {color: #219;}
|
||||
.cm-s-eclipse span.cm-number {color: #164;}
|
||||
.cm-s-eclipse span.cm-def {color: #00f;}
|
||||
.cm-s-eclipse span.cm-variable {color: black;}
|
||||
.cm-s-eclipse span.cm-variable-2 {color: #0000C0;}
|
||||
.cm-s-eclipse span.cm-variable-3 {color: #0000C0;}
|
||||
.cm-s-eclipse span.cm-property {color: black;}
|
||||
.cm-s-eclipse span.cm-operator {color: black;}
|
||||
.cm-s-eclipse span.cm-comment {color: #3F7F5F;}
|
||||
.cm-s-eclipse span.cm-string {color: #2A00FF;}
|
||||
.cm-s-eclipse span.cm-string-2 {color: #f50;}
|
||||
.cm-s-eclipse span.cm-qualifier {color: #555;}
|
||||
.cm-s-eclipse span.cm-builtin {color: #30a;}
|
||||
.cm-s-eclipse span.cm-bracket {color: #cc7;}
|
||||
.cm-s-eclipse span.cm-tag {color: #170;}
|
||||
.cm-s-eclipse span.cm-attribute {color: #00c;}
|
||||
.cm-s-eclipse span.cm-link {color: #219;}
|
||||
.cm-s-eclipse span.cm-error {color: #f00;}
|
||||
.cm-s-eclipse span.cm-atom { color: #219; }
|
||||
.cm-s-eclipse span.cm-number { color: #164; }
|
||||
.cm-s-eclipse span.cm-def { color: #00f; }
|
||||
.cm-s-eclipse span.cm-variable { color: black; }
|
||||
.cm-s-eclipse span.cm-variable-2 { color: #0000C0; }
|
||||
.cm-s-eclipse span.cm-variable-3 { color: #0000C0; }
|
||||
.cm-s-eclipse span.cm-property { color: black; }
|
||||
.cm-s-eclipse span.cm-operator { color: black; }
|
||||
.cm-s-eclipse span.cm-comment { color: #3F7F5F; }
|
||||
.cm-s-eclipse span.cm-string { color: #2A00FF; }
|
||||
.cm-s-eclipse span.cm-string-2 { color: #f50; }
|
||||
.cm-s-eclipse span.cm-qualifier { color: #555; }
|
||||
.cm-s-eclipse span.cm-builtin { color: #30a; }
|
||||
.cm-s-eclipse span.cm-bracket { color: #cc7; }
|
||||
.cm-s-eclipse span.cm-tag { color: #170; }
|
||||
.cm-s-eclipse span.cm-attribute { color: #00c; }
|
||||
.cm-s-eclipse span.cm-link { color: #219; }
|
||||
.cm-s-eclipse span.cm-error { color: #f00; }
|
||||
|
||||
.cm-s-eclipse .CodeMirror-activeline-background {background: #e8f2ff !important;}
|
||||
.cm-s-eclipse .CodeMirror-matchingbracket {outline:1px solid grey; color:black !important;}
|
||||
.cm-s-eclipse .CodeMirror-activeline-background { background: #e8f2ff; }
|
||||
.cm-s-eclipse .CodeMirror-matchingbracket { outline:1px solid grey; color:black !important; }
|
||||
|
|
24
codemirror/theme/elegant.css
vendored
24
codemirror/theme/elegant.css
vendored
|
@ -1,13 +1,13 @@
|
|||
.cm-s-elegant span.cm-number, .cm-s-elegant span.cm-string, .cm-s-elegant span.cm-atom {color: #762;}
|
||||
.cm-s-elegant span.cm-comment {color: #262; font-style: italic; line-height: 1em;}
|
||||
.cm-s-elegant span.cm-meta {color: #555; font-style: italic; line-height: 1em;}
|
||||
.cm-s-elegant span.cm-variable {color: black;}
|
||||
.cm-s-elegant span.cm-variable-2 {color: #b11;}
|
||||
.cm-s-elegant span.cm-qualifier {color: #555;}
|
||||
.cm-s-elegant span.cm-keyword {color: #730;}
|
||||
.cm-s-elegant span.cm-builtin {color: #30a;}
|
||||
.cm-s-elegant span.cm-link {color: #762;}
|
||||
.cm-s-elegant span.cm-error {background-color: #fdd;}
|
||||
.cm-s-elegant span.cm-number, .cm-s-elegant span.cm-string, .cm-s-elegant span.cm-atom { color: #762; }
|
||||
.cm-s-elegant span.cm-comment { color: #262; font-style: italic; line-height: 1em; }
|
||||
.cm-s-elegant span.cm-meta { color: #555; font-style: italic; line-height: 1em; }
|
||||
.cm-s-elegant span.cm-variable { color: black; }
|
||||
.cm-s-elegant span.cm-variable-2 { color: #b11; }
|
||||
.cm-s-elegant span.cm-qualifier { color: #555; }
|
||||
.cm-s-elegant span.cm-keyword { color: #730; }
|
||||
.cm-s-elegant span.cm-builtin { color: #30a; }
|
||||
.cm-s-elegant span.cm-link { color: #762; }
|
||||
.cm-s-elegant span.cm-error { background-color: #fdd; }
|
||||
|
||||
.cm-s-elegant .CodeMirror-activeline-background {background: #e8f2ff !important;}
|
||||
.cm-s-elegant .CodeMirror-matchingbracket {outline:1px solid grey; color:black !important;}
|
||||
.cm-s-elegant .CodeMirror-activeline-background { background: #e8f2ff; }
|
||||
.cm-s-elegant .CodeMirror-matchingbracket { outline:1px solid grey; color:black !important; }
|
||||
|
|
8
codemirror/theme/erlang-dark.css
vendored
8
codemirror/theme/erlang-dark.css
vendored
|
@ -1,12 +1,12 @@
|
|||
.cm-s-erlang-dark.CodeMirror { background: #002240; color: white; }
|
||||
.cm-s-erlang-dark div.CodeMirror-selected { background: #b36539 !important; }
|
||||
.cm-s-erlang-dark div.CodeMirror-selected { background: #b36539; }
|
||||
.cm-s-erlang-dark .CodeMirror-line::selection, .cm-s-erlang-dark .CodeMirror-line > span::selection, .cm-s-erlang-dark .CodeMirror-line > span > span::selection { background: rgba(179, 101, 57, .99); }
|
||||
.cm-s-erlang-dark .CodeMirror-line::-moz-selection, .cm-s-erlang-dark .CodeMirror-line > span::-moz-selection, .cm-s-erlang-dark .CodeMirror-line > span > span::-moz-selection { background: rgba(179, 101, 57, .99); }
|
||||
.cm-s-erlang-dark .CodeMirror-gutters { background: #002240; border-right: 1px solid #aaa; }
|
||||
.cm-s-erlang-dark .CodeMirror-guttermarker { color: white; }
|
||||
.cm-s-erlang-dark .CodeMirror-guttermarker-subtle { color: #d0d0d0; }
|
||||
.cm-s-erlang-dark .CodeMirror-linenumber { color: #d0d0d0; }
|
||||
.cm-s-erlang-dark .CodeMirror-cursor { border-left: 1px solid white !important; }
|
||||
.cm-s-erlang-dark .CodeMirror-cursor { border-left: 1px solid white; }
|
||||
|
||||
.cm-s-erlang-dark span.cm-quote { color: #ccc; }
|
||||
.cm-s-erlang-dark span.cm-atom { color: #f133f1; }
|
||||
|
@ -30,5 +30,5 @@
|
|||
.cm-s-erlang-dark span.cm-variable-3 { color: #ccc; }
|
||||
.cm-s-erlang-dark span.cm-error { color: #9d1e15; }
|
||||
|
||||
.cm-s-erlang-dark .CodeMirror-activeline-background {background: #013461 !important;}
|
||||
.cm-s-erlang-dark .CodeMirror-matchingbracket {outline:1px solid grey; color:white !important;}
|
||||
.cm-s-erlang-dark .CodeMirror-activeline-background { background: #013461; }
|
||||
.cm-s-erlang-dark .CodeMirror-matchingbracket { outline:1px solid grey; color:white !important; }
|
||||
|
|
34
codemirror/theme/hopscotch.css
vendored
Normal file
34
codemirror/theme/hopscotch.css
vendored
Normal file
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
|
||||
Name: Hopscotch
|
||||
Author: Jan T. Sott
|
||||
|
||||
CodeMirror template by Jan T. Sott (https://github.com/idleberg/base16-codemirror)
|
||||
Original Base16 color scheme by Chris Kempson (https://github.com/chriskempson/base16)
|
||||
|
||||
*/
|
||||
|
||||
.cm-s-hopscotch.CodeMirror {background: #322931; color: #d5d3d5;}
|
||||
.cm-s-hopscotch div.CodeMirror-selected {background: #433b42 !important;}
|
||||
.cm-s-hopscotch .CodeMirror-gutters {background: #322931; border-right: 0px;}
|
||||
.cm-s-hopscotch .CodeMirror-linenumber {color: #797379;}
|
||||
.cm-s-hopscotch .CodeMirror-cursor {border-left: 1px solid #989498 !important;}
|
||||
|
||||
.cm-s-hopscotch span.cm-comment {color: #b33508;}
|
||||
.cm-s-hopscotch span.cm-atom {color: #c85e7c;}
|
||||
.cm-s-hopscotch span.cm-number {color: #c85e7c;}
|
||||
|
||||
.cm-s-hopscotch span.cm-property, .cm-s-hopscotch span.cm-attribute {color: #8fc13e;}
|
||||
.cm-s-hopscotch span.cm-keyword {color: #dd464c;}
|
||||
.cm-s-hopscotch span.cm-string {color: #fdcc59;}
|
||||
|
||||
.cm-s-hopscotch span.cm-variable {color: #8fc13e;}
|
||||
.cm-s-hopscotch span.cm-variable-2 {color: #1290bf;}
|
||||
.cm-s-hopscotch span.cm-def {color: #fd8b19;}
|
||||
.cm-s-hopscotch span.cm-error {background: #dd464c; color: #989498;}
|
||||
.cm-s-hopscotch span.cm-bracket {color: #d5d3d5;}
|
||||
.cm-s-hopscotch span.cm-tag {color: #dd464c;}
|
||||
.cm-s-hopscotch span.cm-link {color: #c85e7c;}
|
||||
|
||||
.cm-s-hopscotch .CodeMirror-matchingbracket { text-decoration: underline; color: white !important;}
|
||||
.cm-s-hopscotch .CodeMirror-activeline-background { background: #302020; }
|
43
codemirror/theme/icecoder.css
vendored
Normal file
43
codemirror/theme/icecoder.css
vendored
Normal file
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
ICEcoder default theme by Matt Pass, used in code editor available at https://icecoder.net
|
||||
*/
|
||||
|
||||
.cm-s-icecoder { color: #666; background: #1d1d1b; }
|
||||
|
||||
.cm-s-icecoder span.cm-keyword { color: #eee; font-weight:bold; } /* off-white 1 */
|
||||
.cm-s-icecoder span.cm-atom { color: #e1c76e; } /* yellow */
|
||||
.cm-s-icecoder span.cm-number { color: #6cb5d9; } /* blue */
|
||||
.cm-s-icecoder span.cm-def { color: #b9ca4a; } /* green */
|
||||
|
||||
.cm-s-icecoder span.cm-variable { color: #6cb5d9; } /* blue */
|
||||
.cm-s-icecoder span.cm-variable-2 { color: #cc1e5c; } /* pink */
|
||||
.cm-s-icecoder span.cm-variable-3 { color: #f9602c; } /* orange */
|
||||
|
||||
.cm-s-icecoder span.cm-property { color: #eee; } /* off-white 1 */
|
||||
.cm-s-icecoder span.cm-operator { color: #9179bb; } /* purple */
|
||||
.cm-s-icecoder span.cm-comment { color: #97a3aa; } /* grey-blue */
|
||||
|
||||
.cm-s-icecoder span.cm-string { color: #b9ca4a; } /* green */
|
||||
.cm-s-icecoder span.cm-string-2 { color: #6cb5d9; } /* blue */
|
||||
|
||||
.cm-s-icecoder span.cm-meta { color: #555; } /* grey */
|
||||
|
||||
.cm-s-icecoder span.cm-qualifier { color: #555; } /* grey */
|
||||
.cm-s-icecoder span.cm-builtin { color: #214e7b; } /* bright blue */
|
||||
.cm-s-icecoder span.cm-bracket { color: #cc7; } /* grey-yellow */
|
||||
|
||||
.cm-s-icecoder span.cm-tag { color: #e8e8e8; } /* off-white 2 */
|
||||
.cm-s-icecoder span.cm-attribute { color: #099; } /* teal */
|
||||
|
||||
.cm-s-icecoder span.cm-header { color: #6a0d6a; } /* purple-pink */
|
||||
.cm-s-icecoder span.cm-quote { color: #186718; } /* dark green */
|
||||
.cm-s-icecoder span.cm-hr { color: #888; } /* mid-grey */
|
||||
.cm-s-icecoder span.cm-link { color: #e1c76e; } /* yellow */
|
||||
.cm-s-icecoder span.cm-error { color: #d00; } /* red */
|
||||
|
||||
.cm-s-icecoder .CodeMirror-cursor { border-left: 1px solid white; }
|
||||
.cm-s-icecoder div.CodeMirror-selected { color: #fff; background: #037; }
|
||||
.cm-s-icecoder .CodeMirror-gutters { background: #1d1d1b; min-width: 41px; border-right: 0; }
|
||||
.cm-s-icecoder .CodeMirror-linenumber { color: #555; cursor: default; }
|
||||
.cm-s-icecoder .CodeMirror-matchingbracket { color: #fff !important; background: #555 !important; }
|
||||
.cm-s-icecoder .CodeMirror-activeline-background { background: #000; }
|
34
codemirror/theme/isotope.css
vendored
Normal file
34
codemirror/theme/isotope.css
vendored
Normal file
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
|
||||
Name: Isotope
|
||||
Author: David Desandro / Jan T. Sott
|
||||
|
||||
CodeMirror template by Jan T. Sott (https://github.com/idleberg/base16-codemirror)
|
||||
Original Base16 color scheme by Chris Kempson (https://github.com/chriskempson/base16)
|
||||
|
||||
*/
|
||||
|
||||
.cm-s-isotope.CodeMirror {background: #000000; color: #e0e0e0;}
|
||||
.cm-s-isotope div.CodeMirror-selected {background: #404040 !important;}
|
||||
.cm-s-isotope .CodeMirror-gutters {background: #000000; border-right: 0px;}
|
||||
.cm-s-isotope .CodeMirror-linenumber {color: #808080;}
|
||||
.cm-s-isotope .CodeMirror-cursor {border-left: 1px solid #c0c0c0 !important;}
|
||||
|
||||
.cm-s-isotope span.cm-comment {color: #3300ff;}
|
||||
.cm-s-isotope span.cm-atom {color: #cc00ff;}
|
||||
.cm-s-isotope span.cm-number {color: #cc00ff;}
|
||||
|
||||
.cm-s-isotope span.cm-property, .cm-s-isotope span.cm-attribute {color: #33ff00;}
|
||||
.cm-s-isotope span.cm-keyword {color: #ff0000;}
|
||||
.cm-s-isotope span.cm-string {color: #ff0099;}
|
||||
|
||||
.cm-s-isotope span.cm-variable {color: #33ff00;}
|
||||
.cm-s-isotope span.cm-variable-2 {color: #0066ff;}
|
||||
.cm-s-isotope span.cm-def {color: #ff9900;}
|
||||
.cm-s-isotope span.cm-error {background: #ff0000; color: #c0c0c0;}
|
||||
.cm-s-isotope span.cm-bracket {color: #e0e0e0;}
|
||||
.cm-s-isotope span.cm-tag {color: #ff0000;}
|
||||
.cm-s-isotope span.cm-link {color: #cc00ff;}
|
||||
|
||||
.cm-s-isotope .CodeMirror-matchingbracket { text-decoration: underline; color: white !important;}
|
||||
.cm-s-isotope .CodeMirror-activeline-background { background: #202020; }
|
28
codemirror/theme/lesser-dark.css
vendored
28
codemirror/theme/lesser-dark.css
vendored
|
@ -6,10 +6,10 @@ Ported to CodeMirror by Peter Kroon
|
|||
line-height: 1.3em;
|
||||
}
|
||||
.cm-s-lesser-dark.CodeMirror { background: #262626; color: #EBEFE7; text-shadow: 0 -1px 1px #262626; }
|
||||
.cm-s-lesser-dark div.CodeMirror-selected {background: #45443B !important;} /* 33322B*/
|
||||
.cm-s-lesser-dark div.CodeMirror-selected { background: #45443B; } /* 33322B*/
|
||||
.cm-s-lesser-dark .CodeMirror-line::selection, .cm-s-lesser-dark .CodeMirror-line > span::selection, .cm-s-lesser-dark .CodeMirror-line > span > span::selection { background: rgba(69, 68, 59, .99); }
|
||||
.cm-s-lesser-dark .CodeMirror-line::-moz-selection, .cm-s-lesser-dark .CodeMirror-line > span::-moz-selection, .cm-s-lesser-dark .CodeMirror-line > span > span::-moz-selection { background: rgba(69, 68, 59, .99); }
|
||||
.cm-s-lesser-dark .CodeMirror-cursor { border-left: 1px solid white !important; }
|
||||
.cm-s-lesser-dark .CodeMirror-cursor { border-left: 1px solid white; }
|
||||
.cm-s-lesser-dark pre { padding: 0 8px; }/*editable code holder*/
|
||||
|
||||
.cm-s-lesser-dark.CodeMirror span.CodeMirror-matchingbracket { color: #7EFC7E; }/*65FC65*/
|
||||
|
@ -19,29 +19,29 @@ Ported to CodeMirror by Peter Kroon
|
|||
.cm-s-lesser-dark .CodeMirror-guttermarker-subtle { color: #777; }
|
||||
.cm-s-lesser-dark .CodeMirror-linenumber { color: #777; }
|
||||
|
||||
.cm-s-lesser-dark span.cm-header {color: #a0a;}
|
||||
.cm-s-lesser-dark span.cm-quote {color: #090;}
|
||||
.cm-s-lesser-dark span.cm-header { color: #a0a; }
|
||||
.cm-s-lesser-dark span.cm-quote { color: #090; }
|
||||
.cm-s-lesser-dark span.cm-keyword { color: #599eff; }
|
||||
.cm-s-lesser-dark span.cm-atom { color: #C2B470; }
|
||||
.cm-s-lesser-dark span.cm-number { color: #B35E4D; }
|
||||
.cm-s-lesser-dark span.cm-def {color: white;}
|
||||
.cm-s-lesser-dark span.cm-def { color: white; }
|
||||
.cm-s-lesser-dark span.cm-variable { color:#D9BF8C; }
|
||||
.cm-s-lesser-dark span.cm-variable-2 { color: #669199; }
|
||||
.cm-s-lesser-dark span.cm-variable-3 { color: white; }
|
||||
.cm-s-lesser-dark span.cm-property {color: #92A75C;}
|
||||
.cm-s-lesser-dark span.cm-operator {color: #92A75C;}
|
||||
.cm-s-lesser-dark span.cm-property { color: #92A75C; }
|
||||
.cm-s-lesser-dark span.cm-operator { color: #92A75C; }
|
||||
.cm-s-lesser-dark span.cm-comment { color: #666; }
|
||||
.cm-s-lesser-dark span.cm-string { color: #BCD279; }
|
||||
.cm-s-lesser-dark span.cm-string-2 {color: #f50;}
|
||||
.cm-s-lesser-dark span.cm-string-2 { color: #f50; }
|
||||
.cm-s-lesser-dark span.cm-meta { color: #738C73; }
|
||||
.cm-s-lesser-dark span.cm-qualifier {color: #555;}
|
||||
.cm-s-lesser-dark span.cm-qualifier { color: #555; }
|
||||
.cm-s-lesser-dark span.cm-builtin { color: #ff9e59; }
|
||||
.cm-s-lesser-dark span.cm-bracket { color: #EBEFE7; }
|
||||
.cm-s-lesser-dark span.cm-tag { color: #669199; }
|
||||
.cm-s-lesser-dark span.cm-attribute {color: #00c;}
|
||||
.cm-s-lesser-dark span.cm-hr {color: #999;}
|
||||
.cm-s-lesser-dark span.cm-link {color: #00c;}
|
||||
.cm-s-lesser-dark span.cm-attribute { color: #00c; }
|
||||
.cm-s-lesser-dark span.cm-hr { color: #999; }
|
||||
.cm-s-lesser-dark span.cm-link { color: #00c; }
|
||||
.cm-s-lesser-dark span.cm-error { color: #9d1e15; }
|
||||
|
||||
.cm-s-lesser-dark .CodeMirror-activeline-background {background: #3C3A3A !important;}
|
||||
.cm-s-lesser-dark .CodeMirror-matchingbracket {outline:1px solid grey; color:white !important;}
|
||||
.cm-s-lesser-dark .CodeMirror-activeline-background { background: #3C3A3A; }
|
||||
.cm-s-lesser-dark .CodeMirror-matchingbracket { outline:1px solid grey; color:white !important; }
|
||||
|
|
38
codemirror/theme/liquibyte.css
vendored
38
codemirror/theme/liquibyte.css
vendored
|
@ -4,27 +4,27 @@
|
|||
line-height: 1.2em;
|
||||
font-size: 1em;
|
||||
}
|
||||
.CodeMirror-focused .cm-matchhighlight {
|
||||
.cm-s-liquibyte .CodeMirror-focused .cm-matchhighlight {
|
||||
text-decoration: underline;
|
||||
text-decoration-color: #0f0;
|
||||
text-decoration-style: wavy;
|
||||
}
|
||||
.cm-trailingspace {
|
||||
.cm-s-liquibyte .cm-trailingspace {
|
||||
text-decoration: line-through;
|
||||
text-decoration-color: #f00;
|
||||
text-decoration-style: dotted;
|
||||
}
|
||||
.cm-tab {
|
||||
.cm-s-liquibyte .cm-tab {
|
||||
text-decoration: line-through;
|
||||
text-decoration-color: #404040;
|
||||
text-decoration-style: dotted;
|
||||
}
|
||||
.cm-s-liquibyte .CodeMirror-gutters { background-color: #262626; border-right: 1px solid #505050; padding-right: 0.8em; }
|
||||
.cm-s-liquibyte .CodeMirror-gutter-elt div{ font-size: 1.2em; }
|
||||
.cm-s-liquibyte .CodeMirror-gutter-elt div { font-size: 1.2em; }
|
||||
.cm-s-liquibyte .CodeMirror-guttermarker { }
|
||||
.cm-s-liquibyte .CodeMirror-guttermarker-subtle { }
|
||||
.cm-s-liquibyte .CodeMirror-linenumber { color: #606060; padding-left: 0;}
|
||||
.cm-s-liquibyte .CodeMirror-cursor { border-left: 1px solid #eee !important; }
|
||||
.cm-s-liquibyte .CodeMirror-linenumber { color: #606060; padding-left: 0; }
|
||||
.cm-s-liquibyte .CodeMirror-cursor { border-left: 1px solid #eee; }
|
||||
|
||||
.cm-s-liquibyte span.cm-comment { color: #008000; }
|
||||
.cm-s-liquibyte span.cm-def { color: #ffaf40; font-weight: bold; }
|
||||
|
@ -47,49 +47,49 @@
|
|||
.cm-s-liquibyte span.cm-attribute { color: #c080ff; font-weight: bold; }
|
||||
.cm-s-liquibyte span.cm-error { color: #f00; }
|
||||
|
||||
.cm-s-liquibyte .CodeMirror-selected { background-color: rgba(255, 0, 0, 0.25) !important; }
|
||||
.cm-s-liquibyte div.CodeMirror-selected { background-color: rgba(255, 0, 0, 0.25); }
|
||||
|
||||
.cm-s-liquibyte span.cm-compilation { background-color: rgba(255, 255, 255, 0.12); }
|
||||
|
||||
.cm-s-liquibyte .CodeMirror-activeline-background {background-color: rgba(0, 255, 0, 0.15) !important;}
|
||||
.cm-s-liquibyte .CodeMirror-activeline-background { background-color: rgba(0, 255, 0, 0.15); }
|
||||
|
||||
/* Default styles for common addons */
|
||||
div.CodeMirror span.CodeMirror-matchingbracket { color: #0f0; font-weight: bold; }
|
||||
div.CodeMirror span.CodeMirror-nonmatchingbracket { color: #f00; font-weight: bold; }
|
||||
.cm-s-liquibyte .CodeMirror span.CodeMirror-matchingbracket { color: #0f0; font-weight: bold; }
|
||||
.cm-s-liquibyte .CodeMirror span.CodeMirror-nonmatchingbracket { color: #f00; font-weight: bold; }
|
||||
.CodeMirror-matchingtag { background-color: rgba(150, 255, 0, .3); }
|
||||
/* Scrollbars */
|
||||
/* Simple */
|
||||
div.CodeMirror-simplescroll-horizontal div:hover, div.CodeMirror-simplescroll-vertical div:hover {
|
||||
.cm-s-liquibyte div.CodeMirror-simplescroll-horizontal div:hover, div.CodeMirror-simplescroll-vertical div:hover {
|
||||
background-color: rgba(80, 80, 80, .7);
|
||||
}
|
||||
div.CodeMirror-simplescroll-horizontal div, div.CodeMirror-simplescroll-vertical div {
|
||||
.cm-s-liquibyte div.CodeMirror-simplescroll-horizontal div, div.CodeMirror-simplescroll-vertical div {
|
||||
background-color: rgba(80, 80, 80, .3);
|
||||
border: 1px solid #404040;
|
||||
border-radius: 5px;
|
||||
}
|
||||
div.CodeMirror-simplescroll-vertical div {
|
||||
.cm-s-liquibyte div.CodeMirror-simplescroll-vertical div {
|
||||
border-top: 1px solid #404040;
|
||||
border-bottom: 1px solid #404040;
|
||||
}
|
||||
div.CodeMirror-simplescroll-horizontal div {
|
||||
.cm-s-liquibyte div.CodeMirror-simplescroll-horizontal div {
|
||||
border-left: 1px solid #404040;
|
||||
border-right: 1px solid #404040;
|
||||
}
|
||||
div.CodeMirror-simplescroll-vertical {
|
||||
.cm-s-liquibyte div.CodeMirror-simplescroll-vertical {
|
||||
background-color: #262626;
|
||||
}
|
||||
div.CodeMirror-simplescroll-horizontal {
|
||||
.cm-s-liquibyte div.CodeMirror-simplescroll-horizontal {
|
||||
background-color: #262626;
|
||||
border-top: 1px solid #404040;
|
||||
}
|
||||
/* Overlay */
|
||||
div.CodeMirror-overlayscroll-horizontal div, div.CodeMirror-overlayscroll-vertical div {
|
||||
.cm-s-liquibyte div.CodeMirror-overlayscroll-horizontal div, div.CodeMirror-overlayscroll-vertical div {
|
||||
background-color: #404040;
|
||||
border-radius: 5px;
|
||||
}
|
||||
div.CodeMirror-overlayscroll-vertical div {
|
||||
.cm-s-liquibyte div.CodeMirror-overlayscroll-vertical div {
|
||||
border: 1px solid #404040;
|
||||
}
|
||||
div.CodeMirror-overlayscroll-horizontal div {
|
||||
.cm-s-liquibyte div.CodeMirror-overlayscroll-horizontal div {
|
||||
border: 1px solid #404040;
|
||||
}
|
||||
|
|
53
codemirror/theme/material.css
vendored
Normal file
53
codemirror/theme/material.css
vendored
Normal file
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
|
||||
Name: material
|
||||
Author: Michael Kaminsky (http://github.com/mkaminsky11)
|
||||
|
||||
Original material color scheme by Mattia Astorino (https://github.com/equinusocio/material-theme)
|
||||
|
||||
*/
|
||||
|
||||
.cm-s-material.CodeMirror {
|
||||
background-color: #263238;
|
||||
color: rgba(233, 237, 237, 1);
|
||||
}
|
||||
.cm-s-material .CodeMirror-gutters {
|
||||
background: #263238;
|
||||
color: rgb(83,127,126);
|
||||
border: none;
|
||||
}
|
||||
.cm-s-material .CodeMirror-guttermarker, .cm-s-material .CodeMirror-guttermarker-subtle, .cm-s-material .CodeMirror-linenumber { color: rgb(83,127,126); }
|
||||
.cm-s-material .CodeMirror-cursor { border-left: 1px solid #f8f8f0; }
|
||||
.cm-s-material div.CodeMirror-selected { background: rgba(255, 255, 255, 0.15); }
|
||||
.cm-s-material.CodeMirror-focused div.CodeMirror-selected { background: rgba(255, 255, 255, 0.10); }
|
||||
.cm-s-material .CodeMirror-line::selection, .cm-s-material .CodeMirror-line > span::selection, .cm-s-material .CodeMirror-line > span > span::selection { background: rgba(255, 255, 255, 0.10); }
|
||||
.cm-s-material .CodeMirror-line::-moz-selection, .cm-s-material .CodeMirror-line > span::-moz-selection, .cm-s-material .CodeMirror-line > span > span::-moz-selection { background: rgba(255, 255, 255, 0.10); }
|
||||
|
||||
.cm-s-material .CodeMirror-activeline-background { background: rgba(0, 0, 0, 0); }
|
||||
.cm-s-material .cm-keyword { color: rgba(199, 146, 234, 1); }
|
||||
.cm-s-material .cm-operator { color: rgba(233, 237, 237, 1); }
|
||||
.cm-s-material .cm-variable-2 { color: #80CBC4; }
|
||||
.cm-s-material .cm-variable-3 { color: #82B1FF; }
|
||||
.cm-s-material .cm-builtin { color: #DECB6B; }
|
||||
.cm-s-material .cm-atom { color: #F77669; }
|
||||
.cm-s-material .cm-number { color: #F77669; }
|
||||
.cm-s-material .cm-def { color: rgba(233, 237, 237, 1); }
|
||||
.cm-s-material .cm-string { color: #C3E88D; }
|
||||
.cm-s-material .cm-string-2 { color: #80CBC4; }
|
||||
.cm-s-material .cm-comment { color: #546E7A; }
|
||||
.cm-s-material .cm-variable { color: #82B1FF; }
|
||||
.cm-s-material .cm-tag { color: #80CBC4; }
|
||||
.cm-s-material .cm-meta { color: #80CBC4; }
|
||||
.cm-s-material .cm-attribute { color: #FFCB6B; }
|
||||
.cm-s-material .cm-property { color: #80CBAE; }
|
||||
.cm-s-material .cm-qualifier { color: #DECB6B; }
|
||||
.cm-s-material .cm-variable-3 { color: #DECB6B; }
|
||||
.cm-s-material .cm-tag { color: rgba(255, 83, 112, 1); }
|
||||
.cm-s-material .cm-error {
|
||||
color: rgba(255, 255, 255, 1.0);
|
||||
background-color: #EC5F67;
|
||||
}
|
||||
.cm-s-material .CodeMirror-matchingbracket {
|
||||
text-decoration: underline;
|
||||
color: white !important;
|
||||
}
|
46
codemirror/theme/mbo.css
vendored
46
codemirror/theme/mbo.css
vendored
|
@ -4,34 +4,34 @@
|
|||
/* Create your own: http://tmtheme-editor.herokuapp.com */
|
||||
/****************************************************************/
|
||||
|
||||
.cm-s-mbo.CodeMirror {background: #2c2c2c; color: #ffffec;}
|
||||
.cm-s-mbo div.CodeMirror-selected {background: #716C62 !important;}
|
||||
.cm-s-mbo.CodeMirror { background: #2c2c2c; color: #ffffec; }
|
||||
.cm-s-mbo div.CodeMirror-selected { background: #716C62; }
|
||||
.cm-s-mbo .CodeMirror-line::selection, .cm-s-mbo .CodeMirror-line > span::selection, .cm-s-mbo .CodeMirror-line > span > span::selection { background: rgba(113, 108, 98, .99); }
|
||||
.cm-s-mbo .CodeMirror-line::-moz-selection, .cm-s-mbo .CodeMirror-line > span::-moz-selection, .cm-s-mbo .CodeMirror-line > span > span::-moz-selection { background: rgba(113, 108, 98, .99); }
|
||||
.cm-s-mbo .CodeMirror-gutters {background: #4e4e4e; border-right: 0px;}
|
||||
.cm-s-mbo .CodeMirror-gutters { background: #4e4e4e; border-right: 0px; }
|
||||
.cm-s-mbo .CodeMirror-guttermarker { color: white; }
|
||||
.cm-s-mbo .CodeMirror-guttermarker-subtle { color: grey; }
|
||||
.cm-s-mbo .CodeMirror-linenumber {color: #dadada;}
|
||||
.cm-s-mbo .CodeMirror-cursor {border-left: 1px solid #ffffec !important;}
|
||||
.cm-s-mbo .CodeMirror-linenumber { color: #dadada; }
|
||||
.cm-s-mbo .CodeMirror-cursor { border-left: 1px solid #ffffec; }
|
||||
|
||||
.cm-s-mbo span.cm-comment {color: #95958a;}
|
||||
.cm-s-mbo span.cm-atom {color: #00a8c6;}
|
||||
.cm-s-mbo span.cm-number {color: #00a8c6;}
|
||||
.cm-s-mbo span.cm-comment { color: #95958a; }
|
||||
.cm-s-mbo span.cm-atom { color: #00a8c6; }
|
||||
.cm-s-mbo span.cm-number { color: #00a8c6; }
|
||||
|
||||
.cm-s-mbo span.cm-property, .cm-s-mbo span.cm-attribute {color: #9ddfe9;}
|
||||
.cm-s-mbo span.cm-keyword {color: #ffb928;}
|
||||
.cm-s-mbo span.cm-string {color: #ffcf6c;}
|
||||
.cm-s-mbo span.cm-string.cm-property {color: #ffffec;}
|
||||
.cm-s-mbo span.cm-property, .cm-s-mbo span.cm-attribute { color: #9ddfe9; }
|
||||
.cm-s-mbo span.cm-keyword { color: #ffb928; }
|
||||
.cm-s-mbo span.cm-string { color: #ffcf6c; }
|
||||
.cm-s-mbo span.cm-string.cm-property { color: #ffffec; }
|
||||
|
||||
.cm-s-mbo span.cm-variable {color: #ffffec;}
|
||||
.cm-s-mbo span.cm-variable-2 {color: #00a8c6;}
|
||||
.cm-s-mbo span.cm-def {color: #ffffec;}
|
||||
.cm-s-mbo span.cm-bracket {color: #fffffc; font-weight: bold;}
|
||||
.cm-s-mbo span.cm-tag {color: #9ddfe9;}
|
||||
.cm-s-mbo span.cm-link {color: #f54b07;}
|
||||
.cm-s-mbo span.cm-error {border-bottom: #636363; color: #ffffec;}
|
||||
.cm-s-mbo span.cm-qualifier {color: #ffffec;}
|
||||
.cm-s-mbo span.cm-variable { color: #ffffec; }
|
||||
.cm-s-mbo span.cm-variable-2 { color: #00a8c6; }
|
||||
.cm-s-mbo span.cm-def { color: #ffffec; }
|
||||
.cm-s-mbo span.cm-bracket { color: #fffffc; font-weight: bold; }
|
||||
.cm-s-mbo span.cm-tag { color: #9ddfe9; }
|
||||
.cm-s-mbo span.cm-link { color: #f54b07; }
|
||||
.cm-s-mbo span.cm-error { border-bottom: #636363; color: #ffffec; }
|
||||
.cm-s-mbo span.cm-qualifier { color: #ffffec; }
|
||||
|
||||
.cm-s-mbo .CodeMirror-activeline-background {background: #494b41 !important;}
|
||||
.cm-s-mbo .CodeMirror-matchingbracket {color: #222 !important;}
|
||||
.cm-s-mbo .CodeMirror-matchingtag {background: rgba(255, 255, 255, .37);}
|
||||
.cm-s-mbo .CodeMirror-activeline-background { background: #494b41; }
|
||||
.cm-s-mbo .CodeMirror-matchingbracket { color: #ffb928 !important; }
|
||||
.cm-s-mbo .CodeMirror-matchingtag { background: rgba(255, 255, 255, .37); }
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user