diff --git a/common/content/browser.js b/common/content/browser.js new file mode 100644 index 00000000..d4a41c0c --- /dev/null +++ b/common/content/browser.js @@ -0,0 +1,377 @@ +/***** BEGIN LICENSE BLOCK ***** {{{ +Version: MPL 1.1/GPL 2.0/LGPL 2.1 + +The contents of this file are subject to the Mozilla Public License Version +1.1 (the "License"); you may not use this file except in compliance with +the License. You may obtain a copy of the License at +http://www.mozilla.org/MPL/ + +Software distributed under the License is distributed on an "AS IS" basis, +WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +for the specific language governing rights and limitations under the +License. + +Copyright (c) 2006-2009 by Martin Stubenschrott + +Alternatively, the contents of this file may be used under the terms of +either the GNU General Public License Version 2 or later (the "GPL"), or +the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +in which case the provisions of the GPL or the LGPL are applicable instead +of those above. If you wish to allow use of your version of this file only +under the terms of either the GPL or the LGPL, and not to allow others to +use your version of this file under the terms of the MPL, indicate your +decision by deleting the provisions above and replace them with the notice +and other provisions required by the GPL or the LGPL. If you do not delete +the provisions above, a recipient may use your version of this file under +the terms of any one of the MPL, the GPL or the LGPL. +}}} ***** END LICENSE BLOCK *****/ + +/** @scope modules */ + +/** + * @instance browser + */ +function Browser() //{{{ +{ + //////////////////////////////////////////////////////////////////////////////// + ////////////////////// PRIVATE SECTION ///////////////////////////////////////// + /////////////////////////////////////////////////////////////////////////////{{{ + + // TODO: support 'nrformats'? -> probably not worth it --mst + function incrementURL(count) + { + let matches = buffer.URL.match(/(.*?)(\d+)(\D*)$/); + if (!matches) + return void liberator.beep(); + + let [, pre, number, post] = matches; + let newNumber = parseInt(number, 10) + count; + let newNumberStr = String(newNumber > 0 ? newNumber : 0); + if (number.match(/^0/)) // add 0009 should become 0010 + { + while (newNumberStr.length < number.length) + newNumberStr = "0" + newNumberStr; + } + + liberator.open(pre + newNumberStr + post); + } + + /////////////////////////////////////////////////////////////////////////////}}} + ////////////////////// MAPPINGS //////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////////////{{{ + + mappings.add([modes.NORMAL], + ["y"], "Yank current location to the clipboard", + function () { util.copyToClipboard(buffer.URL, true); }); + + // opening websites + mappings.add([modes.NORMAL], + ["o"], "Open one or more URLs", + function () { commandline.open(":", "open ", modes.EX); }); + + mappings.add([modes.NORMAL], ["O"], + "Open one or more URLs, based on current location", + function () { commandline.open(":", "open " + buffer.URL, modes.EX); }); + + mappings.add([modes.NORMAL], ["t"], + "Open one or more URLs in a new tab", + function () { commandline.open(":", "tabopen ", modes.EX); }); + + mappings.add([modes.NORMAL], ["T"], + "Open one or more URLs in a new tab, based on current location", + function () { commandline.open(":", "tabopen " + buffer.URL, modes.EX); }); + + mappings.add([modes.NORMAL], ["w"], + "Open one or more URLs in a new window", + function () { commandline.open(":", "winopen ", modes.EX); }); + + mappings.add([modes.NORMAL], ["W"], + "Open one or more URLs in a new window, based on current location", + function () { commandline.open(":", "winopen " + buffer.URL, modes.EX); }); + + mappings.add([modes.NORMAL], + [""], "Increment last number in URL", + function (count) { incrementURL(Math.max(count, 1)); }, + { count: true }); + + mappings.add([modes.NORMAL], + [""], "Decrement last number in URL", + function (count) { incrementURL(-Math.max(count, 1)); }, + { count: true }); + + mappings.add([modes.NORMAL], ["~"], + "Open home directory", + function () { liberator.open("~"); }); + + mappings.add([modes.NORMAL], ["gh"], + "Open homepage", + function () { BrowserHome(); }); + + mappings.add([modes.NORMAL], ["gH"], + "Open homepage in a new tab", + function () + { + let homepages = gHomeButton.getHomePage(); + liberator.open(homepages, /\bhomepage\b/.test(options["activate"]) ? + liberator.NEW_TAB : liberator.NEW_BACKGROUND_TAB); + }); + + mappings.add([modes.NORMAL], ["gu"], + "Go to parent directory", + function (count) + { + function isDirectory(url) + { + if (/^file:\/|^\//.test(url)) + { + let file = io.getFile(url); + return file.exists() && file.isDirectory(); + } + else + { + // for all other locations just check if the URL ends with / + return /\/$/.test(url); + } + } + + if (count < 1) + count = 1; + + // XXX + let url = buffer.URL; + for (let i = 0; i < count; i++) + { + if (isDirectory(url)) + url = url.replace(/^(.*?:)(.*?)([^\/]+\/*)$/, "$1$2/"); + else + url = url.replace(/^(.*?:)(.*?)(\/+[^\/]+)$/, "$1$2/"); + } + url = url.replace(/^(.*:\/+.*?)\/+$/, "$1/"); // get rid of more than 1 / at the end + + if (url == buffer.URL) + liberator.beep(); + else + liberator.open(url); + }, + { count: true }); + + mappings.add([modes.NORMAL], ["gU"], + "Go to the root of the website", + function () + { + let uri = content.document.location; + if (/(about|mailto):/.test(uri.protocol)) // exclude these special protocols for now + return void liberator.beep(); + liberator.open(uri.protocol + "//" + (uri.host || "") + "/"); + }); + + mappings.add([modes.NORMAL], [""], + "Redraw the screen", + function () { commands.get("redraw").execute("", false); }); + + /////////////////////////////////////////////////////////////////////////////}}} + ////////////////////// COMMANDS //////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////////////{{{ + + commands.add(["downl[oads]", "dl"], + "Show progress of current downloads", + function () + { + liberator.open("chrome://mozapps/content/downloads/downloads.xul", + options.get("newtab").has("all", "downloads") + ? liberator.NEW_TAB : liberator.CURRENT_TAB); + }, + { argCount: "0" }); + + commands.add(["o[pen]", "e[dit]"], + "Open one or more URLs in the current tab", + function (args) + { + if (args.string) + liberator.open(args.string); + else if (args.bang) + BrowserReloadSkipCache(); + else + BrowserReload(); + }, + { + bang: true, + completer: function (context) completion.url(context), + literal: 0 + }); + + commands.add(["redr[aw]"], + "Redraw the screen", + function () + { + let wu = window.QueryInterface(Ci.nsIInterfaceRequestor) + .getInterface(Ci.nsIDOMWindowUtils); + wu.redraw(); + modes.show(); + }, + { argCount: "0" }); + + /////////////////////////////////////////////////////////////////////////////}}} + ////////////////////// OPTIONS ///////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////////////{{{ + + options.add(["encoding", "enc"], + "Sets the current buffer's character encoding", + "string", "UTF-8", + { + scope: options.OPTION_SCOPE_LOCAL, + getter: function () getBrowser().docShell.QueryInterface(Ci.nsIDocCharset).charset, + setter: function (val) + { + // Stolen from browser.jar/content/browser/browser.js, more or less. + try + { + var docCharset = getBrowser().docShell.QueryInterface(Ci.nsIDocCharset).charset = val + PlacesUtils.history.setCharsetForURI(getWebNavigation().currentURI, val); + getWebNavigation().reload(Ci.nsIWebNavigation.LOAD_FLAGS_CHARSET_CHANGE); + } + catch (e) { liberator.reportError(e); } + }, + completer: function (context) completion.charset(context), + validator: Option.validateCompleter + }); + + options.add(["online"], + "Set the 'work offline' option", + "boolean", true, + { + setter: function (value) + { + const ioService = services.get("io"); + if (ioService.offline == value) + BrowserOffline.toggleOfflineStatus(); + return value; + }, + getter: function () !services.get("io").offline + }); + + // only available in FF 3.5 + services.add("privateBrowsing", "@mozilla.org/privatebrowsing;1", Ci.nsIPrivateBrowsingService); + if (services.get("privateBrowsing")) + { + options.add(["private", "pornmode"], + "Set the 'private browsing' option", + "boolean", false, + { + setter: function (value) services.get("privateBrowsing").privateBrowsingEnabled = value, + getter: function () services.get("privateBrowsing").privateBrowsingEnabled, + }); + let services = modules.services; // Storage objects are global to all windows, 'modules' isn't. + storage.newObject("private-mode", function () { + ({ + init: function () { + services.get("observer").addObserver(this, "private-browsing", false); + services.get("observer").addObserver(this, "quit-application", false); + this.private = services.get("privateBrowsing").privateBrowsingEnabled; + }, + observe: function (subject, topic, data) { + if (topic == "private-browsing") { + if (data == "enter") + storage.privateMode = true; + else if (data == "exit") + storage.privateMode = false; + storage.fireEvent("private-mode", "change", storage.privateMode); + } else if (topic == "quit-application") { + services.get("observer").removeObserver(this, "quit-application"); + services.get("observer").removeObserver(this, "private-browsing"); + } + }, + }).init(); + }, false); + storage.addObserver("private-mode", + function (key, event, value) { + autocommands.trigger("PrivateMode", { state: value }); + }, window); + } + + options.add(["urlseparator"], + "Set the separator regexp used to separate multiple URL args", + "string", ",\\s"); + + /////////////////////////////////////////////////////////////////////////////}}} + ////////////////////// COMMANDS //////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////////////{{{ + + commands.add(["downl[oads]", "dl"], + "Show progress of current downloads", + function () + { + liberator.open("chrome://mozapps/content/downloads/downloads.xul", + options.get("newtab").has("all", "downloads") + ? liberator.NEW_TAB : liberator.CURRENT_TAB); + }, + { argCount: "0" }); + + commands.add(["o[pen]", "e[dit]"], + "Open one or more URLs in the current tab", + function (args) + { + if (args.string) + liberator.open(args.string); + else if (args.bang) + BrowserReloadSkipCache(); + else + BrowserReload(); + }, + { + bang: true, + completer: function (context) completion.url(context), + literal: 0 + }); + + commands.add(["redr[aw]"], + "Redraw the screen", + function () + { + let wu = window.QueryInterface(Ci.nsIInterfaceRequestor) + .getInterface(Ci.nsIDOMWindowUtils); + wu.redraw(); + modes.show(); + }, + { argCount: "0" }); + + /////////////////////////////////////////////////////////////////////////////}}} + ////////////////////// OPTIONS ///////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////////////{{{ + + options.add(["encoding", "enc"], + "Sets the current buffer's character encoding", + "string", "UTF-8", + { + scope: options.OPTION_SCOPE_LOCAL, + getter: function () getBrowser().docShell.QueryInterface(Ci.nsIDocCharset).charset, + setter: function (val) + { + // Stolen from browser.jar/content/browser/browser.js, more or less. + try + { + var docCharset = getBrowser().docShell.QueryInterface(Ci.nsIDocCharset).charset = val + PlacesUtils.history.setCharsetForURI(getWebNavigation().currentURI, val); + getWebNavigation().reload(Ci.nsIWebNavigation.LOAD_FLAGS_CHARSET_CHANGE); + } + catch (e) { liberator.reportError(e); } + }, + completer: function (context) completion.charset(context), + validator: Option.validateCompleter + }); + + options.add(["urlseparator"], + "Set the separator regexp used to separate multiple URL args", + "string", ",\\s"); + + /////////////////////////////////////////////////////////////////////////////}}} + ////////////////////// PUBLIC SECTION ////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////////////{{{ + + return { + // TODO: extract browser-specific functionality from liberator + }; + //}}} +}; //}}} + +// vim: set fdm=marker sw=4 ts=4 et: diff --git a/vimperator/content/config.js b/vimperator/content/config.js index 9a0e2dc1..a4c44b34 100644 --- a/vimperator/content/config.js +++ b/vimperator/content/config.js @@ -137,6 +137,7 @@ const config = { //{{{ }, scripts: [ + "browser.js", "bookmarks.js", "tabs.js" ], @@ -155,25 +156,6 @@ const config = { //{{{ init: function () { - // TODO: support 'nrformats'? -> probably not worth it --mst - function incrementURL(count) - { - let matches = buffer.URL.match(/(.*?)(\d+)(\D*)$/); - if (!matches) - return void liberator.beep(); - - let [, pre, number, post] = matches; - let newNumber = parseInt(number, 10) + count; - let newNumberStr = String(newNumber > 0 ? newNumber : 0); - if (number.match(/^0/)) // add 0009 should become 0010 - { - while (newNumberStr.length < number.length) - newNumberStr = "0" + newNumberStr; - } - - liberator.open(pre + newNumberStr + post); - } - // load Vimperator specific modules // FIXME: Why aren't these listed in config.scripts? // FIXME: Why isn't this automatic? -> how would one know which classes to load where? --mst @@ -184,6 +166,7 @@ const config = { //{{{ // or we could just make sure that they're all sourced in order. // The scripts could even just instantiate them themselves. // --Kris + liberator.loadModule("browser", Browser); liberator.loadModule("finder", Finder); liberator.loadModule("bookmarks", Bookmarks); liberator.loadModule("history", History); @@ -214,146 +197,10 @@ const config = { //{{{ ////////////////////// MAPPINGS //////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////{{{ - mappings.add([modes.NORMAL], - ["y"], "Yank current location to the clipboard", - function () { util.copyToClipboard(buffer.URL, true); }); - - // opening websites - mappings.add([modes.NORMAL], - ["o"], "Open one or more URLs", - function () { commandline.open(":", "open ", modes.EX); }); - - mappings.add([modes.NORMAL], ["O"], - "Open one or more URLs, based on current location", - function () { commandline.open(":", "open " + buffer.URL, modes.EX); }); - - mappings.add([modes.NORMAL], ["t"], - "Open one or more URLs in a new tab", - function () { commandline.open(":", "tabopen ", modes.EX); }); - - mappings.add([modes.NORMAL], ["T"], - "Open one or more URLs in a new tab, based on current location", - function () { commandline.open(":", "tabopen " + buffer.URL, modes.EX); }); - - mappings.add([modes.NORMAL], ["w"], - "Open one or more URLs in a new window", - function () { commandline.open(":", "winopen ", modes.EX); }); - - mappings.add([modes.NORMAL], ["W"], - "Open one or more URLs in a new window, based on current location", - function () { commandline.open(":", "winopen " + buffer.URL, modes.EX); }); - - mappings.add([modes.NORMAL], - [""], "Increment last number in URL", - function (count) { incrementURL(Math.max(count, 1)); }, - { count: true }); - - mappings.add([modes.NORMAL], - [""], "Decrement last number in URL", - function (count) { incrementURL(-Math.max(count, 1)); }, - { count: true }); - - mappings.add([modes.NORMAL], ["~"], - "Open home directory", - function () { liberator.open("~"); }); - - mappings.add([modes.NORMAL], ["gh"], - "Open homepage", - function () { BrowserHome(); }); - - mappings.add([modes.NORMAL], ["gH"], - "Open homepage in a new tab", - function () - { - let homepages = gHomeButton.getHomePage(); - liberator.open(homepages, /\bhomepage\b/.test(options["activate"]) ? - liberator.NEW_TAB : liberator.NEW_BACKGROUND_TAB); - }); - - mappings.add([modes.NORMAL], ["gu"], - "Go to parent directory", - function (count) - { - function isDirectory(url) - { - if (/^file:\/|^\//.test(url)) - { - let file = io.getFile(url); - return file.exists() && file.isDirectory(); - } - else - { - // for all other locations just check if the URL ends with / - return /\/$/.test(url); - } - } - - if (count < 1) - count = 1; - - // XXX - let url = buffer.URL; - for (let i = 0; i < count; i++) - { - if (isDirectory(url)) - url = url.replace(/^(.*?:)(.*?)([^\/]+\/*)$/, "$1$2/"); - else - url = url.replace(/^(.*?:)(.*?)(\/+[^\/]+)$/, "$1$2/"); - } - url = url.replace(/^(.*:\/+.*?)\/+$/, "$1/"); // get rid of more than 1 / at the end - - if (url == buffer.URL) - liberator.beep(); - else - liberator.open(url); - }, - { count: true }); - - mappings.add([modes.NORMAL], ["gU"], - "Go to the root of the website", - function () - { - let uri = content.document.location; - if (/(about|mailto):/.test(uri.protocol)) // exclude these special protocols for now - return void liberator.beep(); - liberator.open(uri.protocol + "//" + (uri.host || "") + "/"); - }); - - mappings.add([modes.NORMAL], [""], - "Redraw the screen", - function () { commands.get("redraw").execute("", false); }); - /////////////////////////////////////////////////////////////////////////////}}} ////////////////////// COMMANDS //////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////{{{ - commands.add(["downl[oads]", "dl"], - "Show progress of current downloads", - function () - { - liberator.open("chrome://mozapps/content/downloads/downloads.xul", - options.get("newtab").has("all", "downloads") - ? liberator.NEW_TAB : liberator.CURRENT_TAB); - }, - { argCount: "0" }); - - commands.add(["o[pen]", "e[dit]"], - "Open one or more URLs in the current tab", - function (args) - { - if (args.string) - liberator.open(args.string); - else if (args.bang) - BrowserReloadSkipCache(); - else - BrowserReload(); - }, - { - bang: true, - completer: function (context) completion.url(context), - literal: 0 - }); - commands.add(["pref[erences]", "prefs"], "Show " + config.hostApplication + " preferences", function (args) @@ -372,17 +219,6 @@ const config = { //{{{ bang: true }); - commands.add(["redr[aw]"], - "Redraw the screen", - function () - { - let wu = window.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIDOMWindowUtils); - wu.redraw(); - modes.show(); - }, - { argCount: "0" }); - commands.add(["sbcl[ose]"], "Close the sidebar window", function () @@ -454,27 +290,6 @@ const config = { //{{{ ////////////////////// OPTIONS ///////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////{{{ - options.add(["encoding", "enc"], - "Sets the current buffer's character encoding", - "string", "UTF-8", - { - scope: options.OPTION_SCOPE_LOCAL, - getter: function () getBrowser().docShell.QueryInterface(Ci.nsIDocCharset).charset, - setter: function (val) - { - // Stolen from browser.jar/content/browser/browser.js, more or less. - try - { - var docCharset = getBrowser().docShell.QueryInterface(Ci.nsIDocCharset).charset = val - PlacesUtils.history.setCharsetForURI(getWebNavigation().currentURI, val); - getWebNavigation().reload(Ci.nsIWebNavigation.LOAD_FLAGS_CHARSET_CHANGE); - } - catch (e) { liberator.reportError(e); } - }, - completer: function (context) completion.charset(context), - validator: Option.validateCompleter - }); - options.add(["online"], "Set the 'work offline' option", "boolean", true, @@ -500,6 +315,7 @@ const config = { //{{{ setter: function (value) services.get("privateBrowsing").privateBrowsingEnabled = value, getter: function () services.get("privateBrowsing").privateBrowsingEnabled, }); + let services = modules.services; // Storage objects are global to all windows, 'modules' isn't. storage.newObject("private-mode", function () { ({ @@ -522,6 +338,7 @@ const config = { //{{{ }, }).init(); }, false); + storage.addObserver("private-mode", function (key, event, value) { autocommands.trigger("PrivateMode", { state: value }); @@ -551,10 +368,6 @@ const config = { //{{{ } }); - options.add(["urlseparator"], - "Set the separator regexp used to separate multiple URL args", - "string", ",\\s"); - /////////////////////////////////////////////////////////////////////////////}}} ////////////////////// COMPLETIONS ///////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////{{{ diff --git a/xulmus/content/config.js b/xulmus/content/config.js index 1924421e..e727f68b 100644 --- a/xulmus/content/config.js +++ b/xulmus/content/config.js @@ -180,6 +180,7 @@ const config = { //{{{ }, scripts: [ + "browser.js", "bookmarks.js", "tabs.js", "player.js", @@ -262,15 +263,7 @@ const config = { //{{{ }; // load Xulmus specific modules - // FIXME: Why aren't these listed in config.scripts? - // FIXME: Why isn't this automatic? -> how would one know which classes to load where? --mst - // Something like: - // liberator.addModule("search", function Search() { ... - // for all modules, or something similar. For modules which - // require other modules, well, there's addObserver("load_foo", - // or we could just make sure that they're all sourced in order. - // The scripts could even just instantiate them themselves. - // --Kris + liberator.loadModule("browser", Browser); liberator.loadModule("finder", Finder); liberator.loadModule("bookmarks", Bookmarks); liberator.loadModule("history", History); @@ -303,175 +296,10 @@ const config = { //{{{ ////////////////////// MAPPINGS //////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////{{{ - mappings.add([modes.NORMAL], - ["y"], "Yank current location to the clipboard", - function () { util.copyToClipboard(buffer.URL, true); }); - - // opening websites - mappings.add([modes.NORMAL], - ["o"], "Open one or more URLs", - function () { commandline.open(":", "open ", modes.EX); }); - - mappings.add([modes.NORMAL], ["O"], - "Open one or more URLs, based on current location", - function () { commandline.open(":", "open " + buffer.URL, modes.EX); }); - - mappings.add([modes.NORMAL], ["t"], - "Open one or more URLs in a new tab", - function () { commandline.open(":", "tabopen ", modes.EX); }); - - mappings.add([modes.NORMAL], ["t"], - "Open one or more URLs in a new tab", - function () { commandline.open(":", "tabopen ", modes.EX); }); - - mappings.add([modes.NORMAL], ["T"], - "Open one or more URLs in a new tab, based on current location", - function () { commandline.open(":", "tabopen " + buffer.URL, modes.EX); }); - - mappings.add([modes.NORMAL], ["T"], - "Open one or more URLs in a new tab, based on current location", - function () { commandline.open(":", "tabopen " + buffer.URL, modes.EX); }); - - mappings.add([modes.NORMAL], - [""], "Increment last number in URL", - function (count) { incrementURL(Math.max(count, 1)); }, - { count: true }); - - mappings.add([modes.NORMAL], - [""], "Decrement last number in URL", - function (count) { incrementURL(-Math.max(count, 1)); }, - { count: true }); - - mappings.add([modes.NORMAL], ["~"], - "Open home directory", - function () { liberator.open("~"); }); - - mappings.add([modes.NORMAL], ["gh"], - "Open homepage", - function () { BrowserHome(); }); - - mappings.add([modes.NORMAL], ["gH"], - "Open homepage in a new tab", - function () - { - let homepages = gHomeButton.getHomePage(); - liberator.open(homepages, /\bhomepage\b/.test(options["activate"]) ? - liberator.NEW_TAB : liberator.NEW_BACKGROUND_TAB); - }); - - mappings.add([modes.NORMAL], ["gu"], - "Go to parent directory", - function (count) - { - function isDirectory(url) - { - if (/^file:\/|^\//.test(url)) - { - let file = io.getFile(url); - return file.exists() && file.isDirectory(); - } - else - { - // for all other locations just check if the URL ends with / - return /\/$/.test(url); - } - } - - if (count < 1) - count = 1; - - // XXX - let url = buffer.URL; - for (let i = 0; i < count; i++) - { - if (isDirectory(url)) - url = url.replace(/^(.*?:)(.*?)([^\/]+\/*)$/, "$1$2/"); - else - url = url.replace(/^(.*?:)(.*?)(\/+[^\/]+)$/, "$1$2/"); - } - url = url.replace(/^(.*:\/+.*?)\/+$/, "$1/"); // get rid of more than 1 / at the end - - if (url == buffer.URL) - liberator.beep(); - else - liberator.open(url); - }, - { count: true }); - - mappings.add([modes.NORMAL], ["gU"], - "Go to the root of the website", - function () - { - let uri = content.document.location; - if (/(about|mailto):/.test(uri.protocol)) // exclude these special protocols for now - return void liberator.beep(); - liberator.open(uri.protocol + "//" + (uri.host || "") + "/"); - }); - - mappings.add([modes.NORMAL], [""], - "Redraw the screen", - function () { commands.get("redraw").execute("", false); }); - - /////////////////////////////////////////////////////////////////////////////}}} + /////////////////////////////////////////////////////////////////////////////}}} ////////////////////// COMMANDS //////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////{{{ - commands.add(["downl[oads]", "dl"], - "Show progress of current downloads", - function () - { - liberator.open("chrome://mozapps/content/downloads/downloads.xul", - options.get("newtab").has("all", "downloads") - ? liberator.NEW_TAB : liberator.CURRENT_TAB); - }, - { argCount: "0" }); - - commands.add(["o[pen]", "e[dit]"], - "Open one or more URLs in the current tab", - function (args) - { - if (args.string) - liberator.open(args.string); - else if (args.bang) - BrowserReloadSkipCache(); - else - BrowserReload(); - }, - { - bang: true, - completer: function (context) completion.url(context), - literal: 0 - }); - - commands.add(["pref[erences]", "prefs"], - "Show " + config.hostApplication + " preferences", - function (args) - { - if (args.bang) // open Songbird settings GUI dialog - { - liberator.open("about:config", - (options["newtab"] && options.get("newtab").has("all", "prefs")) - ? liberator.NEW_TAB : liberator.CURRENT_TAB); - } - else - window.openPreferences(); - }, - { - argCount: "0", - bang: true - }); - - commands.add(["redr[aw]"], - "Redraw the screen", - function () - { - let wu = window.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIDOMWindowUtils); - wu.redraw(); - modes.show(); - }, - { argCount: "0" }); - commands.add(["dpcl[ose]"], "Close a display pane", function (args) @@ -509,6 +337,24 @@ const config = { //{{{ literal: 0 }); + commands.add(["pref[erences]", "prefs"], + "Show " + config.hostApplication + " preferences", + function (args) + { + if (args.bang) // open Songbird settings GUI dialog + { + liberator.open("about:config", + (options["newtab"] && options.get("newtab").has("all", "prefs")) + ? liberator.NEW_TAB : liberator.CURRENT_TAB); + } + else + window.openPreferences(); + }, + { + argCount: "0", + bang: true + }); + /////////////////////////////////////////////////////////////////////////////}}} ////////////////////// OPTIONS ///////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////{{{ @@ -543,9 +389,10 @@ const config = { //{{{ } }); - options.add(["urlseparator"], - "Set the separator regexp used to separate multiple URL args", - "string", ",\\s"); + /////////////////////////////////////////////////////////////////////////////}}} + ////////////////////// COMPLETIONS ///////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////////////{{{ + //}}} // TODO: mention this to SB devs, they seem keen to provide these