Created new data types `Filename' and `FontSpec', intended to be
[u/mdw/putty] / windlg.c
index 6d035ce..944cfda 100644 (file)
--- a/windlg.c
+++ b/windlg.c
@@ -657,22 +657,17 @@ static const char *const colours[] = {
     "ANSI Cyan", "ANSI Cyan Bold",
     "ANSI White", "ANSI White Bold"
 };
-static const int permcolour[] = {
-    TRUE, FALSE, TRUE, FALSE, TRUE, TRUE,
-    TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE,
-    TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE
-};
 
 static void fmtfont(char *buf)
 {
-    sprintf(buf, "Font: %s, ", cfg.font);
-    if (cfg.fontisbold)
+    sprintf(buf, "Font: %s, ", cfg.font.name);
+    if (cfg.font.isbold)
        strcat(buf, "bold, ");
-    if (cfg.fontheight == 0)
+    if (cfg.font.height == 0)
        strcat(buf, "default height");
     else
        sprintf(buf + strlen(buf), "%d-point",
-               (cfg.fontheight < 0 ? -cfg.fontheight : cfg.fontheight));
+               (cfg.font.height < 0 ? -cfg.font.height : cfg.font.height));
 }
 
 char *help_context_cmd(int id)
@@ -1136,11 +1131,11 @@ static void init_dlg_ctrls(HWND hwnd, int keepsess)
     CheckDlgButton(hwnd, IDC_TELNETKEY, cfg.telnet_keyboard);
     CheckDlgButton(hwnd, IDC_TELNETRET, cfg.telnet_newline);
     CheckRadioButton(hwnd, IDC_ECHOBACKEND, IDC_ECHONO,
-                    cfg.localecho == LD_BACKEND ? IDC_ECHOBACKEND :
-                    cfg.localecho == LD_YES ? IDC_ECHOYES : IDC_ECHONO);
+                    cfg.localecho == AUTO ? IDC_ECHOBACKEND :
+                    cfg.localecho == FORCE_ON ? IDC_ECHOYES : IDC_ECHONO);
     CheckRadioButton(hwnd, IDC_EDITBACKEND, IDC_EDITNO,
-                    cfg.localedit == LD_BACKEND ? IDC_EDITBACKEND :
-                    cfg.localedit == LD_YES ? IDC_EDITYES : IDC_EDITNO);
+                    cfg.localedit == AUTO ? IDC_EDITBACKEND :
+                    cfg.localedit == FORCE_ON ? IDC_EDITYES : IDC_EDITNO);
     SetDlgItemText(hwnd, IDC_ANSWEREDIT, cfg.answerback);
     CheckDlgButton(hwnd, IDC_ALWAYSONTOP, cfg.alwaysontop);
     CheckDlgButton(hwnd, IDC_FULLSCREENONALTENTER, cfg.fullscreenonaltenter);
@@ -1166,7 +1161,7 @@ static void init_dlg_ctrls(HWND hwnd, int keepsess)
                     B_IND_DISABLED ? IDC_B_IND_DISABLED : cfg.beep_ind ==
                     B_IND_FLASH ? IDC_B_IND_FLASH : cfg.beep_ind ==
                     B_IND_STEADY ? IDC_B_IND_STEADY : IDC_B_IND_DISABLED);
-    SetDlgItemText(hwnd, IDC_BELL_WAVEEDIT, cfg.bell_wavefile);
+    SetDlgItemText(hwnd, IDC_BELL_WAVEEDIT, cfg.bell_wavefile.path);
     CheckDlgButton(hwnd, IDC_BELLOVL, cfg.bellovl);
     SetDlgItemInt(hwnd, IDC_BELLOVLN, cfg.bellovl_n, FALSE);
     MySetDlgItemFlt(hwnd, IDC_BELLOVLT, cfg.bellovl_t / 1000.0);
@@ -1176,7 +1171,7 @@ static void init_dlg_ctrls(HWND hwnd, int keepsess)
     CheckDlgButton(hwnd, IDC_BLINKTEXT, cfg.blinktext);
 
     SetDlgItemText(hwnd, IDC_WINEDIT, cfg.wintitle);
-    CheckDlgButton(hwnd, IDC_WINNAME, cfg.win_name_always);
+    CheckDlgButton(hwnd, IDC_WINNAME, !cfg.win_name_always);
     CheckDlgButton(hwnd, IDC_HIDEMOUSE, cfg.hide_mouseptr);
     CheckDlgButton(hwnd, IDC_SUNKENEDGE, cfg.sunken_edge);
     SetDlgItemInt(hwnd, IDC_WINBEDIT, cfg.window_border, FALSE);
