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

add prefix count support to :tabprevious, :bprevious, :tabnext, :bnext etc

This commit is contained in:
Doug Kearns
2008-08-12 11:23:01 +00:00
parent 66c46a8b53
commit 16a9c56fbe
3 changed files with 52 additions and 24 deletions

1
NEWS
View File

@@ -15,6 +15,7 @@
generous donation which made this behavior possible) generous donation which made this behavior possible)
* IMPORTANT: ctrl-x/a never take possible negative URLs into account, it was just * IMPORTANT: ctrl-x/a never take possible negative URLs into account, it was just
too unpredictable too unpredictable
* :tabprevious, :bprevious, :tabnext, :bnext and friends now accept a prefix count
* add :comclear and :delcommand * add :comclear and :delcommand
* add a special version to :hardcopy to skip the Print dialog * add a special version to :hardcopy to skip the Print dialog
* add :bl[ast], :bf[irst], :br[ewind] to go to first/last tab * add :bl[ast], :bf[irst], :br[ewind] to go to first/last tab

View File

@@ -304,31 +304,56 @@ liberator.Tabs = function () //{{{
"Switch to the last tab", "Switch to the last tab",
function () { liberator.tabs.select("$", false); }); function () { liberator.tabs.select("$", false); });
// TODO: count support // 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]"],
"Switch to the previous tab or go [count] tabs back", "Switch to the previous tab or go [count] tabs back",
function (args) function (args, special, count)
{ {
if (!args) // count is ignored if an arg is specified, as per Vim
liberator.tabs.select("-1", true); if (args)
else if (/^\d+$/.test(args)) {
if (/^\d+$/.test(args))
liberator.tabs.select("-" + args, true); // FIXME: urgh! liberator.tabs.select("-" + args, true); // FIXME: urgh!
else else
liberator.echoerr("E488: Trailing characters"); liberator.echoerr("E488: Trailing characters");
}
else if (count > 0)
{
liberator.tabs.select("-" + count, true);
}
else
{
liberator.tabs.select("-1", true);
}
}); });
// TODO: count support // 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]"],
"Switch to the next or [count]th tab", "Switch to the next or [count]th tab",
function (args) function (args, special, count)
{ {
if (!args) if (args || count > 0)
{ {
liberator.tabs.select("+1", true); var index;
// count is ignored if an arg is specified, as per Vim
if (args)
{
if (/^\d+$/.test(args))
{
index = args - 1;
} }
else if (/^\d+$/.test(args)) else
{ {
var index = parseInt(args, 10) - 1; liberator.echoerr("E488: Trailing characters");
return;
}
}
else
{
index = count - 1;
}
if (index < liberator.tabs.count) if (index < liberator.tabs.count)
liberator.tabs.select(index, true); liberator.tabs.select(index, true);
else else
@@ -336,7 +361,7 @@ liberator.Tabs = function () //{{{
} }
else else
{ {
liberator.echoerr("E488: Trailing characters"); liberator.tabs.select("+1", true);
} }
}); });
@@ -347,6 +372,7 @@ liberator.Tabs = function () //{{{
if (liberator.config.name == "Vimperator") if (liberator.config.name == "Vimperator")
{ {
// TODO: add count support
liberator.commands.add(["b[uffer]"], liberator.commands.add(["b[uffer]"],
"Switch to a buffer", "Switch to a buffer",
function (args, special) { liberator.tabs.switchTo(args, special); }, function (args, special) { liberator.tabs.switchTo(args, special); },
@@ -373,6 +399,7 @@ liberator.Tabs = function () //{{{
"Reload all tab pages", "Reload all tab pages",
function (args, special) { liberator.tabs.reloadAll(special); }); function (args, special) { liberator.tabs.reloadAll(special); });
// TODO: add count support
liberator.commands.add(["tabm[ove]"], liberator.commands.add(["tabm[ove]"],
"Move the current tab after tab N", "Move the current tab after tab N",
function (args, special) function (args, special)

View File

@@ -120,9 +120,9 @@ ________________________________________________________________________________
|:bn| |:bnext| |:tn| |:tnext| |:tabn| |:tabnext| |:bn| |:bnext| |:tn| |:tnext| |:tabn| |:tabnext|
||:tabn[ext] [count]|| + ||:[count]tabn[ext] [count]|| +
||:tn[ext] [count]|| + ||:[count]tn[ext] [count]|| +
||:bn[ext] [count]|| ||:[count]bn[ext] [count]||
________________________________________________________________________________ ________________________________________________________________________________
Switch to the next or [count]th tab. Cycles to the first tab when the last is Switch to the next or [count]th tab. Cycles to the first tab when the last is
selected and {count} is not specified. selected and {count} is not specified.
@@ -137,11 +137,11 @@ ________________________________________________________________________________
|:bN| |:bNext| |:bp| |:bprevious| |:tN| |:tNext| |:tabN| |:tabNext| |:tp| |:tprevious| |:tabp| |:tabprevious| |:bN| |:bNext| |:bp| |:bprevious| |:tN| |:tNext| |:tabN| |:tabNext| |:tp| |:tprevious| |:tabp| |:tabprevious|
||:tabp[revious] [count]|| + ||:[count]tabp[revious] [count]|| +
||:tp[revious] [count]|| + ||:[count]tp[revious] [count]|| +
||:tabN[ext] [count]|| + ||:[count]tabN[ext] [count]|| +
||:bp[revious] [count]|| + ||:[count]bp[revious] [count]|| +
||:bN[ext] [count]|| ||:[count]bN[ext] [count]||
________________________________________________________________________________ ________________________________________________________________________________
Switch to the previous tab or go [count] tabs back. Wraps around from the Switch to the previous tab or go [count] tabs back. Wraps around from the
first tab to the last tab. first tab to the last tab.