X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/12745e35f6aa5ba7b1a89afe6d5249d8ca46dd37..45a22cae30aa5eecf2c534d7fc943a91d782e0a5:/windows/window.c diff --git a/windows/window.c b/windows/window.c index b5ac961d..214866a8 100644 --- a/windows/window.c +++ b/windows/window.c @@ -40,6 +40,7 @@ #define IDM_COPYALL 0x0170 #define IDM_FULLSCREEN 0x0180 #define IDM_PASTE 0x0190 +#define IDM_SPECIALSEP 0x0200 #define IDM_SPECIAL_MIN 0x0400 #define IDM_SPECIAL_MAX 0x0800 @@ -50,9 +51,9 @@ /* Maximum number of sessions on saved-session submenu */ #define MENU_SAVED_MAX ((IDM_SAVED_MAX-IDM_SAVED_MIN) / MENU_SAVED_STEP) -#define WM_IGNORE_CLIP (WM_XUSER + 2) -#define WM_FULLSCR_ON_MAX (WM_XUSER + 3) -#define WM_AGENT_CALLBACK (WM_XUSER + 4) +#define WM_IGNORE_CLIP (WM_APP + 2) +#define WM_FULLSCR_ON_MAX (WM_APP + 3) +#define WM_AGENT_CALLBACK (WM_APP + 4) /* Needed for Chinese support and apparently not always defined. */ #ifndef VK_PROCESSKEY @@ -111,15 +112,15 @@ static struct unicode_data ucsdata; static int session_closed; static int reconfiguring = FALSE; -static const struct telnet_special *specials; -static int n_specials; +static const struct telnet_special *specials = NULL; +static HMENU specials_menu = NULL; +static int n_specials = 0; #define TIMING_TIMER_ID 1234 static long timing_next_time; static struct { HMENU menu; - int specials_submenu_pos; } popup_menus[2]; enum { SYSMENU, CTXMENU }; static HMENU savedsess_menu; @@ -191,6 +192,11 @@ void ldisc_update(void *frontend, int echo, int edit) { } +char *get_ttymode(void *frontend, const char *mode) +{ + return term_get_ttymode(term, mode); +} + static void start_backend(void) { const char *error; @@ -759,7 +765,6 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show) m = popup_menus[j].menu; AppendMenu(m, MF_SEPARATOR, 0, 0); - popup_menus[j].specials_submenu_pos = GetMenuItemCount(m); AppendMenu(m, MF_ENABLED, IDM_SHOWLOG, "&Event Log"); AppendMenu(m, MF_SEPARATOR, 0, 0); AppendMenu(m, MF_ENABLED, IDM_NEWSESS, "Ne&w Session..."); @@ -791,11 +796,6 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show) set_input_locale(GetKeyboardLayout(0)); /* - * Open the initial log file if there is one. - */ - logfopen(logctx); - - /* * Finally show the window! */ ShowWindow(hwnd, show); @@ -914,8 +914,7 @@ static void update_savedsess_menu(void) */ void update_specials_menu(void *frontend) { - HMENU p; - int menu_already_exists = (specials != NULL); + HMENU new_menu; int i, j; if (back) @@ -928,30 +927,30 @@ void update_specials_menu(void *frontend) * here's a lame "stack" that will do for now. */ HMENU saved_menu = NULL; int nesting = 1; - p = CreatePopupMenu(); + new_menu = CreatePopupMenu(); for (i = 0; nesting > 0; i++) { assert(IDM_SPECIAL_MIN + 0x10 * i < IDM_SPECIAL_MAX); switch (specials[i].code) { case TS_SEP: - AppendMenu(p, MF_SEPARATOR, 0, 0); + AppendMenu(new_menu, MF_SEPARATOR, 0, 0); break; case TS_SUBMENU: assert(nesting < 2); nesting++; - saved_menu = p; /* XXX lame stacking */ - p = CreatePopupMenu(); + saved_menu = new_menu; /* XXX lame stacking */ + new_menu = CreatePopupMenu(); AppendMenu(saved_menu, MF_POPUP | MF_ENABLED, - (UINT) p, specials[i].name); + (UINT) new_menu, specials[i].name); break; case TS_EXITMENU: nesting--; if (nesting) { - p = saved_menu; /* XXX lame stacking */ + new_menu = saved_menu; /* XXX lame stacking */ saved_menu = NULL; } break; default: - AppendMenu(p, MF_ENABLED, IDM_SPECIAL_MIN + 0x10 * i, + AppendMenu(new_menu, MF_ENABLED, IDM_SPECIAL_MIN + 0x10 * i, specials[i].name); break; } @@ -959,29 +958,24 @@ void update_specials_menu(void *frontend) /* Squirrel the highest special. */ n_specials = i - 1; } else { - p = NULL; + new_menu = NULL; n_specials = 0; } for (j = 0; j < lenof(popup_menus); j++) { - if (menu_already_exists) { + if (specials_menu) { /* XXX does this free up all submenus? */ - DeleteMenu(popup_menus[j].menu, - popup_menus[j].specials_submenu_pos, - MF_BYPOSITION); - DeleteMenu(popup_menus[j].menu, - popup_menus[j].specials_submenu_pos, - MF_BYPOSITION); + DeleteMenu(popup_menus[j].menu, specials_menu, MF_BYCOMMAND); + DeleteMenu(popup_menus[j].menu, IDM_SPECIALSEP, MF_BYCOMMAND); } if (specials) { - InsertMenu(popup_menus[j].menu, - popup_menus[j].specials_submenu_pos, - MF_BYPOSITION | MF_SEPARATOR, 0, 0); - InsertMenu(popup_menus[j].menu, - popup_menus[j].specials_submenu_pos, - MF_BYPOSITION | MF_POPUP | MF_ENABLED, - (UINT) p, "S&pecial Command"); + InsertMenu(popup_menus[j].menu, IDM_SHOWLOG, + MF_BYCOMMAND | MF_POPUP | MF_ENABLED, + (UINT) new_menu, "S&pecial Command"); + InsertMenu(popup_menus[j].menu, IDM_SHOWLOG, + MF_BYCOMMAND | MF_SEPARATOR, IDM_SPECIALSEP, 0); } + specials_menu = new_menu; } } @@ -1010,7 +1004,7 @@ static void update_mouse_pointer(void) } { HCURSOR cursor = LoadCursor(NULL, curstype); - SetClassLong(hwnd, GCL_HCURSOR, (LONG)cursor); + SetClassLongPtr(hwnd, GCLP_HCURSOR, (LONG_PTR)cursor); SetCursor(cursor); /* force redraw of cursor at current posn */ } if (force_visible != forced_visible) { @@ -1130,12 +1124,12 @@ static void cfgtopalette(void) for (i = 0; i < NEXTCOLOURS; i++) { if (i < 216) { int r = i / 36, g = (i / 6) % 6, b = i % 6; - defpal[i+16].rgbtRed = r * 0x33; - defpal[i+16].rgbtGreen = g * 0x33; - defpal[i+16].rgbtBlue = b * 0x33; + defpal[i+16].rgbtRed = r ? r * 40 + 55 : 0; + defpal[i+16].rgbtGreen = g ? g * 40 + 55 : 0; + defpal[i+16].rgbtBlue = b ? b * 40 + 55 : 0; } else { int shade = i - 216; - shade = (shade + 1) * 0xFF / (NEXTCOLOURS - 216 + 1); + shade = shade * 10 + 8; defpal[i+16].rgbtRed = defpal[i+16].rgbtGreen = defpal[i+16].rgbtBlue = shade; } @@ -1314,7 +1308,7 @@ static void init_fonts(int pick_width, int pick_height) #define f(i,c,w,u) \ fonts[i] = CreateFont (font_height, font_width, 0, 0, w, FALSE, u, FALSE, \ c, OUT_DEFAULT_PRECIS, \ - CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, \ + CLIP_DEFAULT_PRECIS, FONT_QUALITY(cfg.font_quality), \ FIXED_PITCH | FF_DONTCARE, cfg.font.name) f(FONT_NORMAL, cfg.font.charset, fw_dontcare, FALSE); @@ -1483,7 +1477,7 @@ static void another_font(int fontno) fonts[fontno] = CreateFont(font_height * (1 + !!(fontno & FONT_HIGH)), x, 0, 0, w, FALSE, u, FALSE, c, OUT_DEFAULT_PRECIS, - CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, + CLIP_DEFAULT_PRECIS, FONT_QUALITY(cfg.font_quality), FIXED_PITCH | FF_DONTCARE, s); fontflag[fontno] = 1; @@ -2065,9 +2059,9 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, /* Enable or disable the scroll bar, etc */ { - LONG nflg, flag = GetWindowLong(hwnd, GWL_STYLE); + LONG nflg, flag = GetWindowLongPtr(hwnd, GWL_STYLE); LONG nexflag, exflag = - GetWindowLong(hwnd, GWL_EXSTYLE); + GetWindowLongPtr(hwnd, GWL_EXSTYLE); nexflag = exflag; if (cfg.alwaysontop != prev_cfg.alwaysontop) { @@ -2106,9 +2100,9 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, if (nflg != flag || nexflag != exflag) { if (nflg != flag) - SetWindowLong(hwnd, GWL_STYLE, nflg); + SetWindowLongPtr(hwnd, GWL_STYLE, nflg); if (nexflag != exflag) - SetWindowLong(hwnd, GWL_EXSTYLE, nexflag); + SetWindowLongPtr(hwnd, GWL_EXSTYLE, nexflag); SetWindowPos(hwnd, NULL, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOCOPYBITS | @@ -2137,6 +2131,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, cfg.font.isbold != prev_cfg.font.isbold || cfg.font.height != prev_cfg.font.height || cfg.font.charset != prev_cfg.font.charset || + cfg.font_quality != prev_cfg.font_quality || cfg.vtmode != prev_cfg.vtmode || cfg.bold_colour != prev_cfg.bold_colour || cfg.resize_action == RESIZE_DISABLED || @@ -4508,7 +4503,7 @@ void write_clip(void *frontend, wchar_t * data, int len, int must_deselect) rtfsize = 100 + strlen(cfg.font.name); rtf = snewn(rtfsize, char); - sprintf(rtf, "{\\rtf1\\ansi%d{\\fonttbl\\f0\\fmodern %s;}\\f0", + sprintf(rtf, "{\\rtf1\\ansi%d{\\fonttbl\\f0\\fmodern %s;}\\f0 ", GetACP(), cfg.font.name); rtflen = strlen(rtf); @@ -4772,7 +4767,7 @@ static void flash_window(int mode) /* * Beep. */ -void beep(void *frontend, int mode) +void do_beep(void *frontend, int mode) { if (mode == BELL_DEFAULT) { /* @@ -4937,7 +4932,7 @@ static int is_full_screen() { if (!IsZoomed(hwnd)) return FALSE; - if (GetWindowLong(hwnd, GWL_STYLE) & WS_CAPTION) + if (GetWindowLongPtr(hwnd, GWL_STYLE) & WS_CAPTION) return FALSE; return TRUE; } @@ -4983,13 +4978,13 @@ static void make_full_screen() return; /* Remove the window furniture. */ - style = GetWindowLong(hwnd, GWL_STYLE); + style = GetWindowLongPtr(hwnd, GWL_STYLE); style &= ~(WS_CAPTION | WS_BORDER | WS_THICKFRAME); if (cfg.scrollbar_in_fullscreen) style |= WS_VSCROLL; else style &= ~WS_VSCROLL; - SetWindowLong(hwnd, GWL_STYLE, style); + SetWindowLongPtr(hwnd, GWL_STYLE, style); /* Resize ourselves to exactly cover the nearest monitor. */ get_fullscreen_rect(&ss); @@ -5011,7 +5006,7 @@ static void clear_full_screen() DWORD oldstyle, style; /* Reinstate the window furniture. */ - style = oldstyle = GetWindowLong(hwnd, GWL_STYLE); + style = oldstyle = GetWindowLongPtr(hwnd, GWL_STYLE); style |= WS_CAPTION | WS_BORDER; if (cfg.resize_action == RESIZE_DISABLED) style &= ~WS_THICKFRAME; @@ -5022,7 +5017,7 @@ static void clear_full_screen() else style &= ~WS_VSCROLL; if (style != oldstyle) { - SetWindowLong(hwnd, GWL_STYLE, style); + SetWindowLongPtr(hwnd, GWL_STYLE, style); SetWindowPos(hwnd, NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED); @@ -5064,6 +5059,20 @@ int from_backend(void *frontend, int is_stderr, const char *data, int len) return term_data(term, is_stderr, data, len); } +int from_backend_untrusted(void *frontend, const char *data, int len) +{ + return term_data_untrusted(term, data, len); +} + +int get_userpass_input(prompts_t *p, unsigned char *in, int inlen) +{ + int ret; + ret = cmdline_get_passwd_input(p, in, inlen); + if (ret == -1) + ret = term_get_userpass_input(term, p, in, inlen); + return ret; +} + void agent_schedule_callback(void (*callback)(void *, void *, int), void *callback_ctx, void *data, int len) {