mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-21 23:27:58 +01:00
Rename Search to Finder.
Search generally refers to web searches in this domain and mixing "search" and "find" within the same module is very confusing.
This commit is contained in:
@@ -37,13 +37,12 @@ the terms of any one of the MPL, the GPL or the LGPL.
|
|||||||
// : 'linksearch' searches should highlight link matches only
|
// : 'linksearch' searches should highlight link matches only
|
||||||
// : changing any search settings should also update the search state including highlighting
|
// : changing any search settings should also update the search state including highlighting
|
||||||
// : incremental searches shouldn't permanently update search modifiers
|
// : incremental searches shouldn't permanently update search modifiers
|
||||||
// : normalise the use of "search" vs "find" and rename callbacks
|
|
||||||
|
|
||||||
// make sure you only create this object when the "liberator" object is ready
|
// make sure you only create this object when the "liberator" object is ready
|
||||||
/**
|
/**
|
||||||
* @instance search
|
* @instance finder
|
||||||
*/
|
*/
|
||||||
function Search() //{{{
|
function Finder() //{{{
|
||||||
{
|
{
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
////////////////////// PRIVATE SECTION /////////////////////////////////////////
|
////////////////////// PRIVATE SECTION /////////////////////////////////////////
|
||||||
@@ -62,13 +61,13 @@ function Search() //{{{
|
|||||||
var linksOnly = false; // search is limited to link text only
|
var linksOnly = false; // search is limited to link text only
|
||||||
|
|
||||||
// Event handlers for search - closure is needed
|
// Event handlers for search - closure is needed
|
||||||
liberator.registerCallback("change", modes.SEARCH_FORWARD, function (str) { search.onKeyPress(str); });
|
liberator.registerCallback("change", modes.SEARCH_FORWARD, function (str) { finder.onKeyPress(str); });
|
||||||
liberator.registerCallback("submit", modes.SEARCH_FORWARD, function (str) { search.onSubmit(str); });
|
liberator.registerCallback("submit", modes.SEARCH_FORWARD, function (str) { finder.onSubmit(str); });
|
||||||
liberator.registerCallback("cancel", modes.SEARCH_FORWARD, function () { search.onCancel(); });
|
liberator.registerCallback("cancel", modes.SEARCH_FORWARD, function () { finder.onCancel(); });
|
||||||
// TODO: allow advanced myModes in register/triggerCallback
|
// TODO: allow advanced myModes in register/triggerCallback
|
||||||
liberator.registerCallback("change", modes.SEARCH_BACKWARD, function (str) { search.onKeyPress(str); });
|
liberator.registerCallback("change", modes.SEARCH_BACKWARD, function (str) { finder.onKeyPress(str); });
|
||||||
liberator.registerCallback("submit", modes.SEARCH_BACKWARD, function (str) { search.onSubmit(str); });
|
liberator.registerCallback("submit", modes.SEARCH_BACKWARD, function (str) { finder.onSubmit(str); });
|
||||||
liberator.registerCallback("cancel", modes.SEARCH_BACKWARD, function () { search.onCancel(); });
|
liberator.registerCallback("cancel", modes.SEARCH_BACKWARD, function () { finder.onCancel(); });
|
||||||
|
|
||||||
// set searchString, searchPattern, caseSensitive, linksOnly
|
// set searchString, searchPattern, caseSensitive, linksOnly
|
||||||
function processUserPattern(pattern)
|
function processUserPattern(pattern)
|
||||||
@@ -267,9 +266,9 @@ function Search() //{{{
|
|||||||
setter: function (value)
|
setter: function (value)
|
||||||
{
|
{
|
||||||
if (value)
|
if (value)
|
||||||
search.highlight();
|
finder.highlight();
|
||||||
else
|
else
|
||||||
search.clear();
|
finder.clear();
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
@@ -300,19 +299,19 @@ function Search() //{{{
|
|||||||
|
|
||||||
mappings.add(myModes,
|
mappings.add(myModes,
|
||||||
["/"], "Search forward for a pattern",
|
["/"], "Search forward for a pattern",
|
||||||
function () { search.openPrompt(modes.SEARCH_FORWARD); });
|
function () { finder.openPrompt(modes.SEARCH_FORWARD); });
|
||||||
|
|
||||||
mappings.add(myModes,
|
mappings.add(myModes,
|
||||||
["?"], "Search backwards for a pattern",
|
["?"], "Search backwards for a pattern",
|
||||||
function () { search.openPrompt(modes.SEARCH_BACKWARD); });
|
function () { finder.openPrompt(modes.SEARCH_BACKWARD); });
|
||||||
|
|
||||||
mappings.add(myModes,
|
mappings.add(myModes,
|
||||||
["n"], "Find next",
|
["n"], "Find next",
|
||||||
function () { search.findAgain(false); });
|
function () { finder.findAgain(false); });
|
||||||
|
|
||||||
mappings.add(myModes,
|
mappings.add(myModes,
|
||||||
["N"], "Find previous",
|
["N"], "Find previous",
|
||||||
function () { search.findAgain(true); });
|
function () { finder.findAgain(true); });
|
||||||
|
|
||||||
mappings.add(myModes.concat([modes.CARET, modes.TEXTAREA]), ["*"],
|
mappings.add(myModes.concat([modes.CARET, modes.TEXTAREA]), ["*"],
|
||||||
"Find word under cursor",
|
"Find word under cursor",
|
||||||
@@ -322,7 +321,7 @@ function Search() //{{{
|
|||||||
let word = buffer.getCurrentWord();
|
let word = buffer.getCurrentWord();
|
||||||
// A hacky way to move after the current match before searching forwards
|
// A hacky way to move after the current match before searching forwards
|
||||||
window.content.getSelection().getRangeAt(0).collapse(false);
|
window.content.getSelection().getRangeAt(0).collapse(false);
|
||||||
search.onSubmit(word, false)
|
finder.onSubmit(word, false)
|
||||||
});
|
});
|
||||||
|
|
||||||
mappings.add(myModes.concat([modes.CARET, modes.TEXTAREA]), ["#"],
|
mappings.add(myModes.concat([modes.CARET, modes.TEXTAREA]), ["#"],
|
||||||
@@ -333,7 +332,7 @@ function Search() //{{{
|
|||||||
let word = buffer.getCurrentWord();
|
let word = buffer.getCurrentWord();
|
||||||
// A hacky way to move before the current match before searching backwards
|
// A hacky way to move before the current match before searching backwards
|
||||||
window.content.getSelection().getRangeAt(0).collapse(true);
|
window.content.getSelection().getRangeAt(0).collapse(true);
|
||||||
search.onSubmit(word, true)
|
finder.onSubmit(word, true)
|
||||||
});
|
});
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////}}}
|
/////////////////////////////////////////////////////////////////////////////}}}
|
||||||
@@ -342,7 +341,7 @@ function Search() //{{{
|
|||||||
|
|
||||||
commands.add(["noh[lsearch]"],
|
commands.add(["noh[lsearch]"],
|
||||||
"Remove the search highlighting",
|
"Remove the search highlighting",
|
||||||
function () { search.clear(); },
|
function () { finder.clear(); },
|
||||||
{ argCount: "0" });
|
{ argCount: "0" });
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////}}}
|
/////////////////////////////////////////////////////////////////////////////}}}
|
||||||
@@ -477,7 +476,7 @@ function Search() //{{{
|
|||||||
// TODO: move to find() when reverse incremental searching is kludged in
|
// TODO: move to find() when reverse incremental searching is kludged in
|
||||||
// need to find again for reverse searching
|
// need to find again for reverse searching
|
||||||
if (backwards)
|
if (backwards)
|
||||||
setTimeout(function () { search.findAgain(false); }, 0);
|
setTimeout(function () { finder.findAgain(false); }, 0);
|
||||||
|
|
||||||
if (options["hlsearch"])
|
if (options["hlsearch"])
|
||||||
this.highlight(searchString);
|
this.highlight(searchString);
|
||||||
@@ -41,7 +41,7 @@
|
|||||||
"completion.js",
|
"completion.js",
|
||||||
"editor.js",
|
"editor.js",
|
||||||
"events.js",
|
"events.js",
|
||||||
"find.js",
|
"finder.js",
|
||||||
"hints.js",
|
"hints.js",
|
||||||
"io.js",
|
"io.js",
|
||||||
"mappings.js",
|
"mappings.js",
|
||||||
|
|||||||
@@ -165,7 +165,7 @@ const config = { //{{{
|
|||||||
// or we could just make sure that they're all sourced in order.
|
// or we could just make sure that they're all sourced in order.
|
||||||
// The scripts could even just instantiate them themselves.
|
// The scripts could even just instantiate them themselves.
|
||||||
// --Kris
|
// --Kris
|
||||||
liberator.loadModule("search", Search);
|
liberator.loadModule("finder", Finder);
|
||||||
liberator.loadModule("bookmarks", Bookmarks);
|
liberator.loadModule("bookmarks", Bookmarks);
|
||||||
liberator.loadModule("history", History);
|
liberator.loadModule("history", History);
|
||||||
liberator.loadModule("tabs", Tabs);
|
liberator.loadModule("tabs", Tabs);
|
||||||
|
|||||||
@@ -263,7 +263,7 @@ const config = { //{{{
|
|||||||
// or we could just make sure that they're all sourced in order.
|
// or we could just make sure that they're all sourced in order.
|
||||||
// The scripts could even just instantiate them themselves.
|
// The scripts could even just instantiate them themselves.
|
||||||
// --Kris
|
// --Kris
|
||||||
liberator.loadModule("search", Search);
|
liberator.loadModule("finder", Finder);
|
||||||
liberator.loadModule("bookmarks", Bookmarks);
|
liberator.loadModule("bookmarks", Bookmarks);
|
||||||
liberator.loadModule("history", History);
|
liberator.loadModule("history", History);
|
||||||
liberator.loadModule("tabs", Tabs);
|
liberator.loadModule("tabs", Tabs);
|
||||||
|
|||||||
Reference in New Issue
Block a user