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

add count property to Command's extraInfo to specify whether the command

accepts a count/range
This commit is contained in:
Doug Kearns
2008-10-06 10:42:06 +00:00
parent e38798f66c
commit 0c03963cf9
7 changed files with 46 additions and 36 deletions

View File

@@ -628,7 +628,8 @@ liberator.History = function () //{{{
completions.push([url, title]); completions.push([url, title]);
} }
return [0, completions]; return [0, completions];
} },
count: true
}); });
liberator.commands.add(["fo[rward]", "fw"], liberator.commands.add(["fo[rward]", "fw"],
@@ -675,7 +676,8 @@ liberator.History = function () //{{{
completions.push([url, title]); completions.push([url, title]);
} }
return [0, completions]; return [0, completions];
} },
count: true
}); });
liberator.commands.add(["hist[ory]", "hs"], liberator.commands.add(["hist[ory]", "hs"],

View File

@@ -79,6 +79,7 @@ liberator.Command = function (specs, description, action, extraInfo) //{{{
this.hereDoc = extraInfo.hereDoc || false; this.hereDoc = extraInfo.hereDoc || false;
this.options = extraInfo.options || []; this.options = extraInfo.options || [];
this.bang = extraInfo.bang || false; this.bang = extraInfo.bang || false;
this.count = extraInfo.count || false;
this.isUserCommand = extraInfo.isUserCommand || false; this.isUserCommand = extraInfo.isUserCommand || false;
this.replacementText = extraInfo.replacementText || null; this.replacementText = extraInfo.replacementText || null;

View File

@@ -492,7 +492,8 @@ const liberator = (function () //{{{
return liberator.completion.ex(filter); return liberator.completion.ex(filter);
else else
return liberator.completion.javascript(filter); return liberator.completion.javascript(filter);
} },
count: true
}); });
liberator.commands.add(["ve[rsion]"], liberator.commands.add(["ve[rsion]"],
@@ -710,34 +711,34 @@ const liberator = (function () //{{{
if (/^\s*("|$)/.test(str)) if (/^\s*("|$)/.test(str))
return; return;
if (!modifiers) modifiers = modifiers || {};
modifiers = {};
var [count, cmd, special, args] = liberator.commands.parseCommand(str.replace(/^'(.*)'$/, "$1")); let err = null;
var command = liberator.commands.get(cmd); let [count, cmd, special, args] = liberator.commands.parseCommand(str.replace(/^'(.*)'$/, "$1"));
let command = liberator.commands.get(cmd);
if (command === null) if (command === null)
{ {
liberator.echoerr("E492: Not a browser command: " + str); err = "E492: Not a browser command: " + str;
liberator.focusContent(); liberator.focusContent();
return;
} }
else if (command.action === null)
// TODO: need to perform this test? -- djk
if (command.action === null)
{ {
liberator.echoerr("E666: Internal error: command.action === null"); err = "E666: Internal error: command.action === null"; // TODO: need to perform this test? -- djk
return;
} }
else if (count != -1 && !command.count)
if (special && !command.bang)
{ {
liberator.echoerr("E477: No ! allowed"); err = "E481: No range allowed";
return; }
else if (special && !command.bang)
{
err = "E477: No ! allowed";
} }
// valid command, call it: if (!err)
command.execute(args, special, count, modifiers); command.execute(args, special, count, modifiers);
else
liberator.echoerr(err);
}, },
// TODO: move to liberator.buffer.focus()? // TODO: move to liberator.buffer.focus()?

View File

@@ -678,11 +678,14 @@ liberator.Mail = function () //{{{
else else
SelectFolder(folder.URI); SelectFolder(folder.URI);
}, },
{ completer: function (filter) getFolderCompletions(filter) }); {
completer: function (filter) getFolderCompletions(filter),
count: true
});
liberator.commands.add(["m[essage]"], liberator.commands.add(["m[essage]"],
"Write a new message", "Write a new message",
function (args, special, count) function (args)
{ {
var mailargs = {}; var mailargs = {};
mailargs.to = args.arguments.join(", "); mailargs.to = args.arguments.join(", ");

View File

@@ -390,6 +390,7 @@ liberator.Options = function () //{{{
}, },
{ {
bang: true, bang: true,
count: true,
completer: function (filter, special, count) completer: function (filter, special, count)
{ {
return liberator.commands.get("set").completer(filter, special, count, { scope: liberator.options.OPTION_SCOPE_LOCAL }); return liberator.commands.get("set").completer(filter, special, count, { scope: liberator.options.OPTION_SCOPE_LOCAL });
@@ -405,6 +406,7 @@ liberator.Options = function () //{{{
}, },
{ {
bang: true, bang: true,
count: true,
completer: function (filter, special, count) completer: function (filter, special, count)
{ {
return liberator.commands.get("set").completer(filter, special, count, { scope: liberator.options.OPTION_SCOPE_GLOBAL }); return liberator.commands.get("set").completer(filter, special, count, { scope: liberator.options.OPTION_SCOPE_GLOBAL });

View File

@@ -345,6 +345,7 @@ liberator.Tabs = function () //{{{
}, },
{ {
bang: true, bang: true,
count: true,
completer: function (filter) liberator.completion.buffer(filter) completer: function (filter) liberator.completion.buffer(filter)
}); });
@@ -385,7 +386,8 @@ liberator.Tabs = function () //{{{
{ {
liberator.tabs.select("-1", true); liberator.tabs.select("-1", true);
} }
}); },
{ count: true });
// TODO: "Zero count" if 0 specified as arg // TODO: "Zero count" if 0 specified as arg
liberator.commands.add(["tabn[ext]", "tn[ext]", "bn[ext]"], liberator.commands.add(["tabn[ext]", "tn[ext]", "bn[ext]"],
@@ -423,7 +425,8 @@ liberator.Tabs = function () //{{{
{ {
liberator.tabs.select("+1", true); liberator.tabs.select("+1", true);
} }
}); },
{ count: true });
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",
@@ -457,6 +460,7 @@ liberator.Tabs = function () //{{{
}, },
{ {
bang: true, bang: true,
count: true,
completer: function (filter) liberator.completion.buffer(filter) completer: function (filter) liberator.completion.buffer(filter)
}); });
@@ -528,11 +532,8 @@ liberator.Tabs = function () //{{{
liberator.commands.add(["tabde[tach]"], liberator.commands.add(["tabde[tach]"],
"Detach current tab to its own window", "Detach current tab to its own window",
function (args, special, count) { liberator.tabs.detachTab(null); }, function () { liberator.tabs.detachTab(null); },
{ { argCount: "0" });
argCount: "0",
bang: true
});
liberator.commands.add(["tabd[uplicate]"], liberator.commands.add(["tabd[uplicate]"],
"Duplicate current tab", "Duplicate current tab",
@@ -552,7 +553,8 @@ liberator.Tabs = function () //{{{
}, },
{ {
argCount: "0", argCount: "0",
bang: true bang: true,
count: true
}); });
} }
@@ -598,7 +600,8 @@ liberator.Tabs = function () //{{{
completions.push([url, title]); completions.push([url, title]);
} }
return [0, completions]; return [0, completions];
} },
count: true
}); });
liberator.commands.add(["undoa[ll]"], liberator.commands.add(["undoa[ll]"],
@@ -624,7 +627,8 @@ liberator.Tabs = function () //{{{
}, },
{ {
argCount: "0", argCount: "0",
bang: true bang: true,
count: true
}); });
liberator.commands.add(["wqa[ll]", "wq", "xa[ll]"], liberator.commands.add(["wqa[ll]", "wq", "xa[ll]"],

View File

@@ -345,10 +345,7 @@ liberator.config = { //{{{
liberator.commands.add(["winc[lose]", "wc[lose]"], liberator.commands.add(["winc[lose]", "wc[lose]"],
"Close window", "Close window",
function () function () { window.close(); },
{
window.close();
},
{ argCount: "0" }); { argCount: "0" });
liberator.commands.add(["wino[pen]", "wo[pen]", "wine[dit]"], liberator.commands.add(["wino[pen]", "wo[pen]", "wine[dit]"],