1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-22 23:37:58 +01:00

add ]n and ]p mappings for navigating document relationships defined by the

'nextpattern' and 'previouspattern' options - thanks kidd
This commit is contained in:
Doug Kearns
2007-11-15 02:43:13 +00:00
parent 20e176ee01
commit 5b8d9a05e1
5 changed files with 73 additions and 3 deletions

View File

@@ -15,4 +15,5 @@ Patches:
* Hannes Rist (:set titlestring support)
* Nikolai Weibull ($VIMPERATOR_HOME)
* Joseph Xu (supporting multiple top level windows better)
* Raimon Grau Cusc'o (document relationship navigation - ]n, ]p)
</pre>

4
NEWS
View File

@@ -8,6 +8,8 @@
read up the new help for the f, F and ; commands for details
removed the following hint options: 'hintchars' 'maxhints'
added the following hint options: 'hinttimeout'
* added ]n and ]p to navigate to the next/previous document based on
the regexp specified in 'nextpattern' and 'previouspattern' (thanks kidd)
* abbreviations for text fields (:abbr etc.) (thanks calmar)
* you can edit textfields with Ctrl-i now using an external editor (thanks to Joseph Xu)
* :open, :bmarks, etc. filter on space separated tokens now, so you can
@@ -24,7 +26,7 @@
* support for * and # mappings to search for the text selection or the text under the cursor
* Escape finally clears any selection made in the document
* initial start of caret mode. Start with 'i', stop with Escape;
* many small bug fixes and enhancments
* many small bug fixes and enhancements
2007-10-11:
* version 0.5.2

View File

@@ -769,8 +769,43 @@ vimperator.Buffer = function () //{{{
}
}
vimperator.echo(pageInfoText, vimperator.commandline.FORCE_MULTILINE);
},
followDocumentRelation: function (relation)
{
var regexps;
var relText;
var patternText;
switch (relation)
{
case "next":
regexps = vimperator.options["nextpattern"].split(",");
relText = "next";
break;
case "previous":
//TODO: accept prev\%[ious]
regexps = vimperator.options["previouspattern"].split(",");
relText = "previous";
break;
default: vimperator.echoerr("bad relation");
}
relText = new RegExp(relText);
var elems = window.content.document.getElementsByTagName('a');
for (pattern = 0; pattern < regexps.length; pattern++)
{
patternText = new RegExp(regexps[pattern]);
for (i = 0; i < elems.length; i++)
{
if (patternText.test(elems[i].text) || relText.test(elems[i].rel) )
{
vimperator.buffer.followLink(elems[i],vimperator.CURRENT_TAB);
return;
}
}
}
vimperator.beep();
}
};
//}}}
}; //}}}

View File

@@ -414,6 +414,22 @@ vimperator.Mappings = function () //{{{
flags: vimperator.Mappings.flags.COUNT
}
));
addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["]n"],
function (count) {vimperator.buffer.followDocumentRelation("next");},
{
short_help: "go to 'next' or '>' if it exists. Beep otherwise.",
help: "Opens link labeled with next or >. Useful when browsing forums or documentation. Change nextpattern to modify its behaviour. It follows relations between files too.",
flags: vimperator.Mappings.flags.COUNT
}
));
addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["]p"],
function (count) {vimperator.buffer.followDocumentRelation("previous");},
{
short_help: "go to 'prev', 'previous' or '<' if it exists. Beep otherwise.",
help: "Opens link labeled with prev, previous or <. Useful when browsing forums or documentation. Change nextpattern to modify its behaviour. It follows relations between files too.",
flags: vimperator.Mappings.flags.COUNT
}
));
addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["b"],
function () { vimperator.commandline.open(":", "buffer! ", vimperator.modes.EX); },
{

View File

@@ -768,6 +768,22 @@ vimperator.Options = function () //{{{
validator: function (value) { return /^(sort|)$/.test(value); }
}
));
this.add(new vimperator.Option(["nextpattern"], "stringlist",
{
short_help: "String to search when looking for 'next' page in document relation",
help: "Change it to make it look for another string in links when pressing ]n<br/>" +
"This value is case insensitive",
default_value: "\\bnext,^>$"
}
));
this.add(new vimperator.Option(["previouspattern"], "stringlist",
{
short_help: "String to search when looking for 'prev' page in document relation",
help: "Change it to make it look for another string in links when pressing ]p<br/>" +
"This value is case insensitive",
default_value: "\\bprev,previous\\b,^<$"
}
));
//}}}
// we start with an "empty" GUI so that no toolbars or tabbar is shown if the user