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

process link text only find modifiers \[uU] before looking for capitalized

letters when 'smartcase' is set
This commit is contained in:
Doug Kearns
2007-09-22 14:50:19 +00:00
parent 4ec9477c74
commit 145c854b5e
3 changed files with 39 additions and 17 deletions

1
NEWS
View File

@@ -1,6 +1,7 @@
<pre>
2007-XX-XX:
* version 0.5.2
* :buffer partial_string works now as in vim, and with ! even better
* merge the existing status bar with the standard FF status bar so that
security information and extension buttons are included
* added new :sidebar and :sbclose commands

View File

@@ -318,22 +318,40 @@ function Commands() //{{{
));
addDefaultCommand(new Command(["b[uffer]"],
// TODO: move to v.tabs/buffers
function(args)
function(args, special)
{
var match;
if (match = args.match(/^(\d+):?/))
return vimperator.tabs.select(parseInt(match[1]) - 1, false); // make it zero-based
var matches = [];
var lower_args = args.toLowerCase();
var first = vimperator.tabs.index() + 1;
for (var i = 0; i < getBrowser().browsers.length; i++)
{
var url = getBrowser().getBrowserAtIndex(i).contentDocument.location.href;
var index = (i + first) % getBrowser().browsers.length;
var url = getBrowser().getBrowserAtIndex(index).contentDocument.location.href;
var title = getBrowser().getBrowserAtIndex(index).contentDocument.title.toLowerCase();
if (url == args)
return vimperator.tabs.select(i, false);
return vimperator.tabs.select(index, false);
if (url.indexOf(args) >= 0 || title.indexOf(lower_args) >= 0)
matches.push(index);
}
if (matches.length == 0)
vimperator.echoerr("E94: No matching buffer for " + args);
else if (matches.length > 1 && !special)
vimperator.echoerr("E93: More than one match for " + args);
else
vimperator.tabs.select(matches[0], false);
},
{
usage: ["b[uffer] {url|index}"],
usage: ["b[uffer][!] {url|index}"],
short_help: "Go to buffer from buffer list",
help: "Argument can be either the buffer index or the full URL.<br/>" +
"If argument is neither a full URL nor an index but uniquely identifies a buffer, " +
"it is selected. With <code class=\"argument\">[!]</code> the next buffer matching the argument " +
"is selected, even if it cannot be identified uniquely.<br/>" +
"Use <code class=\"mapping\">b</code> as a shortcut to open this prompt.",
completer: function(filter) { return vimperator.completion.get_buffer_completions(filter); }
}

View File

@@ -70,6 +70,19 @@ function Search() //{{{
search_pattern = pattern;
// links only search - \u wins if both modifiers specified
if (/\\u/.test(pattern))
links_only = false;
else if (/\U/.test(pattern))
links_only = true;
else if (vimperator.options["linksearch"])
links_only = true;
else
links_only = false;
// strip links-only modifiers
pattern = pattern.replace(/(\\)?\\[uU]/g, function($0, $1) { return $1 ? $0 : "" });
// case sensitivity - \c wins if both modifiers specified
if (/\c/.test(pattern))
case_sensitive = false;
@@ -82,20 +95,10 @@ function Search() //{{{
else
case_sensitive = true;
// links only search - \u wins if both modifiers specified
if (/\\u/.test(pattern))
links_only = false;
else if (/\U/.test(pattern))
links_only = true;
else if (vimperator.options["linksearch"])
links_only = true;
else
links_only = false;
// strip case-sensitive modifiers
pattern = pattern.replace(/(\\)?\\[cC]/g, function($0, $1) { return $1 ? $0 : "" });
// strip modifiers
pattern = pattern.replace(/(\\)?\\[cCuU]/g, function($0, $1) { return $1 ? $0 : "" });
// remove the modifer escape \
// remove any modifer escape \
pattern = pattern.replace(/\\(\\[cCuU])/g, '$1')
search_string = pattern;