Set up kbd_codepage at the start of the program, as well as when the
[u/mdw/putty] / windlg.c
index d8f1e03..7113360 100644 (file)
--- a/windlg.c
+++ b/windlg.c
@@ -354,20 +354,29 @@ enum { IDCX_ABOUT =
     IDC_ROWSEDIT,
     IDC_COLSSTATIC,
     IDC_COLSEDIT,
-    IDC_LOCKSIZE,
-    IDC_LOCKFONT,
+    IDC_RESIZESTATIC,
+    IDC_RESIZETERM,
+    IDC_RESIZEFONT,
+    IDC_RESIZENONE,
+    IDC_RESIZEEITHER,
     IDC_SCROLLBAR,
-    IDC_CLOSEWARN,
+    IDC_SCROLLBARFULLSCREEN,
     IDC_SAVESTATIC,
     IDC_SAVEEDIT,
+    IDC_SCROLLKEY,
+    IDC_SCROLLDISP,
+    windowpanelend,
+
+    behaviourpanelstart,
+    IDC_TITLE_BEHAVIOUR,
+    IDC_BOX_BEHAVIOUR1,
+    IDC_CLOSEWARN,
     IDC_ALTF4,
     IDC_ALTSPACE,
     IDC_ALTONLY,
-    IDC_SCROLLKEY,
-    IDC_SCROLLDISP,
     IDC_ALWAYSONTOP,
     IDC_FULLSCREENONALTENTER,
-    windowpanelend,
+    behaviourpanelend,
 
     appearancepanelstart,
     IDC_TITLE_APPEARANCE,
@@ -465,6 +474,7 @@ enum { IDCX_ABOUT =
     IDC_PKBUTTON,
     IDC_AGENTFWD,
     IDC_AUTHTIS,
+    IDC_AUTHKI,
     sshauthpanelend,
 
     selectionpanelstart,
@@ -476,12 +486,16 @@ enum { IDCX_ABOUT =
     IDC_MBWINDOWS,
     IDC_MBXTERM,
     IDC_MOUSEOVERRIDE,
+    IDC_SELTYPESTATIC,
+    IDC_SELTYPELEX,
+    IDC_SELTYPERECT,
     IDC_CCSTATIC,
     IDC_CCLIST,
     IDC_CCSET,
     IDC_CCSTATIC2,
     IDC_CCEDIT,
     IDC_RAWCNP,
+    IDC_RTFPASTE,
     selectionpanelend,
 
     colourspanelstart,
@@ -673,8 +687,12 @@ static void init_dlg_ctrls(HWND hwnd, int keepsess)
                     cfg.cursor_type == 1 ? IDC_CURUNDER : IDC_CURVERT);
     CheckDlgButton(hwnd, IDC_BLINKCUR, cfg.blink_cur);
     CheckDlgButton(hwnd, IDC_SCROLLBAR, cfg.scrollbar);
-    CheckDlgButton(hwnd, IDC_LOCKSIZE, cfg.locksize);
-    CheckDlgButton(hwnd, IDC_LOCKFONT, cfg.lockfont);
+    CheckDlgButton(hwnd, IDC_SCROLLBARFULLSCREEN, cfg.scrollbar_in_fullscreen);
+    CheckRadioButton(hwnd, IDC_RESIZETERM, IDC_RESIZEEITHER,
+                    cfg.resize_action == RESIZE_TERM ? IDC_RESIZETERM :
+                    cfg.resize_action == RESIZE_FONT ? IDC_RESIZEFONT :
+                    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 ==
@@ -723,6 +741,7 @@ static void init_dlg_ctrls(HWND hwnd, int keepsess)
     CheckRadioButton(hwnd, IDC_SSHPROT1, IDC_SSHPROT2,
                     cfg.sshprot == 1 ? IDC_SSHPROT1 : IDC_SSHPROT2);
     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_CMDEDIT, cfg.remote_cmd);
 
@@ -731,7 +750,7 @@ static void init_dlg_ctrls(HWND hwnd, int keepsess)
        static const struct { char *s; int c; } ciphers[] = {
            { "3DES",                   CIPHER_3DES },
            { "Blowfish",               CIPHER_BLOWFISH },
-           { "DES (SSH 1 only)",       CIPHER_DES },
+           { "DES",                    CIPHER_DES },
            { "AES (SSH 2 only)",       CIPHER_AES },
            { "-- warn below here --",  CIPHER_WARN }
        };
@@ -757,11 +776,13 @@ static void init_dlg_ctrls(HWND hwnd, int keepsess)
 
     }
 
-
     CheckRadioButton(hwnd, IDC_MBWINDOWS, IDC_MBXTERM,
                     cfg.mouse_is_xterm ? IDC_MBXTERM : IDC_MBWINDOWS);
+    CheckRadioButton(hwnd, IDC_SELTYPELEX, IDC_SELTYPERECT,
+                    cfg.rect_select == 0 ? IDC_SELTYPELEX : IDC_SELTYPERECT);
     CheckDlgButton(hwnd, IDC_MOUSEOVERRIDE, cfg.mouse_override);
     CheckDlgButton(hwnd, IDC_RAWCNP, cfg.rawcnp);
+    CheckDlgButton(hwnd, IDC_RTFPASTE, cfg.rtf_paste);
     {
        static int tabs[4] = { 25, 61, 96, 128 };
        SendDlgItemMessage(hwnd, IDC_CCLIST, LB_SETTABSTOPS, 4,
@@ -996,10 +1017,8 @@ static void create_controls(HWND hwnd, int dlgtype, int panel)
        /* The Keyboard panel. Accelerators used: [acgo] bhf ruyntd */
        struct ctlpos cp;
        ctlposinit(&cp, hwnd, 80, 3, 13);
-       /*
-          bartitle(&cp, "Options controlling the effects of keys",
-          IDC_TITLE_KEYBOARD);
-        */
+       bartitle(&cp, "Options controlling the effects of keys",
+                IDC_TITLE_KEYBOARD);
        beginbox(&cp, "Change the sequences sent by:", IDC_BOX_KEYBOARD1);
        radioline(&cp, "The &Backspace key", IDC_DELSTATIC, 2,
                  "Control-H", IDC_DEL008,
@@ -1036,7 +1055,7 @@ static void create_controls(HWND hwnd, int dlgtype, int panel)
     }
 
     if (panel == windowpanelstart) {
-       /* The Window panel. Accelerators used: [acgo] rmz sdkp w4ylt f */
+       /* The Window panel. Accelerators used: [acgo] rmz sdikp */
        struct ctlpos cp;
        ctlposinit(&cp, hwnd, 80, 3, 13);
        bartitle(&cp, "Options controlling PuTTY's window",
@@ -1045,34 +1064,30 @@ static void create_controls(HWND hwnd, int dlgtype, int panel)
        multiedit(&cp,
                  "&Rows", IDC_ROWSSTATIC, IDC_ROWSEDIT, 50,
                  "Colu&mns", IDC_COLSSTATIC, IDC_COLSEDIT, 50, NULL);
-       checkbox(&cp, "Lock terminal size against resi&zing", IDC_LOCKSIZE);
-       checkbox(&cp, "Lock font size against resi&zing", IDC_LOCKFONT);
+       radiobig(&cp, "When window is resi&zed:", IDC_RESIZESTATIC,
+                "Change the number of rows and columns", IDC_RESIZETERM,
+                "Change the size of the font", IDC_RESIZEFONT,
+                "Change font size only when maximised", IDC_RESIZEEITHER,
+                "Forbid resizing completely", IDC_RESIZENONE, NULL);
        endbox(&cp);
        beginbox(&cp, "Control the scrollback in the window",
                 IDC_BOX_WINDOW2);
        staticedit(&cp, "Lines of &scrollback",
                   IDC_SAVESTATIC, IDC_SAVEEDIT, 50);
        checkbox(&cp, "&Display scrollbar", IDC_SCROLLBAR);
+       checkbox(&cp, "D&isplay scrollbar in full screen mode", IDC_SCROLLBARFULLSCREEN);
        checkbox(&cp, "Reset scrollback on &keypress", IDC_SCROLLKEY);
        checkbox(&cp, "Reset scrollback on dis&play activity",
                 IDC_SCROLLDISP);
        endbox(&cp);
-       beginbox(&cp, NULL, IDC_BOX_WINDOW3);
-       checkbox(&cp, "&Warn before closing window", IDC_CLOSEWARN);
-       checkbox(&cp, "Window closes on ALT-F&4", IDC_ALTF4);
-       checkbox(&cp, "S&ystem menu appears on ALT-Space", IDC_ALTSPACE);
-       checkbox(&cp, "System menu appears on A&LT alone", IDC_ALTONLY);
-       checkbox(&cp, "Ensure window is always on &top", IDC_ALWAYSONTOP);
-       checkbox(&cp, "&Full screen on Alt-Enter", IDC_FULLSCREENONALTENTER);
-       endbox(&cp);
     }
 
     if (panel == appearancepanelstart) {
        /* The Appearance panel. Accelerators used: [acgo] luvb h ti p s */
        struct ctlpos cp;
        ctlposinit(&cp, hwnd, 80, 3, 13);
-       /* bartitle(&cp, "Options controlling PuTTY's appearance",
-                IDC_TITLE_APPEARANCE); */
+       bartitle(&cp, "Configure the appearance of PuTTY's window",
+                IDC_TITLE_APPEARANCE);
        beginbox(&cp, "Adjust the use of the cursor", IDC_BOX_APPEARANCE1);
        radioline(&cp, "Cursor appearance:", IDC_CURSORSTATIC, 3,
                  "B&lock", IDC_CURBLOCK,
@@ -1103,6 +1118,22 @@ static void create_controls(HWND hwnd, int dlgtype, int panel)
        endbox(&cp);
     }
 
+    if (panel == behaviourpanelstart) {
+       /* The Behaviour panel. Accelerators used: [acgo] w4yltf */
+       struct ctlpos cp;
+       ctlposinit(&cp, hwnd, 80, 3, 13);
+       bartitle(&cp, "Configure the behaviour of PuTTY's window",
+                IDC_TITLE_WINDOW);
+       beginbox(&cp, NULL, IDC_BOX_BEHAVIOUR1);
+       checkbox(&cp, "&Warn before closing window", IDC_CLOSEWARN);
+       checkbox(&cp, "Window closes on ALT-F&4", IDC_ALTF4);
+       checkbox(&cp, "S&ystem menu appears on ALT-Space", IDC_ALTSPACE);
+       checkbox(&cp, "System menu appears on A&LT alone", IDC_ALTONLY);
+       checkbox(&cp, "Ensure window is always on &top", IDC_ALWAYSONTOP);
+       checkbox(&cp, "&Full screen on Alt-Enter", IDC_FULLSCREENONALTENTER);
+       endbox(&cp);
+    }
+
     if (panel == translationpanelstart) {
        /* The Translation panel. Accelerators used: [acgo] rxbepus */
        struct ctlpos cp;
@@ -1116,7 +1147,7 @@ static void create_controls(HWND hwnd, int dlgtype, int panel)
        endbox(&cp);
         beginbox(&cp, "Enable character set translation on input data",
                  IDC_BOX_TRANSLATION2);
-        checkbox(&cp, "CAP&S LOCK acts as cyrillic switch",
+        checkbox(&cp, "Cap&s Lock acts as Cyrillic switch",
                  IDC_CAPSLOCKCYR);
         endbox(&cp);
        beginbox(&cp, "Adjust how PuTTY displays line drawing characters",
@@ -1132,7 +1163,7 @@ static void create_controls(HWND hwnd, int dlgtype, int panel)
     }
 
     if (panel == selectionpanelstart) {
-       /* The Selection panel. Accelerators used: [acgo] d wxp hst */
+       /* The Selection panel. Accelerators used: [acgo] df wxp hst nr */
        struct ctlpos cp;
        ctlposinit(&cp, hwnd, 80, 3, 13);
        bartitle(&cp, "Options controlling copy and paste",
@@ -1142,6 +1173,9 @@ static void create_controls(HWND hwnd, int dlgtype, int panel)
        checkbox(&cp,
                 "&Don't translate line drawing chars into +, - and |",
                 IDC_RAWCNP);
+       checkbox(&cp,
+                "Paste to clipboard in RT&F as well as plain text",
+                IDC_RTFPASTE);
        endbox(&cp);
        beginbox(&cp, "Control which mouse button does which thing",
                 IDC_BOX_SELECTION2);
@@ -1152,6 +1186,11 @@ static void create_controls(HWND hwnd, int dlgtype, int panel)
        checkbox(&cp,
                 "Shift overrides a&pplication's use of mouse",
                 IDC_MOUSEOVERRIDE);
+        radioline(&cp,
+                  "Default selection mode (Alt+drag does the other one):",
+                  IDC_SELTYPESTATIC, 2,
+                 "&Normal", IDC_SELTYPELEX,
+                 "&Rectangular block", IDC_SELTYPERECT, NULL);
        endbox(&cp);
        beginbox(&cp, "Control the select-one-word-at-a-time mode",
                 IDC_BOX_SELECTION3);
@@ -1285,7 +1324,7 @@ static void create_controls(HWND hwnd, int dlgtype, int panel)
     }
 
     if (panel == sshauthpanelstart) {
-       /* The SSH authentication panel. Accelerators used: [acgo] m fkw */
+       /* The SSH authentication panel. Accelerators used: [acgo] m fkiw */
        struct ctlpos cp;
        ctlposinit(&cp, hwnd, 80, 3, 13);
        if (dlgtype == 0) {
@@ -1293,8 +1332,10 @@ static void create_controls(HWND hwnd, int dlgtype, int panel)
                     IDC_TITLE_SSHAUTH);
            beginbox(&cp, "Authentication methods",
                     IDC_BOX_SSHAUTH1);
-           checkbox(&cp, "Atte&mpt TIS or CryptoCard authentication",
+           checkbox(&cp, "Atte&mpt TIS or CryptoCard authentication (SSH1)",
                     IDC_AUTHTIS);
+           checkbox(&cp, "Attempt \"keyboard-&interactive\" authentication"
+                    " (SSH2)", IDC_AUTHKI);
            endbox(&cp);
            beginbox(&cp, "Authentication parameters",
                     IDC_BOX_SSHAUTH2);
@@ -1426,7 +1467,7 @@ static int GenericMainDlgProc(HWND hwnd, UINT msg,
            r.left = 3;
            r.right = r.left + 75;
            r.top = 13;
-           r.bottom = r.top + 206;
+           r.bottom = r.top + 219;
            MapDialogRect(hwnd, &r);
            treeview = CreateWindowEx(WS_EX_CLIENTEDGE, WC_TREEVIEW, "",
                                      WS_CHILD | WS_VISIBLE |
@@ -1453,6 +1494,7 @@ static int GenericMainDlgProc(HWND hwnd, UINT msg,
        treeview_insert(&tvfaff, 1, "Bell");
        treeview_insert(&tvfaff, 0, "Window");
        treeview_insert(&tvfaff, 1, "Appearance");
+       treeview_insert(&tvfaff, 1, "Behaviour");
        treeview_insert(&tvfaff, 1, "Translation");
        treeview_insert(&tvfaff, 1, "Selection");
        treeview_insert(&tvfaff, 1, "Colours");
@@ -1533,6 +1575,8 @@ static int GenericMainDlgProc(HWND hwnd, UINT msg,
                create_controls(hwnd, dlgtype, windowpanelstart);
            if (!strcmp(buffer, "Appearance"))
                create_controls(hwnd, dlgtype, appearancepanelstart);
+           if (!strcmp(buffer, "Behaviour"))
+               create_controls(hwnd, dlgtype, behaviourpanelstart);
            if (!strcmp(buffer, "Tunnels"))
                create_controls(hwnd, dlgtype, tunnelspanelstart);
            if (!strcmp(buffer, "Connection"))
@@ -2108,17 +2152,27 @@ static int GenericMainDlgProc(HWND hwnd, UINT msg,
                        cfg.scrollbar =
                        IsDlgButtonChecked(hwnd, IDC_SCROLLBAR);
                break;
-             case IDC_LOCKSIZE:
+             case IDC_SCROLLBARFULLSCREEN:
                if (HIWORD(wParam) == BN_CLICKED ||
                    HIWORD(wParam) == BN_DOUBLECLICKED)
-                       cfg.locksize =
-                       IsDlgButtonChecked(hwnd, IDC_LOCKSIZE);
+                   cfg.scrollbar_in_fullscreen =
+                   IsDlgButtonChecked(hwnd, IDC_SCROLLBARFULLSCREEN);
                break;
-             case IDC_LOCKFONT:
+             case IDC_RESIZETERM:
+             case IDC_RESIZEFONT:
+             case IDC_RESIZENONE:
+             case IDC_RESIZEEITHER:
                if (HIWORD(wParam) == BN_CLICKED ||
-                   HIWORD(wParam) == BN_DOUBLECLICKED)
-                       cfg.lockfont =
-                       IsDlgButtonChecked(hwnd, IDC_LOCKFONT);
+                   HIWORD(wParam) == BN_DOUBLECLICKED) {
+                   cfg.resize_action =
+                       IsDlgButtonChecked(hwnd,
+                                          IDC_RESIZETERM) ? RESIZE_TERM :
+                       IsDlgButtonChecked(hwnd,
+                                          IDC_RESIZEFONT) ? RESIZE_FONT :
+                       IsDlgButtonChecked(hwnd,
+                                          IDC_RESIZEEITHER) ? RESIZE_EITHER :
+                       RESIZE_DISABLED;
+               }
                break;
              case IDC_WINEDIT:
                if (HIWORD(wParam) == EN_CHANGE)
@@ -2351,6 +2405,12 @@ static int GenericMainDlgProc(HWND hwnd, UINT msg,
                        cfg.try_tis_auth =
                        IsDlgButtonChecked(hwnd, IDC_AUTHTIS);
                break;
+             case IDC_AUTHKI:
+               if (HIWORD(wParam) == BN_CLICKED ||
+                   HIWORD(wParam) == BN_DOUBLECLICKED)
+                       cfg.try_ki_auth =
+                       IsDlgButtonChecked(hwnd, IDC_AUTHKI);
+               break;
              case IDC_PKEDIT:
                if (HIWORD(wParam) == EN_CHANGE)
                    GetDlgItemText(hwnd, IDC_PKEDIT, cfg.keyfile,
@@ -2377,7 +2437,7 @@ static int GenericMainDlgProc(HWND hwnd, UINT msg,
                of.nMaxFile = sizeof(filename);
                of.lpstrFileTitle = NULL;
                of.lpstrInitialDir = NULL;
-               of.lpstrTitle = "Select Public Key File";
+               of.lpstrTitle = "Select Private Key File";
                of.Flags = 0;
                if (GetOpenFileName(&of)) {
                    strcpy(cfg.keyfile, filename);
@@ -2387,10 +2447,17 @@ static int GenericMainDlgProc(HWND hwnd, UINT msg,
              case IDC_RAWCNP:
                cfg.rawcnp = IsDlgButtonChecked(hwnd, IDC_RAWCNP);
                break;
+             case IDC_RTFPASTE:
+               cfg.rtf_paste = IsDlgButtonChecked(hwnd, IDC_RTFPASTE);
+               break;
              case IDC_MBWINDOWS:
              case IDC_MBXTERM:
                cfg.mouse_is_xterm = IsDlgButtonChecked(hwnd, IDC_MBXTERM);
                break;
+             case IDC_SELTYPELEX:
+             case IDC_SELTYPERECT:
+               cfg.rect_select = IsDlgButtonChecked(hwnd, IDC_SELTYPERECT);
+               break;
              case IDC_MOUSEOVERRIDE:
                cfg.mouse_override = IsDlgButtonChecked(hwnd, IDC_MOUSEOVERRIDE);
                break;
@@ -2915,3 +2982,23 @@ int askappend(char *filename)
     else
        return 0;
 }
+
+/*
+ * Warn about the obsolescent key file format.
+ */
+void old_keyfile_warning(void)
+{
+    static const char mbtitle[] = "PuTTY Key File Warning";
+    static const char message[] =
+       "You are loading an SSH 2 private key which has an\n"
+       "old version of the file format. This means your key\n"
+       "file is not fully tamperproof. Future versions of\n"
+       "PuTTY may stop supporting this private key format,\n"
+       "so we recommend you convert your key to the new\n"
+       "format.\n"
+       "\n"
+       "You can perform this conversion by loading the key\n"
+       "into PuTTYgen and then saving it again.";
+
+    MessageBox(NULL, message, mbtitle, MB_OK);
+}