X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/ab2c86b9e339e4c0a7d824b1f7ec4efcce985d79..b9d7bcadee831e9b59fb785f2464a5fc1897bd1a:/window.c diff --git a/window.c b/window.c index 1aa20908..c53395a2 100644 --- a/window.c +++ b/window.c @@ -108,12 +108,15 @@ static LPARAM pend_netevent_lParam = 0; static void enact_pending_netevent(void); static void flash_window(int mode); static void sys_cursor_update(void); +static int is_shift_pressed(void); static int get_fullscreen_rect(RECT * ss); static time_t last_movement = 0; static int caret_x = -1, caret_y = -1; +static void *ldisc; + #define FONT_NORMAL 0 #define FONT_BOLD 1 #define FONT_UNDERLINE 2 @@ -168,7 +171,7 @@ static OSVERSIONINFO osVersion; static UINT wm_mousewheel = WM_MOUSEWHEEL; /* Dummy routine, only required in plink. */ -void ldisc_update(int echo, int edit) +void ldisc_update(void *frontend, int echo, int edit) { } @@ -600,7 +603,7 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show) char msg[1024], *title; char *realhost; - error = back->init((void *)term, + error = back->init((void *)term, &backhandle, cfg.host, cfg.port, &realhost, cfg.tcp_nodelay); if (error) { sprintf(msg, "Unable to open connection to\n" @@ -620,6 +623,16 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show) set_icon(title); } + /* + * Connect the terminal to the backend for resize purposes. + */ + term_provide_resize_fn(term, back->size, backhandle); + + /* + * Set up a line discipline. + */ + ldisc = ldisc_create(term, back, backhandle, NULL); + session_closed = FALSE; /* @@ -1610,7 +1623,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, time_t now; time(&now); if (now - last_movement > cfg.ping_interval) { - back->special(TS_PING); + back->special(backhandle, TS_PING); last_movement = now; } } @@ -1743,7 +1756,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, 0); + ldisc_send(ldisc, NULL, 0, 0); if (pal) DeleteObject(pal); logpal = NULL; @@ -1857,58 +1870,58 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, break; case IDM_RESET: term_pwron(term); - ldisc_send(NULL, 0, 0); + ldisc_send(ldisc, NULL, 0, 0); break; case IDM_TEL_AYT: - back->special(TS_AYT); + back->special(backhandle, TS_AYT); net_pending_errors(); break; case IDM_TEL_BRK: - back->special(TS_BRK); + back->special(backhandle, TS_BRK); net_pending_errors(); break; case IDM_TEL_SYNCH: - back->special(TS_SYNCH); + back->special(backhandle, TS_SYNCH); net_pending_errors(); break; case IDM_TEL_EC: - back->special(TS_EC); + back->special(backhandle, TS_EC); net_pending_errors(); break; case IDM_TEL_EL: - back->special(TS_EL); + back->special(backhandle, TS_EL); net_pending_errors(); break; case IDM_TEL_GA: - back->special(TS_GA); + back->special(backhandle, TS_GA); net_pending_errors(); break; case IDM_TEL_NOP: - back->special(TS_NOP); + back->special(backhandle, TS_NOP); net_pending_errors(); break; case IDM_TEL_ABORT: - back->special(TS_ABORT); + back->special(backhandle, TS_ABORT); net_pending_errors(); break; case IDM_TEL_AO: - back->special(TS_AO); + back->special(backhandle, TS_AO); net_pending_errors(); break; case IDM_TEL_IP: - back->special(TS_IP); + back->special(backhandle, TS_IP); net_pending_errors(); break; case IDM_TEL_SUSP: - back->special(TS_SUSP); + back->special(backhandle, TS_SUSP); net_pending_errors(); break; case IDM_TEL_EOR: - back->special(TS_EOR); + back->special(backhandle, TS_EOR); net_pending_errors(); break; case IDM_TEL_EOF: - back->special(TS_EOF); + back->special(backhandle, TS_EOF); net_pending_errors(); break; case IDM_ABOUT: @@ -2445,7 +2458,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, * we're sent. */ term_seen_key_event(term); - ldisc_send(buf, len, 1); + ldisc_send(ldisc, buf, len, 1); show_mouseptr(0); } } @@ -2493,7 +2506,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, */ term_seen_key_event(term); for (i = 0; i < n; i += 2) { - luni_send((unsigned short *)(buff+i), 1, 1); + luni_send(ldisc, (unsigned short *)(buff+i), 1, 1); } free(buff); } @@ -2508,11 +2521,11 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, buf[1] = wParam; buf[0] = wParam >> 8; term_seen_key_event(term); - lpage_send(kbd_codepage, buf, 2, 1); + lpage_send(ldisc, kbd_codepage, buf, 2, 1); } else { char c = (unsigned char) wParam; term_seen_key_event(term); - lpage_send(kbd_codepage, &c, 1, 1); + lpage_send(ldisc, kbd_codepage, &c, 1, 1); } return (0); case WM_CHAR: @@ -2526,7 +2539,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, { char c = (unsigned char)wParam; term_seen_key_event(term); - lpage_send(CP_ACP, &c, 1, 1); + lpage_send(ldisc, CP_ACP, &c, 1, 1); } return 0; case WM_SETCURSOR: @@ -3775,7 +3788,7 @@ static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam, } keybuf = nc; term_seen_key_event(term); - luni_send(&keybuf, 1, 1); + luni_send(ldisc, &keybuf, 1, 1); continue; } @@ -3786,7 +3799,7 @@ static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam, if (in_utf(term) || dbcs_screenfont) { keybuf = alt_sum; term_seen_key_event(term); - luni_send(&keybuf, 1, 1); + luni_send(ldisc, &keybuf, 1, 1); } else { ch = (char) alt_sum; /* @@ -3799,25 +3812,26 @@ static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam, * everything we're sent. */ term_seen_key_event(term); - ldisc_send(&ch, 1, 1); + ldisc_send(ldisc, &ch, 1, 1); } alt_sum = 0; } else term_seen_key_event(term); - lpage_send(kbd_codepage, &ch, 1, 1); + lpage_send(ldisc, 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(term); - luni_send(cbuf+!left_alt, 1+!!left_alt, 1); + luni_send(ldisc, cbuf+!left_alt, 1+!!left_alt, 1); } else { char cbuf[2]; cbuf[0] = '\033'; cbuf[1] = ch; term_seen_key_event(term); - lpage_send(kbd_codepage, cbuf+!left_alt, 1+!!left_alt, 1); + lpage_send(ldisc, kbd_codepage, + cbuf+!left_alt, 1+!!left_alt, 1); } } show_mouseptr(0); @@ -4554,7 +4568,7 @@ void flip_full_screen() } } -void frontend_keypress(void) +void frontend_keypress(void *handle) { /* * Keypress termination in non-Close-On-Exit mode is not