1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-22 06:47:58 +01:00

* and # support

This commit is contained in:
Martin Stubenschrott
2007-09-06 17:39:21 +00:00
parent d9888288f3
commit 16bb541c98
6 changed files with 68 additions and 6 deletions

View File

@@ -13,6 +13,7 @@
* Nigel McNie
* Paulo Tanimoto
* Nathan Saper
* Albert Menkveld
I want to say a big <b>THANK YOU</b> for all people which supported this project in this way.
</pre>

5
NEWS
View File

@@ -1,8 +1,9 @@
<pre>
2007-xx-xx:
* version 0.6
* <Esc> finally clears any selection made in the document
* initial start of caret mode. Start with 'i', stop with <Esc>
* 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)

View File

@@ -440,6 +440,7 @@ function Events() //{{{
}
}
return false;
//vimperator.setMode(vimperator.modes.CARET); // FOR TESTING ONLY
}
// handle Escape-one-key mode (Ctrl-v)

View File

@@ -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);

View File

@@ -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:

View File

@@ -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)
{