diff --git a/content/buffers.js b/content/buffers.js index 102f364a..70f4ce9c 100644 --- a/content/buffers.js +++ b/content/buffers.js @@ -392,20 +392,6 @@ vimperator.Buffer = function () //{{{ elem.dispatchEvent(evt); }, - yankElementText: function (elem) - { - var text = elem.textContent || ""; - vimperator.copyToClipboard(text); - vimperator.echo("Yanked " + text, vimperator.commandline.FORCE_SINGLELINE); - }, - - yankElementLocation: function (elem) - { - var loc = elem.href || ""; - vimperator.copyToClipboard(loc); - vimperator.echo("Yanked " + loc, vimperator.commandline.FORCE_SINGLELINE); - }, - saveLink: function (elem, skipPrompt) { var doc = elem.ownerDocument; diff --git a/content/hints.js b/content/hints.js index a10e517e..6af6a559 100644 --- a/content/hints.js +++ b/content/hints.js @@ -334,6 +334,7 @@ vimperator.Hints = function () //{{{ return false; } + var timeout = followFirst ? 0 : 500; var activeIndex = (hintNumber ? hintNumber - 1 : 0); var elem = validHints[activeIndex]; var loc = elem.href || ""; @@ -352,14 +353,11 @@ vimperator.Hints = function () //{{{ case "V": vimperator.commands.viewsource(loc, true); break; case "w": vimperator.buffer.followLink(elem, vimperator.NEW_WINDOW); break; case "W": vimperator.commandline.open(":", "winopen " + loc, vimperator.modes.EX); break; - case "y": vimperator.buffer.yankElementLocation(elem); break; - case "Y": vimperator.buffer.yankElementText(elem); break; + case "y": setTimeout(function(){vimperator.copyToClipboard(vimperator.buffer.URL, true)}, timeout + 50); break; + case "Y": setTimeout(function(){vimperator.copyToClipboard(elem.textContent || "", true)}, timeout + 50); break; default: vimperator.echoerr("INTERNAL ERROR: unknown submode: " + submode); } - dump("3\n"); - - var timeout = followFirst ? 0 : 500; removeHints(timeout); if (vimperator.modes.extended & vimperator.modes.ALWAYS_HINT) diff --git a/content/mappings.js b/content/mappings.js index b4f61c77..ea49281f 100644 --- a/content/mappings.js +++ b/content/mappings.js @@ -838,12 +838,7 @@ vimperator.Mappings = function () //{{{ } )); addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["y"], - function () - { - var url = vimperator.buffer.URL; - vimperator.copyToClipboard(url); - vimperator.echo("Yanked " + url, vimperator.commandline.FORCE_SINGLELINE); - }, + function () { vimperator.copyToClipboard(vimperator.buffer.URL, true); }, { shortHelp: "Yank current location to the clipboard", help: "When running in X11 the location is also put into the selection, which can be pasted with the middle mouse button." @@ -853,7 +848,10 @@ vimperator.Mappings = function () //{{{ function () { var sel = window.content.document.getSelection(); - vimperator.copyToClipboard(sel); + if (sel) + vimperator.copyToClipboard(sel, true); + else + vimperator.beep(); }, { shortHelp: "Copy selected text", diff --git a/content/modes.js b/content/modes.js index 7b7bcdbf..cb76afaf 100644 --- a/content/modes.js +++ b/content/modes.js @@ -95,7 +95,7 @@ vimperator.modes = (function () //{{{ { // TODO: fix v.log() to work with verbosity level // vimperator.log("switching from mode " + oldMode + " to mode " + newMode, 7); - dump("switching from mode " + oldMode + " to mode " + newMode + "\n"); + // dump("switching from mode " + oldMode + " to mode " + newMode + "\n"); switch (oldMode) { diff --git a/content/vimperator.js b/content/vimperator.js index 6a545823..c05d24f3 100644 --- a/content/vimperator.js +++ b/content/vimperator.js @@ -111,11 +111,14 @@ const vimperator = (function () //{{{ } }, - copyToClipboard: function (str) + copyToClipboard: function (str, verbose) { var clipboardHelper = Components.classes["@mozilla.org/widget/clipboardhelper;1"] .getService(Components.interfaces.nsIClipboardHelper); clipboardHelper.copyString(str); + + if (verbose) + vimperator.echo("Yanked " + str, vimperator.commandline.FORCE_SINGLELINE); }, execute: function (str, modifiers)