1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-20 20:27:58 +01:00

Add C_<C-t>.

This commit is contained in:
Kris Maglione
2011-08-16 21:38:22 -04:00
parent 1ad3fdf195
commit ee06a63dba
6 changed files with 45 additions and 19 deletions

View File

@@ -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);

View File

@@ -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;
}

View File

@@ -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); });

View File

@@ -58,6 +58,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/>

View File

@@ -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 <C-t> to open the next mapping in a new tab. [b8]
- Added <A-b> to execute a builtin mapping. [b6]
- Added <A-m>l and <A-m>s to aid in the construction of
macros. [b6]

View File

@@ -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);
});
},