Tidy up a comment.
[sgt/putty] / window.c
index cd5f703..b887aca 100644 (file)
--- a/window.c
+++ b/window.c
@@ -526,12 +526,6 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
     session_closed = FALSE;
 
     /*
-     * Set up the input and output buffers.
-     */
-    inbuf_head = 0;
-    outbuf_reap = outbuf_head = 0;
-
-    /*
      * Prepare the mouse handler.
      */
     lastact = MA_NOTHING;
@@ -660,8 +654,7 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
                timer_id = 0;
            }
            HideCaret(hwnd);
-           if (inbuf_head)
-               term_out();
+           term_out();
            term_update();
            ShowCaret(hwnd);
 
@@ -1392,8 +1385,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
       case WM_TIMER:
        if (pending_netevent)
            enact_pending_netevent();
-       if (inbuf_head)
-           term_out();
+       term_out();
        noise_regular();
        HideCaret(hwnd);
        term_update();
@@ -1516,7 +1508,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
                 * Flush the line discipline's edit buffer in the
                 * case where local editing has just been disabled.
                 */
-               ldisc_send(NULL, 0);
+               ldisc_send(NULL, 0, 0);
                if (pal)
                    DeleteObject(pal);
                logpal = NULL;
@@ -2151,6 +2143,14 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
 
                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();
+
+                   /*
                     * We need not bother about stdin backlogs
                     * here, because in GUI PuTTY we can't do
                     * anything about it anyway; there's no means
@@ -2158,7 +2158,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
                     * messages. We _have_ to buffer everything
                     * we're sent.
                     */
-                   ldisc_send(buf, len);
+                   ldisc_send(buf, len, 1);
                    show_mouseptr(0);
                }
            }
@@ -2197,7 +2197,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
            if (n > 0) {
                buff = (char*) smalloc(n);
                ImmGetCompositionStringW(hIMC, GCS_RESULTSTR, buff, n);
-               luni_send((unsigned short *)buff, n / 2);
+               luni_send((unsigned short *)buff, n / 2, 1);
                free(buff);
            }
            ImmReleaseContext(hwnd, hIMC);
@@ -2210,10 +2210,10 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
 
            buf[1] = wParam;
            buf[0] = wParam >> 8;
-           lpage_send(kbd_codepage, buf, 2);
+           lpage_send(kbd_codepage, buf, 2, 1);
        } else {
            char c = (unsigned char) wParam;
-           lpage_send(kbd_codepage, &c, 1);
+           lpage_send(kbd_codepage, &c, 1, 1);
        }
        return (0);
       case WM_CHAR:
@@ -2226,7 +2226,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
         */
        {
            char c = (unsigned char)wParam;
-           lpage_send(CP_ACP, &c, 1);
+           lpage_send(CP_ACP, &c, 1, 1);
        }
        return 0;
       case WM_SETCURSOR:
@@ -2831,10 +2831,6 @@ static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam,
        seen_key_event = 1;
     }
 
-    /* Make sure we're not pasting */
-    if (key_down)
-       term_nopaste();
-
     if (compose_state > 1 && left_alt)
        compose_state = 0;
 
@@ -3364,6 +3360,14 @@ static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam,
 #endif
        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();
+
            p = output;
            for (i = 0; i < r; i++) {
                unsigned char ch = (unsigned char) keys[i];
@@ -3382,7 +3386,7 @@ static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam,
                        return 0;
                    }
                    keybuf = nc;
-                   luni_send(&keybuf, 1);
+                   luni_send(&keybuf, 1, 1);
                    continue;
                }
 
@@ -3392,7 +3396,7 @@ static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam,
                    if (alt_sum) {
                        if (in_utf || dbcs_screenfont) {
                            keybuf = alt_sum;
-                           luni_send(&keybuf, 1);
+                           luni_send(&keybuf, 1, 1);
                        } else {
                            ch = (char) alt_sum;
                            /*
@@ -3404,22 +3408,22 @@ static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam,
                             * messages. We _have_ to buffer
                             * everything we're sent.
                             */
-                           ldisc_send(&ch, 1);
+                           ldisc_send(&ch, 1, 1);
                        }
                        alt_sum = 0;
                    } else
-                       lpage_send(kbd_codepage, &ch, 1);
+                       lpage_send(kbd_codepage, &ch, 1, 1);
                } else {
                    if(capsOn && ch < 0x80) {
                        WCHAR cbuf[2];
                        cbuf[0] = 27;
                        cbuf[1] = xlat_uskbd2cyrllic(ch);
-                       luni_send(cbuf+!left_alt, 1+!!left_alt);
+                       luni_send(cbuf+!left_alt, 1+!!left_alt, 1);
                    } else {
                        char cbuf[2];
                        cbuf[0] = '\033';
                        cbuf[1] = ch;
-                       lpage_send(kbd_codepage, cbuf+!left_alt, 1+!!left_alt);
+                       lpage_send(kbd_codepage, cbuf+!left_alt, 1+!!left_alt, 1);
                    }
                }
                show_mouseptr(0);