Skip to content

Commit

Permalink
Merge master
Browse files Browse the repository at this point in the history
  • Loading branch information
gjtorikian committed Apr 4, 2012
2 parents cafdcec + 40a3775 commit 505d7a5
Show file tree
Hide file tree
Showing 40 changed files with 581 additions and 327 deletions.
22 changes: 19 additions & 3 deletions client/apf/elements/codeeditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ apf.codeeditor = module.exports = function(struct, tagName) {
this.$booleanProperties["behaviors"] = true;
this.$booleanProperties["folding"] = true;
this.$booleanProperties["wrapmode"] = true;

this.$booleanProperties["wrapmodeViewport"] = true;

this.$supportedProperties.push("value", "syntax", "activeline", "selectstyle",
"caching", "readonly", "showinvisibles", "showprintmargin", "printmargincolumn",
"overwrite", "tabsize", "softtabs", "debugger", "model-breakpoints", "scrollspeed",
Expand Down Expand Up @@ -171,7 +172,12 @@ apf.codeeditor = module.exports = function(struct, tagName) {
doc.setTabSize(parseInt(_self.tabsize, 10));
doc.setUseSoftTabs(_self.softtabs);
doc.setUseWrapMode(_self.wrapmode);
doc.setWrapLimitRange(_self.wraplimitmin, _self.wraplimitmax);
if (_self.wrapmodeViewport) {
doc.setWrapLimitRange(_self.wraplimitmin, null);
}
else {
doc.setWrapLimitRange(_self.wraplimitmin, _self.printmargincolumn);
}
doc.setFoldStyle(_self.folding ? "markbegin" : "manual");

_self.$removeDocListeners && _self.$removeDocListeners();
Expand Down Expand Up @@ -393,6 +399,9 @@ apf.codeeditor = module.exports = function(struct, tagName) {

this.$propHandlers["printmargincolumn"] = function(value, prop, initial) {
this.$editor.setPrintMarginColumn(value);
if (!this.wrapmodeViewport) {
this.$editor.getSession().setWrapLimitRange(this.wraplimitmin, value);
}
};

this.$propHandlers["showinvisibles"] = function(value, prop, initial) {
Expand Down Expand Up @@ -440,6 +449,13 @@ apf.codeeditor = module.exports = function(struct, tagName) {
this.$propHandlers["wraplimitmax"] = function(value, prop, initial) {
this.$editor.getSession().setWrapLimitRange(this.wraplimitmin, value);
};
this.$propHandlers["wrapmodeViewport"] = function(value, prop, initial) {
if (value === true)
this.$editor.getSession().setWrapLimitRange(this.wraplimitmin, null);
else {
this.$editor.getSession().setWrapLimitRange(this.wraplimitmin, this.printmargincolumn);
}
};
this.$propHandlers["highlightselectedword"] = function(value, prop, initial) {
this.$editor.setHighlightSelectedWord(value);
};
Expand Down Expand Up @@ -701,7 +717,7 @@ apf.codeeditor = module.exports = function(struct, tagName) {
this.fontsize = 12;
var wraplimit = doc.getWrapLimitRange();
if (this.wraplimitmin === undefined)
this.wraplimitmin = wraplimit.min;
this.wraplimitmin = 40;
if (this.wraplimitmax === undefined)
this.wraplimitmax = wraplimit.max;
if (this.wrapmode === undefined)
Expand Down
2 changes: 1 addition & 1 deletion client/core/ide.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ define(function(require, exports, module) {
// fire up the socket connection:
var options = {
"remember transport": false,
transports: ["websocket", "htmlfile", "xhr-multipart", "xhr-polling"],
transports: [/*"websocket", */"htmlfile", "xhr-multipart", "xhr-polling"],
reconnect: false,
resource: window.cloud9config.socketIoUrl,
"connect timeout": 500,
Expand Down
42 changes: 39 additions & 3 deletions client/core/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ exports.question = function(title, header, msg, onyes, onyestoall, onno, onnotoa
exports.removeInteractive = function (amlNode) {
if (window.cloud9config.readonly == true)
return false;

if (amlNode.confirmed == undefined)
amlNode.confirmed = false;

Expand All @@ -52,9 +52,10 @@ exports.removeInteractive = function (amlNode) {

function confirm(file) {
var name = file.getAttribute("name");
var type = file.getAttribute("type");
require("core/util").question(
"Remove file?",
"You are about to remove the file " + name,
"Confirm Remove",
"You are about to remove the " + type + " " + name,
"Do you want continue? (This change cannot be undone)",
function () { // Yes
amlNode.confirmed = true;
Expand Down Expand Up @@ -280,6 +281,41 @@ exports.escapeXml = function(str, noQuotes) {
});
};

// taken from http://xregexp.com/
exports.escapeRegExp = function(str) {
return str.replace(/[-[\]{}()*+?.,\\^$|#\s"']/g, "\\$&");
}

/**
* Determines whether a string is true in the html attribute sense.
* @param {mixed} value the variable to check
* Possible values:
* true The function returns true.
* 'true' The function returns true.
* 'on' The function returns true.
* 1 The function returns true.
* '1' The function returns true.
* @return {Boolean} whether the string is considered to imply truth.
*/
exports.isTrue = function(c){
return (c === true || c === "true" || c === "on" || typeof c == "number" && c > 0 || c === "1");
};

/**
* Determines whether a string is false in the html attribute sense.
* @param {mixed} value the variable to check
* Possible values:
* false The function returns true.
* 'false' The function returns true.
* 'off' The function returns true.
* 0 The function returns true.
* '0' The function returns true.
* @return {Boolean} whether the string is considered to imply untruth.
*/
exports.isFalse = function(c){
return (c === false || c === "false" || c === "off" || c === 0 || c === "0");
};

/*
* JavaScript Linkify - v0.3 - 6/27/2009
* http://benalman.com/projects/javascript-linkify/
Expand Down
18 changes: 17 additions & 1 deletion client/ext/closeconfirmation/closeconfirmation.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,27 @@ module.exports = ext.register("ext/closeconfirmation/closeconfirmation", {
},

onBeforeUnloadHandler : function () {
var changed = false;
tabEditors.getPages().forEach(function(page){
var at = page.$at;
if (!at.undo_ptr)
at.undo_ptr = at.$undostack[0];
var node = page.$doc.getNode();
if (node && at.undo_ptr && at.$undostack[at.$undostack.length-1] !== at.undo_ptr
|| !at.undo_ptr && node.getAttribute("changed") == 1
&& page.$doc.getValue()) {
changed = true;
}
});

if(changed)
return "You have unsaved changes. Your changes will be lost if you don't save them";

// see what's in the settings
var settingsNode = settings.model.queryNode("general/@confirmexit");
if (settingsNode && apf.isTrue(settingsNode.value)) {
return "Are you sure you want to leave Cloud9?";
}
}
},

enable : function() {
Expand Down
7 changes: 0 additions & 7 deletions client/ext/code/code.js
Original file line number Diff line number Diff line change
Expand Up @@ -388,12 +388,6 @@ module.exports = ext.register("ext/code/code", {
checked : "[{require('ext/settings/settings').model}::editors/code/@showinvisibles]"
});

var menuWrapLines = new apf.item({
type : "check",
caption : "Wrap Lines",
checked : "{ceEditor.wrapmode}"
});

this.nodes.push(
//Add a panel to the statusbar showing whether the insert button is pressed
sbMain.appendChild(new apf.section({
Expand Down Expand Up @@ -452,7 +446,6 @@ module.exports = ext.register("ext/code/code", {
ide.addEventListener("init.ext/statusbar/statusbar", function (e) {
// add preferences to the statusbar plugin
e.ext.addPrefsItem(menuShowInvisibles.cloneNode(true), 0);
e.ext.addPrefsItem(menuWrapLines.cloneNode(true), 1);
});

ide.addEventListener("keybindingschange", function(e) {
Expand Down
5 changes: 3 additions & 2 deletions client/ext/code/code.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@
scrollspeed = "[{require('ext/settings/settings').model}::editors/code/@scrollspeed]"

fontsize = "[{require('ext/settings/settings').model}::editors/code/@fontsize]"
wrapmode = "[@wrapmode]"
wraplimitmin = "80"
wrapmode = "[{require('ext/settings/settings').model}::editors/code/@wrapmode]"
wrapmodeViewport = "[{require('ext/settings/settings').model}::editors/code/@wrapmodeViewport]"
wraplimitmin = "40"
wraplimitmax = "80"
gutter = "[{require('ext/settings/settings').model}::editors/code/@gutter]"
highlightselectedword = "[{require('ext/settings/settings').model}::editors/code/@highlightselectedword]"
Expand Down
5 changes: 4 additions & 1 deletion client/ext/console/console.js
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,10 @@ module.exports = ext.register("ext/console/console", {
});

tabConsole.addEventListener("afterswitch", function(e){
settings.model.setQueryValue("auto/console/@active", e.nextPage.name)
settings.model.setQueryValue("auto/console/@active", e.nextPage.name);
setTimeout(function(){
txtConsoleInput.focus();
});
});

winDbgConsole.previousSibling.addEventListener("dragdrop", function(e){
Expand Down
10 changes: 7 additions & 3 deletions client/ext/editors/editors.js
Original file line number Diff line number Diff line change
Expand Up @@ -717,9 +717,13 @@ module.exports = ext.register("ext/editors/editors", {
});

ide.addEventListener("afterreload", function(e) {
var doc = e.doc,
acesession = doc.acesession,
sel = acesession.getSelection();
var doc = e.doc;
var acesession = doc.acesession;

if(!acesession)
return;

var sel = acesession.getSelection();

sel.selectAll();
acesession.getUndoManager().ignoreChange = true;
Expand Down
2 changes: 1 addition & 1 deletion client/ext/html/html.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<a:application xmlns:a="http://ajax.org/2005/aml">

<a:bar id="barHtmlMode" visible="false">
<a:bar id="barHtmlMode" >
<a:divider skin="c9-divider" />
<!--a:button skin="c9-toolbarbutton" id="btnHtmlRun">run on server...</a:button-->
<a:button skin="c9-toolbarbutton" icon="preview.png" class="preview" id="btnHtmlOpen" tooltip="Preview in browser">Preview</a:button>
Expand Down
4 changes: 2 additions & 2 deletions client/ext/keybindings_default/default_mac.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ return keys.onLoad({
"tab8": "Command-8",
"tab9": "Command-9",
"revealtab": "Command-Shift-L",
"nexttab": "Command-Tab|Option-Tab",
"previoustab": "Command-Shift-Tab|Option-Shift-Tab"
"nexttab": "Option-Tab",
"previoustab": "Option-Shift-Tab"
},
"tabsessions" : {
"savetabsession": "Command-Alt-S"
Expand Down
4 changes: 2 additions & 2 deletions client/ext/language/refactor.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ module.exports = {

var nodes = [];
this.refactorItem = new apf.item({
caption: "Rename variable",
caption: "Rename Variable",
disabled: true,
onclick: function() {
_self.renameVariable();
Expand All @@ -39,7 +39,7 @@ module.exports = {
// There is a problem with APF setting the $disabled attribute of
// a cloned menu item, so we have to create a second one ourselves
this.refactorItemDup = new apf.item({
caption: "Rename variable",
caption: "Rename Variable",
disabled: true,
onclick: function() {
_self.renameVariable();
Expand Down
7 changes: 7 additions & 0 deletions client/ext/newresource/newresource.xml
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,13 @@ app.configure('production', function(){
});
// *******************************************************
]]></item>
<item value="js" icon="page_white_code.png" caption="Node.js web server"><![CDATA[var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World from Cloud9\n');
}).listen(process.env.PORT);
]]>
</item>
</templates>
</a:model>
</a:application>
16 changes: 11 additions & 5 deletions client/ext/openfiles/openfiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,19 @@ module.exports = ext.register("ext/openfiles/openfiles", {
var path = e.path || node.getAttribute("path");

var fNode = model.queryNode("//node()[@path='" + path + "']");
if (node && fNode) {
if (e.path)
fNode.setAttribute("path", node.getAttribute("path"));
if (e.filename)
var trNode = trFiles.queryNode("//node()[@path='" + path + "']");
if (node && fNode && trNode) {
if (e.path)
apf.xmldb.setAttribute(fNode, "path", node.getAttribute("path"));
apf.xmldb.setAttribute(trNode, "path", node.getAttribute("path"));
if (e.filename) {
apf.xmldb.setAttribute(fNode, "name", apf.getFilename(e.filename));
if (e.changed != undefined)
apf.xmldb.setAttribute(trNode, "name", apf.getFilename(e.filename));
}
if (e.changed != undefined) {
apf.xmldb.setAttribute(fNode, "changed", e.changed);
apf.xmldb.setAttribute(trNode, "changed", e.changed);
}
}
});
},
Expand Down
Loading

0 comments on commit 505d7a5

Please sign in to comment.