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

Use 'find' terminology for page search to differentiate from web search.

This commit is contained in:
Kris Maglione
2010-12-18 12:19:33 -05:00
parent 118e3cf42a
commit 716e8cea94
4 changed files with 89 additions and 85 deletions

View File

@@ -9,7 +9,7 @@
/** @instance rangefinder */ /** @instance rangefinder */
const RangeFinder = Module("rangefinder", { const RangeFinder = Module("rangefinder", {
init: function () { init: function () {
this.lastSearchPattern = ""; this.lastFindPattern = "";
}, },
openPrompt: function (mode) { openPrompt: function (mode) {
@@ -29,8 +29,8 @@ const RangeFinder = Module("rangefinder", {
let selections = this.rangeFind && this.rangeFind.selections; let selections = this.rangeFind && this.rangeFind.selections;
let linksOnly = false; let linksOnly = false;
let regexp = false; let regexp = false;
let matchCase = options["searchcase"] === "smart" ? /[A-Z]/.test(str) : let matchCase = options["findcase"] === "smart" ? /[A-Z]/.test(str) :
options["searchcase"] === "ignore" ? false : true; options["findcase"] === "ignore" ? false : true;
str = str.replace(/\\(.|$)/g, function (m, n1) { str = str.replace(/\\(.|$)/g, function (m, n1) {
if (n1 == "c") if (n1 == "c")
@@ -65,12 +65,12 @@ const RangeFinder = Module("rangefinder", {
this.rangeFind.highlighted = highlighted; this.rangeFind.highlighted = highlighted;
this.rangeFind.selections = selections; this.rangeFind.selections = selections;
} }
return this.lastSearchPattern = str; return this.lastFindPattern = str;
}, },
find: function (pattern, backwards) { find: function (pattern, backwards) {
let str = this.bootstrap(pattern, backwards); let str = this.bootstrap(pattern, backwards);
if (!this.rangeFind.search(str)) if (!this.rangeFind.find(str))
this.timeout(function () { dactyl.echoerr("E486: Pattern not found: " + pattern); }, 0); this.timeout(function () { dactyl.echoerr("E486: Pattern not found: " + pattern); }, 0);
return this.rangeFind.found; return this.rangeFind.found;
@@ -78,47 +78,47 @@ const RangeFinder = Module("rangefinder", {
findAgain: function (reverse) { findAgain: function (reverse) {
if (!this.rangeFind) if (!this.rangeFind)
this.find(this.lastSearchPattern); this.find(this.lastFindPattern);
else if (!this.rangeFind.search(null, reverse)) else if (!this.rangeFind.find(null, reverse))
dactyl.echoerr("E486: Pattern not found: " + this.lastSearchPattern); dactyl.echoerr("E486: Pattern not found: " + this.lastFindPattern);
else if (this.rangeFind.wrapped) else if (this.rangeFind.wrapped)
// hack needed, because wrapping causes a "scroll" event which // hack needed, because wrapping causes a "scroll" event which
// clears our command line // clears our command line
this.timeout(function () { this.timeout(function () {
let msg = this.rangeFind.backward ? "search hit TOP, continuing at BOTTOM" let msg = this.rangeFind.backward ? "find hit TOP, continuing at BOTTOM"
: "search hit BOTTOM, continuing at TOP"; : "find hit BOTTOM, continuing at TOP";
commandline.echo(msg, commandline.HL_WARNINGMSG, commandline.echo(msg, commandline.HL_WARNINGMSG,
commandline.APPEND_TO_MESSAGES | commandline.FORCE_SINGLELINE); commandline.APPEND_TO_MESSAGES | commandline.FORCE_SINGLELINE);
}, 0); }, 0);
else else
commandline.echo((this.rangeFind.backward ? "?" : "/") + this.lastSearchPattern, null, commandline.FORCE_SINGLELINE); commandline.echo((this.rangeFind.backward ? "?" : "/") + this.lastFindPattern, null, commandline.FORCE_SINGLELINE);
if (options["hlsearch"]) if (options["hlfind"])
this.highlight(); this.highlight();
this.rangeFind.focus(); this.rangeFind.focus();
}, },
// Called when the user types a key in the search dialog. Triggers a find attempt if 'incsearch' is set // Called when the user types a key in the find dialog. Triggers a find attempt if 'incfind' is set
onKeyPress: function (command) { onKeyPress: function (command) {
if (options["incsearch"]) { if (options["incfind"]) {
command = this.bootstrap(command); command = this.bootstrap(command);
this.rangeFind.search(command); this.rangeFind.find(command);
} }
}, },
onSubmit: function (command) { onSubmit: function (command) {
if (!options["incsearch"] || !this.rangeFind || !this.rangeFind.found) { if (!options["incfind"] || !this.rangeFind || !this.rangeFind.found) {
this.clear(); this.clear();
this.find(command || this.lastSearchPattern, modes.extended & modes.FIND_BACKWARD); this.find(command || this.lastFindPattern, modes.extended & modes.FIND_BACKWARD);
} }
if (options["hlsearch"]) if (options["hlfind"])
this.highlight(); this.highlight();
this.rangeFind.focus(); this.rangeFind.focus();
}, },
// Called when the search is canceled - for example if someone presses // Called when the find is canceled - for example if someone presses
// escape while typing a search // escape while typing a find
onCancel: function () { onCancel: function () {
if (this.rangeFind) if (this.rangeFind)
this.rangeFind.cancel(); this.rangeFind.cancel();
@@ -128,7 +128,7 @@ const RangeFinder = Module("rangefinder", {
set rangeFind(val) buffer.localStore.rangeFind = val, set rangeFind(val) buffer.localStore.rangeFind = val,
/** /**
* Highlights all occurrences of the last searched for string in the * Highlights all occurrences of the last finded for string in the
* current buffer. * current buffer.
*/ */
highlight: function () { highlight: function () {
@@ -137,7 +137,7 @@ const RangeFinder = Module("rangefinder", {
}, },
/** /**
* Clears all search highlighting. * Clears all find highlighting.
*/ */
clear: function () { clear: function () {
if (this.rangeFind) if (this.rangeFind)
@@ -159,8 +159,8 @@ const RangeFinder = Module("rangefinder", {
commandline.registerCallback("cancel", modes.FIND_BACKWARD, this.closure.onCancel); commandline.registerCallback("cancel", modes.FIND_BACKWARD, this.closure.onCancel);
}, },
commands: function () { commands: function () {
commands.add(["noh[lsearch]"], commands.add(["noh[lfind]"],
"Remove the search highlighting", "Remove the find highlighting",
function () { rangefinder.clear(); }, function () { rangefinder.clear(); },
{ argCount: "0" }); { argCount: "0" });
}, },
@@ -168,11 +168,11 @@ const RangeFinder = Module("rangefinder", {
var myModes = config.browserModes.concat([modes.CARET]); var myModes = config.browserModes.concat([modes.CARET]);
mappings.add(myModes, mappings.add(myModes,
["/"], "Search forward for a pattern", ["/"], "Find a pattern starting at the current caret position",
function () { rangefinder.openPrompt(modes.FIND_FORWARD); }); function () { rangefinder.openPrompt(modes.FIND_FORWARD); });
mappings.add(myModes, mappings.add(myModes,
["?"], "Search backwards for a pattern", ["?"], "Find a pattern backward of the current caret position",
function () { rangefinder.openPrompt(modes.FIND_BACKWARD); }); function () { rangefinder.openPrompt(modes.FIND_BACKWARD); });
mappings.add(myModes, mappings.add(myModes,
@@ -203,8 +203,8 @@ const RangeFinder = Module("rangefinder", {
// The above should be sufficient, but: https://bugzilla.mozilla.org/show_bug.cgi?id=348187 // The above should be sufficient, but: https://bugzilla.mozilla.org/show_bug.cgi?id=348187
prefs.safeSet("accessibility.typeaheadfind", false); prefs.safeSet("accessibility.typeaheadfind", false);
options.add(["hlsearch", "hls"], options.add(["hlfind", "hlf"],
"Highlight all /search pattern matches on the current page after a search", "Highlight all /find pattern matches on the current page after submission",
"boolean", false, { "boolean", false, {
setter: function (value) { setter: function (value) {
try { try {
@@ -219,8 +219,8 @@ const RangeFinder = Module("rangefinder", {
} }
}); });
options.add(["searchcase", "sc"], options.add(["findcase", "fc"],
"Search case matching mode", "Find case matching mode",
"string", "smart", "string", "smart",
{ {
completer: function () [ completer: function () [
@@ -230,8 +230,8 @@ const RangeFinder = Module("rangefinder", {
] ]
}); });
options.add(["incsearch", "is"], options.add(["incfind", "if"],
"Search for a pattern incrementally as it is typed rather than awaiting <Return>", "Find a pattern incrementally as it is typed rather than awaiting <Return>",
"boolean", true); "boolean", true);
} }
}); });
@@ -240,21 +240,21 @@ const RangeFinder = Module("rangefinder", {
* @class RangeFind * @class RangeFind
* *
* A fairly sophisticated typeahead-find replacement. It supports * A fairly sophisticated typeahead-find replacement. It supports
* incremental search very much as the builtin component. * incremental find very much as the builtin component.
* Additionally, it supports several features impossible to * Additionally, it supports several features impossible to
* implement using the standard component. Incremental searching * implement using the standard component. Incremental finding
* works both forwards and backwards. Erasing characters during an * works both forwards and backwards. Erasing characters during an
* incremental search moves the selection back to the first * incremental find moves the selection back to the first
* available match for the shorter term. The selection and viewport * available match for the shorter term. The selection and viewport
* are restored when the search is canceled. * are restored when the find is canceled.
* *
* Also, in addition to full support for frames and iframes, this * Also, in addition to full support for frames and iframes, this
* implementation will begin searching from the position of the * implementation will begin finding from the position of the
* caret in the last active frame. This is contrary to the behavior * caret in the last active frame. This is contrary to the behavior
* of the builtin component, which always starts a search from the * of the builtin component, which always starts a find from the
* beginning of the first frame in the case of frameset documents, * beginning of the first frame in the case of frameset documents,
* and cycles through all frames from beginning to end. This makes it * and cycles through all frames from beginning to end. This makes it
* impossible to choose the starting point of a search for such * impossible to choose the starting point of a find for such
* documents, and represents a major detriment to productivity where * documents, and represents a major detriment to productivity where
* large amounts of data are concerned (e.g., for API documents). * large amounts of data are concerned (e.g., for API documents).
*/ */
@@ -292,7 +292,7 @@ const RangeFind = Class("RangeFind", {
} }
}, },
get searchString() this.lastString, get findString() this.lastString,
get selectedRange() { get selectedRange() {
let selection = (buffer.focusedFrame || content).getSelection(); let selection = (buffer.focusedFrame || content).getSelection();
@@ -411,7 +411,7 @@ const RangeFind = Class("RangeFind", {
this.lastRange = null; this.lastRange = null;
this.lastString = word; this.lastString = word;
var res; var res;
while (res = this.search(null, this.reverse, true)) while (res = this.find(null, this.reverse, true))
yield res; yield res;
} }
finally { finally {
@@ -510,7 +510,7 @@ const RangeFind = Class("RangeFind", {
return null; return null;
}, },
search: function (word, reverse, private_) { find: function (word, reverse, private_) {
if (!private_ && this.lastRange && !RangeFind.equal(this.selectedRange, this.lastRange)) if (!private_ && this.lastRange && !RangeFind.equal(this.selectedRange, this.lastRange))
this.reset(); this.reset();

View File

@@ -352,7 +352,6 @@
</p> </p>
<ul> <ul>
<li><pref>dom.popup_allowed_events</pref></li>
<li><pref>accessibility.typeaheadfind</pref></li> <li><pref>accessibility.typeaheadfind</pref></li>
</ul> </ul>
@@ -906,31 +905,31 @@
<default>500</default> <default>500</default>
<description> <description>
<p> <p>
Maximum number of Ex commands and search patterns to store in the Maximum number of Ex commands and find patterns to store in the
<t>command-line</t> history. <t>command-line</t> history.
</p> </p>
</description> </description>
</item> </item>
<item> <item>
<tags>'nohls' 'nohlsearch'</tags> <tags>'nohls' 'nohlfind'</tags>
<tags>'hls' 'hlsearch'</tags> <tags>'hls' 'hlfind'</tags>
<spec>'hlsearch' 'hls'</spec> <spec>'hlfind' 'hls'</spec>
<type>boolean</type> <type>boolean</type>
<default>off</default> <default>off</default>
<description> <description>
<p>Highlight previous search pattern matches.</p> <p>Highlight previous find pattern matches.</p>
</description> </description>
</item> </item>
<item> <item>
<tags>'nois' 'noincsearch'</tags> <tags>'nois' 'noincfind'</tags>
<tags>'is' 'incsearch'</tags> <tags>'is' 'incfind'</tags>
<spec>'incsearch' 'is'</spec> <spec>'incfind' 'is'</spec>
<type>boolean</type> <type>boolean</type>
<default>on</default> <default>on</default>
<description> <description>
<p>Show the first match for a search pattern as it is typed.</p> <p>Show the first match for a find pattern as it is typed.</p>
</description> </description>
</item> </item>

View File

@@ -9,13 +9,13 @@
xmlns="&xmlns.dactyl;" xmlns="&xmlns.dactyl;"
xmlns:html="&xmlns.html;"> xmlns:html="&xmlns.html;">
<h1 tag="text-search-commands">Text search commands</h1> <h1 tag="text-find-commands">Text find commands</h1>
<toc start="2"/> <toc start="2"/>
<p> <p>
&dactyl.appName; provides a Vim-like incremental search interface to &dactyl.appName; provides a Vim-like incremental find interface to
replace &dactyl.host;'s crippled Typeahead Find. Among other improvements, replace &dactyl.host;'s crippled Typeahead Find. Among other improvements,
our search service: our find service:
</p> </p>
<ul> <ul>
<li> <li>
@@ -31,34 +31,34 @@
unlike &dactyl.host;, which will always continue from the last match. unlike &dactyl.host;, which will always continue from the last match.
</li> </li>
<li> <li>
Supports reverse incremental search. Supports reverse incremental find.
</li> </li>
<li> <li>
Escape sequences to toggle link-only and case-sensitive searching. Escape sequences to toggle link-only and case-sensitive find.
</li> </li>
</ul> </ul>
<p> <p>
Regular expression search, however, is not currently available unless the Regular expression find, however, is not currently available unless the
/Find Bar/ service is installed, in which case it may be toggled on with /Find Bar/ service is installed, in which case it may be toggled on with
a search flag. a find flag.
</p> </p>
<item> <item>
<tags>/</tags> <tags>/</tags>
<spec>/<a>pattern</a><oa>/</oa><k name="CR"/></spec> <spec>/<a>pattern</a><oa>/</oa><k name="CR"/></spec>
<description> <description>
<p>Search forward for the first occurrence of <a>pattern</a>.</p> <p>Find <a>pattern</a> starting at the current caret position.</p>
<p> <p>
The following escape sequences can be used to modify the The following escape sequences can be used to modify the
behavior of the search. When flags conflict, the last to behavior of the find. When flags conflict, the last to
appear is the one that takes effect. appear is the one that takes effect.
</p> </p>
<dl dt="width: 6em;"> <dl dt="width: 6em;">
<dt>\c</dt> <dd>Perform case insensitive search (default if <o>searchcase</o>=<str>ignore</str>).</dd> <dt>\c</dt> <dd>Perform case insensitive find (default if <o>findcase</o>=<str>ignore</str>).</dd>
<dt>\C</dt> <dd>Perform case sensitive search (default if <o>searchcase</o>=<str>match</str>).</dd> <dt>\C</dt> <dd>Perform case sensitive find (default if <o>findcase</o>=<str>match</str>).</dd>
<dt>\l</dt> <dd>Search only in links, as defined by <o>hinttags</o>.</dd> <dt>\l</dt> <dd>Search only in links, as defined by <o>hinttags</o>.</dd>
<dt>\L</dt> <dd>Search the entire page.</dd> <dt>\L</dt> <dd>Search the entire page.</dd>
</dl> </dl>
@@ -78,7 +78,10 @@
<tags>?</tags> <tags>?</tags>
<spec>?<a>pattern</a><oa>?</oa><k name="CR"/></spec> <spec>?<a>pattern</a><oa>?</oa><k name="CR"/></spec>
<description> <description>
<p>Search backward for <a>pattern</a>, in exactly the same manner as <k>/</k>.</p> <p>
Find a pattern backward of the current caret position in exactly the
same manner as <k>/</k>
</p>
</description> </description>
</item> </item>
@@ -86,7 +89,7 @@
<tags>n</tags> <tags>n</tags>
<spec>n</spec> <spec>n</spec>
<description short="true"> <description short="true">
<p>Find next. Repeat the last search.</p> <p>Find next. Repeat the last find.</p>
</description> </description>
</item> </item>
@@ -94,7 +97,7 @@
<tags>N</tags> <tags>N</tags>
<spec>N</spec> <spec>N</spec>
<description short="true"> <description short="true">
<p>Find previous. Repeat the last search in the opposite direction.</p> <p>Find previous. Repeat the last find in the opposite direction.</p>
</description> </description>
</item> </item>
@@ -115,13 +118,13 @@
</item> </item>
<item> <item>
<tags>:noh :nohlsearch</tags> <tags>:noh :nohlfind</tags>
<strut/> <strut/>
<spec>:noh<oa>lsearch</oa></spec> <spec>:noh<oa>lfind</oa></spec>
<description> <description>
<p> <p>
Remove the search highlighting. The document is highlighted again Remove the find highlighting. The document is highlighted again
when another search command is used or the <o>hlsearch</o> option when another find command is used or the <o>hlfind</o> option
is set. is set.
</p> </p>
</description> </description>

View File

@@ -49,29 +49,31 @@
* The concept of completion contexts is now exposed to the user * The concept of completion contexts is now exposed to the user
(see :h :contexts), allowing for powerful and fine-grained (see :h :contexts), allowing for powerful and fine-grained
completion system customization. completion system customization.
* IMPORTANT: 'linksearch' has been removed. The \l search modifier can * IMPORTANT option changes:
still be used for this purpose. - 'cdpath' and 'runtimepath' no longer treat ",,"
* IMPORTANT: 'laststatus' has been replaced with the "s" flag in specially. Use "." instead.
'guioptions'. - 'incsearch', 'hlsearch', 'ignorecase', and 'smartcase' have
* IMPORTANT: 'showstatuslinks' is now a string option. been replaced with 'incfind', 'hlfind', and 'findcase'
* IMPORTANT: 'ignorecase' and 'smartcase' have been replaced with 'searchcase' - 'extendedhinttags' is now a regexpmap rather than a
string.
- 'guioptions' default value has changed.
- 'laststatus' has been replaced with the "s" flag in
'guioptions'.
- 'linksearch' has been removed. The \l search modifier can
still be used for this purpose.
- 'loadplugins' is now a regexplist option rather than
a boolean.
- 'mapleader' is now an option rather than a :let
variable.
- 'showstatuslinks' is now a string option.
* IMPORTANT: Command script files now use the *.penta file extension. * IMPORTANT: Command script files now use the *.penta file extension.
* IMPORTANT: Plugins are now loaded from the 'plugins/' * IMPORTANT: Plugins are now loaded from the 'plugins/'
directory in 'runtimepath' rather than 'plugin/'. directory in 'runtimepath' rather than 'plugin/'.
* IMPORTANT: 'loadplugins' is now a regexplist option rather than
a boolean.
* IMPORTANT: 'cdpath' and 'runtimepath' no longer treat ",,"
specially. Use "." instead.
* IMPORTANT: Option value quoting has changed. List options will * IMPORTANT: Option value quoting has changed. List options will
no longer be split at quoted commas and the option name, no longer be split at quoted commas and the option name,
operators, and = sign may no longer be quoted. This will break operators, and = sign may no longer be quoted. This will break
certain automatically-generated configuration files. certain automatically-generated configuration files.
See :help stringlist See :help stringlist
* IMPORTANT: 'extendedhinttags' is now a regexpmap rather than a
string.
* IMPORTANT: 'guioptions' default value has changed.
* IMPORTANT: 'mapleader' is now an option rather than a :let
variable.
* Added "bookmarks", "diverted", and "links" to 'activate' * Added "bookmarks", "diverted", and "links" to 'activate'
option. option.
* Added 'altwildmode' and <A-Tab> command-line key binding. * Added 'altwildmode' and <A-Tab> command-line key binding.