@@ -1192,9 +1187,9 @@ static void init_dlg_ctrls(HWND hwnd, int keepsess)
                     cfg.resize_action == RESIZE_EITHER ? IDC_RESIZEEITHER :
                     IDC_RESIZENONE);
     CheckRadioButton(hwnd, IDC_COEALWAYS, IDC_COENORMAL,
-                    cfg.close_on_exit == COE_NORMAL ? IDC_COENORMAL :
+                    cfg.close_on_exit == AUTO ? IDC_COENORMAL :
                     cfg.close_on_exit ==
-                    COE_NEVER ? IDC_COENEVER : IDC_COEALWAYS);
+                    FORCE_OFF ? IDC_COENEVER : IDC_COEALWAYS);
     CheckDlgButton(hwnd, IDC_CLOSEWARN, cfg.warn_on_close);
 
     SetDlgItemText(hwnd, IDC_TTEDIT, cfg.termtype);
@@ -1202,7 +1197,7 @@ static void init_dlg_ctrls(HWND hwnd, int keepsess)
     SetDlgItemText(hwnd, IDC_R_TSEDIT, cfg.termspeed);
     SetDlgItemText(hwnd, IDC_RLLUSEREDIT, cfg.localusername);
     SetDlgItemText(hwnd, IDC_LOGEDIT, cfg.username);
-    SetDlgItemText(hwnd, IDC_LGFEDIT, cfg.logfilename);
+    SetDlgItemText(hwnd, IDC_LGFEDIT, cfg.logfilename.path);
     CheckRadioButton(hwnd, IDC_LSTATOFF, IDC_LSTATPACKET,
                     cfg.logtype == LGTYP_NONE ? IDC_LSTATOFF :
                     cfg.logtype == LGTYP_ASCII ? IDC_LSTATASCII :
@@ -1245,7 +1240,7 @@ static void init_dlg_ctrls(HWND hwnd, int keepsess)
                     cfg.sshprot == 3 ? IDC_SSHPROT2ONLY : IDC_SSHPROT1ONLY);
     CheckDlgButton(hwnd, IDC_AUTHTIS, cfg.try_tis_auth);
     CheckDlgButton(hwnd, IDC_AUTHKI, cfg.try_ki_auth);
-    SetDlgItemText(hwnd, IDC_PKEDIT, cfg.keyfile);
+    SetDlgItemText(hwnd, IDC_PKEDIT, cfg.keyfile.path);
     SetDlgItemText(hwnd, IDC_CMDEDIT, cfg.remote_cmd);
 
     {
@@ -1308,9 +1303,8 @@ static void init_dlg_ctrls(HWND hwnd, int keepsess)
            SendDlgItemMessage(hwnd, IDC_COLOURLIST,
                               LB_DELETESTRING, i, 0);
        for (i = 0; i < 22; i++)
-           if (cfg.bold_colour || permcolour[i])
-               SendDlgItemMessage(hwnd, IDC_COLOURLIST, LB_ADDSTRING, 0,
-                                  (LPARAM) colours[i]);
+           SendDlgItemMessage(hwnd, IDC_COLOURLIST, LB_ADDSTRING, 0,
+                              (LPARAM) colours[i]);
     }
     SendDlgItemMessage(hwnd, IDC_COLOURLIST, LB_SETCURSEL, 0, 0);
     SetDlgItemInt(hwnd, IDC_RVALUE, cfg.colours[0][0], FALSE);
@@ -1373,8 +1367,8 @@ static void init_dlg_ctrls(HWND hwnd, int keepsess)
     SetDlgItemText(hwnd, IDC_PROXYEXCLUDEEDIT, cfg.proxy_exclude_list);
     CheckDlgButton(hwnd, IDC_PROXYLOCALHOST, cfg.even_proxy_localhost);
     CheckRadioButton(hwnd, IDC_PROXYDNSNO, IDC_PROXYDNSYES,
-                    cfg.proxy_dns == PROXYDNS_NO ? IDC_PROXYDNSNO :
-                    cfg.proxy_dns == PROXYDNS_YES ? IDC_PROXYDNSYES :
+                    cfg.proxy_dns == FORCE_OFF ? IDC_PROXYDNSNO :
+                    cfg.proxy_dns == FORCE_ON ? IDC_PROXYDNSYES :
                     IDC_PROXYDNSAUTO);
     SetDlgItemText(hwnd, IDC_PROXYTELNETCMDEDIT, cfg.proxy_telnet_command);
     SetDlgItemText(hwnd, IDC_PROXYUSEREDIT, cfg.proxy_username);
