summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorKris Maglione <maglione.k@gmail.com>2011-08-16 21:38:22 -0400
committerKris Maglione <maglione.k@gmail.com>2011-08-16 21:38:22 -0400
commitee06a63dbaf346dc15da49145dd5b4a4d20a40a3 (patch)
treeedabc0c2907a96a8d31d288181dcdc5603cf131a /common
parent1ad3fdf195813913a7fabe0e2da0402427bdd5fb (diff)
downloadpentadactyl-ee06a63dbaf346dc15da49145dd5b4a4d20a40a3.tar.gz
Add C_<C-t>.
Diffstat (limited to 'common')
-rw-r--r--common/content/dactyl.js21
-rw-r--r--common/content/mappings.js6
-rw-r--r--common/content/tabs.js23
-rw-r--r--common/locale/en-US/tabs.xml9
4 files changed, 42 insertions, 17 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], ["<C-t>", "<new-tab-next>"],
+ "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
@@ -59,6 +59,15 @@
<h2 tag="opening-tabs">Opening tabs</h2>
<item>
+ <tags><![CDATA[<new-tab-next> <C-t>]]></tags>
+ <spec><oa>count</oa><![CDATA[<C-t>]]></spec>
+ <description>
+ <p>Execute the next <oa>count</oa> mappings in a new tab.</p>
+ </description>
+</item>
+
+
+<item>
<tags>:tab</tags>
<strut/>
<spec>:tab <a>cmd</a></spec>