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

View file

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

View file

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

View file

@ -52,7 +52,7 @@ var Text = function(parentEl) {
this.EOL_CHAR_LF = "\xAC"; this.EOL_CHAR_LF = "\xAC";
this.EOL_CHAR_CRLF = "\xa4"; this.EOL_CHAR_CRLF = "\xa4";
this.EOL_CHAR = this.EOL_CHAR_LF; this.EOL_CHAR = this.EOL_CHAR_LF;
this.TAB_CHAR = "\u2192"; //"\u21E5"; this.TAB_CHAR = "\u2014"; //"\u21E5";
this.SPACE_CHAR = "\xB7"; this.SPACE_CHAR = "\xB7";
this.$padding = 0; this.$padding = 0;
@ -128,8 +128,7 @@ var Text = function(parentEl) {
for (var i = 1; i < tabSize + 1; i++) { for (var i = 1; i < tabSize + 1; i++) {
if (this.showInvisibles) { if (this.showInvisibles) {
tabStr.push("<span class='ace_invisible ace_invisible_tab'>" tabStr.push("<span class='ace_invisible ace_invisible_tab'>"
+ this.TAB_CHAR + lang.stringRepeat(this.TAB_CHAR, i)
+ lang.stringRepeat(" ", i - 1)
+ "</span>"); + "</span>");
} else { } else {
tabStr.push(lang.stringRepeat(" ", i)); tabStr.push(lang.stringRepeat(" ", i));
@ -145,7 +144,7 @@ var Text = function(parentEl) {
spaceClass = " ace_invisible_space"; spaceClass = " ace_invisible_space";
tabClass = " ace_invisible_tab"; tabClass = " ace_invisible_tab";
var spaceContent = lang.stringRepeat(this.SPACE_CHAR, this.tabSize); 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{ } else{
var spaceContent = lang.stringRepeat(" ", this.tabSize); var spaceContent = lang.stringRepeat(" ", this.tabSize);
var tabContent = spaceContent; 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 EOL = "<span class='ace_invisible ace_invisible_eol'>" + textLayer.EOL_CHAR + "</span>";
var SPACE = function(i) {return Array(i+1).join(" ")} var SPACE = function(i) {return Array(i+1).join(" ")}
var DOT = function(i) {return Array(i+1).join(textLayer.SPACE_CHAR)} 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) { function testRender(results) {
for (var i = results.length; i--; ) { for (var i = results.length; i--; ) {
var stringBuilder = []; var stringBuilder = [];

View file

@ -144,6 +144,16 @@ module.exports = {
exec("selectleft", 1); exec("selectleft", 1);
exec("insertstring", 1, '"'); exec("insertstring", 1, '"');
assert.equal(editor.getValue(), '("foo")'); 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() { "test: xml": function() {
editor = new Editor(new MockRenderer()); editor = new Editor(new MockRenderer());

View file

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

View file

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

View file

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

View file

@ -1,8 +1,9 @@
"no use strict"; "no use strict";
;(function(window) { ;(function(window) {
if (typeof window.window != "undefined" && window.document) { if (typeof window.window != "undefined" && window.document)
return;
if (window.require && window.define)
return; return;
}
window.console = function() { window.console = function() {
var msgs = Array.prototype.slice.call(arguments, 0); var msgs = Array.prototype.slice.call(arguments, 0);
@ -19,6 +20,7 @@ window.ace = window;
window.onerror = function(message, file, line, col, err) { window.onerror = function(message, file, line, col, err) {
postMessage({type: "error", data: { postMessage({type: "error", data: {
message: message, message: message,
data: err.data,
file: file, file: file,
line: line, line: line,
col: col, col: col,
@ -46,7 +48,7 @@ window.normalizeModule = function(parentId, moduleName) {
return moduleName; return moduleName;
}; };
window.require = function(parentId, id) { window.require = function require(parentId, id) {
if (!id) { if (!id) {
id = parentId; id = parentId;
parentId = null; parentId = null;
@ -65,16 +67,35 @@ window.require = function(parentId, id) {
return module.exports; return module.exports;
} }
var chunks = id.split("/");
if (!window.require.tlns) if (!window.require.tlns)
return console.log("unable to load " + id); 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.id = id;
window.require.modules[id] = {}; // prevent infinite loop on broken modules
importScripts(path); importScripts(path);
return window.require(parentId, id); 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.modules = {};
window.require.tlns = {}; window.require.tlns = {};
@ -100,9 +121,9 @@ window.define = function(id, deps, factory) {
} }
if (!deps.length) if (!deps.length)
// If there is no dependencies, we inject 'require', 'exports' and // If there is no dependencies, we inject "require", "exports" and
// 'module' as dependencies, to provide CommonJS compatibility. // "module" as dependencies, to provide CommonJS compatibility.
deps = ['require', 'exports', 'module']; deps = ["require", "exports", "module"];
var req = function(childId) { var req = function(childId) {
return window.require(id, childId); return window.require(id, childId);
@ -114,11 +135,11 @@ window.define = function(id, deps, factory) {
var module = this; var module = this;
var returnExports = factory.apply(this, deps.map(function(dep) { var returnExports = factory.apply(this, deps.map(function(dep) {
switch (dep) { switch (dep) {
// Because 'require', 'exports' and 'module' aren't actual // Because "require", "exports" and "module" aren't actual
// dependencies, we must handle them seperately. // dependencies, we must handle them seperately.
case 'require': return req; case "require": return req;
case 'exports': return module.exports; case "exports": return module.exports;
case 'module': return module; case "module": return module;
// But for all other dependencies, we can just go ahead and // But for all other dependencies, we can just go ahead and
// require them. // require them.
default: return req(dep); default: return req(dep);
@ -131,9 +152,10 @@ window.define = function(id, deps, factory) {
}; };
}; };
window.define.amd = {}; window.define.amd = {};
require.tlns = {};
window.initBaseUrls = function initBaseUrls(topLevelNamespaces) { window.initBaseUrls = function initBaseUrls(topLevelNamespaces) {
require.tlns = topLevelNamespaces; for (var i in topLevelNamespaces)
require.tlns[i] = topLevelNamespaces[i];
}; };
window.initSender = function initSender() { window.initSender = function initSender() {
@ -173,21 +195,23 @@ var sender = window.sender = null;
window.onmessage = function(e) { window.onmessage = function(e) {
var msg = e.data; 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]) if (main[msg.command])
main[msg.command].apply(main, msg.args); main[msg.command].apply(main, msg.args);
else if (window[msg.command])
window[msg.command].apply(window, msg.args);
else else
throw new Error("Unknown command:" + msg.command); throw new Error("Unknown command:" + msg.command);
} }
else if (msg.init) { else if (msg.init) {
initBaseUrls(msg.tlns); window.initBaseUrls(msg.tlns);
require("ace/lib/es5-shim"); require("ace/lib/es5-shim");
sender = window.sender = initSender(); sender = window.sender = window.initSender();
var clazz = require(msg.module)[msg.classname]; var clazz = require(msg.module)[msg.classname];
main = window.main = new clazz(sender); main = window.main = new clazz(sender);
} }
else if (msg.event && sender) {
sender._signal(msg.event, msg.data);
}
}; };
})(this); })(this);