@@ -1388,50 +1382,50 @@ static void init_dlg_ctrls(HWND hwnd, int keepsess)
     SendDlgItemMessage(hwnd, IDC_BUGD_IGNORE1, CB_ADDSTRING, 0, (LPARAM)"Off");
     SendDlgItemMessage(hwnd, IDC_BUGD_IGNORE1, CB_ADDSTRING, 0, (LPARAM)"On");
     SendDlgItemMessage(hwnd, IDC_BUGD_IGNORE1, CB_SETCURSEL,
-                      cfg.sshbug_ignore1 == BUG_ON ? 2 :
-                      cfg.sshbug_ignore1 == BUG_OFF ? 1 : 0, 0);
+                      cfg.sshbug_ignore1 == FORCE_ON ? 2 :
+                      cfg.sshbug_ignore1 == FORCE_OFF ? 1 : 0, 0);
     SendDlgItemMessage(hwnd, IDC_BUGD_PLAINPW1, CB_RESETCONTENT, 0, 0);
     SendDlgItemMessage(hwnd, IDC_BUGD_PLAINPW1, CB_ADDSTRING, 0, (LPARAM)"Auto");
     SendDlgItemMessage(hwnd, IDC_BUGD_PLAINPW1, CB_ADDSTRING, 0, (LPARAM)"Off");
     SendDlgItemMessage(hwnd, IDC_BUGD_PLAINPW1, CB_ADDSTRING, 0, (LPARAM)"On");
     SendDlgItemMessage(hwnd, IDC_BUGD_PLAINPW1, CB_SETCURSEL,
-                      cfg.sshbug_plainpw1 == BUG_ON ? 2 :
-                      cfg.sshbug_plainpw1 == BUG_OFF ? 1 : 0, 0);
+                      cfg.sshbug_plainpw1 == FORCE_ON ? 2 :
+                      cfg.sshbug_plainpw1 == FORCE_OFF ? 1 : 0, 0);
     SendDlgItemMessage(hwnd, IDC_BUGD_RSA1, CB_RESETCONTENT, 0, 0);
     SendDlgItemMessage(hwnd, IDC_BUGD_RSA1, CB_ADDSTRING, 0, (LPARAM)"Auto");
     SendDlgItemMessage(hwnd, IDC_BUGD_RSA1, CB_ADDSTRING, 0, (LPARAM)"Off");
     SendDlgItemMessage(hwnd, IDC_BUGD_RSA1, CB_ADDSTRING, 0, (LPARAM)"On");
     SendDlgItemMessage(hwnd, IDC_BUGD_RSA1, CB_SETCURSEL,
-                      cfg.sshbug_rsa1 == BUG_ON ? 2 :
-                      cfg.sshbug_rsa1 == BUG_OFF ? 1 : 0, 0);
+                      cfg.sshbug_rsa1 == FORCE_ON ? 2 :
+                      cfg.sshbug_rsa1 == FORCE_OFF ? 1 : 0, 0);
     SendDlgItemMessage(hwnd, IDC_BUGD_HMAC2, CB_RESETCONTENT, 0, 0);
     SendDlgItemMessage(hwnd, IDC_BUGD_HMAC2, CB_ADDSTRING, 0, (LPARAM)"Auto");
     SendDlgItemMessage(hwnd, IDC_BUGD_HMAC2, CB_ADDSTRING, 0, (LPARAM)"Off");
     SendDlgItemMessage(hwnd, IDC_BUGD_HMAC2, CB_ADDSTRING, 0, (LPARAM)"On");
     SendDlgItemMessage(hwnd, IDC_BUGD_HMAC2, CB_SETCURSEL,
-                      cfg.sshbug_hmac2 == BUG_ON ? 2 :
-                      cfg.sshbug_hmac2 == BUG_OFF ? 1 : 0, 0);
+                      cfg.sshbug_hmac2 == FORCE_ON ? 2 :
+                      cfg.sshbug_hmac2 == FORCE_OFF ? 1 : 0, 0);
     SendDlgItemMessage(hwnd, IDC_BUGD_DERIVEKEY2, CB_RESETCONTENT, 0, 0);
     SendDlgItemMessage(hwnd, IDC_BUGD_DERIVEKEY2, CB_ADDSTRING, 0, (LPARAM)"Auto");
     SendDlgItemMessage(hwnd, IDC_BUGD_DERIVEKEY2, CB_ADDSTRING, 0, (LPARAM)"Off");
     SendDlgItemMessage(hwnd, IDC_BUGD_DERIVEKEY2, CB_ADDSTRING, 0, (LPARAM)"On");
     SendDlgItemMessage(hwnd, IDC_BUGD_DERIVEKEY2, CB_SETCURSEL,
-                      cfg.sshbug_derivekey2 == BUG_ON ? 2 :
-                      cfg.sshbug_derivekey2 == BUG_OFF ? 1 : 0, 0);
+                      cfg.sshbug_derivekey2 == FORCE_ON ? 2 :
+                      cfg.sshbug_derivekey2 == FORCE_OFF ? 1 : 0, 0);
     SendDlgItemMessage(hwnd, IDC_BUGD_RSAPAD2, CB_RESETCONTENT, 0, 0);
     SendDlgItemMessage(hwnd, IDC_BUGD_RSAPAD2, CB_ADDSTRING, 0, (LPARAM)"Auto");
     SendDlgItemMessage(hwnd, IDC_BUGD_RSAPAD2, CB_ADDSTRING, 0, (LPARAM)"Off");
     SendDlgItemMessage(hwnd, IDC_BUGD_RSAPAD2, CB_ADDSTRING, 0, (LPARAM)"On");
     SendDlgItemMessage(hwnd, IDC_BUGD_RSAPAD2, CB_SETCURSEL,
-                      cfg.sshbug_rsapad2 == BUG_ON ? 2 :
-                      cfg.sshbug_rsapad2 == BUG_OFF ? 1 : 0, 0);
+                      cfg.sshbug_rsapad2 == FORCE_ON ? 2 :
+                      cfg.sshbug_rsapad2 == FORCE_OFF ? 1 : 0, 0);
     SendDlgItemMessage(hwnd, IDC_BUGD_DHGEX2, CB_RESETCONTENT, 0, 0);
     SendDlgItemMessage(hwnd, IDC_BUGD_DHGEX2, CB_ADDSTRING, 0, (LPARAM)"Auto");
     SendDlgItemMessage(hwnd, IDC_BUGD_DHGEX2, CB_ADDSTRING, 0, (LPARAM)"Off");
     SendDlgItemMessage(hwnd, IDC_BUGD_DHGEX2, CB_ADDSTRING, 0, (LPARAM)"On");
     SendDlgItemMessage(hwnd, IDC_BUGD_DHGEX2, CB_SETCURSEL,
-                      cfg.sshbug_dhgex2 == BUG_ON ? 2 :
-                      cfg.sshbug_dhgex2 == BUG_OFF ? 1 : 0, 0);
+                      cfg.sshbug_dhgex2 == FORCE_ON ? 2 :
+                      cfg.sshbug_dhgex2 == FORCE_OFF ? 1 : 0, 0);
 }
 
 struct treeview_faff {
@@ -1720,7 +1714,7 @@ static void create_controls(HWND hwnd, int dlgtype, int panel)
                 IDC_BOX_APPEARANCE3);
        multiedit(&cp,
                  "Window &title:", IDC_WINTITLE, IDC_WINEDIT, 100, NULL);
