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

inline yankCurrentSelection(), yankCurrentLocation(), goUp()

This commit is contained in:
Doug Kearns
2007-07-05 06:52:10 +00:00
parent 53f647b488
commit 39c2a87392
2 changed files with 29 additions and 33 deletions

View File

@@ -1205,6 +1205,7 @@ function focusNextFrame(count, forward)
return; return;
// remove all unfocusable frames // remove all unfocusable frames
// TODO: find a better way to do this
var start = document.commandDispatcher.focusedWindow; var start = document.commandDispatcher.focusedWindow;
frames = frames.filter(function(frame) { frames = frames.filter(function(frame) {
frame.focus(); frame.focus();
@@ -1292,36 +1293,6 @@ function getCurrentTitle()
} }
function goUp(count)
{
var gocmd = "";
if (isDirectory(getCurrentLocation()))
gocmd = "../";
else
gocmd = "./";
if (count < 1)
count = 1;
for (var i = 0; i < count - 1; i--)
gocmd += "../";
openURLs(gocmd);
}
function yankCurrentLocation()
{
var loc = getCurrentLocation();
copyToClipboard(loc);
vimperator.echo("Yanked " + loc);
}
function yankCurrentSelection()
{
var sel = window.content.document.getSelection();
copyToClipboard(sel);
vimperator.echo("Yanked " + sel);
}
/////////////////////////////////////////////////////////////////////}}} /////////////////////////////////////////////////////////////////////}}}
// scrolling /////////////////////////////////////////////////////////// // scrolling ///////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////{{{ /////////////////////////////////////////////////////////////////////{{{

View File

@@ -423,14 +423,24 @@ function Mappings() //{{{
} }
)); ));
addDefaultMap(new Map(vimperator.modes.NORMAL, ["y"], addDefaultMap(new Map(vimperator.modes.NORMAL, ["y"],
yankCurrentLocation, function()
{
var loc = getCurrentLocation();
copyToClipboard(loc);
vimperator.echo("Yanked " + loc);
},
{ {
short_help: "Yank current location to the clipboard", short_help: "Yank current location to the clipboard",
help: "Under UNIX the location is also put into the selection, which can be pasted with the middle mouse button." help: "Under UNIX the location is also put into the selection, which can be pasted with the middle mouse button."
} }
)); ));
addDefaultMap(new Map(vimperator.modes.NORMAL, ["Y"], addDefaultMap(new Map(vimperator.modes.NORMAL, ["Y"],
yankCurrentSelection, function()
{
var sel = window.content.document.getSelection();
copyToClipboard(sel);
vimperator.echo("Yanked " + sel);
},
{ {
short_help: "Copy selected text", short_help: "Copy selected text",
help: "The currently selected text is copied to the system clipboard." help: "The currently selected text is copied to the system clipboard."
@@ -604,7 +614,22 @@ function Mappings() //{{{
} }
)); ));
addDefaultMap(new Map(vimperator.modes.NORMAL, ["gu", "<BS>"], addDefaultMap(new Map(vimperator.modes.NORMAL, ["gu", "<BS>"],
goUp, function(count)
{
var gocmd = "";
if (isDirectory(getCurrentLocation()))
gocmd = "../";
else
gocmd = "./";
if (count < 1)
count = 1;
for (var i = 0; i < count - 1; i--)
gocmd += "../";
openURLs(gocmd);
},
{ {
short_help: "Go to parent directory", short_help: "Go to parent directory",
help: "Count is supported, <code class=\"mapping\">2gu</code> on <code>http://www.example.com/dir1/dir2/file.htm</code> would open <code>http://www.example.com/dir1/</code>.", help: "Count is supported, <code class=\"mapping\">2gu</code> on <code>http://www.example.com/dir1/dir2/file.htm</code> would open <code>http://www.example.com/dir1/</code>.",