X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/3ac9cd9f913cd762475a710a2ae2163b74a55c46..3dd87daecf17d0f7d573f8a2d03488f1ffbff392:/windlg.c diff --git a/windlg.c b/windlg.c index 737305df..f164f3e0 100644 --- a/windlg.c +++ b/windlg.c @@ -3,6 +3,7 @@ #include #include #include +#include #include "ssh.h" #include "putty.h" @@ -13,8 +14,6 @@ static char **events = NULL; static int nevents = 0, negsize = 0; -static HWND logbox = NULL, abtbox = NULL; - static int readytogo; void force_normal(HWND hwnd) @@ -56,7 +55,9 @@ static int CALLBACK LogProc (HWND hwnd, UINT msg, case WM_COMMAND: switch (LOWORD(wParam)) { case IDOK: + case IDCANCEL: logbox = NULL; + SetActiveWindow(GetParent(hwnd)); DestroyWindow (hwnd); return 0; case IDN_COPY: @@ -66,6 +67,11 @@ static int CALLBACK LogProc (HWND hwnd, UINT msg, int *selitems; selcount = SendDlgItemMessage(hwnd, IDN_LIST, LB_GETSELCOUNT, 0, 0); + if (selcount == 0) { /* don't even try to copy zero items */ + MessageBeep(0); + break; + } + selitems = smalloc(selcount * sizeof(int)); if (selitems) { int count = SendDlgItemMessage(hwnd, IDN_LIST, @@ -111,6 +117,7 @@ static int CALLBACK LogProc (HWND hwnd, UINT msg, return 0; case WM_CLOSE: logbox = NULL; + SetActiveWindow(GetParent(hwnd)); DestroyWindow (hwnd); return 0; } @@ -145,8 +152,8 @@ static int CALLBACK AboutProc (HWND hwnd, UINT msg, case WM_COMMAND: switch (LOWORD(wParam)) { case IDOK: - abtbox = NULL; - DestroyWindow (hwnd); + case IDCANCEL: + EndDialog(hwnd, TRUE); return 0; case IDA_LICENCE: EnableWindow(hwnd, 0); @@ -158,8 +165,7 @@ static int CALLBACK AboutProc (HWND hwnd, UINT msg, } return 0; case WM_CLOSE: - abtbox = NULL; - DestroyWindow (hwnd); + EndDialog(hwnd, TRUE); return 0; } return 0; @@ -198,8 +204,22 @@ enum { IDCX_ABOUT = IDC_ABOUT, IDCX_TVSTATIC, IDCX_TREEVIEW, controlstartvalue, IDC_SESSSAVE, IDC_SESSDEL, IDC_CLOSEEXIT, + IDC_COEALWAYS, + IDC_COENEVER, + IDC_COENORMAL, sessionpanelend, + loggingpanelstart, + IDC_BOX_LOGGING1, + IDC_LSTATSTATIC, + IDC_LSTATOFF, + IDC_LSTATASCII, + IDC_LSTATRAW, + IDC_LGFSTATIC, + IDC_LGFEDIT, + IDC_LGFBUTTON, + loggingpanelend, + keyboardpanelstart, IDC_TITLE_KEYBOARD, IDC_BOX_KEYBOARD1, @@ -238,14 +258,14 @@ enum { IDCX_ABOUT = IDC_ABOUT, IDCX_TVSTATIC, IDCX_TREEVIEW, controlstartvalue, IDC_BEEP, IDC_BCE, IDC_BLINKTEXT, - IDC_LDISCTERM, - IDC_LSTATSTATIC, - IDC_LSTATOFF, - IDC_LSTATASCII, - IDC_LSTATRAW, - IDC_LGFSTATIC, - IDC_LGFEDIT, - IDC_LGFBUTTON, + IDC_ECHOSTATIC, + IDC_ECHOBACKEND, + IDC_ECHOYES, + IDC_ECHONO, + IDC_EDITSTATIC, + IDC_EDITBACKEND, + IDC_EDITYES, + IDC_EDITNO, terminalpanelend, windowpanelstart, @@ -489,7 +509,12 @@ static void init_dlg_ctrls(HWND hwnd) { CheckDlgButton (hwnd, IDC_ALTSPACE, cfg.alt_space); CheckDlgButton (hwnd, IDC_ALTONLY, cfg.alt_only); CheckDlgButton (hwnd, IDC_COMPOSEKEY, cfg.compose_key); - CheckDlgButton (hwnd, IDC_LDISCTERM, cfg.ldisc_term); + CheckRadioButton (hwnd, IDC_ECHOBACKEND, IDC_ECHONO, + cfg.localecho == LD_BACKEND ? IDC_ECHOBACKEND: + cfg.localecho == LD_YES ? IDC_ECHOYES : IDC_ECHONO); + CheckRadioButton (hwnd, IDC_EDITBACKEND, IDC_EDITNO, + cfg.localedit == LD_BACKEND ? IDC_EDITBACKEND: + cfg.localedit == LD_YES ? IDC_EDITYES : IDC_EDITNO); CheckDlgButton (hwnd, IDC_ALWAYSONTOP, cfg.alwaysontop); CheckDlgButton (hwnd, IDC_SCROLLKEY, cfg.scroll_on_key); CheckDlgButton (hwnd, IDC_SCROLLDISP, cfg.scroll_on_disp); @@ -515,7 +540,9 @@ static void init_dlg_ctrls(HWND hwnd) { CheckDlgButton (hwnd, IDC_BLINKCUR, cfg.blink_cur); CheckDlgButton (hwnd, IDC_SCROLLBAR, cfg.scrollbar); CheckDlgButton (hwnd, IDC_LOCKSIZE, cfg.locksize); - CheckDlgButton (hwnd, IDC_CLOSEEXIT, cfg.close_on_exit); + CheckRadioButton (hwnd, IDC_COEALWAYS, IDC_COENORMAL, + cfg.close_on_exit==COE_NORMAL ? IDC_COENORMAL : + cfg.close_on_exit==COE_NEVER ? IDC_COENEVER : IDC_COEALWAYS); CheckDlgButton (hwnd, IDC_CLOSEWARN, cfg.warn_on_close); SetDlgItemText (hwnd, IDC_TTEDIT, cfg.termtype); @@ -637,7 +664,7 @@ static HTREEITEM treeview_insert(struct treeview_faff *faff, */ static void create_controls(HWND hwnd, int dlgtype, int panel) { if (panel == sessionpanelstart) { - /* The Session panel. Accelerators used: [acgo] nprthelsdx */ + /* The Session panel. Accelerators used: [acgo] nprtih elsd w */ struct ctlpos cp; ctlposinit(&cp, hwnd, 80, 3, 13); bartitle(&cp, "Basic options for your PuTTY session", @@ -653,12 +680,12 @@ static void create_controls(HWND hwnd, int dlgtype, int panel) { radioline(&cp, "Protocol:", IDC_PROTSTATIC, 4, "&Raw", IDC_PROTRAW, "&Telnet", IDC_PROTTELNET, - "R&login", IDC_PROTRLOGIN, NULL); + "Rlog&in", IDC_PROTRLOGIN, NULL); } else { radioline(&cp, "Protocol:", IDC_PROTSTATIC, 4, "&Raw", IDC_PROTRAW, "&Telnet", IDC_PROTTELNET, - "R&login", IDC_PROTRLOGIN, + "Rlog&in", IDC_PROTRLOGIN, #ifdef FWHACK "SS&H/hack", #else @@ -677,12 +704,33 @@ static void create_controls(HWND hwnd, int dlgtype, int panel) { endbox(&cp); } beginbox(&cp, NULL, IDC_BOX_SESSION3); - checkbox(&cp, "Close Window on E&xit", IDC_CLOSEEXIT); + radioline(&cp, "Close &window on exit:", IDC_CLOSEEXIT, 4, + "Always", IDC_COEALWAYS, + "Never", IDC_COENEVER, + "Only on clean exit", IDC_COENORMAL, NULL); + endbox(&cp); + } + + if (panel == loggingpanelstart) { + /* The Logging panel. Accelerators used: [acgo] tplfw */ + struct ctlpos cp; + ctlposinit(&cp, hwnd, 80, 3, 13); + bartitle(&cp, "Options controlling session logging", + IDC_TITLE_TERMINAL); + beginbox(&cp, NULL, IDC_BOX_LOGGING1); + radiobig(&cp, + "Session logging:", IDC_LSTATSTATIC, + "Logging &turned off completely", IDC_LSTATOFF, + "Log &printable output only", IDC_LSTATASCII, + "&Log all session output", IDC_LSTATRAW, NULL); + editbutton(&cp, "Log &file name:", + IDC_LGFSTATIC, IDC_LGFEDIT, "Bro&wse...", + IDC_LGFBUTTON); endbox(&cp); } if (panel == terminalpanelstart) { - /* The Terminal panel. Accelerators used: [acgo] &dflbenuw */ + /* The Terminal panel. Accelerators used: [acgo] wdlben ht */ struct ctlpos cp; ctlposinit(&cp, hwnd, 80, 3, 13); bartitle(&cp, "Options controlling the terminal emulation", @@ -695,24 +743,23 @@ static void create_controls(HWND hwnd, int dlgtype, int panel) { checkbox(&cp, "&Beep enabled", IDC_BEEP); checkbox(&cp, "Use background colour to &erase screen", IDC_BCE); checkbox(&cp, "Enable bli&nking text", IDC_BLINKTEXT); - checkbox(&cp, "&Use local terminal line discipline", IDC_LDISCTERM); endbox(&cp); - beginbox(&cp, "Control session logging", + beginbox(&cp, "Line discipline options", IDC_BOX_TERMINAL2); - radiobig(&cp, - "Session logging:", IDC_LSTATSTATIC, - "Logging turned &off completely", IDC_LSTATOFF, - "Log printable output only", IDC_LSTATASCII, - "Log all session output", IDC_LSTATRAW, NULL); - editbutton(&cp, "Log &file name:", - IDC_LGFSTATIC, IDC_LGFEDIT, "Bro&wse...", - IDC_LGFBUTTON); + radioline(&cp, "Local ec&ho:", IDC_ECHOSTATIC, 3, + "Auto", IDC_ECHOBACKEND, + "Force on", IDC_ECHOYES, + "Force off", IDC_ECHONO, NULL); + radioline(&cp, "Local line edi&ting:", IDC_EDITSTATIC, 3, + "Auto", IDC_EDITBACKEND, + "Force on", IDC_EDITYES, + "Force off", IDC_EDITNO, NULL); endbox(&cp); } if (panel == keyboardpanelstart) { - /* The Keyboard panel. Accelerators used: [acgo] h?srvlxvnpmietu */ + /* The Keyboard panel. Accelerators used: [acgo] h?sr~lxv unpymie t */ struct ctlpos cp; ctlposinit(&cp, hwnd, 80, 3, 13); bartitle(&cp, "Options controlling the effects of keys", @@ -755,7 +802,7 @@ static void create_controls(HWND hwnd, int dlgtype, int panel) { } if (panel == windowpanelstart) { - /* The Window panel. Accelerators used: [acgo] bsdkw4ylpt */ + /* The Window panel. Accelerators used: [acgo] rmz sdkp w4ylt */ struct ctlpos cp; ctlposinit(&cp, hwnd, 80, 3, 13); bartitle(&cp, "Options controlling PuTTY's window", @@ -766,7 +813,7 @@ static void create_controls(HWND hwnd, int dlgtype, int panel) { "&Rows", IDC_ROWSSTATIC, IDC_ROWSEDIT, 50, "Colu&mns", IDC_COLSSTATIC, IDC_COLSEDIT, 50, NULL); - checkbox(&cp, "Loc&k window size against resizing", IDC_LOCKSIZE); + checkbox(&cp, "Lock window size against resi&zing", IDC_LOCKSIZE); endbox(&cp); beginbox(&cp, "Control the scrollback in the window", IDC_BOX_WINDOW2); @@ -787,7 +834,7 @@ static void create_controls(HWND hwnd, int dlgtype, int panel) { } if (panel == appearancepanelstart) { - /* The Appearance panel. Accelerators used: [acgo] rmkhtibluv */ + /* The Appearance panel. Accelerators used: [acgo] luvb h ti p */ struct ctlpos cp; ctlposinit(&cp, hwnd, 80, 3, 13); bartitle(&cp, "Options controlling PuTTY's appearance", @@ -820,7 +867,7 @@ static void create_controls(HWND hwnd, int dlgtype, int panel) { } if (panel == translationpanelstart) { - /* The Translation panel. Accelerators used: [acgo] xbepnkis */ + /* The Translation panel. Accelerators used: [acgo] xbep t s */ struct ctlpos cp; ctlposinit(&cp, hwnd, 80, 3, 13); bartitle(&cp, "Options controlling character set translation", @@ -838,11 +885,11 @@ static void create_controls(HWND hwnd, int dlgtype, int panel) { beginbox(&cp, "Enable character set translation on received data", IDC_BOX_TRANSLATION2); radiobig(&cp, - "Character set translation:", IDC_XLATSTATIC, - "&None", IDC_NOXLAT, - "&KOI8 / Win-1251", IDC_KOI8WIN1251, - "&ISO-8859-2 / Win-1250", IDC_88592WIN1250, - "&ISO-8859-2 / CP852", IDC_88592CP852, NULL); + "Character set &translation:", IDC_XLATSTATIC, + "None", IDC_NOXLAT, + "KOI8 / Win-1251", IDC_KOI8WIN1251, + "ISO-8859-2 / Win-1250", IDC_88592WIN1250, + "ISO-8859-2 / CP852", IDC_88592CP852, NULL); endbox(&cp); beginbox(&cp, "Enable character set translation on input data", IDC_BOX_TRANSLATION3); @@ -852,7 +899,7 @@ static void create_controls(HWND hwnd, int dlgtype, int panel) { } if (panel == selectionpanelstart) { - /* The Selection panel. Accelerators used: [acgo] wxst */ + /* The Selection panel. Accelerators used: [acgo] wx hst */ struct ctlpos cp; ctlposinit(&cp, hwnd, 80, 3, 13); bartitle(&cp, "Options controlling copy and paste", @@ -866,7 +913,7 @@ static void create_controls(HWND hwnd, int dlgtype, int panel) { endbox(&cp); beginbox(&cp, "Control the select-one-word-at-a-time mode", IDC_BOX_SELECTION2); - charclass(&cp, "Character classes:", IDC_CCSTATIC, IDC_CCLIST, + charclass(&cp, "C&haracter classes:", IDC_CCSTATIC, IDC_CCLIST, "&Set", IDC_CCSET, IDC_CCEDIT, "&to class", IDC_CCSTATIC2); endbox(&cp); @@ -909,12 +956,12 @@ static void create_controls(HWND hwnd, int dlgtype, int panel) { beginbox(&cp, "Sending of null packets to keep session active", IDC_BOX_CONNECTION2); staticedit(&cp, "Seconds between &keepalives (0 to turn off)", - IDC_PINGSTATIC, IDC_PINGEDIT, 25); + IDC_PINGSTATIC, IDC_PINGEDIT, 20); endbox(&cp); } if (panel == telnetpanelstart) { - /* The Telnet panel. Accelerators used: [acgo] svldrbf */ + /* The Telnet panel. Accelerators used: [acgo] svldr bf */ struct ctlpos cp; ctlposinit(&cp, hwnd, 80, 3, 13); if (dlgtype == 0) { @@ -952,7 +999,7 @@ static void create_controls(HWND hwnd, int dlgtype, int panel) { } if (panel == sshpanelstart) { - /* The SSH panel. Accelerators used: [acgo] rmakwp123bd */ + /* The SSH panel. Accelerators used: [acgo] rmfkw pe123bd i */ struct ctlpos cp; ctlposinit(&cp, hwnd, 80, 3, 13); if (dlgtype == 0) { @@ -967,7 +1014,7 @@ static void create_controls(HWND hwnd, int dlgtype, int panel) { IDC_BOX_SSH2); checkbox(&cp, "Atte&mpt TIS or CryptoCard authentication", IDC_AUTHTIS); - checkbox(&cp, "Allow &agent forwarding", IDC_AGENTFWD); + checkbox(&cp, "Allow agent &forwarding", IDC_AGENTFWD); editbutton(&cp, "Private &key file for authentication:", IDC_PKSTATIC, IDC_PKEDIT, "Bro&wse...", IDC_PKBUTTON); endbox(&cp); @@ -982,7 +1029,7 @@ static void create_controls(HWND hwnd, int dlgtype, int panel) { "&3DES", IDC_CIPHER3DES, "&Blowfish", IDC_CIPHERBLOWF, "&DES", IDC_CIPHERDES, NULL); - checkbox(&cp, "Imitate SSH 2 MAC bug in commercial <= v2.3.x", + checkbox(&cp, "&Imitate SSH 2 MAC bug in commercial <= v2.3.x", IDC_BUGGYMAC); endbox(&cp); } @@ -1081,6 +1128,7 @@ static int GenericMainDlgProc (HWND hwnd, UINT msg, * Set up the tree view contents. */ hsession = treeview_insert(&tvfaff, 0, "Session"); + treeview_insert(&tvfaff, 1, "Logging"); treeview_insert(&tvfaff, 0, "Terminal"); treeview_insert(&tvfaff, 1, "Keyboard"); treeview_insert(&tvfaff, 0, "Window"); @@ -1092,9 +1140,10 @@ static int GenericMainDlgProc (HWND hwnd, UINT msg, if (dlgtype == 0) { treeview_insert(&tvfaff, 1, "Telnet"); treeview_insert(&tvfaff, 1, "Rlogin"); - if (backends[3].backend != NULL) + if (backends[3].backend != NULL) { treeview_insert(&tvfaff, 1, "SSH"); - treeview_insert(&tvfaff, 2, "Tunnels"); + treeview_insert(&tvfaff, 2, "Tunnels"); + } } /* @@ -1143,6 +1192,8 @@ static int GenericMainDlgProc (HWND hwnd, UINT msg, } if (!strcmp(buffer, "Session")) create_controls(hwnd, dlgtype, sessionpanelstart); + if (!strcmp(buffer, "Logging")) + create_controls(hwnd, dlgtype, loggingpanelstart); if (!strcmp(buffer, "Keyboard")) create_controls(hwnd, dlgtype, keyboardpanelstart); if (!strcmp(buffer, "Terminal")) @@ -1397,10 +1448,25 @@ static int GenericMainDlgProc (HWND hwnd, UINT msg, HIWORD(wParam) == BN_DOUBLECLICKED) cfg.alt_only = IsDlgButtonChecked (hwnd, IDC_ALTONLY); break; - case IDC_LDISCTERM: + case IDC_ECHOBACKEND: + case IDC_ECHOYES: + case IDC_ECHONO: if (HIWORD(wParam) == BN_CLICKED || - HIWORD(wParam) == BN_DOUBLECLICKED) - cfg.ldisc_term = IsDlgButtonChecked (hwnd, IDC_LDISCTERM); + HIWORD(wParam) == BN_DOUBLECLICKED) { + if (LOWORD(wParam)==IDC_ECHOBACKEND) cfg.localecho=LD_BACKEND; + if (LOWORD(wParam)==IDC_ECHOYES) cfg.localecho=LD_YES; + if (LOWORD(wParam)==IDC_ECHONO) cfg.localecho=LD_NO; + } + break; + case IDC_EDITBACKEND: + case IDC_EDITYES: + case IDC_EDITNO: + if (HIWORD(wParam) == BN_CLICKED || + HIWORD(wParam) == BN_DOUBLECLICKED) { + if (LOWORD(wParam)==IDC_EDITBACKEND) cfg.localedit=LD_BACKEND; + if (LOWORD(wParam)==IDC_EDITYES) cfg.localedit=LD_YES; + if (LOWORD(wParam)==IDC_EDITNO) cfg.localedit=LD_NO; + } break; case IDC_ALWAYSONTOP: if (HIWORD(wParam) == BN_CLICKED || @@ -1538,11 +1604,16 @@ static int GenericMainDlgProc (HWND hwnd, UINT msg, GetDlgItemText (hwnd, IDC_WINEDIT, cfg.wintitle, sizeof(cfg.wintitle)-1); break; - case IDC_CLOSEEXIT: - if (HIWORD(wParam) == BN_CLICKED || - HIWORD(wParam) == BN_DOUBLECLICKED) - cfg.close_on_exit = IsDlgButtonChecked (hwnd, IDC_CLOSEEXIT); - break; + case IDC_COEALWAYS: + case IDC_COENEVER: + case IDC_COENORMAL: + if (HIWORD(wParam) == BN_CLICKED || + HIWORD(wParam) == BN_DOUBLECLICKED) { + cfg.close_on_exit = IsDlgButtonChecked (hwnd, IDC_COEALWAYS) ? COE_ALWAYS : + IsDlgButtonChecked (hwnd, IDC_COENEVER) ? COE_NEVER : + COE_NORMAL; + } + break; case IDC_CLOSEWARN: if (HIWORD(wParam) == BN_CLICKED || HIWORD(wParam) == BN_DOUBLECLICKED) @@ -1569,15 +1640,15 @@ static int GenericMainDlgProc (HWND hwnd, UINT msg, of.lpstrFilter = "All Files\0*\0\0\0"; of.lpstrCustomFilter = NULL; of.nFilterIndex = 1; - of.lpstrFile = filename; strcpy(filename, cfg.keyfile); + of.lpstrFile = filename; strcpy(filename, cfg.logfilename); of.nMaxFile = sizeof(filename); of.lpstrFileTitle = NULL; of.lpstrInitialDir = NULL; of.lpstrTitle = "Select session log file"; of.Flags = 0; if (GetSaveFileName(&of)) { - strcpy(cfg.keyfile, filename); - SetDlgItemText (hwnd, IDC_LGFEDIT, cfg.keyfile); + strcpy(cfg.logfilename, filename); + SetDlgItemText (hwnd, IDC_LGFEDIT, cfg.logfilename); } break; case IDC_LSTATOFF: @@ -1911,8 +1982,6 @@ static int GenericMainDlgProc (HWND hwnd, UINT msg, static int CALLBACK MainDlgProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { - static HWND page = NULL; - if (msg == WM_COMMAND && LOWORD(wParam) == IDOK) { } if (msg == WM_COMMAND && LOWORD(wParam) == IDCX_ABOUT) { @@ -1927,7 +1996,6 @@ static int CALLBACK MainDlgProc (HWND hwnd, UINT msg, static int CALLBACK ReconfDlgProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { - static HWND page; return GenericMainDlgProc (hwnd, msg, wParam, lParam, 1); } @@ -1992,14 +2060,11 @@ void showeventlog (HWND hwnd) { hwnd, LogProc); ShowWindow (logbox, SW_SHOWNORMAL); } + SetActiveWindow(logbox); } void showabout (HWND hwnd) { - if (!abtbox) { - abtbox = CreateDialog (hinst, MAKEINTRESOURCE(IDD_ABOUTBOX), - hwnd, AboutProc); - ShowWindow (abtbox, SW_SHOWNORMAL); - } + DialogBox(hinst, MAKEINTRESOURCE(IDD_ABOUTBOX),hwnd, AboutProc); } void verify_ssh_host_key(char *host, int port, char *keytype,