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

Closes issue #531.

This commit is contained in:
Kris Maglione
2011-05-20 11:37:53 -04:00
parent 4a85962ccc
commit bd84ce439e

View File

@@ -1757,28 +1757,32 @@ var Buffer = Module("buffer", {
}, },
{ count: true }); { count: true });
function url() {
let url = dactyl.clipboardRead();
dactyl.assert(url, _("error.clipboardEmpty"));
let proto = /^([-\w]+):/.exec(url);
if (proto && "@mozilla.org/network/protocol;1?name=" + proto[1] in Cc && !RegExp(options["urlseparator"]).test(url))
return url.replace(/\s+/g, "");
return url;
}
mappings.add([modes.NORMAL], ["gP"], mappings.add([modes.NORMAL], ["gP"],
"Open (]put) a URL based on the current clipboard contents in a new buffer", "Open (]put) a URL based on the current clipboard contents in a new buffer",
function () { function () {
let url = dactyl.clipboardRead(); dactyl.open(url(), { from: "paste", where: dactyl.NEW_TAB, background: true });
dactyl.assert(url, _("error.clipboardEmpty"));
dactyl.open(url, { from: "paste", where: dactyl.NEW_TAB, background: true });
}); });
mappings.add([modes.NORMAL], ["p", "<MiddleMouse>", "<open-clipboard-url>"], mappings.add([modes.NORMAL], ["p", "<MiddleMouse>", "<open-clipboard-url>"],
"Open (put) a URL based on the current clipboard contents in the current buffer", "Open (put) a URL based on the current clipboard contents in the current buffer",
function () { function () {
let url = dactyl.clipboardRead(); dactyl.open(url());
dactyl.assert(url, _("error.clipboardEmpty"));
dactyl.open(url.replace(/\s+/g, ""));
}); });
mappings.add([modes.NORMAL], ["P", "<tab-open-clipboard-url>"], mappings.add([modes.NORMAL], ["P", "<tab-open-clipboard-url>"],
"Open (put) a URL based on the current clipboard contents in a new buffer", "Open (put) a URL based on the current clipboard contents in a new buffer",
function () { function () {
let url = dactyl.clipboardRead(); dactyl.open(url(), { from: "paste", where: dactyl.NEW_TAB });
dactyl.assert(url, _("error.clipboardEmpty"));
dactyl.open(url.replace(/\s+/g, ""), { from: "paste", where: dactyl.NEW_TAB });
}); });
// reloading // reloading