1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-22 21:17:59 +01:00

allow :tabnext and :tabprevious to accept an arg and make gT use its count for

relative tab motion
This commit is contained in:
Doug Kearns
2007-10-30 09:03:53 +00:00
parent 4c799598a4
commit 6bc2054ce2
3 changed files with 46 additions and 14 deletions

4
NEWS
View File

@@ -1,9 +1,11 @@
<pre> <pre>
2007-XX-XX: 2007-XX-XX:
* version 0.5.3 * version 0.5.3
* new :pa[geinfo] command, and ctrl-g and g, ctrl-g mappings (thanks Marco Candrian)
* IMPORTANT! options are no longer automatically stored - use the * IMPORTANT! options are no longer automatically stored - use the
~/.vimperatorrc file instead for persistent options ~/.vimperatorrc file instead for persistent options
* :tabnext and :tabprevious now accept an argument
* the count to gT now specifies a relative tab motion like Vim
* new :pa[geinfo] command, and ctrl-g and g, ctrl-g mappings (thanks Marco Candrian)
* added new :mkvimperatorc command * added new :mkvimperatorc command
* remove :redraw and Ctrl-L commands as they rely on FF3 features * remove :redraw and Ctrl-L commands as they rely on FF3 features
* :ls, :history and :bmarks output is now hyperlinked * :ls, :history and :bmarks output is now hyperlinked

View File

@@ -178,6 +178,7 @@ vimperator.Commands = function() //{{{
return null; return null;
} }
// TODO: generalized 0 count handling -> "Zero count"
// FIXME: doesn't really belong here... // FIXME: doesn't really belong here...
// return [null, null, null, null, heredoc_tag || false]; // return [null, null, null, null, heredoc_tag || false];
// [count, cmd, special, args] = match; // [count, cmd, special, args] = match;
@@ -1470,10 +1471,30 @@ vimperator.Commands = function() //{{{
} }
)); ));
addDefaultCommand(new vimperator.Command(["tabn[ext]", "tn[ext]"], 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", if (!args)
help: "Cycles to the first tab, when the last is selected." {
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 <code class=\"argument\">{count}</code> is not specified."
} }
)); ));
addDefaultCommand(new vimperator.Command(["tabo[nly]"], addDefaultCommand(new vimperator.Command(["tabo[nly]"],
@@ -1503,11 +1524,20 @@ vimperator.Commands = function() //{{{
} }
)); ));
addDefaultCommand(new vimperator.Command(["tabp[revious]", "tp[revious]", "tabN[ext]", "tN[ext]"], 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]"], if (!args)
short_help: "Switch to the previous tab", vimperator.tabs.select("-1", true);
help: "Cycles to the last tab, when the first is selected." 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]"], addDefaultCommand(new vimperator.Command(["tabr[ewind]", "tabfir[st]"],

View File

@@ -483,19 +483,19 @@ vimperator.Mappings = function() //{{{
help: "Works like <code class=\"mapping\">P</code>, but inverts the <code class=\"option\">'activate'</code> option." help: "Works like <code class=\"mapping\">P</code>, but inverts the <code class=\"option\">'activate'</code> option."
} }
)); ));
addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["gt", "<C-n>", "<C-Tab>"], addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["gt", "<C-n>", "<C-Tab>", "<C-PageDown>"],
function(count) { vimperator.tabs.select(count > 0 ? count -1: "+1", count > 0 ? false : true); }, function(count) { vimperator.tabs.select(count > 0 ? count - 1: "+1", count > 0 ? false : true); },
{ {
short_help: "Go to the next tab", short_help: "Go to the next tab",
help: "Cycles to the first tab, when the last is selected.<br/>Count is supported: <code class=\"mapping\">3gt</code> goes to the third tab.", help: "Cycles to the first tab, when the last is selected.<br/>Count is supported: <code class=\"mapping\">3gt</code> goes to the third tab.",
flags: vimperator.Mappings.flags.COUNT flags: vimperator.Mappings.flags.COUNT
} }
)); ));
addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["gT", "<C-p>", "<C-S-Tab>"], addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["gT", "<C-p>", "<C-S-Tab>", "<C-PageUp>"],
function(count) { vimperator.tabs.select(count > 0 ? count -1: "-1", count > 0 ? false : true); }, function(count) { vimperator.tabs.select("-" + (count < 1 ? 1 : count), true); },
{ {
short_help: "Go to the previous tab", short_help: "Go {count} pages back",
help: "Cycles to the last tab, when the first is selected.<br/>Count is supported: <code class=\"mapping\">3gT</code> goes to the third tab.", help: "Wraps around from the first tab to the last tab.<br/>Count is supported: <code class=\"mapping\">3gT</code> goes three tabs back.",
flags: vimperator.Mappings.flags.COUNT flags: vimperator.Mappings.flags.COUNT
} }
)); ));