mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-23 05:57:58 +01:00
make use of our argsParser to handle commands with zero arguments
This commit is contained in:
@@ -154,8 +154,7 @@ liberator.Bookmarks = function () //{{{
|
|||||||
|
|
||||||
liberator.commandline.echo(list, liberator.commandline.HL_NORMAL, liberator.commandline.FORCE_MULTILINE);
|
liberator.commandline.echo(list, liberator.commandline.HL_NORMAL, liberator.commandline.FORCE_MULTILINE);
|
||||||
},
|
},
|
||||||
{}
|
{ argCount: "0" });
|
||||||
);
|
|
||||||
|
|
||||||
liberator.commands.add(["bma[rk]"],
|
liberator.commands.add(["bma[rk]"],
|
||||||
"Add a bookmark",
|
"Add a bookmark",
|
||||||
|
|||||||
@@ -460,7 +460,11 @@ liberator.Buffer = function () //{{{
|
|||||||
|
|
||||||
liberator.commands.add(["pa[geinfo]"],
|
liberator.commands.add(["pa[geinfo]"],
|
||||||
"Show various page information",
|
"Show various page information",
|
||||||
function () { liberator.buffer.showPageInfo(true); });
|
function ()
|
||||||
|
{
|
||||||
|
liberator.buffer.showPageInfo(true);
|
||||||
|
},
|
||||||
|
{ argCount: "0" });
|
||||||
|
|
||||||
liberator.commands.add(["pagest[yle]"],
|
liberator.commands.add(["pagest[yle]"],
|
||||||
"Select the author style sheet to apply",
|
"Select the author style sheet to apply",
|
||||||
@@ -485,7 +489,11 @@ liberator.Buffer = function () //{{{
|
|||||||
|
|
||||||
liberator.commands.add(["re[load]"],
|
liberator.commands.add(["re[load]"],
|
||||||
"Reload current page",
|
"Reload current page",
|
||||||
function (args, special) { liberator.tabs.reload(getBrowser().mCurrentTab, special); });
|
function (args, special)
|
||||||
|
{
|
||||||
|
liberator.tabs.reload(getBrowser().mCurrentTab, special);
|
||||||
|
},
|
||||||
|
{ argCount: "0" });
|
||||||
|
|
||||||
liberator.commands.add(["sav[eas]", "w[rite]"],
|
liberator.commands.add(["sav[eas]", "w[rite]"],
|
||||||
"Save current document to disk",
|
"Save current document to disk",
|
||||||
@@ -505,7 +513,11 @@ liberator.Buffer = function () //{{{
|
|||||||
|
|
||||||
liberator.commands.add(["st[op]"],
|
liberator.commands.add(["st[op]"],
|
||||||
"Stop loading",
|
"Stop loading",
|
||||||
function () { BrowserStop(); });
|
function ()
|
||||||
|
{
|
||||||
|
BrowserStop();
|
||||||
|
},
|
||||||
|
{ argCount: "0" });
|
||||||
|
|
||||||
liberator.commands.add(["vie[wsource]"],
|
liberator.commands.add(["vie[wsource]"],
|
||||||
"View source code of current document",
|
"View source code of current document",
|
||||||
|
|||||||
@@ -281,8 +281,8 @@ liberator.Commands = function () //{{{
|
|||||||
// @param argCount can be:
|
// @param argCount can be:
|
||||||
// "0": no arguments
|
// "0": no arguments
|
||||||
// "1": exactly one argument
|
// "1": exactly one argument
|
||||||
// "+": one or more aguments
|
// "+": one or more arguments
|
||||||
// "*": zero or more arguments
|
// "*": zero or more arguments (default if unspecified)
|
||||||
// "?": zero or one arguments
|
// "?": zero or one arguments
|
||||||
// @param allowUnknownOptions: -foo won't result in an error, if -foo isn't
|
// @param allowUnknownOptions: -foo won't result in an error, if -foo isn't
|
||||||
// specified in "options"
|
// specified in "options"
|
||||||
@@ -688,7 +688,7 @@ liberator.Commands = function () //{{{
|
|||||||
|
|
||||||
commandManager.add(["comc[lear]"],
|
commandManager.add(["comc[lear]"],
|
||||||
"Delete all user-defined commands",
|
"Delete all user-defined commands",
|
||||||
function (args)
|
function ()
|
||||||
{
|
{
|
||||||
var commands = getUserCommands();
|
var commands = getUserCommands();
|
||||||
for (var i = 0; i < commands.length; i++)
|
for (var i = 0; i < commands.length; i++)
|
||||||
|
|||||||
@@ -178,7 +178,11 @@ liberator.Editor = function () //{{{
|
|||||||
|
|
||||||
liberator.commands.add([ch + "abc[lear]"],
|
liberator.commands.add([ch + "abc[lear]"],
|
||||||
"Remove all abbreviations" + modeDescription,
|
"Remove all abbreviations" + modeDescription,
|
||||||
function (args) { liberator.editor.removeAllAbbreviations(mode); });
|
function ()
|
||||||
|
{
|
||||||
|
liberator.editor.removeAllAbbreviations(mode);
|
||||||
|
},
|
||||||
|
{ argCount: "0" });
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////}}}
|
/////////////////////////////////////////////////////////////////////////////}}}
|
||||||
|
|||||||
@@ -191,7 +191,11 @@ liberator.Search = function () //{{{
|
|||||||
|
|
||||||
liberator.commands.add(["noh[lsearch]"],
|
liberator.commands.add(["noh[lsearch]"],
|
||||||
"Remove the search highlighting",
|
"Remove the search highlighting",
|
||||||
function (args) { liberator.search.clear(); });
|
function ()
|
||||||
|
{
|
||||||
|
liberator.search.clear();
|
||||||
|
},
|
||||||
|
{ argCount: "0" });
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////}}}
|
/////////////////////////////////////////////////////////////////////////////}}}
|
||||||
////////////////////// PUBLIC SECTION //////////////////////////////////////////
|
////////////////////// PUBLIC SECTION //////////////////////////////////////////
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ liberator.IO = function () //{{{
|
|||||||
|
|
||||||
liberator.commands.add(["pw[d]"],
|
liberator.commands.add(["pw[d]"],
|
||||||
"Print the current directory name",
|
"Print the current directory name",
|
||||||
function (args)
|
function ()
|
||||||
{
|
{
|
||||||
liberator.echo(liberator.io.getCurrentDirectory());
|
liberator.echo(liberator.io.getCurrentDirectory());
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -120,11 +120,16 @@ const liberator = (function () //{{{
|
|||||||
(liberator.options["newtab"] &&
|
(liberator.options["newtab"] &&
|
||||||
(liberator.options["newtab"] == "all" || liberator.options["newtab"].split(",").indexOf("addons") != -1)) ?
|
(liberator.options["newtab"] == "all" || liberator.options["newtab"].split(",").indexOf("addons") != -1)) ?
|
||||||
liberator.NEW_TAB: liberator.CURRENT_TAB);
|
liberator.NEW_TAB: liberator.CURRENT_TAB);
|
||||||
});
|
},
|
||||||
|
{ argCount: "0" });
|
||||||
|
|
||||||
liberator.commands.add(["beep"],
|
liberator.commands.add(["beep"],
|
||||||
"Play a system beep",
|
"Play a system beep",
|
||||||
function () { liberator.beep(); });
|
function ()
|
||||||
|
{
|
||||||
|
liberator.beep();
|
||||||
|
},
|
||||||
|
{ argCount: "0" });
|
||||||
|
|
||||||
liberator.commands.add(["dia[log]"],
|
liberator.commands.add(["dia[log]"],
|
||||||
"Open a " + liberator.config.appName + " dialog",
|
"Open a " + liberator.config.appName + " dialog",
|
||||||
@@ -230,7 +235,8 @@ const liberator = (function () //{{{
|
|||||||
usage += "</table>";
|
usage += "</table>";
|
||||||
|
|
||||||
liberator.echo(usage, liberator.commandline.FORCE_MULTILINE);
|
liberator.echo(usage, liberator.commandline.FORCE_MULTILINE);
|
||||||
});
|
},
|
||||||
|
{ argCount: "0" });
|
||||||
|
|
||||||
liberator.commands.add(["h[elp]"],
|
liberator.commands.add(["h[elp]"],
|
||||||
"Display help",
|
"Display help",
|
||||||
@@ -302,11 +308,16 @@ const liberator = (function () //{{{
|
|||||||
liberator.tabs.remove(getBrowser().mCurrentTab, 1, false, 1);
|
liberator.tabs.remove(getBrowser().mCurrentTab, 1, false, 1);
|
||||||
else
|
else
|
||||||
liberator.quit(false);
|
liberator.quit(false);
|
||||||
});
|
},
|
||||||
|
{ argCount: "0" });
|
||||||
|
|
||||||
liberator.commands.add(["res[tart]"],
|
liberator.commands.add(["res[tart]"],
|
||||||
"Force " + liberator.config.appName + " to restart",
|
"Force " + liberator.config.appName + " to restart",
|
||||||
function () { liberator.restart(); });
|
function ()
|
||||||
|
{
|
||||||
|
liberator.restart();
|
||||||
|
},
|
||||||
|
{ argCount: "0" });
|
||||||
|
|
||||||
liberator.commands.add(["time"],
|
liberator.commands.add(["time"],
|
||||||
"Profile a piece of code or run a command multiple times",
|
"Profile a piece of code or run a command multiple times",
|
||||||
@@ -411,7 +422,8 @@ const liberator = (function () //{{{
|
|||||||
liberator.echo(":" + liberator.util.escapeHTML(liberator.commandline.getCommand()) + "\n" +
|
liberator.echo(":" + liberator.util.escapeHTML(liberator.commandline.getCommand()) + "\n" +
|
||||||
liberator.config.name + " " + liberator.version +
|
liberator.config.name + " " + liberator.version +
|
||||||
" running on:\n" + navigator.userAgent);
|
" running on:\n" + navigator.userAgent);
|
||||||
});
|
},
|
||||||
|
{ argCount: "0" });
|
||||||
|
|
||||||
liberator.commands.add(["viu[sage]"],
|
liberator.commands.add(["viu[sage]"],
|
||||||
"List all mappings with a short description",
|
"List all mappings with a short description",
|
||||||
@@ -427,7 +439,8 @@ const liberator = (function () //{{{
|
|||||||
usage += "</table>";
|
usage += "</table>";
|
||||||
|
|
||||||
liberator.echo(usage, liberator.commandline.FORCE_MULTILINE);
|
liberator.echo(usage, liberator.commandline.FORCE_MULTILINE);
|
||||||
});
|
},
|
||||||
|
{ argCount: "0" });
|
||||||
}
|
}
|
||||||
|
|
||||||
function getHelpCompletions(filter)
|
function getHelpCompletions(filter)
|
||||||
|
|||||||
@@ -725,7 +725,7 @@ liberator.Mail = function () //{{{
|
|||||||
|
|
||||||
liberator.commands.add(["empty[trash]"],
|
liberator.commands.add(["empty[trash]"],
|
||||||
"Empty trash of the current account",
|
"Empty trash of the current account",
|
||||||
function (args, special)
|
function ()
|
||||||
{
|
{
|
||||||
goDoCommand("cmd_emptyTrash");
|
goDoCommand("cmd_emptyTrash");
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -211,7 +211,7 @@ liberator.Mappings = function () //{{{
|
|||||||
|
|
||||||
liberator.commands.add([ch + "mapc[lear]"],
|
liberator.commands.add([ch + "mapc[lear]"],
|
||||||
"Remove all mappings" + modeDescription,
|
"Remove all mappings" + modeDescription,
|
||||||
function (args)
|
function ()
|
||||||
{
|
{
|
||||||
for (let i = 0; i < modes.length; i++)
|
for (let i = 0; i < modes.length; i++)
|
||||||
liberator.mappings.removeAll(modes[i]);
|
liberator.mappings.removeAll(modes[i]);
|
||||||
|
|||||||
@@ -321,7 +321,7 @@ liberator.Options = function () //{{{
|
|||||||
|
|
||||||
liberator.commands.add(["pref[erences]", "prefs"],
|
liberator.commands.add(["pref[erences]", "prefs"],
|
||||||
"Show " + liberator.config.hostApplication + " preferences",
|
"Show " + liberator.config.hostApplication + " preferences",
|
||||||
function (args, special, count, modifiers)
|
function (args, special)
|
||||||
{
|
{
|
||||||
if (special) // open Firefox settings GUI dialog
|
if (special) // open Firefox settings GUI dialog
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -303,7 +303,11 @@ liberator.Tabs = function () //{{{
|
|||||||
|
|
||||||
liberator.commands.add(["tabl[ast]", "bl[ast]"],
|
liberator.commands.add(["tabl[ast]", "bl[ast]"],
|
||||||
"Switch to the last tab",
|
"Switch to the last tab",
|
||||||
function () { liberator.tabs.select("$", false); });
|
function ()
|
||||||
|
{
|
||||||
|
liberator.tabs.select("$", false);
|
||||||
|
},
|
||||||
|
{ argCount: "0" });
|
||||||
|
|
||||||
// TODO: "Zero count" if 0 specified as arg
|
// TODO: "Zero count" if 0 specified as arg
|
||||||
liberator.commands.add(["tabp[revious]", "tp[revious]", "tabN[ext]", "tN[ext]", "bp[revious]", "bN[ext]"],
|
liberator.commands.add(["tabp[revious]", "tp[revious]", "tabN[ext]", "tN[ext]", "bp[revious]", "bN[ext]"],
|
||||||
@@ -368,7 +372,11 @@ liberator.Tabs = function () //{{{
|
|||||||
|
|
||||||
liberator.commands.add(["tabr[ewind]", "tabfir[st]", "br[ewind]", "bf[irst]"],
|
liberator.commands.add(["tabr[ewind]", "tabfir[st]", "br[ewind]", "bf[irst]"],
|
||||||
"Switch to the first tab",
|
"Switch to the first tab",
|
||||||
function () { liberator.tabs.select(0, false); });
|
function ()
|
||||||
|
{
|
||||||
|
liberator.tabs.select(0, false);
|
||||||
|
},
|
||||||
|
{ argCount: "0" });
|
||||||
|
|
||||||
|
|
||||||
if (liberator.config.name == "Vimperator")
|
if (liberator.config.name == "Vimperator")
|
||||||
@@ -408,11 +416,19 @@ liberator.Tabs = function () //{{{
|
|||||||
|
|
||||||
liberator.commands.add(["quita[ll]", "qa[ll]"],
|
liberator.commands.add(["quita[ll]", "qa[ll]"],
|
||||||
"Quit " + liberator.config.appName,
|
"Quit " + liberator.config.appName,
|
||||||
function () { liberator.quit(false); });
|
function ()
|
||||||
|
{
|
||||||
|
liberator.quit(false);
|
||||||
|
},
|
||||||
|
{ argCount: "0" });
|
||||||
|
|
||||||
liberator.commands.add(["reloada[ll]"],
|
liberator.commands.add(["reloada[ll]"],
|
||||||
"Reload all tab pages",
|
"Reload all tab pages",
|
||||||
function (args, special) { liberator.tabs.reloadAll(special); });
|
function (args, special)
|
||||||
|
{
|
||||||
|
liberator.tabs.reloadAll(special);
|
||||||
|
},
|
||||||
|
{ argCount: "0" });
|
||||||
|
|
||||||
// TODO: add count support
|
// TODO: add count support
|
||||||
liberator.commands.add(["tabm[ove]"],
|
liberator.commands.add(["tabm[ove]"],
|
||||||
@@ -434,7 +450,11 @@ liberator.Tabs = function () //{{{
|
|||||||
|
|
||||||
liberator.commands.add(["tabo[nly]"],
|
liberator.commands.add(["tabo[nly]"],
|
||||||
"Close all other tabs",
|
"Close all other tabs",
|
||||||
function () { liberator.tabs.keepOnly(getBrowser().mCurrentTab); });
|
function ()
|
||||||
|
{
|
||||||
|
liberator.tabs.keepOnly(getBrowser().mCurrentTab);
|
||||||
|
},
|
||||||
|
{ argCount: "0" });
|
||||||
|
|
||||||
liberator.commands.add(["tabopen", "t[open]", "tabnew", "tabe[dit]"],
|
liberator.commands.add(["tabopen", "t[open]", "tabnew", "tabe[dit]"],
|
||||||
"Open one or more URLs in a new tab",
|
"Open one or more URLs in a new tab",
|
||||||
@@ -466,7 +486,8 @@ liberator.Tabs = function () //{{{
|
|||||||
|
|
||||||
for (var i = 0; i < count; i++)
|
for (var i = 0; i < count; i++)
|
||||||
liberator.tabs.cloneTab(tab, activate);
|
liberator.tabs.cloneTab(tab, activate);
|
||||||
});
|
},
|
||||||
|
{ argCount: "0" });
|
||||||
}
|
}
|
||||||
|
|
||||||
if (liberator.has("session"))
|
if (liberator.has("session"))
|
||||||
@@ -535,11 +556,16 @@ liberator.Tabs = function () //{{{
|
|||||||
var undoItems = eval("(" + ss.getClosedTabData(window) + ")");
|
var undoItems = eval("(" + ss.getClosedTabData(window) + ")");
|
||||||
for (var i = 0; i < undoItems.length; i++)
|
for (var i = 0; i < undoItems.length; i++)
|
||||||
undoCloseTab(); // doesn't work with i as the index to undoCloseTab
|
undoCloseTab(); // doesn't work with i as the index to undoCloseTab
|
||||||
});
|
},
|
||||||
|
{ argCount: "0" });
|
||||||
|
|
||||||
liberator.commands.add(["wqa[ll]", "wq", "xa[ll]"],
|
liberator.commands.add(["wqa[ll]", "wq", "xa[ll]"],
|
||||||
"Save the session and quit",
|
"Save the session and quit",
|
||||||
function () { liberator.quit(true); });
|
function ()
|
||||||
|
{
|
||||||
|
liberator.quit(true);
|
||||||
|
},
|
||||||
|
{ argCount: "0" });
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////}}}
|
/////////////////////////////////////////////////////////////////////////////}}}
|
||||||
|
|||||||
@@ -256,7 +256,8 @@ liberator.config = { //{{{
|
|||||||
liberator.open("chrome://mozapps/content/downloads/downloads.xul",
|
liberator.open("chrome://mozapps/content/downloads/downloads.xul",
|
||||||
(liberator.options["newtab"] == "all" || liberator.options["newtab"].split(",").indexOf("downloads") != -1) ?
|
(liberator.options["newtab"] == "all" || liberator.options["newtab"].split(",").indexOf("downloads") != -1) ?
|
||||||
liberator.NEW_TAB : liberator.CURRENT_TAB);
|
liberator.NEW_TAB : liberator.CURRENT_TAB);
|
||||||
});
|
},
|
||||||
|
{ argCount: "0" });
|
||||||
|
|
||||||
liberator.commands.add(["o[pen]", "e[dit]"],
|
liberator.commands.add(["o[pen]", "e[dit]"],
|
||||||
"Open one or more URLs in the current tab",
|
"Open one or more URLs in the current tab",
|
||||||
@@ -285,12 +286,13 @@ liberator.config = { //{{{
|
|||||||
var wu = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor).
|
var wu = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor).
|
||||||
getInterface(Components.interfaces.nsIDOMWindowUtils);
|
getInterface(Components.interfaces.nsIDOMWindowUtils);
|
||||||
wu.redraw();
|
wu.redraw();
|
||||||
});
|
},
|
||||||
|
{ argCount: "0" });
|
||||||
|
|
||||||
// TODO: move sidebar commands to ui.js?
|
// TODO: move sidebar commands to ui.js?
|
||||||
liberator.commands.add(["sbcl[ose]"],
|
liberator.commands.add(["sbcl[ose]"],
|
||||||
"Close the sidebar window",
|
"Close the sidebar window",
|
||||||
function (args)
|
function ()
|
||||||
{
|
{
|
||||||
if (document.getElementById("sidebar-box").hidden == false)
|
if (document.getElementById("sidebar-box").hidden == false)
|
||||||
toggleSidebar();
|
toggleSidebar();
|
||||||
@@ -335,7 +337,11 @@ liberator.config = { //{{{
|
|||||||
|
|
||||||
liberator.commands.add(["winc[lose]", "wc[lose]"],
|
liberator.commands.add(["winc[lose]", "wc[lose]"],
|
||||||
"Close window",
|
"Close window",
|
||||||
function (args) { window.close(); });
|
function ()
|
||||||
|
{
|
||||||
|
window.close();
|
||||||
|
},
|
||||||
|
{ argCount: "0" });
|
||||||
|
|
||||||
liberator.commands.add(["wino[pen]", "wo[pen]", "wine[dit]"],
|
liberator.commands.add(["wino[pen]", "wo[pen]", "wine[dit]"],
|
||||||
"Open one or more URLs in a new window",
|
"Open one or more URLs in a new window",
|
||||||
|
|||||||
Reference in New Issue
Block a user