From f67073d33eb4707efc5dcab08e7b787dcaae57af Mon Sep 17 00:00:00 2001 From: KLuka Date: Tue, 20 Oct 2015 20:39:42 +0200 Subject: [PATCH] Issue #350: Support for middle click paste * Added limited support for middle click pasting. For most browsers and operating systems middle click pasting works only for concent selected in current shellinabox window. --- shellinabox/vt100.jspp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/shellinabox/vt100.jspp b/shellinabox/vt100.jspp index d44c631..5c1a0ed 100755 --- a/shellinabox/vt100.jspp +++ b/shellinabox/vt100.jspp @@ -1429,6 +1429,25 @@ VT100.prototype.mouseEvent = function(event, type) { return this.cancelEvent(event); } + // Simulate middle click pasting from inside of current window. Note that + // pasting content from other programs will not work in this way, since we + // don't have access to native clipboard. + if ((event.which || event.button) == 2 && selection.length) { + if (type == MOUSE_UP) { + // Use timeout to prevent double paste on Chrome/Linux. + setTimeout(function (vt100) { + return function() { + vt100.keysPressed(selection); + vt100.input.focus(); + } + }(this), 10); + } + if (type == MOUSE_DOWN) { + // Prevent middle click scroll on Windows systems. + return this.cancelEvent(event); + } + } + if (this.mouseReporting) { try { event.shiftKey = false;