X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/a832773496d46caa5e328d36a15b4918f24a804e..5dc6132d3a8e6e4048698bf1914b486f9cf41e2c:/window.c diff --git a/window.c b/window.c index e5f22800..1ca1f050 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); @@ -115,10 +114,16 @@ static time_t last_movement = 0; static int caret_x = -1, caret_y = -1; +static int kbd_codepage; + static void *ldisc; static Backend *back; static void *backhandle; +static int session_closed; + +extern struct sesslist sesslist; /* imported from windlg.c */ + #define FONT_NORMAL 0 #define FONT_BOLD 1 #define FONT_UNDERLINE 2 @@ -400,6 +405,8 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show) cfg.host[sizeof(cfg.host) - 1] = '\0'; got_host = 1; } + } else { + cmdline_error("unknown option \"%s\"", p); } } } @@ -498,7 +505,7 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show) hwnd = NULL; - term = term_init(NULL); + term = term_init(&cfg, NULL); logctx = log_init(NULL); term_provide_logctx(term, logctx); @@ -636,7 +643,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; @@ -683,10 +690,12 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show) AppendMenu(m, MF_ENABLED, IDM_NEWSESS, "Ne&w Session..."); AppendMenu(m, MF_ENABLED, IDM_DUPSESS, "&Duplicate Session"); s = CreateMenu(); - get_sesslist(TRUE); - for (i = 1; i < ((nsessions < 256) ? nsessions : 256); i++) + get_sesslist(&sesslist, TRUE); + for (i = 1; + i < ((sesslist.nsessions < 256) ? sesslist.nsessions : 256); + i++) AppendMenu(s, MF_ENABLED, IDM_SAVED_MIN + (16 * i), - sessions[i]); + sesslist.sessions[i]); AppendMenu(m, MF_POPUP | MF_ENABLED, (UINT) s, "Sa&ved Sessions"); AppendMenu(m, MF_ENABLED, IDM_RECONF, "Chan&ge Settings..."); AppendMenu(m, MF_SEPARATOR, 0, 0); @@ -1692,9 +1701,9 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, sprintf(c, "putty &%p", filemap); cl = c; } else if (wParam == IDM_SAVEDSESS) { - if ((lParam - IDM_SAVED_MIN) / 16 < nsessions) { + if ((lParam - IDM_SAVED_MIN) / 16 < sesslist.nsessions) { char *session = - sessions[(lParam - IDM_SAVED_MIN) / 16]; + sesslist.sessions[(lParam - IDM_SAVED_MIN) / 16]; cl = smalloc(16 + strlen(session)); /* 8, but play safe */ if (!cl) @@ -2082,7 +2091,8 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, (p.rcPaint.left-offset_width)/font_width, (p.rcPaint.top-offset_height)/font_height, (p.rcPaint.right-offset_width-1)/font_width, - (p.rcPaint.bottom-offset_height-1)/font_height); + (p.rcPaint.bottom-offset_height-1)/font_height, + is_alt_pressed()); if (p.fErase || p.rcPaint.left < offset_width || @@ -2189,7 +2199,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.resize_action != RESIZE_FONT && !alt_pressed) { + if (cfg.resize_action != RESIZE_FONT && !is_alt_pressed()) { int width, height, w, h, ew, eh; LPRECT r = (LPRECT) lParam; @@ -2350,7 +2360,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, * down the connection during an NT opaque drag.) */ if (resizing) { - if (cfg.resize_action != RESIZE_FONT && !alt_pressed) { + if (cfg.resize_action != RESIZE_FONT && !is_alt_pressed()) { need_backend_resize = TRUE; w = (width-cfg.window_border*2) / font_width; if (w < 1) w = 1; @@ -2554,7 +2564,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, } default: if (message == wm_mousewheel || message == WM_MOUSEWHEEL) { - int shift_pressed=0, control_pressed=0, alt_pressed=0; + int shift_pressed=0, control_pressed=0; if (message == WM_MOUSEWHEEL) { wheel_accumulator += (short)HIWORD(wParam); @@ -2988,7 +2998,7 @@ void do_cursor(Context ctx, int x, int y, char *text, int len, /* This function gets the actual width of a character in the normal font. */ -int CharWidth(Context ctx, int uc) { +int char_width(Context ctx, int uc) { HDC hdc = ctx; int ibuf = 0; @@ -3188,8 +3198,6 @@ static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam, } } - alt_pressed = (left_alt && key_down); - scan = (HIWORD(lParam) & (KF_UP | KF_EXTENDED | 0xFF)); shift_state = ((keystate[VK_SHIFT] & 0x80) != 0) + ((keystate[VK_CONTROL] & 0x80) != 0) * 2;