diff --git a/package.json b/package.json index ad9bc4da..b9bc8a51 100644 --- a/package.json +++ b/package.json @@ -78,7 +78,7 @@ "c9.ide.ace.keymaps": "#2e3c6e3c8f", "c9.ide.ace.repl": "#4b88a85b7b", "c9.ide.ace.split": "#0ae0151c78", - "c9.ide.ace.statusbar": "#d95be89d53", + "c9.ide.ace.statusbar": "#2155083cf6", "c9.ide.ace.stripws": "#cf0f42ac59", "c9.ide.behaviors": "#ee32d7da73", "c9.ide.closeconfirmation": "#cee4674141", diff --git a/plugins/c9.ide.editors/tabmanager.js b/plugins/c9.ide.editors/tabmanager.js index fa60a1b9..c289b62a 100644 --- a/plugins/c9.ide.editors/tabmanager.js +++ b/plugins/c9.ide.editors/tabmanager.js @@ -1345,6 +1345,8 @@ define(function(require, module, exports) { } function cancelPreview(keep) { + var lastFocussedTab = focussedTab; + // Unload last preview tab if (lastPreviewTab) { lastPreviewTab.unload(); @@ -1364,11 +1366,13 @@ define(function(require, module, exports) { delete previewTab.document.meta.existing; } else { - previewTab.unload(); + var tab = previewTab; + previewTab = null; + tab.unload(); // TODO this focusses the last tab. If there is a speed concern, fix this. } previewTab = null; - focussedTab && focussedTab.activate(); + lastFocussedTab && lastFocussedTab.activate(); return false; } diff --git a/plugins/c9.ide.preferences/experimental.js b/plugins/c9.ide.preferences/experimental.js index d7f84b52..8160966d 100644 --- a/plugins/c9.ide.preferences/experimental.js +++ b/plugins/c9.ide.preferences/experimental.js @@ -1,17 +1,16 @@ define(function(require, exports, module) { main.consumes = [ - "PreferencePanel", "ui", "dialog.confirm", "settings", - "preferences", "c9" + "PreferencePanel", "ui", "dialog.alert", "settings", "c9" ]; main.provides = ["preferences.experimental"]; return main; function main(options, imports, register) { var PreferencePanel = imports.PreferencePanel; - var prefs = imports.preferences; var settings = imports.settings; var ui = imports.ui; var c9 = imports.c9; + var alert = imports["dialog.alert"].show; /***** Initialization *****/ @@ -23,7 +22,7 @@ define(function(require, exports, module) { var emit = plugin.getEmitter(); emit.setMaxListeners(1000); - var intro; + var intro, hasAlerted; var loaded = false; function load() { @@ -71,6 +70,14 @@ define(function(require, exports, module) { } current.type = "checkbox"; current.setting = "state/experiments/@" + uniqueId; + current.onchange = function(e){ + if (!hasAlerted) { + alert("Refresh Needed", + "Please Refresh Cloud9 To Activate This Change", + "To see the effect of this change, please refresh Cloud9."); + hasAlerted = true; + } + }; if (!found[name]) plugin.add(obj, plugin); diff --git a/plugins/c9.ide.terminal/aceterm/hover_link.js b/plugins/c9.ide.terminal/aceterm/hover_link.js index d38f554b..2296476e 100644 --- a/plugins/c9.ide.terminal/aceterm/hover_link.js +++ b/plugins/c9.ide.terminal/aceterm/hover_link.js @@ -100,6 +100,9 @@ var HoverLink = function(editor) { }; this.onClick = function(e) { + if (!this.editor.isFocused()) + return; + if (this.link && this.isOpen) { // && this.link.isFocused if (this.editor.selection.isEmpty()) { this.editor.selection.setSelectionRange(this.range); @@ -298,10 +301,10 @@ var HoverLink = function(editor) { match.value = value.replace(/['">)}\].,;:]+$/, ""); } else if (/^[ab]?\//.test(value) && /^([+\-]{3}|diff)/.test(line)) { // diff - match.type = "path"; - match.basePath = ""; - match.start++; - match.value = value.substr(2); + match.type = "path"; + match.basePath = ""; + match.start++; + match.value = value.substr(2); } else if (prompt.command === "git") { // git status var prefix = line.substr(0, match.start); @@ -378,6 +381,9 @@ var HoverLink = function(editor) { }; this.onMouseMove = function(e) { + if (e.shiftKey || e.ctrlKey || e.metaKey || !this.editor.isFocused()) + return this.clear(); + if (this.editor.$mouseHandler.isMousePressed) { if (!this.editor.selection.isEmpty()) this.clear(); diff --git a/plugins/c9.ide.terminal/link_handler.js b/plugins/c9.ide.terminal/link_handler.js index fb744d5c..4543a31f 100644 --- a/plugins/c9.ide.terminal/link_handler.js +++ b/plugins/c9.ide.terminal/link_handler.js @@ -30,7 +30,7 @@ define(function(require, exports, module) { var BASEPATH = options.previewUrl; var plugin = new Plugin("Ajax.org", main.consumes); - var menu, lastLink; + var menuPath, lastLink; var reHome = new RegExp("^" + util.escapeRegExp(c9.home)); @@ -38,17 +38,17 @@ define(function(require, exports, module) { terminal.on("create", function(e) { var ace = e.editor.ace; - if (!ace) - return; + if (!ace) return; + ace.hoverLink = new HoverLink(ace); ace.hoverLink.on("open", showMenu); - }); + }, plugin); - function createMenu(e) { - if (menu) + function createMenu() { + if (menuPath) return; - var submenu = new Menu({ + var submenu = new Menu({ items: [ new MenuItem({ value: "path", caption: "Copy Path" }), new MenuItem({ value: "directory", caption: "Copy Directory" }), @@ -71,9 +71,6 @@ define(function(require, exports, module) { ? "Unable to access via preview" : BASEPATH + info.path }); } - // else if (e.value == "github") { - - // } } }, plugin); @@ -92,10 +89,9 @@ define(function(require, exports, module) { new MenuItem({ caption: "Copy Special", submenu: submenu }), new Divider(), new MenuItem({ value: "reveal", caption: "Reveal in File Tree" }) - // new MenuItem({ caption: "Open in GitHub" }), ]; - menu = new Menu({ + menuPath = new Menu({ items: menuItems, onitemclick: function(e) { var info = buildPath(lastLink, true); @@ -121,91 +117,116 @@ define(function(require, exports, module) { } }, plugin); } + + var menuLink; + function createLinkMenu(){ + menuLink = new Menu({ + items: [ + new MenuItem({ value: "open", caption: "Open" }), + new MenuItem({ value: "open-in-preview", caption: "Open In Preview" }), + new MenuItem({ value: "copy", caption: "Copy" }), + ], + onitemclick: function(e) { + if (e.value == "open") + openLink(lastLink.value); + if (e.value == "open-in-preview") + openLink(lastLink.value, true); + else if (e.value == "copy") + commands.exec("copy", null, { data: lastLink.value }); + } + }, plugin); + } /***** Methods *****/ function showMenu(e) { - if (e.type == "link" && (tabManager.focussedTab || 0).editorType) - return open(e); if (e.action == "open") return open(e); - createMenu(e); - lastLink = e; - menu.once("show", function(){ - var isGit = e && e.command === "git"; - var items = menu.items; - for (var i = 0; i < 6; i++) { - items[i].aml.visible = -1; - items[i][isGit ? "show" : "hide"](); - } - }); + var menu; + if (e.type == "link" && (tabManager.focussedTab || 0).editorType) { + createLinkMenu(); + menu = menuLink; + } + else { + createMenu(); + menuPath.once("show", function(){ + var isGit = e && e.command === "git"; + var items = menuPath.items; + for (var i = 0; i < 6; i++) { + items[i].aml.visible = -1; + items[i][isGit ? "show" : "hide"](); + } + }); + + var ace = e.editor; + menuPath.once("hide", function(){ + ace.selection.clearSelection(); + }); + + menu = menuPath; + } menu.show(e.x, e.y); - - var ace = e.editor; - menu.once("hide", function(){ - ace.selection.clearSelection(); - }); } - function open(e, cb) { - if (typeof e == "string") - e = {type: "path", value: e}; - - if (e.type == "link") { - var href = e.value; - if (!/(https?|ftp|file):/.test(href)) { - href = "http://" + href; - } - href = href.replace(/(^https?:\/\/)(0.0.0.0|localhost)(?=:|\/|$)/, function(_, protocol, host) { - host = c9.hostname || window.location.host; - return protocol + host.replace(/:\d+/, ""); - }); - if (e.metaKey || e.ctrlKey) - window.open(href); - else - commands.exec("preview", null, { path: href }); - } else if (e.type == "path") { - var info = buildPath(e); - var path = info.path; - - var m = /:(\d*)(?::(\d*))?$/.exec(path); - var jump = {}; - if (m) { - if (m[1]) - jump.row = parseInt(m[1], 10) - 1; - if (m[2]) - jump.column = parseInt(m[2], 10); - path = path.slice(0, m.index); - } - - // Make sure home dir is marked correctly - path = path.replace(reHome, "~"); - if (path[0] != "/") path = "/" + path; - - fs.stat(path, function(err, stat) { - if (err) { - return commands.exec("navigate", null, { keyword: path }); - } - if (stat.linkStat) - stat = stat.linkStat; - if (/directory/.test(stat.mime)) { - return tabbehavior.revealtab({path: path}); - } - tabManager.open({ - path: path, - focus: true, - document: { - ace: { - jump: jump - } - } - }, cb); - }); + function openLink(href, inPreview){ + if (!/^(https?|ftp|file):/.test(href)) { + href = "http://" + href; } + href = href.replace(/(^https?:\/\/)(0.0.0.0|localhost)(?=:|\/|$)/, function(_, protocol, host) { + host = c9.hostname || window.location.host; + return protocol + host.replace(/:\d+/, ""); + }); + + if (inPreview) + commands.exec("preview", null, { path: href }); + else + window.open(href); + } + + function open(e) { + if (e.type == "link") + return openLink(e.value); + + var info = buildPath(e); + var path = info.path; + + var m = /:(\d*)(?::(\d*))?$/.exec(path); + var jump = {}; + if (m) { + if (m[1]) + jump.row = parseInt(m[1], 10) - 1; + if (m[2]) + jump.column = parseInt(m[2], 10); + path = path.slice(0, m.index); + } + + // Make sure home dir is marked correctly + path = path.replace(reHome, "~"); + if (path[0] != "/") path = "/" + path; + + fs.stat(path, function(err, stat) { + if (err) { + return commands.exec("navigate", null, { keyword: path }); + } + if (stat.linkStat) + stat = stat.linkStat; + if (/directory/.test(stat.mime)) { + return tabbehavior.revealtab({path: path}); + } + tabManager.open({ + path: path, + focus: true, + document: { + ace: { + jump: jump + } + } + }, function(){}); + }); } function buildPath(e) { diff --git a/plugins/c9.ide.ui/forms.js b/plugins/c9.ide.ui/forms.js index 400e7148..959e0d45 100644 --- a/plugins/c9.ide.ui/forms.js +++ b/plugins/c9.ide.ui/forms.js @@ -190,8 +190,11 @@ define(function(require, exports, module) { ? createBind(options.path) : (options.defaultValue || ""), values: options.values, - skin: "cboffline" - // width: "55" + skin: "cboffline", + onafterchange: function(e) { + if (options.onchange) + options.onchange({ value: e.value }); + } }) ]; break;