]> asedeno.scripts.mit.edu Git - PuTTY.git/commitdiff
Make calling term_nopaste() a cross-platform feature.
authorSimon Tatham <anakin@pobox.com>
Sat, 17 Aug 2013 16:06:40 +0000 (16:06 +0000)
committerSimon Tatham <anakin@pobox.com>
Sat, 17 Aug 2013 16:06:40 +0000 (16:06 +0000)
It was one of those things that went in ages ago on Windows and never
got replicated in the Unix front end. And it needn't be: ldisc.c is a
perfect place to put it, since it knows which of the data it's sending
is based on a keystroke and which is automatically generated, and it
also has access to the terminal context. So now a keypress can
interrupt a runaway paste on all platforms.

[originally from svn r10025]

Recipe
ldisc.c
noterm.c [new file with mode: 0644]
windows/window.c

diff --git a/Recipe b/Recipe
index dee4da8ff4840ceb4b2c0c2139eb7832f33a72e1..ca79f1fcea48a70a5dcef966dbc6270c025dc41c 100644 (file)
--- a/Recipe
+++ b/Recipe
@@ -343,7 +343,7 @@ U_BE_NOSSH = be_nos_s uxser nocproxy
 putty    : [G] GUITERM NONSSH WINSSH W_BE_ALL WINMISC winx11 putty.res LIBS
 puttytel : [G] GUITERM NONSSH W_BE_NOSSH WINMISC puttytel.res nogss LIBS
 plink    : [C] winplink wincons NONSSH WINSSH W_BE_ALL logging WINMISC
-         + winx11 plink.res winnojmp LIBS
+         + winx11 plink.res winnojmp noterm LIBS
 pscp     : [C] pscp winsftp wincons WINSSH BE_SSH SFTP wildcard WINMISC
          + pscp.res winnojmp LIBS
 psftp    : [C] psftp winsftp wincons WINSSH BE_SSH SFTP wildcard WINMISC
@@ -369,7 +369,7 @@ puttytel : [X] GTKTERM uxmisc misc ldisc settings uxsel U_BE_NOSSH
         + nogss
 
 plink    : [U] uxplink uxcons NONSSH UXSSH U_BE_ALL logging UXMISC uxsignal
-         + ux_x11
+         + ux_x11 noterm
 
 puttygen : [U] cmdgen sshrsag sshdssg sshprime sshdes sshbn sshmd5 version
          + sshrand uxnoise sshsha misc sshrsa sshdss uxcons uxstore uxmisc
diff --git a/ldisc.c b/ldisc.c
index efbb871488d7f0b64972369295349d7fff9c46cb..8f653a18f0ee23c74323eb1c83a249f13f87f820 100644 (file)
--- a/ldisc.c
+++ b/ldisc.c
@@ -146,6 +146,18 @@ void ldisc_send(void *handle, char *buf, int len, int interactive)
      */
     frontend_keypress(ldisc->frontend);
 
+    if (interactive && ldisc->term) {
+        /*
+         * Interrupt a paste from the clipboard, if one was in
+         * progress when the user pressed a key. This is easier than
+         * buffering the current piece of data and saving it until the
+         * terminal has finished pasting, and has the potential side
+         * benefit of permitting a user to cancel an accidental huge
+         * paste.
+         */
+        term_nopaste(ldisc->term);
+    }
+
     /*
      * Less than zero means null terminated special string.
      */
diff --git a/noterm.c b/noterm.c
new file mode 100644 (file)
index 0000000..4ca99fa
--- /dev/null
+++ b/noterm.c
@@ -0,0 +1,11 @@
+/*
+ * Stubs of functions in terminal.c, for use in programs that don't
+ * have a terminal.
+ */
+
+#include "putty.h"
+#include "terminal.h"
+
+void term_nopaste(Terminal *term)
+{
+}
index ca7260bb0107871c44ff9e1e9608c1dbaba945e5..bc89195579f94da84cf248a3b1500e50cfffbba8 100644 (file)
@@ -3051,14 +3051,6 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
                    return DefWindowProc(hwnd, message, wParam, lParam);
 
                if (len != 0) {
-                   /*
-                    * Interrupt an ongoing paste. I'm not sure
-                    * this is sensible, but for the moment it's
-                    * preferable to having to faff about buffering
-                    * things.
-                    */
-                   term_nopaste(term);
-
                    /*
                     * We need not bother about stdin backlogs
                     * here, because in GUI PuTTY we can't do
@@ -4608,13 +4600,6 @@ static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam,
        if (r > 0) {
            WCHAR keybuf;
 
-           /*
-            * Interrupt an ongoing paste. I'm not sure this is
-            * sensible, but for the moment it's preferable to
-            * having to faff about buffering things.
-            */
-           term_nopaste(term);
-
            p = output;
            for (i = 0; i < r; i++) {
                wchar_t wch = keys_unicode[i];