mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-22 11:37:57 +01:00
move vimperator.getCurrentWord to vimperator.buffer
This commit is contained in:
@@ -164,6 +164,29 @@ function Buffer() //{{{
|
|||||||
return result;
|
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()
|
// TODO: move to v.buffers.list()
|
||||||
this.list = function(fullmode)
|
this.list = function(fullmode)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1381,7 +1381,7 @@ function Mappings() //{{{
|
|||||||
addDefaultMap(new Map([vimperator.modes.NORMAL, vimperator.modes.CARET, vimperator.modes.TEXTAREA], ["*"],
|
addDefaultMap(new Map([vimperator.modes.NORMAL, vimperator.modes.CARET, vimperator.modes.TEXTAREA], ["*"],
|
||||||
function(count)
|
function(count)
|
||||||
{
|
{
|
||||||
vimperator.search.searchSubmitted(vimperator.getCurrentWord(), false);
|
vimperator.search.searchSubmitted(vimperator.buffer.getCurrentWord(), false);
|
||||||
vimperator.search.findAgain();
|
vimperator.search.findAgain();
|
||||||
},
|
},
|
||||||
{ }
|
{ }
|
||||||
@@ -1389,7 +1389,7 @@ function Mappings() //{{{
|
|||||||
addDefaultMap(new Map([vimperator.modes.NORMAL, vimperator.modes.CARET, vimperator.modes.TEXTAREA], ["#"],
|
addDefaultMap(new Map([vimperator.modes.NORMAL, vimperator.modes.CARET, vimperator.modes.TEXTAREA], ["#"],
|
||||||
function(count)
|
function(count)
|
||||||
{
|
{
|
||||||
vimperator.search.searchSubmitted(vimperator.getCurrentWord(), true);
|
vimperator.search.searchSubmitted(vimperator.buffer.getCurrentWord(), true);
|
||||||
vimperator.search.findAgain();
|
vimperator.search.findAgain();
|
||||||
},
|
},
|
||||||
{ }
|
{ }
|
||||||
|
|||||||
@@ -358,28 +358,6 @@ const vimperator = (function() //{{{
|
|||||||
return new LocalFile(path, mode, perms, tmp);
|
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
|
// logs a message to the javascript error console
|
||||||
log: function(msg, level)
|
log: function(msg, level)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user