X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/2102eb8a3a40dbf18235c73cf23f018f411db9bc..4044fc45ca4a742c0ff29a49faca7cc9db99b251:/window.c?ds=sidebyside diff --git a/window.c b/window.c index 9fa45bae..ac8ac85c 100644 --- a/window.c +++ b/window.c @@ -87,7 +87,6 @@ static void init_fonts(int, int); static void another_font(int); static void deinit_fonts(void); static void set_input_locale(HKL); -static int do_mouse_wheel_msg(UINT message, WPARAM wParam, LPARAM lParam); static int is_full_screen(void); static void make_full_screen(void); @@ -121,8 +120,11 @@ static void *ldisc; static Backend *back; static void *backhandle; +static struct unicode_data ucsdata; static int session_closed; +Config cfg; /* exported to windlg.c */ + extern struct sesslist sesslist; /* imported from windlg.c */ #define FONT_NORMAL 0 @@ -330,7 +332,8 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show) char *p = argv[i]; int ret; - ret = cmdline_process_param(p, i+1init((void *)term, &backhandle, + error = back->init((void *)term, &backhandle, &cfg, cfg.host, cfg.port, &realhost, cfg.tcp_nodelay); back->provide_logctx(backhandle, logctx); if (error) { @@ -642,7 +649,7 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show) /* * Set up a line discipline. */ - ldisc = ldisc_create(term, back, backhandle, NULL); + ldisc = ldisc_create(&cfg, term, back, backhandle, NULL); session_closed = FALSE; @@ -899,7 +906,8 @@ void connection_fatal(void *frontend, char *fmt, ...) PostQuitMessage(1); else { session_closed = TRUE; - SetWindowText(hwnd, "PuTTY (inactive)"); + set_icon(NULL, "PuTTY (inactive)"); + set_title(NULL, "PuTTY (inactive)"); } } @@ -943,7 +951,8 @@ static void enact_pending_netevent(void) cfg.close_on_exit == COE_NORMAL) PostQuitMessage(0); else { session_closed = TRUE; - SetWindowText(hwnd, "PuTTY (inactive)"); + set_icon(NULL, "PuTTY (inactive)"); + set_title(NULL, "PuTTY (inactive)"); MessageBox(hwnd, "Connection closed by remote host", "PuTTY", MB_OK | MB_ICONINFORMATION); } @@ -1108,16 +1117,15 @@ static void init_fonts(int pick_width, int pick_height) /* !!! Yes the next line is right */ if (cset == OEM_CHARSET) - font_codepage = GetOEMCP(); + ucsdata.font_codepage = GetOEMCP(); else - if (TranslateCharsetInfo - ((DWORD *) cset, &info, TCI_SRCCHARSET)) font_codepage = - info.ciACP; + if (TranslateCharsetInfo ((DWORD *) cset, &info, TCI_SRCCHARSET)) + ucsdata.font_codepage = info.ciACP; else - font_codepage = -1; + ucsdata.font_codepage = -1; - GetCPInfo(font_codepage, &cpinfo); - dbcs_screenfont = (cpinfo.MaxCharSize > 1); + GetCPInfo(ucsdata.font_codepage, &cpinfo); + ucsdata.dbcs_screenfont = (cpinfo.MaxCharSize > 1); } f(FONT_UNDERLINE, cfg.fontcharset, fw_dontcare, TRUE); @@ -1205,7 +1213,7 @@ static void init_fonts(int pick_width, int pick_height) } fontflag[0] = fontflag[1] = fontflag[2] = 1; - init_ucs(); + init_ucs(&cfg, &ucsdata); } static void another_font(int fontno) @@ -1758,11 +1766,8 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, } } - if (strcmp(prev_cfg.logfilename, cfg.logfilename) || - prev_cfg.logtype != cfg.logtype) { - logfclose(logctx); /* reset logging */ - logfopen(logctx); - } + /* Pass new config data to the logging module */ + log_reconfig(logctx, &cfg); sfree(logpal); /* @@ -1777,8 +1782,11 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, cfgtopalette(); init_palette(); - /* Give terminal a heads-up on miscellaneous stuff */ - term_reconfig(term); + /* Pass new config data to the terminal */ + term_reconfig(term, &cfg); + + /* Pass new config data to the back end */ + back->reconfig(backhandle, &cfg); /* Screen size changed ? */ if (cfg.height != prev_cfg.height || @@ -2756,8 +2764,8 @@ void do_text(Context ctx, int x, int y, char *text, int len, if (lattr == LATTR_TOP || lattr == LATTR_BOT) text_adjust *= 2; attr &= ~CSET_MASK; - text[0] = (char) (unitab_xterm['q'] & CHAR_MASK); - attr |= (unitab_xterm['q'] & CSET_MASK); + text[0] = (char) (ucsdata.unitab_xterm['q'] & CHAR_MASK); + attr |= (ucsdata.unitab_xterm['q'] & CSET_MASK); if (attr & ATTR_UNDER) { attr &= ~ATTR_UNDER; force_manual_underline = 1; @@ -2818,7 +2826,7 @@ void do_text(Context ctx, int x, int y, char *text, int len, line_box.right = font_width*term->cols+offset_width; /* We're using a private area for direct to font. (512 chars.) */ - if (dbcs_screenfont && (attr & CSET_MASK) == ATTR_ACP) { + if (ucsdata.dbcs_screenfont && (attr & CSET_MASK) == ATTR_ACP) { /* Ho Hum, dbcs fonts are a PITA! */ /* To display on W9x I have to convert to UCS */ static wchar_t *uni_buf = 0; @@ -2831,15 +2839,15 @@ void do_text(Context ctx, int x, int y, char *text, int len, for(nlen = mptr = 0; mptr= ' ' && (uc&CHAR_MASK)<= '~') @@ -3286,10 +3294,18 @@ static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam, SendMessage(hwnd, WM_VSCROLL, SB_PAGEUP, 0); return 0; } + if (wParam == VK_PRIOR && shift_state == 2) { + SendMessage(hwnd, WM_VSCROLL, SB_LINEUP, 0); + return 0; + } if (wParam == VK_NEXT && shift_state == 1) { SendMessage(hwnd, WM_VSCROLL, SB_PAGEDOWN, 0); return 0; } + if (wParam == VK_NEXT && shift_state == 2) { + SendMessage(hwnd, WM_VSCROLL, SB_LINEDOWN, 0); + return 0; + } if (wParam == VK_INSERT && shift_state == 1) { term_do_paste(term); return 0; @@ -3484,7 +3500,7 @@ static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam, *p++ = "\000\033\034\035\036\037\177"[wParam - '2']; return p - output; } - if (shift_state == 2 && wParam == 0xBD) { + if (shift_state == 2 && (wParam == 0xBD || wParam == 0xBF)) { *p++ = 0x1F; return p - output; } @@ -3755,7 +3771,7 @@ static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam, #ifdef SHOW_TOASCII_RESULT if (r == 1 && !key_down) { if (alt_sum) { - if (in_utf(term) || dbcs_screenfont) + if (in_utf(term) || ucsdata.dbcs_screenfont) debug((", (U+%04x)", alt_sum)); else debug((", LCH(%d)", alt_sum)); @@ -3808,7 +3824,7 @@ static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam, if (!key_down) { if (alt_sum) { - if (in_utf(term) || dbcs_screenfont) { + if (in_utf(term) || ucsdata.dbcs_screenfont) { keybuf = alt_sum; term_seen_key_event(term); luni_send(ldisc, &keybuf, 1, 1); @@ -3858,7 +3874,7 @@ static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam, if (!left_alt) keys[0] = 0; /* If we will be using alt_sum fix the 256s */ - else if (keys[0] && (in_utf(term) || dbcs_screenfont)) + else if (keys[0] && (in_utf(term) || ucsdata.dbcs_screenfont)) keys[0] = 10; }