commit
0609c8e1a8
28 changed files with 1519 additions and 120 deletions
|
|
@ -289,13 +289,12 @@ function Folding() {
|
|||
if (startFold && endFold == startFold)
|
||||
return startFold.addSubFold(fold);
|
||||
|
||||
if (
|
||||
(startFold && !startFold.range.isStart(startRow, startColumn))
|
||||
|| (endFold && !endFold.range.isEnd(endRow, endColumn))
|
||||
) {
|
||||
throw new Error("A fold can't intersect already existing fold" + fold.range + startFold.range);
|
||||
}
|
||||
|
||||
if (startFold && !startFold.range.isStart(startRow, startColumn))
|
||||
this.removeFold(startFold);
|
||||
|
||||
if (endFold && !endFold.range.isEnd(endRow, endColumn))
|
||||
this.removeFold(endFold);
|
||||
|
||||
// Check if there are folds in the range we create the new fold for.
|
||||
var folds = this.getFoldsInRange(fold.range);
|
||||
if (folds.length > 0) {
|
||||
|
|
|
|||
|
|
@ -45,9 +45,10 @@ function LineWidgets(session) {
|
|||
this.renderWidgets = this.renderWidgets.bind(this);
|
||||
this.measureWidgets = this.measureWidgets.bind(this);
|
||||
this.session._changedWidgets = [];
|
||||
this.detach = this.detach.bind(this);
|
||||
this.$onChangeEditor = this.$onChangeEditor.bind(this);
|
||||
|
||||
this.session.on("change", this.updateOnChange);
|
||||
this.session.on("changeEditor", this.$onChangeEditor);
|
||||
}
|
||||
|
||||
(function() {
|
||||
|
|
@ -73,8 +74,12 @@ function LineWidgets(session) {
|
|||
return screenRows;
|
||||
};
|
||||
|
||||
this.$onChangeEditor = function(e) {
|
||||
this.attach(e.editor);
|
||||
};
|
||||
|
||||
this.attach = function(editor) {
|
||||
if (editor.widgetManager && editor.widgetManager != this)
|
||||
if (editor && editor.widgetManager && editor.widgetManager != this)
|
||||
editor.widgetManager.detach();
|
||||
|
||||
if (this.editor == editor)
|
||||
|
|
@ -83,21 +88,16 @@ function LineWidgets(session) {
|
|||
this.detach();
|
||||
this.editor = editor;
|
||||
|
||||
this.editor.on("changeSession", this.detach);
|
||||
|
||||
editor.widgetManager = this;
|
||||
|
||||
editor.renderer.on("beforeRender", this.measureWidgets);
|
||||
editor.renderer.on("afterRender", this.renderWidgets);
|
||||
if (editor) {
|
||||
editor.widgetManager = this;
|
||||
editor.renderer.on("beforeRender", this.measureWidgets);
|
||||
editor.renderer.on("afterRender", this.renderWidgets);
|
||||
}
|
||||
};
|
||||
this.detach = function(e) {
|
||||
if (e && e.session == this.session)
|
||||
return; // sometimes attach can be called before setSession
|
||||
var editor = this.editor;
|
||||
if (!editor)
|
||||
return;
|
||||
|
||||
editor.off("changeSession", this.detach);
|
||||
|
||||
this.editor = null;
|
||||
editor.widgetManager = null;
|
||||
|
|
|
|||
|
|
@ -1,20 +1,66 @@
|
|||
var fs = require("fs");
|
||||
var path = require("path");
|
||||
if (!fs.existsSync)
|
||||
fs.existsSync = require("path").existsSync;
|
||||
fs.existsSync = path.existsSync;
|
||||
|
||||
require("amd-loader");
|
||||
|
||||
var cwd = __dirname + "/";
|
||||
var root = path.normalize(cwd + Array(5).join("../"));
|
||||
|
||||
function jsFileList(path, filter) {
|
||||
if (!filter) filter = /_test/;
|
||||
return fs.readdirSync(path).map(function(x) {
|
||||
if (x.slice(-3) == ".js" && !filter.test(x) && !/\s/.test(x))
|
||||
return x.slice(0, -3);
|
||||
}).filter(Boolean);
|
||||
}
|
||||
|
||||
function modeList() {
|
||||
return jsFileList(cwd + "../", /_highlight_rules|_test|_worker|xml_util|_outdent|behaviour|completions/);
|
||||
}
|
||||
|
||||
function checkModes() {
|
||||
modeList().forEach(function(modeName) {
|
||||
try {
|
||||
var Mode = require("../" + modeName).Mode;
|
||||
} catch(e) {
|
||||
console.warn("Can't load mode :" + modeName, e);
|
||||
return;
|
||||
}
|
||||
var m = new Mode();
|
||||
if (!m.lineCommentStart && !m.blockComment)
|
||||
console.warn("missing comment in " + modeName);
|
||||
if (!m.$id)
|
||||
console.warn("missing id in " + modeName);
|
||||
var tokenizer = (new Mode).getTokenizer();
|
||||
if (m.lineCommentStart) {
|
||||
if (Array.isArray(m.lineCommentStart)) {
|
||||
m.lineCommentStart.forEach(function(x) {
|
||||
testLineComment(tokenizer, x, modeName)
|
||||
});
|
||||
} else {
|
||||
testLineComment(tokenizer, m.lineCommentStart, modeName)
|
||||
}
|
||||
}
|
||||
// if (m.blockComment) {
|
||||
// var tokens = tok.getLineTokens(m.lineCommentStart, "start");
|
||||
// if (!/comment/.test(tokens[0]))
|
||||
// console.warn("broken lineCommentStart in " + modeName);
|
||||
// }
|
||||
});
|
||||
|
||||
function testLineComment(tokenizer, commentStart, modeName) {
|
||||
var tokens = tokenizer.getLineTokens(commentStart + " ", "start").tokens;
|
||||
if (!/comment/.test(tokens[0].type))
|
||||
console.warn("broken lineCommentStart in " + modeName);
|
||||
}
|
||||
}
|
||||
|
||||
function generateTestData() {
|
||||
var root = Array(5).join("../") + "/demo/kitchen-sink/docs";
|
||||
var docs = fs.readdirSync(cwd + root);
|
||||
var docs = jsFileList(cwd + root);
|
||||
var specialDocs = fs.readdirSync(cwd);
|
||||
var modes = fs.readdirSync(cwd + "../").filter(function(x){
|
||||
return !/(_highlight_rules|behaviour|worker)\.js$/.test(x) && /\.js$/.test(x);
|
||||
}).map(function(x) {
|
||||
return x.replace(/\.js$/, "");
|
||||
});
|
||||
var modes = modeList();
|
||||
|
||||
console.log("Docs:", docs);
|
||||
console.log("Modes:", modes);
|
||||
|
|
@ -61,7 +107,7 @@ function generateTestData() {
|
|||
return tmp.join(",\n ");
|
||||
});
|
||||
|
||||
jsonStr = "[[\n " + data.join("\n],[\n ") + "\n]]";
|
||||
var jsonStr = "[[\n " + data.join("\n],[\n ") + "\n]]";
|
||||
fs.writeFileSync(cwd + "tokens_" + modeName + ".json", jsonStr, "utf8");
|
||||
});
|
||||
}
|
||||
|
|
@ -91,7 +137,7 @@ function testMode(modeName, i) {
|
|||
lineData.state = lineData.shift();
|
||||
var line = null;
|
||||
if (typeof lineData[lineData.length - 1] == "string")
|
||||
line = lineData.pop()
|
||||
line = lineData.pop();
|
||||
lineData.forEach(function(x) {
|
||||
lineData.types.push(x[0]);
|
||||
lineData.values.push(x[1]);
|
||||
|
|
@ -103,14 +149,13 @@ function testMode(modeName, i) {
|
|||
var values = tokens.tokens.map(function(x) {return x.value;});
|
||||
var types = tokens.tokens.map(function(x) {return x.type;});
|
||||
|
||||
var success = true;
|
||||
var err = testEqual([
|
||||
JSON.stringify(lineData.state), JSON.stringify(tokens.state),
|
||||
lineData.types, types,
|
||||
lineData.values, values]);
|
||||
|
||||
if (err) {
|
||||
console.log(line)
|
||||
console.log(line);
|
||||
throw "error";
|
||||
}
|
||||
|
||||
|
|
@ -150,10 +195,12 @@ function padNumber(num, digits) {
|
|||
// cli
|
||||
var arg = process.argv[2];
|
||||
if (!arg)
|
||||
test()
|
||||
test();
|
||||
else if (/--?g(en)?/.test(arg))
|
||||
generateTestData(process.argv.splice(3));
|
||||
else if (/--?c(heck)?/.test(arg))
|
||||
checkModes(process.argv.splice(3));
|
||||
else if (/\d+/.test(arg))
|
||||
test(parseInt(process.argv[2],10) || 0);
|
||||
else
|
||||
testMode(arg, -1)
|
||||
testMode(arg, -1);
|
||||
|
|
@ -27,10 +27,6 @@
|
|||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -26,11 +26,6 @@
|
|||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
|
|
@ -53,7 +48,7 @@ var Mode = function() {
|
|||
oop.inherits(Mode, TextMode);
|
||||
|
||||
(function() {
|
||||
this.lineCommentStart = "/\\*";
|
||||
this.lineCommentStart = ";";
|
||||
this.blockComment = {start: "/*", end: "*/"};
|
||||
this.$id = "ace/mode/autohotkey";
|
||||
}).call(Mode.prototype);
|
||||
|
|
|
|||
|
|
@ -50,11 +50,12 @@ var c_cppHighlightRules = function() {
|
|||
// regexp must not have capturing parentheses. Use (?:) instead.
|
||||
// regexps are ordered -> the first match is used
|
||||
|
||||
this.$rules = {
|
||||
this.$rules = {
|
||||
"start" : [
|
||||
{
|
||||
token : "comment",
|
||||
regex : "\\/\\/.*$"
|
||||
regex : "//",
|
||||
next : "singleLineComment"
|
||||
},
|
||||
DocCommentHighlightRules.getStartRule("doc-start"),
|
||||
{
|
||||
|
|
@ -121,14 +122,26 @@ var c_cppHighlightRules = function() {
|
|||
regex : ".+"
|
||||
}
|
||||
],
|
||||
"singleLineComment" : [
|
||||
{
|
||||
token : "comment",
|
||||
regex : /\\$/,
|
||||
next : "singleLineComment"
|
||||
}, {
|
||||
token : "comment",
|
||||
regex : /$/,
|
||||
next : "start"
|
||||
}, {
|
||||
defaultToken: "comment"
|
||||
}
|
||||
],
|
||||
"qqstring" : [
|
||||
{
|
||||
token : "string",
|
||||
regex : '(?:(?:\\\\.)|(?:[^"\\\\]))*?"',
|
||||
next : "start"
|
||||
}, {
|
||||
token : "string",
|
||||
regex : '.+'
|
||||
defaultToken : "string"
|
||||
}
|
||||
],
|
||||
"qstring" : [
|
||||
|
|
@ -137,8 +150,7 @@ var c_cppHighlightRules = function() {
|
|||
regex : "(?:(?:\\\\.)|(?:[^'\\\\]))*?'",
|
||||
next : "start"
|
||||
}, {
|
||||
token : "string",
|
||||
regex : '.+'
|
||||
defaultToken : "string"
|
||||
}
|
||||
],
|
||||
"directive" : [
|
||||
|
|
|
|||
|
|
@ -142,7 +142,7 @@ define(function(require, exports, module) {
|
|||
}
|
||||
if (val == "}" && stack.length) {
|
||||
stack.shift();
|
||||
this.next = stack.shift();
|
||||
this.next = stack.shift() || "";
|
||||
if (this.next.indexOf("string") != -1)
|
||||
return "paren.string";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ var Mode = function() {
|
|||
oop.inherits(Mode, TextMode);
|
||||
|
||||
(function() {
|
||||
this.lineCommentStart = "/\\+";
|
||||
this.lineCommentStart = "//";
|
||||
this.blockComment = {start: "/*", end: "*/"};
|
||||
this.$id = "ace/mode/d";
|
||||
}).call(Mode.prototype);
|
||||
|
|
|
|||
|
|
@ -27,10 +27,6 @@
|
|||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
|
|
@ -53,7 +49,7 @@ var Mode = function() {
|
|||
oop.inherits(Mode, TextMode);
|
||||
|
||||
(function() {
|
||||
this.lineCommentStart = "(?<=^|\\s)\\.?\\( [^)]*\\)";
|
||||
this.lineCommentStart = "--";
|
||||
this.blockComment = {start: "/*", end: "*/"};
|
||||
this.$id = "ace/mode/forth";
|
||||
}).call(Mode.prototype);
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ var Mode = function() {
|
|||
oop.inherits(Mode, TextMode);
|
||||
|
||||
(function() {
|
||||
this.lineCommentStart = "#";
|
||||
this.$id = "ace/mode/gitignore";
|
||||
}).call(Mode.prototype);
|
||||
|
||||
|
|
|
|||
|
|
@ -26,11 +26,6 @@
|
|||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -27,10 +27,6 @@
|
|||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -51,7 +51,10 @@ var Mode = function() {
|
|||
};
|
||||
oop.inherits(Mode, TextMode);
|
||||
|
||||
(function() {
|
||||
(function() {
|
||||
this.lineCommentStart = "//";
|
||||
this.blockComment = {start: "/*", end: "*/"};
|
||||
|
||||
this.$id = "ace/mode/stylus";
|
||||
}).call(Mode.prototype);
|
||||
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ var Mode = function() {
|
|||
oop.inherits(Mode, TextMode);
|
||||
|
||||
(function() {
|
||||
this.type = "text";
|
||||
this.getNextLineIndent = function(state, line, tab) {
|
||||
if (state == "intag")
|
||||
return tab;
|
||||
|
|
|
|||
|
|
@ -305,7 +305,7 @@ var Search = function() {
|
|||
if (options.wholeWord)
|
||||
needle = "\\b" + needle + "\\b";
|
||||
|
||||
var modifier = options.caseSensitive ? "g" : "gi";
|
||||
var modifier = options.caseSensitive ? "gm" : "gmi";
|
||||
|
||||
options.$isMultiLine = !$disableFakeMultiline && /[\n\r]/.test(needle);
|
||||
if (options.$isMultiLine)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
.ace-cobalt .ace_gutter {
|
||||
background: #011e3a;
|
||||
color: #fff
|
||||
color: rgb(128,145,160)
|
||||
}
|
||||
|
||||
.ace-cobalt .ace_print-margin {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
.ace-idle-fingers .ace_gutter {
|
||||
background: #3b3b3b;
|
||||
color: #fff
|
||||
color: rgb(153,153,153)
|
||||
}
|
||||
|
||||
.ace-idle-fingers .ace_print-margin {
|
||||
|
|
|
|||
|
|
@ -34,12 +34,13 @@
|
|||
margin: -1px 0 0 -1px;
|
||||
border: 1px solid #888888
|
||||
}
|
||||
|
||||
.ace-tomorrow-night-bright .ace_marker-layer .ace_highlight {
|
||||
border: 1px solid rgb(110, 119, 0);
|
||||
border-bottom: 0;
|
||||
box-shadow: inset 0 -1px rgb(110, 119, 0);
|
||||
margin: -1px 0 0 -1px;
|
||||
background: rgba(255, 235, 0, 0.1);
|
||||
border: 1px solid rgb(110, 119, 0);
|
||||
border-bottom: 0;
|
||||
box-shadow: inset 0 -1px rgb(110, 119, 0);
|
||||
margin: -1px 0 0 -1px;
|
||||
background: rgba(255, 235, 0, 0.1)
|
||||
}
|
||||
|
||||
.ace-tomorrow-night-bright .ace_marker-layer .ace_active-line {
|
||||
|
|
@ -132,7 +133,7 @@
|
|||
}
|
||||
|
||||
.ace-tomorrow-night-bright .ace_c9searchresults.ace_keyword {
|
||||
color: #C2C280;
|
||||
color: #C2C280
|
||||
}
|
||||
|
||||
.ace-tomorrow-night-bright .ace_indent-guide {
|
||||
|
|
|
|||
|
|
@ -17,7 +17,13 @@ window.window = window;
|
|||
window.ace = window;
|
||||
|
||||
window.onerror = function(message, file, line, col, err) {
|
||||
console.error("Worker " + (err ? err.stack : message));
|
||||
postMessage({type: "error", data: {
|
||||
message: message,
|
||||
file: file,
|
||||
line: line,
|
||||
col: col,
|
||||
stack: err.stack
|
||||
}});
|
||||
};
|
||||
|
||||
window.normalizeModule = function(parentId, moduleName) {
|
||||
|
|
@ -84,15 +90,20 @@ window.define = function(id, deps, factory) {
|
|||
deps = [];
|
||||
id = window.require.id;
|
||||
}
|
||||
|
||||
if (typeof factory != "function") {
|
||||
window.require.modules[id] = {
|
||||
exports: factory,
|
||||
initialized: true
|
||||
};
|
||||
return;
|
||||
}
|
||||
|
||||
if (!deps.length)
|
||||
// If there is no dependencies, we inject 'require', 'exports' and
|
||||
// 'module' as dependencies, to provide CommonJS compatibility.
|
||||
deps = ['require', 'exports', 'module'];
|
||||
|
||||
if (id.indexOf("text!") === 0)
|
||||
return;
|
||||
|
||||
var req = function(childId) {
|
||||
return window.require(id, childId);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -92,14 +92,9 @@ var WorkerClient = function(topLevelNamespaces, mod, classname, workerUrl) {
|
|||
this.onMessage = function(e) {
|
||||
var msg = e.data;
|
||||
switch(msg.type) {
|
||||
case "log":
|
||||
window.console && console.log && console.log.apply(console, msg.data);
|
||||
break;
|
||||
|
||||
case "event":
|
||||
this._signal(msg.name, {data: msg.data});
|
||||
break;
|
||||
|
||||
case "call":
|
||||
var callback = this.callbacks[msg.id];
|
||||
if (callback) {
|
||||
|
|
@ -107,8 +102,18 @@ var WorkerClient = function(topLevelNamespaces, mod, classname, workerUrl) {
|
|||
delete this.callbacks[msg.id];
|
||||
}
|
||||
break;
|
||||
case "error":
|
||||
this.reportError(msg.data);
|
||||
break;
|
||||
case "log":
|
||||
window.console && console.log && console.log.apply(console, msg.data);
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
this.reportError = function(err) {
|
||||
window.console && console.error && console.error(err);
|
||||
};
|
||||
|
||||
this.$normalizePath = function(path) {
|
||||
return net.qualifyURL(path);
|
||||
|
|
@ -119,7 +124,8 @@ var WorkerClient = function(topLevelNamespaces, mod, classname, workerUrl) {
|
|||
this.deltaQueue = null;
|
||||
this.$worker.terminate();
|
||||
this.$worker = null;
|
||||
this.$doc.removeEventListener("change", this.changeListener);
|
||||
if (this.$doc)
|
||||
this.$doc.off("change", this.changeListener);
|
||||
this.$doc = null;
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue