X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/f25da523d156f0d30858552e0eec860462df1ca8..972a41c8b8558a89b9acd5b19a53367de7b1a7c5:/windlg.c diff --git a/windlg.c b/windlg.c index e7d58fd6..afe96249 100644 --- a/windlg.c +++ b/windlg.c @@ -9,14 +9,12 @@ #include "putty.h" #include "win_res.h" -#define NPANELS 7 -#define MAIN_NPANELS 7 -#define RECONF_NPANELS 4 +#define NPANELS 8 +#define MAIN_NPANELS 8 +#define RECONF_NPANELS 5 static const char *const puttystr = PUTTY_REG_POS "\\Sessions"; -static void get_sesslist(int allocate); - static char **negots = NULL; static int nnegots = 0, negsize = 0; static HWND logbox = NULL, abtbox = NULL; @@ -95,9 +93,6 @@ static void gppi(HKEY key, LPCTSTR name, int def, int *i) { static HINSTANCE hinst; -static char **sessions; -static int nsessions; - static int readytogo; static void save_settings (char *section, int do_host) { @@ -121,9 +116,11 @@ static void save_settings (char *section, int do_host) { wpps (sesskey, "HostName", cfg.host); wppi (sesskey, "PortNumber", cfg.port); wpps (sesskey, "Protocol", - cfg.protocol == PROT_SSH ? "ssh" : "telnet"); + cfg.protocol == PROT_SSH ? "ssh" : + cfg.protocol == PROT_TELNET ? "telnet" : "raw" ); } wppi (sesskey, "CloseOnExit", !!cfg.close_on_exit); + wppi (sesskey, "WarnOnClose", !!cfg.warn_on_close); wpps (sesskey, "TerminalType", cfg.termtype); wpps (sesskey, "TerminalSpeed", cfg.termspeed); { @@ -148,7 +145,7 @@ static void save_settings (char *section, int do_host) { wpps (sesskey, "UserName", cfg.username); wppi (sesskey, "NoPTY", cfg.nopty); wpps (sesskey, "Cipher", cfg.cipher == CIPHER_BLOWFISH ? "blowfish" : - "3des"); + cfg.cipher == CIPHER_DES ? "des" : "3des"); wppi (sesskey, "RFCEnviron", cfg.rfc_environ); wppi (sesskey, "BackspaceIsDelete", cfg.bksp_is_delete); wppi (sesskey, "RXVTHomeEnd", cfg.rxvt_homeend); @@ -164,6 +161,7 @@ static void save_settings (char *section, int do_host) { wppi (sesskey, "TermHeight", cfg.height); wpps (sesskey, "Font", cfg.font); wppi (sesskey, "FontIsBold", cfg.fontisbold); + wppi (sesskey, "FontCharSet", cfg.fontcharset); wppi (sesskey, "FontHeight", cfg.fontheight); wppi (sesskey, "FontVTMode", cfg.vtmode); wppi (sesskey, "TryPalette", cfg.try_palette); @@ -187,6 +185,8 @@ static void save_settings (char *section, int do_host) { } wpps (sesskey, buf, buf2); } + wppi (sesskey, "KoiWinXlat", cfg.xlat_enablekoiwin); + wppi (sesskey, "CapsLockCyr", cfg.xlat_capslockcyr); RegCloseKey(sesskey); } @@ -210,6 +210,7 @@ static void load_settings (char *section, int do_host) { int i; HKEY subkey1, sesskey; char *p; + char prot[10]; p = malloc(3*strlen(section)+1); mungestr(section, p); @@ -225,21 +226,20 @@ static void load_settings (char *section, int do_host) { free(p); - if (do_host) { - char prot[10]; - gpps (sesskey, "HostName", "", cfg.host, sizeof(cfg.host)); - gppi (sesskey, "PortNumber", 23, &cfg.port); - gpps (sesskey, "Protocol", "telnet", prot, 10); - if (!strcmp(prot, "ssh")) - cfg.protocol = PROT_SSH; - else - cfg.protocol = PROT_TELNET; - } else { + gpps (sesskey, "HostName", "", cfg.host, sizeof(cfg.host)); + gppi (sesskey, "PortNumber", default_port, &cfg.port); + gpps (sesskey, "Protocol", "default", prot, 10); + if (!strcmp(prot, "ssh")) + cfg.protocol = PROT_SSH; + else if (!strcmp(prot, "telnet")) cfg.protocol = PROT_TELNET; - cfg.port = 23; - *cfg.host = '\0'; - } + else if (!strcmp(prot, "raw")) + cfg.protocol = PROT_RAW; + else + cfg.protocol = default_protocol; + gppi (sesskey, "CloseOnExit", 1, &cfg.close_on_exit); + gppi (sesskey, "WarnOnClose", 1, &cfg.warn_on_close); gpps (sesskey, "TerminalType", "xterm", cfg.termtype, sizeof(cfg.termtype)); gpps (sesskey, "TerminalSpeed", "38400,38400", cfg.termspeed, @@ -270,6 +270,8 @@ static void load_settings (char *section, int do_host) { gpps (sesskey, "Cipher", "3des", cipher, 10); if (!strcmp(cipher, "blowfish")) cfg.cipher = CIPHER_BLOWFISH; + else if (!strcmp(cipher, "des")) + cfg.cipher = CIPHER_DES; else cfg.cipher = CIPHER_3DES; } @@ -288,6 +290,7 @@ static void load_settings (char *section, int do_host) { gppi (sesskey, "TermHeight", 24, &cfg.height); gpps (sesskey, "Font", "Courier", cfg.font, sizeof(cfg.font)); gppi (sesskey, "FontIsBold", 0, &cfg.fontisbold); + gppi (sesskey, "FontCharSet", ANSI_CHARSET, &cfg.fontcharset); gppi (sesskey, "FontHeight", 10, &cfg.fontheight); gppi (sesskey, "FontVTMode", VT_POORMAN, &cfg.vtmode); gppi (sesskey, "TryPalette", 0, &cfg.try_palette); @@ -330,6 +333,9 @@ static void load_settings (char *section, int do_host) { cfg.wordness[j] = atoi(q); } } + gppi (sesskey, "KoiWinXlat", 0, &cfg.xlat_enablekoiwin); + gppi (sesskey, "CapsLockCyr", 0, &cfg.xlat_capslockcyr); + RegCloseKey(sesskey); } @@ -453,9 +459,11 @@ static int CALLBACK ConnectionProc (HWND hwnd, UINT msg, for (i = 0; i < nsessions; i++) SendDlgItemMessage (hwnd, IDC0_SESSLIST, LB_ADDSTRING, 0, (LPARAM) (sessions[i])); - CheckRadioButton (hwnd, IDC0_PROTTELNET, IDC0_PROTSSH, - cfg.protocol==PROT_SSH ? IDC0_PROTSSH : IDC0_PROTTELNET); + CheckRadioButton (hwnd, IDC0_PROTRAW, IDC0_PROTSSH, + cfg.protocol==PROT_SSH ? IDC0_PROTSSH : + cfg.protocol==PROT_TELNET ? IDC0_PROTTELNET : IDC0_PROTRAW ); CheckDlgButton (hwnd, IDC0_CLOSEEXIT, cfg.close_on_exit); + CheckDlgButton (hwnd, IDC0_CLOSEWARN, cfg.warn_on_close); break; case WM_LBUTTONUP: /* @@ -470,10 +478,12 @@ static int CALLBACK ConnectionProc (HWND hwnd, UINT msg, switch (LOWORD(wParam)) { case IDC0_PROTTELNET: case IDC0_PROTSSH: + case IDC0_PROTRAW: if (HIWORD(wParam) == BN_CLICKED || HIWORD(wParam) == BN_DOUBLECLICKED) { int i = IsDlgButtonChecked (hwnd, IDC0_PROTSSH); - cfg.protocol = i ? PROT_SSH : PROT_TELNET; + int j = IsDlgButtonChecked (hwnd, IDC0_PROTTELNET); + cfg.protocol = i ? PROT_SSH : j ? PROT_TELNET : PROT_RAW ; if ((cfg.protocol == PROT_SSH && cfg.port == 23) || (cfg.protocol == PROT_TELNET && cfg.port == 22)) { cfg.port = i ? 22 : 23; @@ -495,6 +505,11 @@ static int CALLBACK ConnectionProc (HWND hwnd, UINT msg, HIWORD(wParam) == BN_DOUBLECLICKED) cfg.close_on_exit = IsDlgButtonChecked (hwnd, IDC0_CLOSEEXIT); break; + case IDC0_CLOSEWARN: + if (HIWORD(wParam) == BN_CLICKED || + HIWORD(wParam) == BN_DOUBLECLICKED) + cfg.warn_on_close = IsDlgButtonChecked (hwnd, IDC0_CLOSEWARN); + break; case IDC0_SESSEDIT: if (HIWORD(wParam) == EN_CHANGE) SendDlgItemMessage (hwnd, IDC0_SESSLIST, LB_SETCURSEL, @@ -549,10 +564,11 @@ static int CALLBACK ConnectionProc (HWND hwnd, UINT msg, !!strcmp(sessions[n], "Default Settings")); SetDlgItemText (hwnd, IDC0_HOST, cfg.host); SetDlgItemInt (hwnd, IDC0_PORT, cfg.port, FALSE); - CheckRadioButton (hwnd, IDC0_PROTTELNET, IDC0_PROTSSH, + CheckRadioButton (hwnd, IDC0_PROTRAW, IDC0_PROTSSH, (cfg.protocol==PROT_SSH ? IDC0_PROTSSH : - IDC0_PROTTELNET)); + cfg.protocol==PROT_TELNET ? IDC0_PROTTELNET : IDC0_PROTRAW)); CheckDlgButton (hwnd, IDC0_CLOSEEXIT, cfg.close_on_exit); + CheckDlgButton (hwnd, IDC0_CLOSEWARN, cfg.warn_on_close); SendDlgItemMessage (hwnd, IDC0_SESSLIST, LB_SETCURSEL, (WPARAM) -1, 0); } @@ -712,7 +728,7 @@ static int CALLBACK TerminalProc (HWND hwnd, UINT msg, lf.lfWidth = lf.lfEscapement = lf.lfOrientation = 0; lf.lfItalic = lf.lfUnderline = lf.lfStrikeOut = 0; lf.lfWeight = (cfg.fontisbold ? FW_BOLD : 0); - lf.lfCharSet = ANSI_CHARSET; + lf.lfCharSet = cfg.fontcharset; lf.lfOutPrecision = OUT_DEFAULT_PRECIS; lf.lfClipPrecision = CLIP_DEFAULT_PRECIS; lf.lfQuality = DEFAULT_QUALITY; @@ -730,6 +746,7 @@ static int CALLBACK TerminalProc (HWND hwnd, UINT msg, strncpy (cfg.font, lf.lfFaceName, sizeof(cfg.font)-1); cfg.font[sizeof(cfg.font)-1] = '\0'; cfg.fontisbold = (lf.lfWeight == FW_BOLD); + cfg.fontcharset = lf.lfCharSet; cfg.fontheight = lf.lfHeight; fmtfont (fontstatic); SetDlgItemText (hwnd, IDC2_FONTSTATIC, fontstatic); @@ -874,8 +891,10 @@ static int CALLBACK SshProc (HWND hwnd, UINT msg, SetDlgItemText (hwnd, IDC3_TTEDIT, cfg.termtype); SetDlgItemText (hwnd, IDC3_LOGEDIT, cfg.username); CheckDlgButton (hwnd, IDC3_NOPTY, cfg.nopty); - CheckRadioButton (hwnd, IDC3_CIPHER3DES, IDC3_CIPHERBLOWF, + CheckRadioButton (hwnd, IDC3_CIPHER3DES, IDC3_CIPHERDES, cfg.cipher == CIPHER_BLOWFISH ? IDC3_CIPHERBLOWF : + cfg.cipher == CIPHER_DES ? IDC3_CIPHERDES : + IDC3_CIPHER3DES); break; case WM_COMMAND: @@ -897,12 +916,15 @@ static int CALLBACK SshProc (HWND hwnd, UINT msg, break; case IDC3_CIPHER3DES: case IDC3_CIPHERBLOWF: + case IDC3_CIPHERDES: if (HIWORD(wParam) == BN_CLICKED || HIWORD(wParam) == BN_DOUBLECLICKED) { if (IsDlgButtonChecked (hwnd, IDC3_CIPHER3DES)) cfg.cipher = CIPHER_3DES; else if (IsDlgButtonChecked (hwnd, IDC3_CIPHERBLOWF)) cfg.cipher = CIPHER_BLOWFISH; + else if (IsDlgButtonChecked (hwnd, IDC3_CIPHERDES)) + cfg.cipher = CIPHER_DES; } break; } @@ -1084,9 +1106,36 @@ static int CALLBACK ColourProc (HWND hwnd, UINT msg, return GeneralPanelProc (hwnd, msg, wParam, lParam); } +static int CALLBACK LanguageProc (HWND hwnd, UINT msg, + WPARAM wParam, LPARAM lParam) { + switch (msg) { + case WM_INITDIALOG: + CheckDlgButton (hwnd, IDC6_ENABLEKOIWINXLAT, cfg.xlat_enablekoiwin); + CheckDlgButton (hwnd, IDC6_CAPSLOCKCYR, cfg.xlat_capslockcyr); + case WM_COMMAND: + switch (LOWORD(wParam)) { + case IDC6_ENABLEKOIWINXLAT: + if (HIWORD(wParam) == BN_CLICKED || + HIWORD(wParam) == BN_DOUBLECLICKED) { + cfg.xlat_enablekoiwin = + IsDlgButtonChecked (hwnd, IDC6_ENABLEKOIWINXLAT); + } + break; + case IDC6_CAPSLOCKCYR: + if (HIWORD(wParam) == BN_CLICKED || + HIWORD(wParam) == BN_DOUBLECLICKED) { + cfg.xlat_capslockcyr = + IsDlgButtonChecked (hwnd, IDC6_CAPSLOCKCYR); + } + break; + } + } + return GeneralPanelProc (hwnd, msg, wParam, lParam); +} + static DLGPROC panelproc[NPANELS] = { ConnectionProc, KeyboardProc, TerminalProc, - TelnetProc, SshProc, SelectionProc, ColourProc + TelnetProc, SshProc, SelectionProc, ColourProc, LanguageProc }; static char *panelids[NPANELS] = { MAKEINTRESOURCE(IDD_PANEL0), @@ -1095,14 +1144,17 @@ static char *panelids[NPANELS] = { MAKEINTRESOURCE(IDD_PANEL3), MAKEINTRESOURCE(IDD_PANEL35), MAKEINTRESOURCE(IDD_PANEL4), - MAKEINTRESOURCE(IDD_PANEL5) + MAKEINTRESOURCE(IDD_PANEL5), + MAKEINTRESOURCE(IDD_PANEL6) }; + static char *names[NPANELS] = { - "Connection", "Keyboard", "Terminal", "Telnet", "SSH", "Selection", "Colours" + "Connection", "Keyboard", "Terminal", "Telnet", + "SSH", "Selection", "Colours", "Language" }; -static int mainp[MAIN_NPANELS] = { 0, 1, 2, 3, 4, 5, 6 }; -static int reconfp[RECONF_NPANELS] = { 1, 2, 5, 6 }; +static int mainp[MAIN_NPANELS] = { 0, 1, 2, 3, 4, 5, 6, 7}; +static int reconfp[RECONF_NPANELS] = { 1, 2, 5, 6, 7}; static int GenericMainDlgProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam, @@ -1221,7 +1273,7 @@ static int CALLBACK ReconfDlgProc (HWND hwnd, UINT msg, RECONF_NPANELS, reconfp, &page); } -static void get_sesslist(int allocate) { +void get_sesslist(int allocate) { static char *buffer; int buflen, bufsize, i, ret; char otherbuf[2048];