diff --git a/NEWS b/NEWS
index df3880b8..8556ce33 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,8 @@
2007-xx-xx:
* version 0.6
* THIS VERSION ONLY WORKS WITH FIREFOX 3.0
+ * :tabnext and :tabprevious now accept an argument
+ * the count to gT now specifies a relative tab motion like
* IMPORTANT! options are no longer automatically stored - use the
~/.vimperatorrc file instead for persistent options
* IMPORTANT! Major hints rewrite
diff --git a/content/commands.js b/content/commands.js
index 9988c080..b150f280 100644
--- a/content/commands.js
+++ b/content/commands.js
@@ -474,6 +474,7 @@ vimperator.Commands = function() //{{{
return null;
}
+ // TODO: generalized 0 count handling -> "Zero count"
// FIXME: doesn't really belong here...
// return [null, null, null, null, heredoc_tag || false];
// [count, cmd, special, args] = match;
@@ -1802,10 +1803,30 @@ vimperator.Commands = function() //{{{
}
));
addDefaultCommand(new vimperator.Command(["tabn[ext]", "tn[ext]"],
- function() { vimperator.tabs.select("+1", true); },
+ // TODO: count support
+ function(args)
{
- short_help: "Switch to the next tab",
- help: "Cycles to the first tab, when the last is selected."
+ if (!args)
+ {
+ vimperator.tabs.select("+1", true);
+ }
+ else if (/^\d+$/.test(args))
+ {
+ var index = parseInt(args) - 1;
+ if (index < vimperator.tabs.count())
+ vimperator.tabs.select(index, true);
+ else
+ vimperator.beep();
+ }
+ else
+ {
+ vimperator.echoerr("E488: Trailing characters");
+ }
+ },
+ {
+ usage: ["tabn[ext] {count}"],
+ short_help: "Switch to the next or [count]th tab",
+ help: "Cycles to the first tab when the last is selected and {count} is not specified."
}
));
addDefaultCommand(new vimperator.Command(["tabo[nly]"],
@@ -1835,11 +1856,20 @@ vimperator.Commands = function() //{{{
}
));
addDefaultCommand(new vimperator.Command(["tabp[revious]", "tp[revious]", "tabN[ext]", "tN[ext]"],
- function() { vimperator.tabs.select("-1", true); },
+ // TODO: count support
+ function(args)
{
- usage: ["tabp[revious]", "tabN[ext]"],
- short_help: "Switch to the previous tab",
- help: "Cycles to the last tab, when the first is selected."
+ if (!args)
+ vimperator.tabs.select("-1", true);
+ else if (/^\d+$/.test(args))
+ vimperator.tabs.select("-" + args, true); // FIXME: urgh!
+ else
+ vimperator.echoerr("E488: Trailing characters");
+ },
+ {
+ usage: ["tabp[revious] {count}"],
+ short_help: "Switch to the previous tab or go [count] tabs back",
+ help: "Wraps around from the first tab to the last tab."
}
));
addDefaultCommand(new vimperator.Command(["tabr[ewind]", "tabfir[st]"],
diff --git a/content/mappings.js b/content/mappings.js
index 6732decf..8c1d085d 100644
--- a/content/mappings.js
+++ b/content/mappings.js
@@ -531,19 +531,19 @@ vimperator.Mappings = function() //{{{
help: "Works like P, but inverts the 'activate' option."
}
));
- addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["gt", "", ""],
- function(count) { vimperator.tabs.select(count > 0 ? count -1: "+1", count > 0 ? false : true); },
+ addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["gt", "", "", ""],
+ function(count) { vimperator.tabs.select(count > 0 ? count - 1: "+1", count > 0 ? false : true); },
{
short_help: "Go to the next tab",
help: "Cycles to the first tab, when the last is selected.
Count is supported: 3gt goes to the third tab.",
flags: vimperator.Mappings.flags.COUNT
}
));
- addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["gT", "", ""],
- function(count) { vimperator.tabs.select(count > 0 ? count -1: "-1", count > 0 ? false : true); },
+ addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["gT", "", "", ""],
+ function(count) { vimperator.tabs.select("-" + (count < 1 ? 1 : count), true); },
{
- short_help: "Go to the previous tab",
- help: "Cycles to the last tab, when the first is selected.
Count is supported: 3gT goes to the third tab.",
+ short_help: "Go {count} pages back",
+ help: "Wraps around from the first tab to the last tab.
Count is supported: 3gT goes three tabs back.",
flags: vimperator.Mappings.flags.COUNT
}
));