terminal.c's from_backend() no longer calls term_out(), because
[sgt/putty] / window.c
index 3eb9567..3347260 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();
@@ -3334,6 +3326,14 @@ static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam,
     /* Okay we've done everything interesting; let windows deal with 
      * the boring stuff */
     {
+       BOOL capsOn=0;
+
+       /* helg: clear CAPS LOCK state if caps lock switches to cyrillic */
+       if(cfg.xlat_capslockcyr && keystate[VK_CAPITAL] != 0) {
+           capsOn= !left_alt;
+           keystate[VK_CAPITAL] = 0;
+       }
+
        r = ToAsciiEx(wParam, scan, keystate, keys, 0, kbd_layout);
 #ifdef SHOW_TOASCII_RESULT
        if (r == 1 && !key_down) {
@@ -3402,10 +3402,17 @@ static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam,
                    } else
                        lpage_send(kbd_codepage, &ch, 1);
                } else {
-                   static char cbuf[] = "\033 ";
-                   cbuf[1] = ch;
-                   lpage_send(kbd_codepage, cbuf + !left_alt,
-                              1 + !!left_alt);
+                   if(capsOn && ch < 0x80) {
+                       WCHAR cbuf[2];
+                       cbuf[0] = 27;
+                       cbuf[1] = xlat_uskbd2cyrllic(ch);
+                       luni_send(cbuf+!left_alt, 1+!!left_alt);
+                   } else {
+                       char cbuf[2];
+                       cbuf[0] = '\033';
+                       cbuf[1] = ch;
+                       lpage_send(kbd_codepage, cbuf+!left_alt, 1+!!left_alt);
+                   }
                }
                show_mouseptr(0);
            }