Make sure SIGINT and SIGQUIT haven't been nobbled in our child
[u/mdw/putty] / window.c
index 59757d9..3b60154 100644 (file)
--- a/window.c
+++ b/window.c
@@ -430,6 +430,21 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
         * Trim a colon suffix off the hostname if it's there.
         */
        cfg.host[strcspn(cfg.host, ":")] = '\0';
+
+       /*
+        * Remove any remaining whitespace from the hostname.
+        */
+       {
+           int p1 = 0, p2 = 0;
+           while (cfg.host[p2] != '\0') {
+               if (cfg.host[p2] != ' ' && cfg.host[p2] != '\t') {
+                   cfg.host[p1] = cfg.host[p2];
+                   p1++;
+               }
+               p2++;
+           }
+           cfg.host[p1] = '\0';
+       }
     }
 
     /*
@@ -2424,6 +2439,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
                     * messages. We _have_ to buffer everything
                     * we're sent.
                     */
+                   term_seen_key_event();
                    ldisc_send(buf, len, 1);
                    show_mouseptr(0);
                }
@@ -2470,8 +2486,10 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
                 * luni_send() covering the whole of buff. So
                 * instead we luni_send the characters one by one.
                 */
-               for (i = 0; i < n; i += 2)
+               term_seen_key_event();
+               for (i = 0; i < n; i += 2) {
                    luni_send((unsigned short *)(buff+i), 1, 1);
+               }
                free(buff);
            }
            ImmReleaseContext(hwnd, hIMC);
@@ -2484,9 +2502,11 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
 
            buf[1] = wParam;
            buf[0] = wParam >> 8;
+           term_seen_key_event();
            lpage_send(kbd_codepage, buf, 2, 1);
        } else {
            char c = (unsigned char) wParam;
+           term_seen_key_event();
            lpage_send(kbd_codepage, &c, 1, 1);
        }
        return (0);
@@ -2500,6 +2520,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
         */
        {
            char c = (unsigned char)wParam;
+           term_seen_key_event();
            lpage_send(CP_ACP, &c, 1, 1);
        }
        return 0;
@@ -3169,15 +3190,6 @@ static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam,
     } else if (compose_state == 1 && wParam != VK_CONTROL)
        compose_state = 0;
 
-    /* 
-     * Record that we pressed key so the scroll window can be reset, but
-     * be careful to avoid Shift-UP/Down
-     */
-    if (wParam != VK_SHIFT && wParam != VK_PRIOR && wParam != VK_NEXT &&
-       wParam != VK_MENU && wParam != VK_CONTROL) {
-       seen_key_event = 1;
-    }
-
     if (compose_state > 1 && left_alt)
        compose_state = 0;
 
@@ -3404,6 +3416,12 @@ static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam,
            *p++ = 0;
            return -2;
        }
+       if (wParam == VK_BACK && shift_state == 1) {    /* Shift Backspace */
+           /* We do the opposite of what is configured */
+           *p++ = (cfg.bksp_is_delete ? 0x08 : 0x7F);
+           *p++ = 0;
+           return -2;
+       }
        if (wParam == VK_TAB && shift_state == 1) {     /* Shift tab */
            *p++ = 0x1B;
            *p++ = '[';
@@ -3748,6 +3766,7 @@ static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam,
                        return 0;
                    }
                    keybuf = nc;
+                   term_seen_key_event();
                    luni_send(&keybuf, 1, 1);
                    continue;
                }
@@ -3758,6 +3777,7 @@ static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam,
                    if (alt_sum) {
                        if (in_utf || dbcs_screenfont) {
                            keybuf = alt_sum;
+                           term_seen_key_event();
                            luni_send(&keybuf, 1, 1);
                        } else {
                            ch = (char) alt_sum;
@@ -3770,21 +3790,25 @@ static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam,
                             * messages. We _have_ to buffer
                             * everything we're sent.
                             */
+                           term_seen_key_event();
                            ldisc_send(&ch, 1, 1);
                        }
                        alt_sum = 0;
                    } else
+                       term_seen_key_event();
                        lpage_send(kbd_codepage, &ch, 1, 1);
                } else {
                    if(capsOn && ch < 0x80) {
                        WCHAR cbuf[2];
                        cbuf[0] = 27;
                        cbuf[1] = xlat_uskbd2cyrllic(ch);
+                       term_seen_key_event();
                        luni_send(cbuf+!left_alt, 1+!!left_alt, 1);
                    } else {
                        char cbuf[2];
                        cbuf[0] = '\033';
                        cbuf[1] = ch;
+                       term_seen_key_event();
                        lpage_send(kbd_codepage, cbuf+!left_alt, 1+!!left_alt, 1);
                    }
                }
@@ -3817,6 +3841,16 @@ static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam,
     return -1;
 }
 
+void request_paste(void)
+{
+    /*
+     * In Windows, pasting is synchronous: we can read the
+     * clipboard with no difficulty, so request_paste() can just go
+     * ahead and paste.
+     */
+    term_do_paste();
+}
+
 void set_title(char *title)
 {
     sfree(window_name);