1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-23 19:52:26 +01:00

Allow :q! and :qa!, as in vim.

This commit is contained in:
Kris Maglione
2008-09-15 21:24:51 +00:00
parent a0cbde84b1
commit 7c19363383
2 changed files with 18 additions and 20 deletions

View File

@@ -362,12 +362,12 @@ const liberator = (function () //{{{
liberator.commands.add(["q[uit]"], liberator.commands.add(["q[uit]"],
liberator.has("tabs") ? "Quit current tab" : "Quit application", liberator.has("tabs") ? "Quit current tab" : "Quit application",
function () function (args, special)
{ {
if (liberator.has("tabs")) if (liberator.has("tabs"))
liberator.tabs.remove(getBrowser().mCurrentTab, 1, false, 1); liberator.tabs.remove(getBrowser().mCurrentTab, 1, false, 1);
else else
liberator.quit(false); liberator.quit(false, special);
}, },
{ argCount: "0" }); { argCount: "0" });
@@ -963,14 +963,20 @@ const liberator = (function () //{{{
plugins: {}, plugins: {},
// quit liberator, no matter how many tabs/windows are open // quit liberator, no matter how many tabs/windows are open
quit: function (saveSession) quit: function (saveSession, force)
{ {
if (saveSession) if (saveSession)
liberator.options.setPref("browser.startup.page", 3); // start with saved session liberator.options.setPref("browser.startup.page", 3); // start with saved session
else else
liberator.options.setPref("browser.startup.page", 1); // start with default homepage session liberator.options.setPref("browser.startup.page", 1); // start with default homepage session
goQuitApplication(); const nsIAppStartup = Components.interfaces.nsIAppStartup;
if (force)
Components.classes["@mozilla.org/toolkit/app-startup;1"]
.getService(nsIAppStartup)
.quit(nsIAppStartup.eForceQuit);
else
goQuitApplication();
}, },
restart: function () restart: function ()

View File

@@ -471,9 +471,9 @@ liberator.Tabs = function () //{{{
liberator.commands.add(["quita[ll]", "qa[ll]"], liberator.commands.add(["quita[ll]", "qa[ll]"],
"Quit " + liberator.config.name, "Quit " + liberator.config.name,
function () function (args, special)
{ {
liberator.quit(false); liberator.quit(false, special);
}, },
{ argCount: "0" }); { argCount: "0" });
@@ -743,11 +743,8 @@ liberator.Tabs = function () //{{{
// quitOnLastTab = 2: quit and save session // quitOnLastTab = 2: quit and save session
remove: function (tab, count, focusLeftTab, quitOnLastTab) remove: function (tab, count, focusLeftTab, quitOnLastTab)
{ {
var removeOrBlankTab = (function () var removeOrBlankTab = {
{ Firefox: function (tab)
if (liberator.config.hostApplication == "Firefox")
{
return function (tab)
{ {
if (getBrowser().mTabs.length > 1) if (getBrowser().mTabs.length > 1)
getBrowser().removeTab(tab); getBrowser().removeTab(tab);
@@ -762,20 +759,15 @@ liberator.Tabs = function () //{{{
else else
liberator.beep(); liberator.beep();
} }
}; },
} Thunderbird: function (tab)
else if (liberator.config.hostApplication == "Thunderbird")
{
return function (tab)
{ {
if (getBrowser().mTabs.length > 1) if (getBrowser().mTabs.length > 1)
getBrowser().removeTab(tab); getBrowser().removeTab(tab);
else else
liberator.beep(); liberator.beep();
}; }
} }[liberator.config.hostApplication] || function () {};
return function () { return null; };
})();
if (typeof count != "number" || count < 1) if (typeof count != "number" || count < 1)
count = 1; count = 1;