From ee06a63dbaf346dc15da49145dd5b4a4d20a40a3 Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Tue, 16 Aug 2011 21:38:22 -0400 Subject: [PATCH] Add C_. --- common/content/dactyl.js | 21 +++++++++------------ common/content/mappings.js | 6 ++++-- common/content/tabs.js | 23 ++++++++++++++++++++--- common/locale/en-US/tabs.xml | 9 +++++++++ pentadactyl/NEWS | 1 + pentadactyl/content/config.js | 4 ++-- 6 files changed, 45 insertions(+), 19 deletions(-) diff --git a/common/content/dactyl.js b/common/content/dactyl.js index 721abc1c..b0f1b8ee 100644 --- a/common/content/dactyl.js +++ b/common/content/dactyl.js @@ -172,8 +172,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { NEW_BACKGROUND_TAB: "background-tab", NEW_WINDOW: "window", - forceNewTab: false, - forceNewWindow: false, + forceTarget: null, version: deprecated("config.version", { get: function version() config.version }), @@ -215,7 +214,6 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { this._observers[type] = this._observers[type].filter(function (c) c.get() != callback); }, - // TODO: "zoom": if the zoom value of the current buffer changed applyTriggerObserver: function triggerObserver(type, args) { if (type in this._observers) this._observers[type] = this._observers[type].filter(function (callback) { @@ -1237,8 +1235,9 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { event.preventDefault(); if (dactyl.commands[command]) - dactyl.withSavedValues(["forceNewTab"], function () { - dactyl.forceNewTab = event.ctrlKey || event.shiftKey || event.button == 1; + dactyl.withSavedValues(["forceTarget"], function () { + if (event.ctrlKey || event.shiftKey || event.button == 1) + dactyl.forceTarget = dactyl.NEW_TAB; dactyl.commands[command](event); }); } @@ -1348,10 +1347,8 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { // any genuine errors go unreported. } - if (dactyl.forceNewTab) - where = dactyl.NEW_TAB; - else if (dactyl.forceNewWindow) - where = dactyl.NEW_WINDOW; + if (dactyl.forceTarget) + where = dactyl.forceTarget; else if (!where) where = dactyl.CURRENT_TAB; @@ -1553,7 +1550,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { wrapCallback: function (callback, self) { self = self || this; - let save = ["forceNewTab", "forceNewWindow"]; + let save = ["forceTarget"]; let saved = save.map(function (p) dactyl[p]); return function wrappedCallback() { let args = arguments; @@ -2176,8 +2173,8 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { if (localPrefs.get("first-run", true)) dactyl.timeout(function () { localPrefs.set("first-run", false); - this.withSavedValues(["forceNewTab"], function () { - this.forceNewTab = true; + this.withSavedValues(["forceTarget"], function () { + this.forceTarget = dactyl.NEW_TAB; this.help(); }); }, 1000); diff --git a/common/content/mappings.js b/common/content/mappings.js index 7c5214e9..6fbcead3 100644 --- a/common/content/mappings.js +++ b/common/content/mappings.js @@ -128,9 +128,10 @@ var Map = Class("Map", { if (this.names[0] != ".") // FIXME: Kludge. mappings.repeat = repeat; - if (this.executing) + if (this.executing) { util.dumpStack(_("map.recursive", args.command)); - dactyl.assert(!this.executing, _("map.recursive", args.command)); + throw AssertionError(_("map.recursive", args.command)); + } try { this.preExecute(args); @@ -144,6 +145,7 @@ var Map = Class("Map", { finally { this.executing = false; this.postExecute(args); + dactyl.triggerObserver("mappings.executed", this, args); } return res; } diff --git a/common/content/tabs.js b/common/content/tabs.js index c5c156c0..d76092cf 100644 --- a/common/content/tabs.js +++ b/common/content/tabs.js @@ -54,9 +54,16 @@ var Tabs = Module("tabs", { enter: function enter() { if (window.TabsInTitlebar) window.TabsInTitlebar.allowedBy("dactyl", true); - } + }, + + "mappings.executed": function mappings_executed() { + if (this._mappingCount && !--this._mappingCount) + dactyl.forceTarget = this._originalTarget; + }, }, + _mappingCount: 0, + _alternates: Class.memoize(function () [config.tabbrowser.mCurrentTab, null]), cleanup: function cleanup() { @@ -645,8 +652,8 @@ var Tabs = Module("tabs", { commands.add(["tab"], "Execute a command and tell it to output in a new tab", function (args) { - dactyl.withSavedValues(["forceNewTab"], function () { - this.forceNewTab = true; + dactyl.withSavedValues(["forceTarget"], function () { + this.forceTarget = dactyl.NEW_TAB; dactyl.execute(args[0], null, true); }); }, { @@ -948,6 +955,16 @@ var Tabs = Module("tabs", { events.listen(tabContainer, "TabSelect", tabs.closure._onTabSelect, false); }, mappings: function () { + + mappings.add([modes.COMMAND], ["", ""], + "Execute the next mapping in a new tab", + function ({ count }) { + tabs._mappingCount += (count || 1) + 1; + tabs._originalTarget = dactyl.forceTarget; + dactyl.forceTarget = dactyl.NEW_TAB; + }, + { count: true }); + mappings.add([modes.NORMAL], ["g0", "g^"], "Go to the first tab", function () { tabs.select(0); }); diff --git a/common/locale/en-US/tabs.xml b/common/locale/en-US/tabs.xml index 9a024836..fdf27624 100644 --- a/common/locale/en-US/tabs.xml +++ b/common/locale/en-US/tabs.xml @@ -58,6 +58,15 @@

Opening tabs

+ + ]]> + count]]> + +

Execute the next count mappings in a new tab.

+
+
+ + :tab diff --git a/pentadactyl/NEWS b/pentadactyl/NEWS index dc3a1b37..d823f2aa 100644 --- a/pentadactyl/NEWS +++ b/pentadactyl/NEWS @@ -86,6 +86,7 @@ - Added 'timeout' and 'timeoutlen' options. [b6] - Added n_{, n_}, n_[ and n_] mappings. [b7] - Added n_g], n_[d and n_]d. [b8] + - Added to open the next mapping in a new tab. [b8] - Added to execute a builtin mapping. [b6] - Added l and s to aid in the construction of macros. [b6] diff --git a/pentadactyl/content/config.js b/pentadactyl/content/config.js index a69f7fbf..b7307678 100644 --- a/pentadactyl/content/config.js +++ b/pentadactyl/content/config.js @@ -242,8 +242,8 @@ var Config = Module("config", ConfigBase, { commands.add(["wind[ow]"], "Execute a command and tell it to output in a new window", function (args) { - dactyl.withSavedValues(["forceNewWindow"], function () { - this.forceNewWindow = true; + dactyl.withSavedValues(["forceTarget"], function () { + this.forceTarget = dactyl.NEW_WINDOW; this.execute(args[0], null, true); }); },