diff --git a/Donators b/Donators index 611138a1..2edd0bdb 100644 --- a/Donators +++ b/Donators @@ -13,6 +13,7 @@ * Nigel McNie * Paulo Tanimoto * Nathan Saper +* Albert Menkveld I want to say a big THANK YOU for all people which supported this project in this way. diff --git a/NEWS b/NEWS index 759fad20..74165c02 100644 --- a/NEWS +++ b/NEWS @@ -1,8 +1,9 @@
 2007-xx-xx:
 	* version 0.6
-	*  finally clears any selection made in the document
-	* initial start of caret mode. Start with 'i', stop with 
+	* support for * and # mappings to search for the text selection or the text under the cursor
+	* Escape finally clears any selection made in the document
+	* initial start of caret mode. Start with 'i', stop with Escape;
 	* vimperator trys to stay in command mode after loading pages instead of having a text field focused
 	* added a visual bell and replaced 'beep' with 'visualbell'
 	* added vimperator logo (can be seen in the addons manager)
diff --git a/chrome/content/vimperator/events.js b/chrome/content/vimperator/events.js
index 4c33d6c1..1723c998 100644
--- a/chrome/content/vimperator/events.js
+++ b/chrome/content/vimperator/events.js
@@ -440,6 +440,7 @@ function Events() //{{{
                 }
             }
             return false;
+            //vimperator.setMode(vimperator.modes.CARET); // FOR TESTING ONLY
         }
 
         // handle Escape-one-key mode (Ctrl-v)
diff --git a/chrome/content/vimperator/find.js b/chrome/content/vimperator/find.js
index 6b0b6d07..bfe7746a 100644
--- a/chrome/content/vimperator/find.js
+++ b/chrome/content/vimperator/find.js
@@ -108,10 +108,10 @@ function Search() //{{{
     this.find = function(str, backwards)
     {
         var fastFind = getBrowser().fastFind;
+        str = processPattern(str);
 
         fastFind.caseSensitive = case_sensitive;
         found = fastFind.find(str, false) != Components.interfaces.nsITypeAheadFind.FIND_NOTFOUND;
-
         return found;
     }
 
@@ -158,15 +158,17 @@ function Search() //{{{
         if (!vimperator.options["incsearch"])
             return;
 
-        command = processPattern(command);
         this.find(command, backwards);
     }
 
     // Called when the enter key is pressed to trigger a search
-    this.searchSubmitted = function(command)
+    // use forced_direction if you call this function directly
+    this.searchSubmitted = function(command, forced_backward)
     {
+        if (typeof forced_backward === "boolean")
+            backwards = forced_backward;
+
         this.clear();
-        command = processPattern(command);
         this.find(command, backwards);
         this.highlight(command);
 
diff --git a/chrome/content/vimperator/mappings.js b/chrome/content/vimperator/mappings.js
index dc8028f9..6bef5310 100644
--- a/chrome/content/vimperator/mappings.js
+++ b/chrome/content/vimperator/mappings.js
@@ -1377,6 +1377,41 @@ function Mappings() //{{{
         { }
     ));
 
+
+    // BIG FIXME: unify event handling to allow keys to be valid in more than one mode!!
+    addDefaultMap(new Map(vimperator.modes.CARET, ["*"],
+        function(count)
+        {
+            vimperator.search.searchSubmitted(vimperator.getCurrentWord(), false);
+            vimperator.search.findAgain();
+        },
+        { }
+    ));
+    addDefaultMap(new Map(vimperator.modes.NORMAL, ["*"],
+        function(count)
+        {
+            vimperator.search.searchSubmitted(vimperator.getCurrentWord(), false);
+            vimperator.search.findAgain();
+        },
+        { }
+    ));
+    addDefaultMap(new Map(vimperator.modes.CARET, ["#"],
+        function(count)
+        {
+            vimperator.search.searchSubmitted(vimperator.getCurrentWord(), true);
+            vimperator.search.findAgain();
+        },
+        { }
+    ));
+    addDefaultMap(new Map(vimperator.modes.NORMAL, ["#"],
+        function(count)
+        {
+            vimperator.search.searchSubmitted(vimperator.getCurrentWord(), true);
+            vimperator.search.findAgain();
+        },
+        { }
+    ));
+
 } //}}}
 
 // vim: set fdm=marker sw=4 ts=4 et:
diff --git a/chrome/content/vimperator/vimperator.js b/chrome/content/vimperator/vimperator.js
index 1110193e..b47253e5 100644
--- a/chrome/content/vimperator/vimperator.js
+++ b/chrome/content/vimperator/vimperator.js
@@ -354,6 +354,28 @@ const vimperator = (function() //{{{
             return new LocalFile(path, mode, perms, tmp);
         },
 
+
+        // in contrast to vim, returns the selection if one is made, 
+        // otherwise tries to guess the current word unter the text cursor
+        // NOTE: might change the selection 
+        getCurrentWord: function()
+        {
+            var selection = window.content.getSelection().toString();
+            if (!selection)
+            {
+                var selection_controller = getBrowser().docShell
+                    .QueryInterface(Components.interfaces.nsIInterfaceRequestor)
+                    .getInterface(Components.interfaces.nsISelectionDisplay)
+                    .QueryInterface(Components.interfaces.nsISelectionController);
+
+                selection_controller.setCaretEnabled(true);
+                selection_controller.wordMove(false, false);
+                selection_controller.wordMove(true, true);
+                selection = window.content.getSelection().toString();
+            }
+            return selection;
+        },
+
         // logs a message to the javascript error console
         log: function(msg, level)
         {