From 6d33284a7628c9a8c84d4383d6d47508f96c4301 Mon Sep 17 00:00:00 2001 From: Doug Kearns Date: Mon, 3 Sep 2007 19:10:32 +0000 Subject: [PATCH] add 'hlsearch' option --- chrome/content/vimperator/find.js | 13 +++++++++---- chrome/content/vimperator/options.js | 7 +++++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/chrome/content/vimperator/find.js b/chrome/content/vimperator/find.js index 684d203c..530c1273 100644 --- a/chrome/content/vimperator/find.js +++ b/chrome/content/vimperator/find.js @@ -28,13 +28,12 @@ the terms of any one of the MPL, the GPL or the LGPL. // make sure you only create this object when the "vimperator" object is ready -// vimperator.search = new function() function Search() //{{{ { - var self = this; // needed for callbacks since "this" is the "vimperator" object in a callback - var found = false; // true if the last search was successful + var self = this; // needed for callbacks since "this" is the "vimperator" object in a callback + var found = false; // true if the last search was successful var backwards = false; - var lastsearch = ""; // keep track of the last searched string + var lastsearch = ""; // keep track of the last searched string var lastsearch_backwards = false; // like "backwards", but for the last search, so if you cancel a search with this is not set // Event handlers for search - closure is needed @@ -145,6 +144,12 @@ function Search() //{{{ vimperator.focusContent(); } + this.highlight = function() + { + if (lastsearch) + gFindBar._highlightDoc("yellow", "black", lastsearch); + } + this.clear = function() { gFindBar._highlightDoc(); diff --git a/chrome/content/vimperator/options.js b/chrome/content/vimperator/options.js index 3f97c35a..5cbdb4fa 100644 --- a/chrome/content/vimperator/options.js +++ b/chrome/content/vimperator/options.js @@ -425,6 +425,13 @@ function Options() //{{{ default_value: DEFAULT_HINTTAGS } )); + addOption(new Option(["hlsearch", "hls"], "boolean", + { + short_help: "Highlight previous search pattern matches", + setter: function(value) { if (value) vimperator.search.highlight(); else vimperator.search.clear(); }, + default_value: false + } + )); addOption(new Option(["maxhints", "mh"], "number", { short_help: "Maximum number of simultaneously shown hints",