Merge pull request #2507 from ajaxorg/c9

Sync with cloud9
This commit is contained in:
Lennart Kats 2015-06-01 17:39:25 +02:00
commit d953740339
10 changed files with 92 additions and 47 deletions

View file

@ -423,6 +423,12 @@ exports.commands = [{
exec: function() {},
passEvent: true,
readOnly: true
}, {
name: "copy",
exec: function(editor) {
// placeholder for replay macro
},
readOnly: true
},
// commands disabled in readOnly mode
@ -439,6 +445,12 @@ exports.commands = [{
},
scrollIntoView: "cursor",
multiSelectAction: "forEach"
}, {
name: "paste",
exec: function(editor, args) {
editor.$handlePaste(args);
},
scrollIntoView: "cursor"
}, {
name: "removeline",
bindKey: bindKey("Ctrl-D", "Command-D"),

View file

@ -916,13 +916,15 @@ var Editor = function(renderer, session) {
*
**/
this.onPaste = function(text, event) {
// todo this should change when paste becomes a command
if (this.$readOnly)
return;
var e = {text: text, event: event};
this.commands.exec("paste", this, e);
};
this.$handlePaste = function(e) {
if (typeof e == "string")
e = {text: e};
this._signal("paste", e);
text = e.text;
var text = e.text;
if (!this.inMultiSelectMode || this.inVirtualSelectionMode) {
this.insert(text);
} else {
@ -940,7 +942,6 @@ var Editor = function(renderer, session) {
this.session.insert(range.start, lines[i]);
}
}
this.renderer.scrollCursorIntoView();
};
this.execCommand = function(command, args) {

View file

@ -122,7 +122,7 @@ var supportedModes = {
Pascal: ["pas|p"],
Perl: ["pl|pm"],
pgSQL: ["pgsql"],
PHP: ["php|phtml"],
PHP: ["php|phtml|shtml|php3|php4|php5|phps|phpt|aw|ctp"],
Powershell: ["ps1"],
Praat: ["praat|praatscript|psc|proc"],
Prolog: ["plg|prolog"],

View file

@ -52,7 +52,7 @@ var Text = function(parentEl) {
this.EOL_CHAR_LF = "\xAC";
this.EOL_CHAR_CRLF = "\xa4";
this.EOL_CHAR = this.EOL_CHAR_LF;
this.TAB_CHAR = "\u2192"; //"\u21E5";
this.TAB_CHAR = "\u2014"; //"\u21E5";
this.SPACE_CHAR = "\xB7";
this.$padding = 0;
@ -128,8 +128,7 @@ var Text = function(parentEl) {
for (var i = 1; i < tabSize + 1; i++) {
if (this.showInvisibles) {
tabStr.push("<span class='ace_invisible ace_invisible_tab'>"
+ this.TAB_CHAR
+ lang.stringRepeat(" ", i - 1)
+ lang.stringRepeat(this.TAB_CHAR, i)
+ "</span>");
} else {
tabStr.push(lang.stringRepeat(" ", i));
@ -145,7 +144,7 @@ var Text = function(parentEl) {
spaceClass = " ace_invisible_space";
tabClass = " ace_invisible_tab";
var spaceContent = lang.stringRepeat(this.SPACE_CHAR, this.tabSize);
var tabContent = this.TAB_CHAR + lang.stringRepeat(" ", this.tabSize - 1);
var tabContent = lang.stringRepeat(this.TAB_CHAR, this.tabSize);
} else{
var spaceContent = lang.stringRepeat(" ", this.tabSize);
var tabContent = spaceContent;

View file

@ -91,7 +91,7 @@ module.exports = {
var EOL = "<span class='ace_invisible ace_invisible_eol'>" + textLayer.EOL_CHAR + "</span>";
var SPACE = function(i) {return Array(i+1).join(" ")}
var DOT = function(i) {return Array(i+1).join(textLayer.SPACE_CHAR)}
var TAB = function(i) {return textLayer.TAB_CHAR + SPACE(i-1)}
var TAB = function(i) {return Array(i+1).join(textLayer.TAB_CHAR)}
function testRender(results) {
for (var i = results.length; i--; ) {
var stringBuilder = [];

View file

@ -144,6 +144,16 @@ module.exports = {
exec("selectleft", 1);
exec("insertstring", 1, '"');
assert.equal(editor.getValue(), '("foo")');
editor.setValue("", 1);
exec("selectleft", 1);
exec("insertstring", 1, '"');
assert.equal(editor.getValue(), '""');
exec("insertstring", 1, '\\');
exec("insertstring", 1, 'n');
exec("insertstring", 1, '"');
assert.equal(editor.getValue(), '"\\n"');
},
"test: xml": function() {
editor = new Editor(new MockRenderer());

View file

@ -269,8 +269,8 @@ var CstyleBehaviour = function() {
if (leftChar == "\\" && token && /escape/.test(token.type))
return null;
var stringBefore = token && /string/.test(token.type);
var stringAfter = !rightToken || /string/.test(rightToken.type);
var stringBefore = token && /string|escape/.test(token.type);
var stringAfter = !rightToken || /string|escape/.test(rightToken.type);
var pair;
if (rightChar == quote) {

View file

@ -13,7 +13,6 @@ var Mode = function() {
HtmlMode.call(this);
this.HighlightRules = HandlebarsHighlightRules;
this.$behaviour = new HtmlBehaviour();
this.foldingRules = new HtmlFoldMode();
};
@ -21,7 +20,7 @@ var Mode = function() {
oop.inherits(Mode, HtmlMode);
(function() {
this.blockComment = {start: "{!--", end: "--}"};
this.blockComment = {start: "{{!--", end: "--}}"};
this.$id = "ace/mode/handlebars";
}).call(Mode.prototype);

View file

@ -231,7 +231,7 @@ var LessHighlightRules = function() {
regex: "\\.[a-z0-9-_]+"
}, {
token: "variable.language",
regex: ":[a-z0-9-_]+"
regex: ":[a-z_][a-z0-9-_]*"
}, {
token: "constant",
regex: "[a-z0-9-_]+"

View file

@ -1,8 +1,9 @@
"no use strict";
;(function(window) {
if (typeof window.window != "undefined" && window.document) {
if (typeof window.window != "undefined" && window.document)
return;
if (window.require && window.define)
return;
}
window.console = function() {
var msgs = Array.prototype.slice.call(arguments, 0);
@ -19,6 +20,7 @@ window.ace = window;
window.onerror = function(message, file, line, col, err) {
postMessage({type: "error", data: {
message: message,
data: err.data,
file: file,
line: line,
col: col,
@ -37,7 +39,7 @@ window.normalizeModule = function(parentId, moduleName) {
var base = parentId.split("/").slice(0, -1).join("/");
moduleName = (base ? base + "/" : "") + moduleName;
while(moduleName.indexOf(".") !== -1 && previous != moduleName) {
while (moduleName.indexOf(".") !== -1 && previous != moduleName) {
var previous = moduleName;
moduleName = moduleName.replace(/^\.\//, "").replace(/\/\.\//, "/").replace(/[^\/]+\/\.\.\//, "");
}
@ -46,7 +48,7 @@ window.normalizeModule = function(parentId, moduleName) {
return moduleName;
};
window.require = function(parentId, id) {
window.require = function require(parentId, id) {
if (!id) {
id = parentId;
parentId = null;
@ -64,17 +66,36 @@ window.require = function(parentId, id) {
}
return module.exports;
}
var chunks = id.split("/");
if (!window.require.tlns)
return console.log("unable to load " + id);
chunks[0] = window.require.tlns[chunks[0]] || chunks[0];
var path = chunks.join("/") + ".js";
var path = resolveModuleId(id, window.require.tlns);
if (path.slice(-3) != ".js") path += ".js";
window.require.id = id;
window.require.modules[id] = {}; // prevent infinite loop on broken modules
importScripts(path);
return window.require(parentId, id);
};
function resolveModuleId(id, paths) {
var testPath = id, tail = "";
while (testPath) {
var alias = paths[testPath];
if (typeof alias == "string") {
return alias + tail;
} else if (alias) {
return alias.location.replace(/\/*$/, "/") + (tail || alias.main || alias.name);
} else if (alias === false) {
return "";
}
var i = testPath.lastIndexOf("/");
if (i === -1) break;
tail = testPath.substr(i) + tail;
testPath = testPath.slice(0, i);
}
return id;
}
window.require.modules = {};
window.require.tlns = {};
@ -100,9 +121,9 @@ window.define = function(id, deps, factory) {
}
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 there is no dependencies, we inject "require", "exports" and
// "module" as dependencies, to provide CommonJS compatibility.
deps = ["require", "exports", "module"];
var req = function(childId) {
return window.require(id, childId);
@ -113,16 +134,16 @@ window.define = function(id, deps, factory) {
factory: function() {
var module = this;
var returnExports = factory.apply(this, deps.map(function(dep) {
switch(dep) {
// Because 'require', 'exports' and 'module' aren't actual
// dependencies, we must handle them seperately.
case 'require': return req;
case 'exports': return module.exports;
case 'module': return module;
// But for all other dependencies, we can just go ahead and
// require them.
default: return req(dep);
}
switch (dep) {
// Because "require", "exports" and "module" aren't actual
// dependencies, we must handle them seperately.
case "require": return req;
case "exports": return module.exports;
case "module": return module;
// But for all other dependencies, we can just go ahead and
// require them.
default: return req(dep);
}
}));
if (returnExports)
module.exports = returnExports;
@ -131,9 +152,10 @@ window.define = function(id, deps, factory) {
};
};
window.define.amd = {};
require.tlns = {};
window.initBaseUrls = function initBaseUrls(topLevelNamespaces) {
require.tlns = topLevelNamespaces;
for (var i in topLevelNamespaces)
require.tlns[i] = topLevelNamespaces[i];
};
window.initSender = function initSender() {
@ -173,21 +195,23 @@ var sender = window.sender = null;
window.onmessage = function(e) {
var msg = e.data;
if (msg.command) {
if (msg.event && sender) {
sender._signal(msg.event, msg.data);
}
else if (msg.command) {
if (main[msg.command])
main[msg.command].apply(main, msg.args);
else if (window[msg.command])
window[msg.command].apply(window, msg.args);
else
throw new Error("Unknown command:" + msg.command);
}
else if (msg.init) {
initBaseUrls(msg.tlns);
else if (msg.init) {
window.initBaseUrls(msg.tlns);
require("ace/lib/es5-shim");
sender = window.sender = initSender();
sender = window.sender = window.initSender();
var clazz = require(msg.module)[msg.classname];
main = window.main = new clazz(sender);
}
else if (msg.event && sender) {
sender._signal(msg.event, msg.data);
}
};
})(this);