Skip to content

Commit

Permalink
Merge branch 'master' of github.com:ajaxorg/cloud9
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruben Daniels committed Sep 28, 2010
2 parents 4b77479 + 9c126a3 commit d0a6b3d
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 69 deletions.
95 changes: 43 additions & 52 deletions client/ext/console/console.js
Expand Up @@ -37,7 +37,7 @@ return ext.register("ext/console/console", {

for (var i=0; i<lines.length; i++) {
if (!lines[i]) continue;

log.push("<div class='item'><span style='" + style + "'>" + lines[i]
.replace(/\s/g, "&nbsp;")
.replace(/(((http:\/\/)|(www\.))[\w\d\.]*(:\d+)?(\/[\w\d]+)?)/, function(m, url) {
Expand All @@ -55,39 +55,39 @@ return ext.register("ext/console/console", {
}
txtConsole.addValue(log.join(""));
},

log : function(msg, type, pre, post){
msg = apf.htmlentities(String(msg));
/*
code.replace(/ /g, "&nbsp;")
.replace(/\t/g, "&nbsp;&nbsp;&nbsp;")
.replace(/</g, "&lt;")
.replace(/\n/g, "\n<br />") */
if (!type)

if (!type)
type = "log";
else if (type == "command") {
msg = "<span style='color:blue'><span style='float:left'>&gt;&gt;&gt;</span><div style='margin:0 0 0 25px'>"
+ msg + "</div></span>";
}

txtConsole.addValue("<div class='item console_" + type + "'>" + (pre || "") + msg + (post || "") + "</div>");
},

evaluate : function(expression, callback){
var _self = this;
var frame = dgStack && dgStack.selected && dgStack.selected.getAttribute("ref") || null;
dbg.evaluate(expression, frame, null, null, callback || function(xmlNode){
_self.showObject(xmlNode);
});
},

checkChange : function(xmlNode){
var value = xmlNode.getAttribute("value");
if (xmlNode.tagName == "method" || "Boolean|String|undefined|null|Number".indexOf(xmlNode.getAttribute("type")) == -1)
return false;
},

applyChange : function(xmlNode){
var value = xmlNode.getAttribute("value");
var name = this.calcName(xmlNode);
Expand All @@ -99,9 +99,9 @@ return ext.register("ext/console/console", {
return;
}
}

self.parent.eval(name + " = " + value);

//@todo determine new type
}
catch(e) {
Expand All @@ -110,15 +110,15 @@ return ext.register("ext/console/console", {
//@todo undo
}
},

calcName : function(xmlNode, useDisplay){
var isMethod = xmlNode.tagName == "method";
var name, loopNode = xmlNode, path = [];
do {
name = useDisplay
? loopNode.getAttribute("display") || loopNode.getAttribute("name")
name = useDisplay
? loopNode.getAttribute("display") || loopNode.getAttribute("name")
: loopNode.getAttribute("name");

if (!name)
break;

Expand All @@ -134,12 +134,12 @@ return ext.register("ext/console/console", {
}
}
while (loopNode && loopNode.nodeType == 1);

if (path[0].charAt(0) == "[")
path[0] = path[0].substr(2, path[0].length - 4);
return path.join(".").replace(/\.\[/g, "[");
},

consoleTextHandler: function(e) {
if (e.keyCode == 9 && e.currentTarget == txtConsole) {
txtConsole.focus();
Expand All @@ -149,41 +149,41 @@ return ext.register("ext/console/console", {
else if(e.keyCode == 13 && e.ctrlKey) {
var _self = this;
var expression = txtCode.value;
if (!expression.trim())
if (!expression.trim())
return;

this.log(expression, "command");
this.evaluate(expression, function(xmlNode, body, refs, error){
if (error)
_self.log(error.message, "error");
else {
var type = body.type, value = body.value || body.text, ref = body.handle, className = body.className;
if (className == "Function") {
var pre = "<a class='xmlhl' href='javascript:void(0)' style='font-weight:bold;font-size:7pt;color:green' onclick='require(\"ext/console/console\").showObject(null, ["
+ body.scriptId + ", " + body.line + ", " + body.position + ", "
+ body.handler + ",\"" + (body.name || body.inferredName) + "\"], \""
var pre = "<a class='xmlhl' href='javascript:void(0)' style='font-weight:bold;font-size:7pt;color:green' onclick='require(\"ext/console/console\").showObject(null, ["
+ body.scriptId + ", " + body.line + ", " + body.position + ", "
+ body.handler + ",\"" + (body.name || body.inferredName) + "\"], \""
+ (expression || "").split(";").pop().replace(/"/g, "\\&quot;") + "\")'>";
var post = "</a>";
var name = body.name || body.inferredName || "function";
_self.log(name + "()", "log", pre, post);
}
else if (className == "Array") {
var pre = "<a class='xmlhl' href='javascript:void(0)' style='font-weight:bold;font-size:7pt;color:green' onclick='require(\"ext/console/console\").showObject(\""
+ apf.escapeXML(xmlNode.xml.replace(/"/g, "\\\"")) + "\", "
+ apf.escapeXML(xmlNode.xml.replace(/"/g, "\\\"")) + "\", "
+ ref + ", \"" + apf.escapeXML((expression || "").trim().split(/;|\n/).pop().trim().replace(/"/g, "\\\"")) + "\")'>";
var post = " }</a>";
_self.log("Array { length: "

_self.log("Array { length: "
+ (body.properties && body.properties.length - 1), "log", pre, post);
}
else if (type == "object") {
var refs = [], props = body.properties;
for (var i = 0, l = body.properties.length; i < l; i++) {
refs.push(props[i].ref);
}

var pre = "<a class='xmlhl' href='javascript:void(0)' style='font-weight:bold;font-size:7pt;color:green' onclick='require(\"ext/console/console\").showObject(\""
+ apf.escapeXML(xmlNode.xml.replace(/"/g, "\\\"")) + "\", "
+ apf.escapeXML(xmlNode.xml.replace(/"/g, "\\\"")) + "\", "
+ ref + ", \"" + apf.escapeXML((expression || "").trim().split(/;|\n/).pop().trim().replace(/"/g, "\\\"")) + "\")'>";
var post = " }</a>";

Expand All @@ -210,31 +210,22 @@ return ext.register("ext/console/console", {
_self.log(value, "log");
}
});

require("ext/settings/settings").save();
return false;
}
},

showObject : function(xmlNode, ref, expression){
if (ref && ref.dataType == apf.ARRAY) {
require("ext/debugger/debugger").$showFile(ref[0]);
ide.addEventListener("openfile", function(e){
if (e.node.getAttribute("scriptid") == ref[0]) {
ceEditor.$editor.gotoLine(ref[1] + 1);
if (ref[4])
ceEditor.$editor.find(ref[4]);
ceEditor.focus();
ide.removeEventListener("openfile", arguments.callee);
}
});
require("ext/debugger/debugger").$showFile(ref[0], ref[1] + 1, ref[4]);
}
else {
tabConsole.set(1);

if (xmlNode && typeof xmlNode == "string")
xmlNode = apf.getXml(xmlNode);

var name = xmlNode && xmlNode.getAttribute("name") || expression;
txtCurObject.setValue(name);
dgWatch.clear("loading");
Expand All @@ -249,27 +240,27 @@ return ext.register("ext/console/console", {
}, 10);
}
else if (ref) {

}
else {
this.evaluate(expression);
}
}
},

types : ["Object", "Number", "Boolean", "String", "Array", "Date", "RegExp", "Function", "Object"],
domtypes : [null, "Element", "Attr", "Text", "CDataSection",
"EntityReference", "Entity", "ProcessingInstruction", "Comment",
domtypes : [null, "Element", "Attr", "Text", "CDataSection",
"EntityReference", "Entity", "ProcessingInstruction", "Comment",
"Document", "DocumentType", "DocumentFragment", "Notation"],

calcName : function(xmlNode, useDisplay){
var isMethod = xmlNode.tagName == "method";
var name, loopNode = xmlNode, path = [];
do {
name = useDisplay
? loopNode.getAttribute("display") || loopNode.getAttribute("name")
name = useDisplay
? loopNode.getAttribute("display") || loopNode.getAttribute("name")
: loopNode.getAttribute("name");

if (!name)
break;

Expand All @@ -285,12 +276,12 @@ return ext.register("ext/console/console", {
}
}
while (loopNode && loopNode.nodeType == 1);

if (path[0].charAt(0) == "[")
path[0] = path[0].substr(2, path[0].length - 4);
return path.join(".").replace(/\.\[/g, "[");
},

/**** Init ****/

hook : function(){
Expand All @@ -299,11 +290,11 @@ return ext.register("ext/console/console", {

init : function(amlNode){
this.panel = winDbgConsole;

lstScripts.addEventListener("afterselect", function(e) {
e.selected && require("ext/debugger/debugger").$showFile(e.selected.getAttribute("scriptid"));
});

apf.importCssString(".console_date{display:inline}");
},

Expand Down
31 changes: 26 additions & 5 deletions client/ext/debugger/debugger.js
Expand Up @@ -33,14 +33,14 @@ return ext.register("ext/debugger/debugger", {
init : function(amlNode){
this.rightPane = ide.vbMain.selectSingleNode("a:hbox/a:vbox[3]");
this.nodes.push(
//Append the debug toolbar to the main toolbar
//winDbgConsole.insertBefore(tbDebug, winDbgConsole.firstChild),

//Append the stack window at the right
this.rightPane.appendChild(winDbgStack),

//Append the variable window on the right
this.rightPane.appendChild(winDbgVariables)
this.rightPane.appendChild(winDbgVariables),

//Append the variable window on the right
this.rightPane.appendChild(winDbgBreakpoints)
);

this.paths = {};
Expand All @@ -65,11 +65,32 @@ return ext.register("ext/debugger/debugger", {
e.data && _self.$showFile(e.data.getAttribute("scriptid"));
});

lstBreakpoints.addEventListener("afterselect", function(e) {
if (e.selected && e.selected.getAttribute("scriptid"))
_self.$showFile(e.selected.getAttribute("scriptid"), e.selected.getAttribute("line"));
// TODO sometimes we don't have a scriptID
});

log.enable(true);
},

$showFile : function(scriptId) {
$showFile : function(scriptId, line, text) {
var file = fs.model.queryNode("//file[@scriptid='" + scriptId + "']");

if (line !== undefined) {
ide.addEventListener("afteropenfile", function(e) {
if (e.node.getAttribute("scriptid") == scriptId) {
ide.removeEventListener("afteropenfile", arguments.callee);
setTimeout(function() {
ceEditor.$editor.gotoLine(line);
if (text)
ceEditor.$editor.find(text);
ceEditor.focus();
}, 30);
}
});
}

if (file) {
ide.dispatchEvent("openfile", {
node: file
Expand Down
18 changes: 9 additions & 9 deletions client/ext/debugger/debugger.xml
Expand Up @@ -41,15 +41,15 @@
</a:datagrid>
</a:window>

<!-- a:window id="winDbgBreakpoints" skin="dockwin" title="Breakpoints" modal="false" flex="1" width="200">
<a:list
id="lstBreakpoints"
anchors="0 0 0 0"
model="mdlDbgBreakpoints"
each="[breakpoint]"
caption="[@text]"
icon="debugger/brkp_obj.gif">
<a:window id="winDbgBreakpoints" skin="dockwin" title="Breakpoints" modal="false" flex="1" buttons="close">
<a:list id="lstBreakpoints"
autoselect = "false"
anchors = "0 0 0 0"
model = "mdlDbgBreakpoints"
each = "[breakpoint]"
caption = "[@text]"
icon = "debugger/brkp_obj.gif">
<a:actions />
</a:list>
</a:window-->
</a:window>
</a:application>
6 changes: 5 additions & 1 deletion client/ext/filesystem/filesystem.js
Expand Up @@ -166,8 +166,10 @@ return ext.register("ext/filesystem/filesystem", {
ide.addEventListener("openfile", function(e){
var node = e.node;

if (node.selectSingleNode("data"))
if (node.selectSingleNode("data")) {
ide.dispatchEvent("afteropenfile", {node: node});
return;
}

var path = node.getAttribute("path");
fs.readFile(path, function(data, state, extra) {
Expand All @@ -192,6 +194,8 @@ return ext.register("ext/filesystem/filesystem", {
xml.appendChild(doc.createTextNode(data));
xml.setAttribute("newline", nl);
apf.b(node).append(xml);

ide.dispatchEvent("afteropenfile", {node: node});
}
});
});
Expand Down
2 changes: 1 addition & 1 deletion common/ace
Submodule ace updated from a96c54 to b646c0
2 changes: 1 addition & 1 deletion server/lib/cloud9/index.js
Expand Up @@ -23,7 +23,7 @@ exports.main = function(projectDir, port) {
server = connect.createServer(
//connect.logger(),
connect.conditionalGet(),
connect.gzip(),
// connect.gzip(),
connect.staticProvider(__dirname + "/../../../client"),
commonProvider()
);
Expand Down

0 comments on commit d0a6b3d

Please sign in to comment.