X-Git-Url: https://git.distorted.org.uk/~mdw/sgt/putty/blobdiff_plain/a9c0245444b7b67e077826089b026d46297fab64..ad5c93cc19001ef3e9f3ccb0fb63d34140481c05:/window.c diff --git a/window.c b/window.c index cd5f703c..8e576bf3 100644 --- a/window.c +++ b/window.c @@ -429,7 +429,7 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show) int exwinmode = 0; if (!cfg.scrollbar) winmode &= ~(WS_VSCROLL); - if (cfg.locksize && cfg.lockfont) + if (cfg.resize_action == RESIZE_DISABLED) winmode &= ~(WS_THICKFRAME | WS_MAXIMIZEBOX); if (cfg.alwaysontop) exwinmode |= WS_EX_TOPMOST; @@ -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); @@ -1099,11 +1092,11 @@ void request_resize(int w, int h) /* If the window is maximized supress resizing attempts */ if (IsZoomed(hwnd)) { - if (cfg.lockfont) + if (cfg.resize_action != RESIZE_FONT) return; } - if (cfg.lockfont && cfg.locksize) return; + if (cfg.resize_action == RESIZE_DISABLED) return; if (h == rows && w == cols) return; /* Sanity checks ... */ @@ -1136,7 +1129,7 @@ void request_resize(int w, int h) term_size(h, w, cfg.savelines); - if (cfg.lockfont) { + if (cfg.resize_action != RESIZE_FONT) { width = extra_width + font_width * w; height = extra_height + font_height * h; @@ -1204,7 +1197,7 @@ static void reset_window(int reinit) { extra_width = wr.right - wr.left - cr.right + cr.left; extra_height = wr.bottom - wr.top - cr.bottom + cr.top; - if (!cfg.lockfont) { + if (cfg.resize_action == RESIZE_FONT) { if ( font_width != win_width/cols || font_height != win_height/rows) { deinit_fonts(); @@ -1267,7 +1260,7 @@ static void reset_window(int reinit) { * window. But that may be too big for the screen which forces us * to change the terminal. */ - if ((cfg.lockfont && reinit==0) || reinit>0) { + if ((cfg.resize_action != RESIZE_FONT && reinit==0) || reinit>0) { offset_width = offset_height = cfg.window_border; extra_width = wr.right - wr.left - cr.right + cr.left + offset_width*2; extra_height = wr.bottom - wr.top - cr.bottom + cr.top +offset_height*2; @@ -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; @@ -1528,7 +1520,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, if (cfg.height != prev_cfg.height || cfg.width != prev_cfg.width || cfg.savelines != prev_cfg.savelines || - cfg.locksize ) + cfg.resize_action != RESIZE_TERM) term_size(cfg.height, cfg.width, cfg.savelines); /* Enable or disable the scroll bar, etc */ @@ -1559,7 +1551,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, nflg |= WS_VSCROLL; else nflg &= ~WS_VSCROLL; - if (cfg.locksize && cfg.lockfont) + if (cfg.resize_action == RESIZE_DISABLED) nflg &= ~(WS_THICKFRAME | WS_MAXIMIZEBOX); else nflg |= (WS_THICKFRAME | WS_MAXIMIZEBOX); @@ -1580,7 +1572,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, } /* Oops */ - if (cfg.locksize && cfg.lockfont && IsZoomed(hwnd)) { + if (cfg.resize_action == RESIZE_DISABLED && IsZoomed(hwnd)) { force_normal(hwnd); init_lvl = 2; } @@ -1599,7 +1591,8 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, cfg.fontcharset != prev_cfg.fontcharset || cfg.vtmode != prev_cfg.vtmode || cfg.bold_colour != prev_cfg.bold_colour || - (cfg.lockfont && !prev_cfg.lockfont)) + (cfg.resize_action != RESIZE_FONT && + prev_cfg.resize_action == RESIZE_FONT)) init_lvl = 2; InvalidateRect(hwnd, NULL, TRUE); @@ -1910,7 +1903,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, * 1) Keep the sizetip uptodate * 2) Make sure the window size is _stepped_ in units of the font size. */ - if (!cfg.locksize && !alt_pressed) { + if (cfg.resize_action == RESIZE_TERM && !alt_pressed) { int width, height, w, h, ew, eh; LPRECT r = (LPRECT) lParam; @@ -2010,7 +2003,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, if (wParam == SIZE_RESTORED || wParam == SIZE_MAXIMIZED) SetWindowText(hwnd, window_name); - if (cfg.lockfont && cfg.locksize) { + if (cfg.resize_action == RESIZE_DISABLED) { /* A resize, well it better be a minimize. */ reset_window(-1); } else { @@ -2025,7 +2018,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, was_zoomed = 1; prev_rows = rows; prev_cols = cols; - if (cfg.lockfont) { + if (cfg.resize_action != RESIZE_FONT) { w = width / font_width; if (w < 1) w = 1; h = height / font_height; @@ -2036,7 +2029,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, reset_window(0); } else if (wParam == SIZE_RESTORED && was_zoomed) { was_zoomed = 0; - if (cfg.lockfont) + if (cfg.resize_action != RESIZE_FONT) term_size(prev_rows, prev_cols, cfg.savelines); reset_window(0); } @@ -2055,7 +2048,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, * down the connection during an NT opaque drag.) */ if (resizing) { - if (!cfg.locksize && !alt_pressed) { + if (cfg.resize_action == RESIZE_TERM && !alt_pressed) { need_backend_resize = TRUE; w = (width-cfg.window_border*2) / font_width; if (w < 1) w = 1; @@ -2151,6 +2144,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 +2159,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 +2198,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 +2211,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 +2227,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 +2832,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 +3361,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 +3387,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 +3397,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 +3409,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);