We can now configure the terminal's answerback string when it receives ^E.
[sgt/putty] / windlg.c
index 7f99468..c57dee9 100644 (file)
--- a/windlg.c
+++ b/windlg.c
@@ -49,6 +49,11 @@ static int CALLBACK LogProc (HWND hwnd, UINT msg,
 
     switch (msg) {
       case WM_INITDIALOG:
+        {
+            static int tabs[4] = {78, 108};
+            SendDlgItemMessage (hwnd, IDN_LIST, LB_SETTABSTOPS, 2,
+                                (LPARAM) tabs);
+        }
        for (i=0; i<nevents; i++)
            SendDlgItemMessage (hwnd, IDN_LIST, LB_ADDSTRING,
                                0, (LPARAM)events[i]);
@@ -163,6 +168,13 @@ static int CALLBACK AboutProc (HWND hwnd, UINT msg,
            EnableWindow(hwnd, 1);
             SetActiveWindow(hwnd);
            return 0;
+
+          case IDA_WEB:
+            /* Load web browser */
+            ShellExecute(hwnd, "open",
+                         "http://www.chiark.greenend.org.uk/~sgtatham/putty/",
+                         0, 0, SW_SHOWDEFAULT);
+            return 0;
        }
        return 0;
       case WM_CLOSE:
@@ -259,6 +271,8 @@ enum { IDCX_ABOUT = IDC_ABOUT, IDCX_TVSTATIC, IDCX_TREEVIEW, controlstartvalue,
     IDC_BEEP,
     IDC_BCE,
     IDC_BLINKTEXT,
+    IDC_ANSWERBACK,
+    IDC_ANSWEREDIT,
     IDC_ECHOSTATIC,
     IDC_ECHOBACKEND,
     IDC_ECHOYES,
@@ -361,6 +375,7 @@ enum { IDCX_ABOUT = IDC_ABOUT, IDCX_TVSTATIC, IDCX_TREEVIEW, controlstartvalue,
     IDC_CIPHER3DES,
     IDC_CIPHERBLOWF,
     IDC_CIPHERDES,
+    IDC_CIPHERAES,
     IDC_BUGGYMAC,
     IDC_AUTHTIS,
     IDC_PKSTATIC,
@@ -379,6 +394,7 @@ enum { IDCX_ABOUT = IDC_ABOUT, IDCX_TVSTATIC, IDCX_TREEVIEW, controlstartvalue,
     IDC_TITLE_SELECTION,
     IDC_BOX_SELECTION1,
     IDC_BOX_SELECTION2,
+    IDC_BOX_SELECTION3,
     IDC_MBSTATIC,
     IDC_MBWINDOWS,
     IDC_MBXTERM,
@@ -387,6 +403,7 @@ enum { IDCX_ABOUT = IDC_ABOUT, IDCX_TVSTATIC, IDCX_TREEVIEW, controlstartvalue,
     IDC_CCSET,
     IDC_CCSTATIC2,
     IDC_CCEDIT,
+    IDC_RAWCNP,
     selectionpanelend,
 
     colourspanelstart,
@@ -461,9 +478,8 @@ static void fmtfont (char *buf) {
     if (cfg.fontheight == 0)
        strcat (buf, "default height");
     else
-       sprintf (buf+strlen(buf), "%d-%s",
-                (cfg.fontheight < 0 ? -cfg.fontheight : cfg.fontheight),
-                (cfg.fontheight < 0 ? "pixel" : "point"));
+       sprintf (buf+strlen(buf), "%d-point",
+                (cfg.fontheight < 0 ? -cfg.fontheight : cfg.fontheight));
 }
 
 static void init_dlg_ctrls(HWND hwnd) {
@@ -516,6 +532,7 @@ static void init_dlg_ctrls(HWND hwnd) {
     CheckRadioButton (hwnd, IDC_EDITBACKEND, IDC_EDITNO,
                      cfg.localedit == LD_BACKEND ? IDC_EDITBACKEND:
                       cfg.localedit == LD_YES ? IDC_EDITYES : IDC_EDITNO);
+    SetDlgItemText (hwnd, IDC_ANSWEREDIT, cfg.answerback);
     CheckDlgButton (hwnd, IDC_ALWAYSONTOP, cfg.alwaysontop);
     CheckDlgButton (hwnd, IDC_SCROLLKEY, cfg.scroll_on_key);
     CheckDlgButton (hwnd, IDC_SCROLLDISP, cfg.scroll_on_disp);
@@ -573,9 +590,10 @@ static void init_dlg_ctrls(HWND hwnd) {
     CheckDlgButton (hwnd, IDC_COMPRESS, cfg.compression);
     CheckDlgButton (hwnd, IDC_BUGGYMAC, cfg.buggymac);
     CheckDlgButton (hwnd, IDC_AGENTFWD, cfg.agentfwd);
-    CheckRadioButton (hwnd, IDC_CIPHER3DES, IDC_CIPHERDES,
+    CheckRadioButton (hwnd, IDC_CIPHER3DES, IDC_CIPHERAES,
                      cfg.cipher == CIPHER_BLOWFISH ? IDC_CIPHERBLOWF :
                      cfg.cipher == CIPHER_DES ? IDC_CIPHERDES :
+                     cfg.cipher == CIPHER_AES ? IDC_CIPHERAES :
                      IDC_CIPHER3DES);
     CheckRadioButton (hwnd, IDC_SSHPROT1, IDC_SSHPROT2,
                      cfg.sshprot == 1 ? IDC_SSHPROT1 : IDC_SSHPROT2);
@@ -585,6 +603,7 @@ static void init_dlg_ctrls(HWND hwnd) {
 
     CheckRadioButton (hwnd, IDC_MBWINDOWS, IDC_MBXTERM,
                      cfg.mouse_is_xterm ? IDC_MBXTERM : IDC_MBWINDOWS);
+    CheckDlgButton (hwnd, IDC_RAWCNP, cfg.rawcnp);
     {
        static int tabs[4] = {25, 61, 96, 128};
        SendDlgItemMessage (hwnd, IDC_CCLIST, LB_SETTABSTOPS, 4,
@@ -731,7 +750,7 @@ static void create_controls(HWND hwnd, int dlgtype, int panel) {
     }
 
     if (panel == terminalpanelstart) {
-        /* The Terminal panel. Accelerators used: [acgo] wdlben ht */
+        /* The Terminal panel. Accelerators used: [acgo] wdlben hts */
         struct ctlpos cp;
         ctlposinit(&cp, hwnd, 80, 3, 13);
         bartitle(&cp, "Options controlling the terminal emulation",
@@ -744,6 +763,9 @@ 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);
+        multiedit(&cp,
+                  "An&swerback to ^E:", IDC_ANSWERBACK,
+                  IDC_ANSWEREDIT, 100, NULL);
         endbox(&cp);
 
         beginbox(&cp, "Line discipline options",
@@ -900,20 +922,25 @@ static void create_controls(HWND hwnd, int dlgtype, int panel) {
     }
 
     if (panel == selectionpanelstart) {
-        /* The Selection panel. Accelerators used: [acgo] wx hst */
+        /* The Selection panel. Accelerators used: [acgo] wx hst */
         struct ctlpos cp;
         ctlposinit(&cp, hwnd, 80, 3, 13);
         bartitle(&cp, "Options controlling copy and paste",
                  IDC_TITLE_SELECTION);
-        beginbox(&cp, "Control which mouse button does which thing",
+        beginbox(&cp, "Translation of pasted characters",
                  IDC_BOX_SELECTION1);
+        checkbox(&cp, "&Don't translate line drawing chars into +, - and |",
+                 IDC_RAWCNP);
+        endbox(&cp);
+        beginbox(&cp, "Control which mouse button does which thing",
+                 IDC_BOX_SELECTION2);
         radiobig(&cp, "Action of mouse buttons:", IDC_MBSTATIC,
                  "&Windows (Right pastes, Middle extends)", IDC_MBWINDOWS,
                  "&xterm (Right extends, Middle pastes)", IDC_MBXTERM,
                  NULL);
         endbox(&cp);
         beginbox(&cp, "Control the select-one-word-at-a-time mode",
-                 IDC_BOX_SELECTION2);
+                 IDC_BOX_SELECTION3);
         charclass(&cp, "C&haracter classes:", IDC_CCSTATIC, IDC_CCLIST,
                   "&Set", IDC_CCSET, IDC_CCEDIT,
                   "&to class", IDC_CCSTATIC2);
@@ -1000,7 +1027,7 @@ static void create_controls(HWND hwnd, int dlgtype, int panel) {
     }
 
     if (panel == sshpanelstart) {
-        /* The SSH panel. Accelerators used: [acgo] rmfkw pe123bd i */
+        /* The SSH panel. Accelerators used: [acgo] rmfkw pe123bds i */
         struct ctlpos cp;
         ctlposinit(&cp, hwnd, 80, 3, 13);
         if (dlgtype == 0) {
@@ -1026,10 +1053,12 @@ static void create_controls(HWND hwnd, int dlgtype, int panel) {
             radioline(&cp, "Preferred SSH protocol version:",
                       IDC_SSHPROTSTATIC, 2,
                       "&1", IDC_SSHPROT1, "&2", IDC_SSHPROT2, NULL);
-            radioline(&cp, "Preferred encryption algorithm:", IDC_CIPHERSTATIC, 3,
+            radioline(&cp, "Preferred encryption algorithm:", IDC_CIPHERSTATIC, 4,
                       "&3DES", IDC_CIPHER3DES,
                       "&Blowfish", IDC_CIPHERBLOWF,
-                      "&DES", IDC_CIPHERDES, NULL);
+                      "&DES", IDC_CIPHERDES,
+                      "AE&S", IDC_CIPHERAES,
+                      NULL);
             checkbox(&cp, "&Imitate SSH 2 MAC bug in commercial <= v2.3.x",
                      IDC_BUGGYMAC);
             endbox(&cp);
@@ -1469,6 +1498,11 @@ static int GenericMainDlgProc (HWND hwnd, UINT msg,
                if (LOWORD(wParam)==IDC_EDITNO) cfg.localedit=LD_NO;
             }
            break;
+         case IDC_ANSWEREDIT:
+           if (HIWORD(wParam) == EN_CHANGE)
+               GetDlgItemText (hwnd, IDC_ANSWEREDIT, cfg.answerback,
+                               sizeof(cfg.answerback)-1);
+           break;
           case IDC_ALWAYSONTOP:
            if (HIWORD(wParam) == BN_CLICKED ||
                HIWORD(wParam) == BN_DOUBLECLICKED)
@@ -1540,7 +1574,7 @@ static int GenericMainDlgProc (HWND hwnd, UINT msg,
                cfg.font[sizeof(cfg.font)-1] = '\0';
                cfg.fontisbold = (lf.lfWeight == FW_BOLD);
                cfg.fontcharset = lf.lfCharSet;
-               cfg.fontheight = lf.lfHeight;
+               cfg.fontheight = cf.iPointSize / 10;
                fmtfont (fontstatic);
                SetDlgItemText (hwnd, IDC_FONTSTATIC, fontstatic);
            }
@@ -1774,6 +1808,7 @@ static int GenericMainDlgProc (HWND hwnd, UINT msg,
          case IDC_CIPHER3DES:
          case IDC_CIPHERBLOWF:
          case IDC_CIPHERDES:
+         case IDC_CIPHERAES:
            if (HIWORD(wParam) == BN_CLICKED ||
                HIWORD(wParam) == BN_DOUBLECLICKED) {
                if (IsDlgButtonChecked (hwnd, IDC_CIPHER3DES))
@@ -1782,6 +1817,8 @@ static int GenericMainDlgProc (HWND hwnd, UINT msg,
                    cfg.cipher = CIPHER_BLOWFISH;
                else if (IsDlgButtonChecked (hwnd, IDC_CIPHERDES))
                    cfg.cipher = CIPHER_DES;
+               else if (IsDlgButtonChecked (hwnd, IDC_CIPHERAES))
+                   cfg.cipher = CIPHER_AES;
            }
            break;
          case IDC_SSHPROT1:
@@ -1831,6 +1868,8 @@ static int GenericMainDlgProc (HWND hwnd, UINT msg,
                 SetDlgItemText (hwnd, IDC_PKEDIT, cfg.keyfile);
             }
            break;
+         case IDC_RAWCNP:
+           cfg.rawcnp = IsDlgButtonChecked (hwnd, IDC_RAWCNP);
          case IDC_MBWINDOWS:
          case IDC_MBXTERM:
            cfg.mouse_is_xterm = IsDlgButtonChecked (hwnd, IDC_MBXTERM);
@@ -2048,19 +2087,19 @@ void logevent (char *string) {
     }
 
     time(&t);
-    strftime(timebuf, sizeof(timebuf), "%Y-%m-%d %H:%M:%S    ", localtime(&t));
+    strftime(timebuf, sizeof(timebuf), "%Y-%m-%d %H:%M:%S\t", localtime(&t));
 
     events[nevents] = smalloc(strlen(timebuf)+strlen(string)+1);
     strcpy(events[nevents], timebuf);
     strcat(events[nevents], string);
-    nevents++;
     if (logbox) {
         int count;
        SendDlgItemMessage (logbox, IDN_LIST, LB_ADDSTRING,
-                           0, (LPARAM)string);
+                           0, (LPARAM)events[nevents]);
        count = SendDlgItemMessage (logbox, IDN_LIST, LB_GETCOUNT, 0, 0);
        SendDlgItemMessage (logbox, IDN_LIST, LB_SETTOPINDEX, count-1, 0);
     }
+    nevents++;
 }
 
 void showeventlog (HWND hwnd) {