mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-04-01 00:33:32 +02:00
add 'ignorecase' option
This commit is contained in:
2
NEWS
2
NEWS
@@ -1,7 +1,7 @@
|
|||||||
<pre>
|
<pre>
|
||||||
2007-xx-xx:
|
2007-xx-xx:
|
||||||
* version 0.6
|
* version 0.6
|
||||||
* add 'hlsearch' and 'incsearch' options
|
* add 'hlsearch','incsearch' and 'ignorecase' options
|
||||||
|
|
||||||
2007-09-03:
|
2007-09-03:
|
||||||
* version 0.5.1
|
* version 0.5.1
|
||||||
|
|||||||
@@ -67,11 +67,10 @@ function Search() //{{{
|
|||||||
// TODO: backwards seems impossible i fear :(
|
// TODO: backwards seems impossible i fear :(
|
||||||
this.find = function(str, backwards)
|
this.find = function(str, backwards)
|
||||||
{
|
{
|
||||||
const FIND_NORMAL = 0;
|
var fastFind = getBrowser().fastFind;
|
||||||
const FIND_TYPEAHEAD = 1;
|
|
||||||
const FIND_LINKS = 2;
|
|
||||||
|
|
||||||
found = getBrowser().fastFind.find(str, false) != Components.interfaces.nsITypeAheadFind.FIND_NOTFOUND;
|
fastFind.caseSensitive = !vimperator.options["ignorecase"];
|
||||||
|
found = fastFind.find(str, false) != Components.interfaces.nsITypeAheadFind.FIND_NOTFOUND;
|
||||||
|
|
||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
@@ -81,23 +80,26 @@ function Search() //{{{
|
|||||||
{
|
{
|
||||||
// this hack is needed to make n/N work with the correct string, if
|
// this hack is needed to make n/N work with the correct string, if
|
||||||
// we typed /foo<esc> after the original search
|
// we typed /foo<esc> after the original search
|
||||||
|
// TODO: this should also clear the current item highlighting
|
||||||
if (getBrowser().fastFind.searchString != lastsearch)
|
if (getBrowser().fastFind.searchString != lastsearch)
|
||||||
{
|
{
|
||||||
this.clear();
|
this.clear();
|
||||||
this.find(lastsearch, false);
|
this.find(lastsearch, false);
|
||||||
gFindBar._highlightDoc("yellow", "black", lastsearch);
|
this.highlight(lastsearch);
|
||||||
}
|
}
|
||||||
|
|
||||||
var up = reverse ? !lastsearch_backwards : lastsearch_backwards;
|
var up = reverse ? !lastsearch_backwards : lastsearch_backwards;
|
||||||
var result = getBrowser().fastFind.findAgain(up, false);
|
var result = getBrowser().fastFind.findAgain(up, false);
|
||||||
|
|
||||||
if (result == Components.interfaces.nsITypeAheadFind.FIND_NOTFOUND)
|
if (result == Components.interfaces.nsITypeAheadFind.FIND_NOTFOUND)
|
||||||
|
{
|
||||||
vimperator.echoerr("E486: Pattern not found: " + lastsearch);
|
vimperator.echoerr("E486: Pattern not found: " + lastsearch);
|
||||||
|
}
|
||||||
else if (result == Components.interfaces.nsITypeAheadFind.FIND_WRAPPED)
|
else if (result == Components.interfaces.nsITypeAheadFind.FIND_WRAPPED)
|
||||||
{
|
{
|
||||||
// hack needed, because wrapping causes a "scroll" event which clears
|
// hack needed, because wrapping causes a "scroll" event which clears
|
||||||
// our command line
|
// our command line
|
||||||
setTimeout( function() {
|
setTimeout(function() {
|
||||||
if (up)
|
if (up)
|
||||||
vimperator.echoerr("search hit TOP, continuing at BOTTOM");
|
vimperator.echoerr("search hit TOP, continuing at BOTTOM");
|
||||||
else
|
else
|
||||||
@@ -105,7 +107,9 @@ function Search() //{{{
|
|||||||
}, 10);
|
}, 10);
|
||||||
}
|
}
|
||||||
else // just clear the command line if something has been found
|
else // just clear the command line if something has been found
|
||||||
|
{
|
||||||
vimperator.echo("");
|
vimperator.echo("");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called when the user types a key in the search dialog. Triggers a find attempt
|
// Called when the user types a key in the search dialog. Triggers a find attempt
|
||||||
@@ -114,16 +118,15 @@ function Search() //{{{
|
|||||||
if (!vimperator.options['incsearch'])
|
if (!vimperator.options['incsearch'])
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// FIXME: isn't the global already set here? -- djk
|
this.find(command, backwards);
|
||||||
var backward = vimperator.hasMode(vimperator.modes.SEARCH_BACKWARD);
|
|
||||||
this.find(command, backward);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called when the enter key is pressed to trigger a search
|
// Called when the enter key is pressed to trigger a search
|
||||||
this.searchSubmitted = function(command)
|
this.searchSubmitted = function(command)
|
||||||
{
|
{
|
||||||
this.clear();
|
this.clear();
|
||||||
gFindBar._highlightDoc("yellow", "black", command);
|
this.find(command, backwards);
|
||||||
|
this.highlight(command);
|
||||||
|
|
||||||
// need to find again to draw the highlight of the current search
|
// need to find again to draw the highlight of the current search
|
||||||
// result over the "highlight all" search results
|
// result over the "highlight all" search results
|
||||||
@@ -147,10 +150,13 @@ function Search() //{{{
|
|||||||
vimperator.focusContent();
|
vimperator.focusContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.highlight = function()
|
this.highlight = function(word)
|
||||||
{
|
{
|
||||||
if (lastsearch)
|
if (!word)
|
||||||
gFindBar._highlightDoc("yellow", "black", lastsearch);
|
word = lastsearch;
|
||||||
|
|
||||||
|
gFindBar._setCaseSensitivity(!vimperator.options["ignorecase"])
|
||||||
|
gFindBar._highlightDoc("yellow", "black", word);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.clear = function()
|
this.clear = function()
|
||||||
|
|||||||
@@ -432,6 +432,12 @@ function Options() //{{{
|
|||||||
default_value: false
|
default_value: false
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
|
addOption(new Option(["ignorecase", "ic"], "boolean",
|
||||||
|
{
|
||||||
|
short_help: "Ignore case in search patterns",
|
||||||
|
default_value: false
|
||||||
|
}
|
||||||
|
));
|
||||||
addOption(new Option(["incsearch", "is"], "boolean",
|
addOption(new Option(["incsearch", "is"], "boolean",
|
||||||
{
|
{
|
||||||
short_help: "Show where the search pattern matches as it is typed",
|
short_help: "Show where the search pattern matches as it is typed",
|
||||||
|
|||||||
Reference in New Issue
Block a user