mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-04-21 15:51:26 +02:00
tab related mappings for muttator, thanks teramako
This commit is contained in:
@@ -82,7 +82,7 @@ liberator.Addressbook = function () //{{{
|
||||
{
|
||||
to = gDBView.hdrForFirstSelectedMessage.mime2DecodedAuthor;
|
||||
}
|
||||
catch (e) { liberator.echoerr("Exxx: No message is selected");}
|
||||
catch (e) { liberator.beep();}
|
||||
|
||||
if (!to)
|
||||
return;
|
||||
@@ -93,7 +93,8 @@ liberator.Addressbook = function () //{{{
|
||||
if (/^\S+\s+\S+\s*$/.test(displayName))
|
||||
{
|
||||
var names = displayName.split(/\s+/);
|
||||
displayName = "-firstname=" + names[0] + " -lastname=" + names[1];
|
||||
displayName = "-firstname=" + names[0].replace(/"/g, "")
|
||||
+ " -lastname=" + names[1].replace(/"/g, "");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -140,7 +141,7 @@ liberator.Addressbook = function () //{{{
|
||||
[["-name", "-n"], liberator.commands.OPTION_STRING]]
|
||||
});
|
||||
|
||||
liberator.commands.add(["contacts", "abook"],
|
||||
liberator.commands.add(["contacts", "addr[essbook]"],
|
||||
"List or open multiple addresses",
|
||||
function (args, special) { liberator.addressbook.list(args, special); });
|
||||
|
||||
|
||||
@@ -793,7 +793,7 @@ const liberator = (function () //{{{
|
||||
.quit(nsIAppStartup.eRestart | nsIAppStartup.eAttemptQuit);
|
||||
},
|
||||
|
||||
// TODO: probably move to {muttator,vimperator,...}.js
|
||||
// TODO: move to {muttator,vimperator,...}.js
|
||||
// this function is called, when the chrome is ready
|
||||
startup: function ()
|
||||
{
|
||||
@@ -820,7 +820,7 @@ const liberator = (function () //{{{
|
||||
if (liberator.has("bookmarks")) { log("bookmarks"); liberator.bookmarks = liberator.Bookmarks(); }
|
||||
if (liberator.has("history")) { log("history"); liberator.history = liberator.History(); }
|
||||
if (liberator.has("mail") && liberator.Mail) { log("mail"); liberator.mail = liberator.Mail(); }
|
||||
if (liberator.has("tabs")) { log("tabs"); liberator.tabs = liberator.Tabs(); }
|
||||
if (liberator.has("tabs") && liberator.Tabs) { log("tabs"); liberator.tabs = liberator.Tabs(); }
|
||||
if (liberator.has("marks")) { log("marks"); liberator.marks = liberator.Marks(); }
|
||||
if (liberator.has("quickmarks")) { log("quickmarks"); liberator.quickmarks = liberator.QuickMarks(); }
|
||||
if (liberator.has("hints")) { log("hints"); liberator.hints = liberator.Hints(); }
|
||||
|
||||
@@ -223,6 +223,18 @@ liberator.Mail = function () //{{{
|
||||
"Inspect (focus) message",
|
||||
function () { content.focus(); });
|
||||
|
||||
liberator.mappings.add(modes, ["I"],
|
||||
"Open the message in new tab",
|
||||
function ()
|
||||
{
|
||||
if (gDBView && gDBView.selection.count < 1)
|
||||
{
|
||||
liberator.echoerr("Message is not selected");
|
||||
return;
|
||||
}
|
||||
MsgOpenNewTabForMessage();
|
||||
});
|
||||
|
||||
liberator.mappings.add(modes, ["<Space>"],
|
||||
"Scroll message or select next unread one",
|
||||
function () { return true; },
|
||||
@@ -583,6 +595,8 @@ liberator.Mail = function () //{{{
|
||||
var folder = liberator.mail.getFolders(args, true, true)[count];
|
||||
if (!folder)
|
||||
liberator.echoerr("Folder \"" + args + "\" does not exist");
|
||||
else if (liberator.forceNewTab)
|
||||
MsgOpenNewTabForFolder(folder.URI);
|
||||
else
|
||||
SelectFolder(folder.URI);
|
||||
},
|
||||
|
||||
+2
-2
@@ -32,7 +32,7 @@ liberator.config = {
|
||||
hostApplication: "Thunderbird", // TODO: can this be found out otherwise? gBrandBundle.getString("brandShortName");
|
||||
|
||||
/*** optional options, there are checked for existance and a fallback provided ***/
|
||||
features: ["hints", "mail", "marks", "addressbook"],
|
||||
features: ["hints", "mail", "marks", "addressbook", "tabs"],
|
||||
guioptions: { m: ["mail-toolbar-menubar2"], T: ["mail-bar2"], f: ["folderPaneBox", "folderpane_splitter"], F: ["folderPaneHeader"] },
|
||||
|
||||
get browserModes() { return [liberator.modes.MESSAGE]; },
|
||||
@@ -45,7 +45,7 @@ liberator.config = {
|
||||
isComposeWindow: false,
|
||||
|
||||
dialogs: [
|
||||
["about", "About Thunderbird", //XXX: Shredder ?
|
||||
["about", "About Thunderbird",
|
||||
function () { openAboutDialog(); }],
|
||||
["addons", "Manage Add-ons",
|
||||
function () { openAddonsMgr(); }],
|
||||
|
||||
@@ -56,6 +56,7 @@ the terms of any one of the MPL, the GPL or the LGPL.
|
||||
<script type="application/x-javascript;version=1.8" src="options.js"/>
|
||||
<script type="application/x-javascript;version=1.8" src="ui.js"/>
|
||||
<script type="application/x-javascript;version=1.8" src="util.js"/>
|
||||
<script type="application/x-javascript;version=1.8" src="tabs.js"/>
|
||||
|
||||
<window id="messengerWindow">
|
||||
|
||||
|
||||
+161
-101
@@ -26,11 +26,33 @@ 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 *****/
|
||||
|
||||
// TODO: many methods do not work with Thunderbird correctly yet
|
||||
|
||||
liberator.Tabs = function () //{{{
|
||||
{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////// PRIVATE SECTION /////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////{{{
|
||||
var tabmail;
|
||||
var getBrowser = (function(){
|
||||
if (liberator.config.hostApplication == "Thunderbird")
|
||||
{
|
||||
return function()
|
||||
{
|
||||
if (!tabmail)
|
||||
{
|
||||
tabmail = document.getElementById('tabmail');
|
||||
tabmail.__defineGetter__('mTabContainer',function(){ return this.tabContainer; });
|
||||
tabmail.__defineGetter__('mTabs',function(){ return this.tabContainer.childNodes; });
|
||||
tabmail.__defineGetter__('mCurrentTab',function(){ return this.tabContainer.selectedItem; });
|
||||
tabmail.__defineGetter__('mStrip',function(){ return this.tabStrip; });
|
||||
}
|
||||
return tabmail;
|
||||
};
|
||||
}
|
||||
else
|
||||
return window.getBrowser;
|
||||
})();
|
||||
var alternates = [getBrowser().mCurrentTab, null];
|
||||
|
||||
// used for the "gb" and "gB" mappings to remember the last :buffer[!] command
|
||||
@@ -72,12 +94,44 @@ liberator.Tabs = function () //{{{
|
||||
}
|
||||
|
||||
// hide tabs initially
|
||||
if (liberator.config.name == "Vimperator")
|
||||
getBrowser().mStrip.getElementsByClassName("tabbrowser-tabs")[0].collapsed = true;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////}}}
|
||||
////////////////////// OPTIONS /////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////{{{
|
||||
|
||||
liberator.options.add(["showtabline", "stal"],
|
||||
"Control when to show the tab bar of opened web pages",
|
||||
"number", liberator.config.name == "Vimperator" ? 2 : 0,
|
||||
{
|
||||
setter: function (value)
|
||||
{
|
||||
var tabs = liberator.tabs.tabStrip;
|
||||
if (!tabs)
|
||||
return;
|
||||
|
||||
if (value == 0)
|
||||
{
|
||||
tabs.collapsed = true;
|
||||
}
|
||||
else if (value == 1)
|
||||
{
|
||||
liberator.options.setPref("browser.tabs.autoHide", true);
|
||||
tabs.collapsed = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
liberator.options.setPref("browser.tabs.autoHide", false);
|
||||
tabs.collapsed = false;
|
||||
}
|
||||
},
|
||||
validator: function (value) { return (value >= 0 && value <= 2); }
|
||||
});
|
||||
|
||||
|
||||
if (liberator.config.name == "Vimperator")
|
||||
{
|
||||
liberator.options.add(["activate", "act"],
|
||||
"Define when tabs are automatically activated",
|
||||
"stringlist", "homepage,quickmark,tabopen,paste",
|
||||
@@ -114,39 +168,33 @@ liberator.Tabs = function () //{{{
|
||||
},
|
||||
validator: function (value) { return (value >= 0 && value <= 4); }
|
||||
});
|
||||
|
||||
liberator.options.add(["showtabline", "stal"],
|
||||
"Control when to show the tab bar of opened web pages",
|
||||
"number", 2,
|
||||
{
|
||||
setter: function (value)
|
||||
{
|
||||
var tabs = getBrowser().mStrip.getElementsByClassName("tabbrowser-tabs")[0];
|
||||
if (!tabs)
|
||||
return;
|
||||
|
||||
if (value == 0)
|
||||
{
|
||||
tabs.collapsed = true;
|
||||
}
|
||||
else if (value == 1)
|
||||
{
|
||||
liberator.options.setPref("browser.tabs.autoHide", true);
|
||||
tabs.collapsed = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
liberator.options.setPref("browser.tabs.autoHide", false);
|
||||
tabs.collapsed = false;
|
||||
}
|
||||
},
|
||||
validator: function (value) { return (value >= 0 && value <= 2); }
|
||||
});
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////}}}
|
||||
////////////////////// MAPPINGS ////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////{{{
|
||||
|
||||
liberator.mappings.add([liberator.modes.NORMAL], ["g0", "g^"],
|
||||
"Go to the first tab",
|
||||
function (count) { liberator.tabs.select(0); });
|
||||
|
||||
liberator.mappings.add([liberator.modes.NORMAL], ["g$"],
|
||||
"Go to the last tab",
|
||||
function (count) { liberator.tabs.select("$"); });
|
||||
|
||||
liberator.mappings.add([liberator.modes.NORMAL], ["gt", "<C-n>", "<C-Tab>", "<C-PageDown>"],
|
||||
"Go to the next tab",
|
||||
function (count) { liberator.tabs.select(count > 0 ? count - 1: "+1", count > 0 ? false : true); },
|
||||
{ flags: liberator.Mappings.flags.COUNT });
|
||||
|
||||
liberator.mappings.add([liberator.modes.NORMAL], ["gT", "<C-p>", "<C-S-Tab>", "<C-PageUp>"],
|
||||
"Go to previous tab",
|
||||
function (count) { liberator.tabs.select("-" + (count < 1 ? 1 : count), true); },
|
||||
{ flags: liberator.Mappings.flags.COUNT });
|
||||
|
||||
|
||||
if (liberator.config.name == "Vimperator")
|
||||
{
|
||||
liberator.mappings.add([liberator.modes.NORMAL], ["b"],
|
||||
"Open a prompt to switch buffers",
|
||||
function () { liberator.commandline.open(":", "buffer! ", liberator.modes.EX); });
|
||||
@@ -175,24 +223,6 @@ liberator.Tabs = function () //{{{
|
||||
function (count) { liberator.tabs.switchTo(null, null, count, true); },
|
||||
{ flags: liberator.Mappings.flags.COUNT });
|
||||
|
||||
liberator.mappings.add([liberator.modes.NORMAL], ["g0", "g^"],
|
||||
"Go to the first tab",
|
||||
function (count) { liberator.tabs.select(0); });
|
||||
|
||||
liberator.mappings.add([liberator.modes.NORMAL], ["g$"],
|
||||
"Go to the last tab",
|
||||
function (count) { liberator.tabs.select("$"); });
|
||||
|
||||
liberator.mappings.add([liberator.modes.NORMAL], ["gt", "<C-n>", "<C-Tab>", "<C-PageDown>"],
|
||||
"Go to the next tab",
|
||||
function (count) { liberator.tabs.select(count > 0 ? count - 1: "+1", count > 0 ? false : true); },
|
||||
{ flags: liberator.Mappings.flags.COUNT });
|
||||
|
||||
liberator.mappings.add([liberator.modes.NORMAL], ["gT", "<C-p>", "<C-S-Tab>", "<C-PageUp>"],
|
||||
"Go to previous tab",
|
||||
function (count) { liberator.tabs.select("-" + (count < 1 ? 1 : count), true); },
|
||||
{ flags: liberator.Mappings.flags.COUNT });
|
||||
|
||||
liberator.mappings.add([liberator.modes.NORMAL], ["u"],
|
||||
"Undo closing of a tab",
|
||||
function (count) { liberator.commands.get("undo").execute("", false, count); },
|
||||
@@ -220,6 +250,7 @@ liberator.Tabs = function () //{{{
|
||||
else
|
||||
liberator.tabs.select(index);
|
||||
});
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////}}}
|
||||
////////////////////// COMMANDS ////////////////////////////////////////////////
|
||||
@@ -232,6 +263,63 @@ liberator.Tabs = function () //{{{
|
||||
liberator.tabs.remove(getBrowser().mCurrentTab, count > 0 ? count : 1, special, 0);
|
||||
});
|
||||
|
||||
liberator.commands.add(["tab"],
|
||||
"Execute a command and tell it to output in a new tab",
|
||||
function (args)
|
||||
{
|
||||
liberator.forceNewTab = true;
|
||||
liberator.execute(args);
|
||||
liberator.forceNewTab = false;
|
||||
},
|
||||
{ completer: function (filter) { return liberator.completion.exTabCompletion(filter); } });
|
||||
|
||||
liberator.commands.add(["tabl[ast]"],
|
||||
"Switch to the last tab",
|
||||
function () { liberator.tabs.select("$", false); });
|
||||
|
||||
// TODO: count support
|
||||
liberator.commands.add(["tabp[revious]", "tp[revious]", "tabN[ext]", "tN[ext]"],
|
||||
"Switch to the previous tab or go [count] tabs back",
|
||||
function (args)
|
||||
{
|
||||
if (!args)
|
||||
liberator.tabs.select("-1", true);
|
||||
else if (/^\d+$/.test(args))
|
||||
liberator.tabs.select("-" + args, true); // FIXME: urgh!
|
||||
else
|
||||
liberator.echoerr("E488: Trailing characters");
|
||||
});
|
||||
|
||||
// TODO: count support
|
||||
liberator.commands.add(["tabn[ext]", "tn[ext]"],
|
||||
"Switch to the next or [count]th tab",
|
||||
function (args)
|
||||
{
|
||||
if (!args)
|
||||
{
|
||||
liberator.tabs.select("+1", true);
|
||||
}
|
||||
else if (/^\d+$/.test(args))
|
||||
{
|
||||
var index = parseInt(args, 10) - 1;
|
||||
if (index < liberator.tabs.count)
|
||||
liberator.tabs.select(index, true);
|
||||
else
|
||||
liberator.beep();
|
||||
}
|
||||
else
|
||||
{
|
||||
liberator.echoerr("E488: Trailing characters");
|
||||
}
|
||||
});
|
||||
|
||||
liberator.commands.add(["tabr[ewind]", "tabfir[st]"],
|
||||
"Switch to the first tab",
|
||||
function () { liberator.tabs.select(0, false); });
|
||||
|
||||
|
||||
if (liberator.config.name == "Vimperator")
|
||||
{
|
||||
liberator.commands.add(["b[uffer]"],
|
||||
"Switch to a buffer",
|
||||
function (args, special) { liberator.tabs.switchTo(args, special); },
|
||||
@@ -258,20 +346,6 @@ liberator.Tabs = function () //{{{
|
||||
"Reload all tab pages",
|
||||
function (args, special) { liberator.tabs.reloadAll(special); });
|
||||
|
||||
liberator.commands.add(["tab"],
|
||||
"Execute a command and tell it to output in a new tab",
|
||||
function (args)
|
||||
{
|
||||
liberator.forceNewTab = true;
|
||||
liberator.execute(args);
|
||||
liberator.forceNewTab = false;
|
||||
},
|
||||
{ completer: function (filter) { return liberator.completion.command(filter); } });
|
||||
|
||||
liberator.commands.add(["tabl[ast]"],
|
||||
"Switch to the last tab",
|
||||
function () { liberator.tabs.select("$", false); });
|
||||
|
||||
liberator.commands.add(["tabm[ove]"],
|
||||
"Move the current tab after tab N",
|
||||
function (args, special)
|
||||
@@ -289,29 +363,6 @@ liberator.Tabs = function () //{{{
|
||||
liberator.tabs.move(getBrowser().mCurrentTab, args, special);
|
||||
});
|
||||
|
||||
// TODO: count support
|
||||
liberator.commands.add(["tabn[ext]", "tn[ext]"],
|
||||
"Switch to the next or [count]th tab",
|
||||
function (args)
|
||||
{
|
||||
if (!args)
|
||||
{
|
||||
liberator.tabs.select("+1", true);
|
||||
}
|
||||
else if (/^\d+$/.test(args))
|
||||
{
|
||||
var index = parseInt(args, 10) - 1;
|
||||
if (index < liberator.tabs.count)
|
||||
liberator.tabs.select(index, true);
|
||||
else
|
||||
liberator.beep();
|
||||
}
|
||||
else
|
||||
{
|
||||
liberator.echoerr("E488: Trailing characters");
|
||||
}
|
||||
});
|
||||
|
||||
liberator.commands.add(["tabo[nly]"],
|
||||
"Close all other tabs",
|
||||
function () { liberator.tabs.keepOnly(getBrowser().mCurrentTab); });
|
||||
@@ -330,24 +381,10 @@ liberator.Tabs = function () //{{{
|
||||
liberator.open("about:blank", where);
|
||||
},
|
||||
{ completer: function (filter) { return liberator.completion.url(filter); } });
|
||||
}
|
||||
|
||||
// TODO: count support
|
||||
liberator.commands.add(["tabp[revious]", "tp[revious]", "tabN[ext]", "tN[ext]"],
|
||||
"Switch to the previous tab or go [count] tabs back",
|
||||
function (args)
|
||||
if (liberator.has("session"))
|
||||
{
|
||||
if (!args)
|
||||
liberator.tabs.select("-1", true);
|
||||
else if (/^\d+$/.test(args))
|
||||
liberator.tabs.select("-" + args, true); // FIXME: urgh!
|
||||
else
|
||||
liberator.echoerr("E488: Trailing characters");
|
||||
});
|
||||
|
||||
liberator.commands.add(["tabr[ewind]", "tabfir[st]"],
|
||||
"Switch to the first tab",
|
||||
function () { liberator.tabs.select(0, false); });
|
||||
|
||||
// TODO: extract common functionality of "undoall"
|
||||
liberator.commands.add(["u[ndo]"],
|
||||
"Undo closing of a tab",
|
||||
@@ -414,8 +451,6 @@ liberator.Tabs = function () //{{{
|
||||
undoCloseTab(); // doesn't work with i as the index to undoCloseTab
|
||||
});
|
||||
|
||||
if (liberator.has("session"))
|
||||
{
|
||||
liberator.commands.add(["wqa[ll]", "wq", "xa[ll]"],
|
||||
"Save the session and quit",
|
||||
function () { liberator.quit(true); });
|
||||
@@ -431,6 +466,14 @@ liberator.Tabs = function () //{{{
|
||||
|
||||
get count() { return getBrowser().mTabs.length; },
|
||||
|
||||
get tabStrip()
|
||||
{
|
||||
if (liberator.config.hostApplication == "Firefox")
|
||||
return getBrowser().mStrip.getElementsByClassName("tabbrowser-tabs")[0];
|
||||
else if (liberator.config.hostApplication == "Thunderbird")
|
||||
return getBrowser().mStrip;
|
||||
},
|
||||
|
||||
// @returns the index of the currently selected tab starting with 0
|
||||
index: function (tab)
|
||||
{
|
||||
@@ -531,7 +574,11 @@ liberator.Tabs = function () //{{{
|
||||
// quitOnLastTab = 2: quit and save session
|
||||
remove: function (tab, count, focusLeftTab, quitOnLastTab)
|
||||
{
|
||||
function removeOrBlankTab (tab)
|
||||
var removeOrBlankTab = (function ()
|
||||
{
|
||||
if (liberator.config.hostApplication == "Firefox")
|
||||
{
|
||||
return function (tab)
|
||||
{
|
||||
if (getBrowser().mTabs.length > 1)
|
||||
getBrowser().removeTab(tab);
|
||||
@@ -546,7 +593,20 @@ liberator.Tabs = function () //{{{
|
||||
else
|
||||
liberator.beep();
|
||||
}
|
||||
};
|
||||
}
|
||||
else if (liberator.config.hostApplication == "Thunderbird")
|
||||
{
|
||||
return function (tab)
|
||||
{
|
||||
if (getBrowser().mTabs.length > 1)
|
||||
getBrowser().removeTab(tab);
|
||||
else
|
||||
liberator.beep();
|
||||
};
|
||||
}
|
||||
return function() { return null; };
|
||||
})();
|
||||
|
||||
if (typeof count != "number" || count < 1)
|
||||
count = 1;
|
||||
|
||||
Reference in New Issue
Block a user