1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-23 07:27:58 +01:00

move vimperator.getCurrentWord to vimperator.buffer

This commit is contained in:
Doug Kearns
2007-09-11 02:03:28 +00:00
parent 45f7609f32
commit c13127eb0b
3 changed files with 25 additions and 24 deletions

View File

@@ -164,6 +164,29 @@ function Buffer() //{{{
return result;
}
// 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
this.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;
}
// TODO: move to v.buffers.list()
this.list = function(fullmode)
{