diff --git a/NEWS b/NEWS index 350e4733..4723119e 100644 --- a/NEWS +++ b/NEWS @@ -54,6 +54,7 @@ * Escape finally clears any selection made in the document * initial start of caret mode. Start with 'i', stop with Escape; * many small bug fixes and enhancements + * new "newtab" option for opening the command output in a new tab 2007-12-21: * version 0.5.3 diff --git a/content/liberator.js b/content/liberator.js index 255eb5a2..cd37b810 100644 --- a/content/liberator.js +++ b/content/liberator.js @@ -121,7 +121,12 @@ const liberator = (function () //{{{ { liberator.commands.add(["addo[ns]"], "Manage available Extensions and Themes", - function () { liberator.open("chrome://mozapps/content/extensions/extensions.xul", liberator.NEW_TAB); }); + function () + { + liberator.open("chrome://mozapps/content/extensions/extensions.xul", + (liberator.options.newtab == "all" || liberator.options.newtab.split(",").indexOf("addons") != -1) ? + liberator.NEW_TAB: liberator.CURRENT_TAB); + }); liberator.commands.add(["beep"], "Play a system beep", @@ -182,7 +187,11 @@ const liberator = (function () //{{{ function (args, special) { if (special) // open javascript console - liberator.open("chrome://global/content/console.xul", liberator.NEW_TAB); + { + liberator.open("chrome://global/content/console.xul", + (liberator.options.newtab == "all" || liberator.options.newtab.split(",").indexOf("javascript") != -1) ? + liberator.NEW_TAB : liberator.CURRENT_TAB); + } else { // check for a heredoc @@ -395,6 +404,8 @@ const liberator = (function () //{{{ NEW_BACKGROUND_TAB: 3, NEW_WINDOW: 4, + forceNewTab: false, + // ###VERSION### and ###DATE### are replaced by the Makefile version: "###VERSION### (created: ###DATE###)", @@ -592,9 +603,12 @@ const liberator = (function () //{{{ help: function(topic) { + var where = (liberator.options.newtab == "all" || liberator.options.newtab.split(",").indexOf("help") != -1) ? + liberator.NEW_TAB : liberator.CURRENT_TAB; + function jumpToTag(file, tag) { - liberator.open("chrome://" + liberator.config.name.toLowerCase() + "/locale/" + file); + liberator.open("chrome://" + liberator.config.name.toLowerCase() + "/locale/" + file, where); setTimeout(function() { var elem = liberator.buffer.getElement('@class="tag" and text()="' + tag + '"'); if (elem) @@ -606,7 +620,7 @@ const liberator = (function () //{{{ if (!topic) { - liberator.open("chrome://" + liberator.config.name.toLowerCase() + "/locale/intro.html"); + liberator.open("chrome://" + liberator.config.name.toLowerCase() + "/locale/intro.html", where); return; } @@ -651,6 +665,7 @@ const liberator = (function () //{{{ // ["url1", "url2", "url3", ...] or: // [["url1", postdata1], ["url2", postdata2], ...] // @param where: if ommited, CURRENT_TAB is assumed + // but NEW_TAB is set when liberator.forceNewTab is true. // @param callback: not implemented, will be allowed to specify a callback function // which is called, when the page finished loading // @returns true when load was initiated, or false on error @@ -664,7 +679,9 @@ const liberator = (function () //{{{ if (urls.length == 0) return false; - if (!where || !liberator.has("tabs")) + if (liberator.forceNewTab && liberator.has("tabs")) + where = liberator.NEW_TAB; + else if (!where || !liberator.has("tabs")) where = liberator.CURRENT_TAB; var url = typeof urls[0] == "string" ? urls[0] : urls[0][0]; diff --git a/content/options.js b/content/options.js index 275ab27c..27699c4a 100644 --- a/content/options.js +++ b/content/options.js @@ -296,18 +296,15 @@ liberator.Options = function () //{{{ { if (!args) { - // TODO: copy these snippets to more function which should work with :tab xxx - if (modifiers && modifiers.inTab) + if (special) // open firefox settings gui dialog { - liberator.open(special ? "about:config" : - "chrome://browser/content/preferences/preferences.xul", liberator.NEW_TAB); + liberator.open("about:config", + (liberator.options.newtab == "all" || liberator.options.newtab.split(",").indexOf("prefs") != -1) ? + liberator.NEW_TAB : liberator.CURRENT_TAB); } else { - if (special) // open firefox settings gui dialog - liberator.open("about:config", liberator.CURRENT_TAB); - else - openPreferences(); + openPreferences(); } } else diff --git a/content/tabs.js b/content/tabs.js index ea8ce625..bb072802 100644 --- a/content/tabs.js +++ b/content/tabs.js @@ -88,6 +88,16 @@ liberator.Tabs = function () //{{{ } }); + liberator.options.add(["newtab"], + "Define which commands should output in a new tab by default", + "stringlist", "", + { + validator: function(value) + { + return value == "all" || value.split(",").every(function (item) { return /^(addons|downloads|help|javascript|prefs|)$/.test(item); }); + } + }); + liberator.options.add(["popups", "pps"], "Where to show requested popup windows", "number", 1, @@ -250,7 +260,12 @@ liberator.Tabs = function () //{{{ liberator.commands.add(["tab"], "Execute a command and tell it to output in a new tab", - function (args) { liberator.execute(args, { inTab: true }); }, + function (args) + { + liberator.forceNewTab = true; + liberator.execute(args); + liberator.forceNewTab = false; + }, { completer: function (filter) { return liberator.completion.command(filter); } }); liberator.commands.add(["tabl[ast]"], diff --git a/content/vimperator.js b/content/vimperator.js index ee399aee..03020112 100644 --- a/content/vimperator.js +++ b/content/vimperator.js @@ -228,7 +228,12 @@ liberator.config = { liberator.commands.add(["downl[oads]", "dl"], "Show progress of current downloads", - function () { liberator.open("chrome://mozapps/content/downloads/downloads.xul", liberator.NEW_TAB); }); + function () + { + liberator.open("chrome://mozapps/content/downloads/downloads.xul", + (liberator.options.newtab == "all" || liberator.options.newtab.split(",").indexOf("downloads") != -1) ? + liberator.NEW_TAB : liberator.CURRENT_TAB); + }); liberator.commands.add(["o[pen]", "e[dit]"], "Open one or more URLs in the current tab", diff --git a/locale/en-US/options.txt b/locale/en-US/options.txt index e9311b21..56e4968c 100644 --- a/locale/en-US/options.txt +++ b/locale/en-US/options.txt @@ -342,8 +342,26 @@ ____ Pause the message list window when more than one screen of listings is displayed ____ +|\'newtab'| +||'newtab'|| stringlist (default: "") +____ +Define which ex commands output the result in a new tab automatically. You can +also use [c]:tab command[c] to manually output a command in a new tab. + +The possible values: +`------------`--------------------------------------------- +*all* All commands +*addons* [c]:addo[ns][c] command +*downloads* [c]:downl[oads][c] command +*help* [c]:h[elp][c] command +*javascript* [c]:javascript![c] or [c]:js![c] command +*prefs* [c]:pref[erences]![c] or [c]:prefs![c] command +----------------------------------------------------------- + +____ + |\'nextpattern'| -||'nextpattern'|| stringlist (default: \bnext,^>$,^(>>|»)$,^(>|»),(>|»)$) +||'nextpattern'|| stringlist (default: \bnext,^>$,^(>>|»)$,^(>|»),(>|»)$,\bmore\b) ____ Patterns to use when guessing the 'next' page in a document sequence. Each pattern, in order, is matched against all links in the page with the first match being used.