-       checkbox(&cp, "Avoid ever using &icon title", IDC_WINNAME);
+       checkbox(&cp, "Separate window and &icon titles", IDC_WINNAME);
        endbox(&cp);
        beginbox(&cp, "Adjust the use of the mouse pointer",
                 IDC_BOX_APPEARANCE4);
@@ -1965,7 +1959,7 @@ static void create_controls(HWND hwnd, int dlgtype, int panel)
     }
 
     if (panel == sshpanelstart) {
-       /* The SSH panel. Accelerators used: [acgoh] r pe12ni sd */
+       /* The SSH panel. Accelerators used: [acgoh] r pel12n sud i */
        struct ctlpos cp;
        ctlposinit(&cp, hwnd, 80, 3, 13);
        if (dlgtype == 0) {
@@ -1986,10 +1980,11 @@ static void create_controls(HWND hwnd, int dlgtype, int panel)
                      "2 o&nly", IDC_SSHPROT2ONLY, NULL);
            endbox(&cp);
            beginbox(&cp, "Encryption options", IDC_BOX_SSH3);
+           /* Adds accelerators: ud */
            prefslist(&cipherlist, &cp, "Encryption cipher &selection policy:",
                      IDC_CIPHERSTATIC2, IDC_CIPHERLIST, IDC_CIPHERUP,
                      IDC_CIPHERDN);
-           checkbox(&cp, "Enable non-standard use of single-&DES in SSH 2",
+           checkbox(&cp, "Enable non-standard use of s&ingle-DES in SSH 2",
                     IDC_SSH2DES);
            endbox(&cp);
        }
@@ -2022,7 +2017,7 @@ static void create_controls(HWND hwnd, int dlgtype, int panel)
     }
 
     if (panel == sshbugspanelstart) {
-       /* The SSH bugs panel. Accelerators used: [acgoh] isrmep */
+       /* The SSH bugs panel. Accelerators used: [acgoh] isrmepd */
        struct ctlpos cp;
        ctlposinit(&cp, hwnd, 80, 3, 13);
        if (dlgtype == 0) {
@@ -2049,7 +2044,7 @@ static void create_controls(HWND hwnd, int dlgtype, int panel)
     }
 
     if (panel == tunnelspanelstart) {
-       /* The Tunnels panel. Accelerators used: [acgoh] deilmrstxp */
+       /* The Tunnels panel. Accelerators used: [acgoh] exu tprsdilm */
        struct ctlpos cp;
        ctlposinit(&cp, hwnd, 80, 3, 13);
        if (dlgtype == 0) {
@@ -2121,7 +2116,7 @@ static int GenericMainDlgProc(HWND hwnd, UINT msg,
     struct treeview_faff tvfaff;
     HTREEITEM hsession;
     OPENFILENAME of;
-    char filename[sizeof(cfg.keyfile)];
+    char filename[sizeof(cfg.keyfile.path)];
     CHOOSEFONT cf;
     LOGFONT lf;
     char fontstatic[256];
@@ -2677,11 +2672,11 @@ static int GenericMainDlgProc(HWND hwnd, UINT msg,
                if (HIWORD(wParam) == BN_CLICKED ||
                    HIWORD(wParam) == BN_DOUBLECLICKED) {
                    if (LOWORD(wParam) == IDC_ECHOBACKEND)
-                       cfg.localecho = LD_BACKEND;
+                       cfg.localecho = AUTO;
                    if (LOWORD(wParam) == IDC_ECHOYES)
-                       cfg.localecho = LD_YES;
+                       cfg.localecho = FORCE_ON;
                    if (LOWORD(wParam) == IDC_ECHONO)
-                       cfg.localecho = LD_NO;
+                       cfg.localecho = FORCE_OFF;
                }
                break;
              case IDC_EDITBACKEND:
@@ -2690,11 +2685,11 @@ static int GenericMainDlgProc(HWND hwnd, UINT msg,
                if (HIWORD(wParam) == BN_CLICKED ||
                    HIWORD(wParam) == BN_DOUBLECLICKED) {
                    if (LOWORD(wParam) == IDC_EDITBACKEND)
-                       cfg.localedit = LD_BACKEND;
+                       cfg.localedit = AUTO;
                    if (LOWORD(wParam) == IDC_EDITYES)
-                       cfg.localedit = LD_YES;
+                       cfg.localedit = FORCE_ON;
                    if (LOWORD(wParam) == IDC_EDITNO)
-                       cfg.localedit = LD_NO;
+                       cfg.localedit = FORCE_OFF;
                }
                break;
              case IDC_ANSWEREDIT:
@@ -2782,20 +2777,20 @@ static int GenericMainDlgProc(HWND hwnd, UINT msg,
              case IDC_CHOOSEFONT:
                {
                    HDC hdc = GetDC(0);
-                   lf.lfHeight = -MulDiv(cfg.fontheight,
+                   lf.lfHeight = -MulDiv(cfg.font.height,
                                          GetDeviceCaps(hdc, LOGPIXELSY),
                                          72);
                    ReleaseDC(0, hdc);
                }
                lf.lfWidth = lf.lfEscapement = lf.lfOrientation = 0;
                lf.lfItalic = lf.lfUnderline = lf.lfStrikeOut = 0;
-               lf.lfWeight = (cfg.fontisbold ? FW_BOLD : 0);
-               lf.lfCharSet = cfg.fontcharset;
+               lf.lfWeight = (cfg.font.isbold ? FW_BOLD : 0);
+               lf.lfCharSet = cfg.font.charset;
                lf.lfOutPrecision = OUT_DEFAULT_PRECIS;
                lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
                lf.lfQuality = DEFAULT_QUALITY;
                lf.lfPitchAndFamily = FIXED_PITCH | FF_DONTCARE;
-               strncpy(lf.lfFaceName, cfg.font,
+               strncpy(lf.lfFaceName, cfg.font.name,
                        sizeof(lf.lfFaceName) - 1);
                lf.lfFaceName[sizeof(lf.lfFaceName) - 1] = '\0';
 
@@ -2806,11 +2801,12 @@ static int GenericMainDlgProc(HWND hwnd, UINT msg,
                    CF_INITTOLOGFONTSTRUCT | CF_SCREENFONTS;
 
                if (ChooseFont(&cf)) {
-                   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 = cf.iPointSize / 10;
+                   strncpy(cfg.font.name, lf.lfFaceName,
+                           sizeof(cfg.font.name) - 1);
+                   cfg.font.name[sizeof(cfg.font.name) - 1] = '\0';
+                   cfg.font.isbold = (lf.lfWeight == FW_BOLD);
+                   cfg.font.charset = lf.lfCharSet;
+                   cfg.font.height = cf.iPointSize / 10;
                    fmtfont(fontstatic);
                    SetDlgItemText(hwnd, IDC_FONTSTATIC, fontstatic);
                }
@@ -2852,27 +2848,28 @@ static int GenericMainDlgProc(HWND hwnd, UINT msg,
                of.lStructSize = sizeof(of);
 #endif
                of.hwndOwner = hwnd;
-               of.lpstrFilter = "Wave Files\0*.WAV\0AllFiles\0*\0\0\0";
+               of.lpstrFilter = "Wave Files (*.wav)\0*.WAV\0"
+                   "All Files (*.*)\0*\0\0\0";
                of.lpstrCustomFilter = NULL;
                of.nFilterIndex = 1;
                of.lpstrFile = filename;
-               strcpy(filename, cfg.bell_wavefile);
+               strcpy(filename, cfg.bell_wavefile.path);
                of.nMaxFile = sizeof(filename);
                of.lpstrFileTitle = NULL;
                of.lpstrInitialDir = NULL;
                of.lpstrTitle = "Select Bell Sound File";
                of.Flags = 0;
                if (GetOpenFileName(&of)) {
-                   strcpy(cfg.bell_wavefile, filename);
+                   strcpy(cfg.bell_wavefile.path, filename);
                    SetDlgItemText(hwnd, IDC_BELL_WAVEEDIT,
-                                  cfg.bell_wavefile);
+                                  cfg.bell_wavefile.path);
                }
                break;
              case IDC_BELL_WAVEEDIT:
                if (HIWORD(wParam) == EN_CHANGE)
                    GetDlgItemText(hwnd, IDC_BELL_WAVEEDIT,
-                                  cfg.bell_wavefile,
-                                  sizeof(cfg.bell_wavefile) - 1);
+                                  cfg.bell_wavefile.path,
+                                  sizeof(cfg.bell_wavefile.path) - 1);
                break;
              case IDC_BELLOVL:
                if (HIWORD(wParam) == BN_CLICKED ||
@@ -2909,7 +2906,7 @@ static int GenericMainDlgProc(HWND hwnd, UINT msg,
                if (HIWORD(wParam) == BN_CLICKED ||
                    HIWORD(wParam) == BN_DOUBLECLICKED)
                        cfg.win_name_always =
-                       IsDlgButtonChecked(hwnd, IDC_WINNAME);
+                       !IsDlgButtonChecked(hwnd, IDC_WINNAME);
                break;
              case IDC_HIDEMOUSE:
                if (HIWORD(wParam) == BN_CLICKED ||
@@ -2991,10 +2988,10 @@ static int GenericMainDlgProc(HWND hwnd, UINT msg,
                    HIWORD(wParam) == BN_DOUBLECLICKED) {
                    cfg.close_on_exit =
                        IsDlgButtonChecked(hwnd,
-                                          IDC_COEALWAYS) ? COE_ALWAYS :
+                                          IDC_COEALWAYS) ? FORCE_ON :
                        IsDlgButtonChecked(hwnd,
-                                          IDC_COENEVER) ? COE_NEVER :
-                       COE_NORMAL;
+                                          IDC_COENEVER) ? FORCE_OFF :
+                       AUTO;
                }
                break;
              case IDC_CLOSEWARN:
@@ -3073,9 +3070,9 @@ static int GenericMainDlgProc(HWND hwnd, UINT msg,
                if (HIWORD(wParam) == BN_CLICKED ||
                    HIWORD(wParam) == BN_DOUBLECLICKED) {
                    cfg.proxy_dns =
-                       IsDlgButtonChecked(hwnd, IDC_PROXYDNSNO) ? PROXYDNS_NO :
-                       IsDlgButtonChecked(hwnd, IDC_PROXYDNSYES) ? PROXYDNS_YES :
-                       PROXYDNS_AUTO;
+                       IsDlgButtonChecked(hwnd, IDC_PROXYDNSNO) ? FORCE_OFF :
+                       IsDlgButtonChecked(hwnd, IDC_PROXYDNSYES) ? FORCE_ON :
+                       AUTO;
                }
                break;
              case IDC_PROXYTYPENONE:
@@ -3094,8 +3091,8 @@ static int GenericMainDlgProc(HWND hwnd, UINT msg,
 
              case IDC_LGFEDIT:
                if (HIWORD(wParam) == EN_CHANGE)
-                   GetDlgItemText(hwnd, IDC_LGFEDIT, cfg.logfilename,
-                                  sizeof(cfg.logfilename) - 1);
+                   GetDlgItemText(hwnd, IDC_LGFEDIT, cfg.logfilename.path,
+                                  sizeof(cfg.logfilename.path) - 1);
                break;
              case IDC_LGFBUTTON:
                memset(&of, 0, sizeof(of));
@@ -3105,19 +3102,19 @@ static int GenericMainDlgProc(HWND hwnd, UINT msg,
                of.lStructSize = sizeof(of);
 #endif
                of.hwndOwner = hwnd;
-               of.lpstrFilter = "All Files\0*\0\0\0";
+               of.lpstrFilter = "All Files (*.*)\0*\0\0\0";
                of.lpstrCustomFilter = NULL;
                of.nFilterIndex = 1;
                of.lpstrFile = filename;
-               strcpy(filename, cfg.logfilename);
+               strcpy(filename, cfg.logfilename.path);
                of.nMaxFile = sizeof(filename);
                of.lpstrFileTitle = NULL;
                of.lpstrInitialDir = NULL;
                of.lpstrTitle = "Select session log file";
                of.Flags = 0;
                if (GetSaveFileName(&of)) {
-                   strcpy(cfg.logfilename, filename);
-                   SetDlgItemText(hwnd, IDC_LGFEDIT, cfg.logfilename);
+                   strcpy(cfg.logfilename.path, filename);
+                   SetDlgItemText(hwnd, IDC_LGFEDIT, cfg.logfilename.path);
                }
                break;
              case IDC_LSTATOFF:
@@ -3317,8 +3314,8 @@ static int GenericMainDlgProc(HWND hwnd, UINT msg,
                break;
              case IDC_PKEDIT:
                if (HIWORD(wParam) == EN_CHANGE)
-                   GetDlgItemText(hwnd, IDC_PKEDIT, cfg.keyfile,
-                                  sizeof(cfg.keyfile) - 1);
+                   GetDlgItemText(hwnd, IDC_PKEDIT, cfg.keyfile.path,
+                                  sizeof(cfg.keyfile.path) - 1);
                break;
              case IDC_CMDEDIT:
                if (HIWORD(wParam) == EN_CHANGE)
@@ -3333,20 +3330,20 @@ static int GenericMainDlgProc(HWND hwnd, UINT msg,
                of.lStructSize = sizeof(of);
 #endif
                of.hwndOwner = hwnd;
-               of.lpstrFilter = "PuTTY Private Key Files (*.ppk)\0*.PPK\0"
-                   "AllFiles\0*\0\0\0";
+               of.lpstrFilter = "PuTTY Private Key Files (*.ppk)\0*.ppk\0"
+                   "All Files (*.*)\0*\0\0\0";
                of.lpstrCustomFilter = NULL;
                of.nFilterIndex = 1;
                of.lpstrFile = filename;
-               strcpy(filename, cfg.keyfile);
+               strcpy(filename, cfg.keyfile.path);
                of.nMaxFile = sizeof(filename);
                of.lpstrFileTitle = NULL;
                of.lpstrInitialDir = NULL;
                of.lpstrTitle = "Select Private Key File";
                of.Flags = 0;
                if (GetOpenFileName(&of)) {
-                   strcpy(cfg.keyfile, filename);
-                   SetDlgItemText(hwnd, IDC_PKEDIT, cfg.keyfile);
+                   strcpy(cfg.keyfile.path, filename);
+                   SetDlgItemText(hwnd, IDC_PKEDIT, cfg.keyfile.path);
                }
                break;
              case IDC_RAWCNP:
@@ -3398,25 +3395,6 @@ static int GenericMainDlgProc(HWND hwnd, UINT msg,
                    int n, i;
                    cfg.bold_colour =
                        IsDlgButtonChecked(hwnd, IDC_BOLDCOLOUR);
-                   SendDlgItemMessage(hwnd, IDC_COLOURLIST, WM_SETREDRAW,
-                                      FALSE, 0);
-                   n =
-                       SendDlgItemMessage(hwnd, IDC_COLOURLIST,
-                                          LB_GETCOUNT, 0, 0);
-                   if (n != 12 + 10 * cfg.bold_colour) {
-                       for (i = n; i-- > 0;)
-                           SendDlgItemMessage(hwnd, IDC_COLOURLIST,
-                                              LB_DELETESTRING, i, 0);
-                       for (i = 0; i < 22; i++)
-                           if (cfg.bold_colour || permcolour[i])
-                               SendDlgItemMessage(hwnd, IDC_COLOURLIST,
-                                                  LB_ADDSTRING, 0,
-                                                  (LPARAM) colours[i]);
-                   }
-                   SendDlgItemMessage(hwnd, IDC_COLOURLIST, WM_SETREDRAW,
-                                      TRUE, 0);
-                   InvalidateRect(GetDlgItem(hwnd, IDC_COLOURLIST), NULL,
-                                  TRUE);
                }
                break;
              case IDC_PALETTE:
@@ -3648,56 +3626,56 @@ static int GenericMainDlgProc(HWND hwnd, UINT msg,
                if (HIWORD(wParam) == CBN_SELCHANGE) {
                    int index = SendDlgItemMessage(hwnd, IDC_BUGD_IGNORE1,
                                                   CB_GETCURSEL, 0, 0);
-                   cfg.sshbug_ignore1 = (index == 0 ? BUG_AUTO :
-                                         index == 1 ? BUG_OFF : BUG_ON);
+                   cfg.sshbug_ignore1 = (index == 0 ? AUTO :
+                                         index == 1 ? FORCE_OFF : FORCE_ON);
                }
                break;
              case IDC_BUGD_PLAINPW1:
                if (HIWORD(wParam) == CBN_SELCHANGE) {
                    int index = SendDlgItemMessage(hwnd, IDC_BUGD_PLAINPW1,
                                                   CB_GETCURSEL, 0, 0);
-                   cfg.sshbug_plainpw1 = (index == 0 ? BUG_AUTO :
-                                          index == 1 ? BUG_OFF : BUG_ON);
+                   cfg.sshbug_plainpw1 = (index == 0 ? AUTO :
+                                          index == 1 ? FORCE_OFF : FORCE_ON);
                }
                break;
              case IDC_BUGD_RSA1:
                if (HIWORD(wParam) == CBN_SELCHANGE) {
                    int index = SendDlgItemMessage(hwnd, IDC_BUGD_RSA1,
                                                   CB_GETCURSEL, 0, 0);
-                   cfg.sshbug_rsa1 = (index == 0 ? BUG_AUTO :
-                                      index == 1 ? BUG_OFF : BUG_ON);
+                   cfg.sshbug_rsa1 = (index == 0 ? AUTO :
+                                      index == 1 ? FORCE_OFF : FORCE_ON);
                }
                break;
              case IDC_BUGD_HMAC2:
                if (HIWORD(wParam) == CBN_SELCHANGE) {
                    int index = SendDlgItemMessage(hwnd, IDC_BUGD_HMAC2,
                                                   CB_GETCURSEL, 0, 0);
-                   cfg.sshbug_hmac2 = (index == 0 ? BUG_AUTO :
-                                       index == 1 ? BUG_OFF : BUG_ON);
+                   cfg.sshbug_hmac2 = (index == 0 ? AUTO :
+                                       index == 1 ? FORCE_OFF : FORCE_ON);
                }
                break;
              case IDC_BUGD_DERIVEKEY2:
                if (HIWORD(wParam) == CBN_SELCHANGE) {
                    int index = SendDlgItemMessage(hwnd, IDC_BUGD_DERIVEKEY2,
                                                   CB_GETCURSEL, 0, 0);
-                   cfg.sshbug_derivekey2 = (index == 0 ? BUG_AUTO :
-                                            index == 1 ? BUG_OFF : BUG_ON);
+                   cfg.sshbug_derivekey2 = (index == 0 ? AUTO :
+                                            index == 1 ? FORCE_OFF:FORCE_ON);
                }
                break;
              case IDC_BUGD_RSAPAD2:
                if (HIWORD(wParam) == CBN_SELCHANGE) {
                    int index = SendDlgItemMessage(hwnd, IDC_BUGD_RSAPAD2,
                                                   CB_GETCURSEL, 0, 0);
-                   cfg.sshbug_rsapad2 = (index == 0 ? BUG_AUTO :
-                                         index == 1 ? BUG_OFF : BUG_ON);
+                   cfg.sshbug_rsapad2 = (index == 0 ? AUTO :
+                                         index == 1 ? FORCE_OFF : FORCE_ON);
                }
                break;
              case IDC_BUGD_DHGEX2:
                if (HIWORD(wParam) == CBN_SELCHANGE) {
                    int index = SendDlgItemMessage(hwnd, IDC_BUGD_DHGEX2,
                                                   CB_GETCURSEL, 0, 0);
-                   cfg.sshbug_dhgex2 = (index == 0 ? BUG_AUTO :
-                                        index == 1 ? BUG_OFF : BUG_ON);
+                   cfg.sshbug_dhgex2 = (index == 0 ? AUTO :
+                                        index == 1 ? FORCE_OFF : FORCE_ON);
                }
                break;
            }
@@ -3964,7 +3942,7 @@ void askcipher(void *frontend, char *ciphername, int cs)
  * Ask whether to wipe a session log file before writing to it.
  * Returns 2 for wipe, 1 for append, 0 for cancel (don't log).
  */
-int askappend(void *frontend, char *filename)
+int askappend(void *frontend, Filename filename)
 {
     static const char mbtitle[] = "PuTTY Log to File";
     static const char msgtemplate[] =
@@ -3977,7 +3955,7 @@ int askappend(void *frontend, char *filename)
     char message[sizeof(msgtemplate) + FILENAME_MAX];
     int mbret;
 
-    sprintf(message, msgtemplate, FILENAME_MAX, filename);
+    sprintf(message, msgtemplate, FILENAME_MAX, filename.path);
 
     mbret = MessageBox(NULL, message, mbtitle,
                       MB_ICONQUESTION | MB_YESNOCANCEL);