Some introductory blurb in the docs
[sgt/putty] / windlg.c
index d6fce02..e619469 100644 (file)
--- a/windlg.c
+++ b/windlg.c
@@ -4,6 +4,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <ctype.h>
+#include <time.h>
 
 #include "ssh.h"
 #include "putty.h"
@@ -48,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]);
@@ -162,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:
@@ -204,6 +217,9 @@ enum { IDCX_ABOUT = IDC_ABOUT, IDCX_TVSTATIC, IDCX_TREEVIEW, controlstartvalue,
     IDC_SESSSAVE,
     IDC_SESSDEL,
     IDC_CLOSEEXIT,
+    IDC_COEALWAYS,
+    IDC_COENEVER,
+    IDC_COENORMAL,
     sessionpanelend,
 
     loggingpanelstart,
@@ -243,6 +259,7 @@ enum { IDCX_ABOUT = IDC_ABOUT, IDCX_TVSTATIC, IDCX_TREEVIEW, controlstartvalue,
     IDC_CURNORMAL,
     IDC_CURAPPLIC,
     IDC_COMPOSEKEY,
+    IDC_CTRLALTKEYS,
     keyboardpanelend,
 
     terminalpanelstart,
@@ -255,6 +272,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,
@@ -357,6 +376,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,
@@ -375,6 +395,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,
@@ -383,6 +404,7 @@ enum { IDCX_ABOUT = IDC_ABOUT, IDCX_TVSTATIC, IDCX_TREEVIEW, controlstartvalue,
     IDC_CCSET,
     IDC_CCSTATIC2,
     IDC_CCEDIT,
+    IDC_RAWCNP,
     selectionpanelend,
 
     colourspanelstart,
@@ -457,9 +479,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) {
@@ -506,12 +527,14 @@ 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_CTRLALTKEYS, cfg.ctrlaltkeys);
     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);
+    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);
@@ -537,7 +560,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);
@@ -567,9 +592,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);
@@ -579,6 +605,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,
@@ -659,7 +686,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] nprtih elsd x */
+       /* 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",
@@ -699,7 +726,10 @@ 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);
     }
 
@@ -722,7 +752,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",
@@ -735,6 +765,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",
@@ -751,7 +784,7 @@ static void create_controls(HWND hwnd, int dlgtype, int panel) {
     }
 
     if (panel == keyboardpanelstart) {
-        /* The Keyboard panel. Accelerators used: [acgo] h?sr~lxv unpymie t */
+        /* The Keyboard panel. Accelerators used: [acgo] h?sr~lxvunpymietd */
         struct ctlpos cp;
         ctlposinit(&cp, hwnd, 80, 3, 13);
         bartitle(&cp, "Options controlling the effects of keys",
@@ -788,8 +821,10 @@ static void create_controls(HWND hwnd, int dlgtype, int panel) {
         endbox(&cp);
         beginbox(&cp, "Enable extra keyboard features:",
                  IDC_BOX_KEYBOARD3);
-        checkbox(&cp, "Application and AltGr ac&t as Compose key",
+        checkbox(&cp, "AltGr ac&ts as Compose key",
                  IDC_COMPOSEKEY);
+        checkbox(&cp, "Control-Alt is &different from AltGr",
+                 IDC_CTRLALTKEYS);
         endbox(&cp);
     }
 
@@ -891,20 +926,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);
@@ -991,7 +1031,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) {
@@ -1017,10 +1057,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);
@@ -1460,6 +1502,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)
@@ -1480,6 +1527,11 @@ static int GenericMainDlgProc (HWND hwnd, UINT msg,
                HIWORD(wParam) == BN_DOUBLECLICKED)
                cfg.compose_key = IsDlgButtonChecked (hwnd, IDC_COMPOSEKEY);
            break;
+         case IDC_CTRLALTKEYS:
+           if (HIWORD(wParam) == BN_CLICKED ||
+               HIWORD(wParam) == BN_DOUBLECLICKED)
+               cfg.ctrlaltkeys = IsDlgButtonChecked (hwnd, IDC_CTRLALTKEYS);
+           break;
          case IDC_WRAPMODE:
            if (HIWORD(wParam) == BN_CLICKED ||
                HIWORD(wParam) == BN_DOUBLECLICKED)
@@ -1531,7 +1583,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);
            }
@@ -1596,11 +1648,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)
@@ -1760,6 +1817,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))
@@ -1768,6 +1826,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:
@@ -1817,6 +1877,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);
@@ -2025,20 +2087,28 @@ int do_reconfig (HWND hwnd) {
 }
 
 void logevent (char *string) {
+    char timebuf[40];
+    time_t t;
+
     if (nevents >= negsize) {
        negsize += 64;
        events = srealloc (events, negsize * sizeof(*events));
     }
-    events[nevents] = smalloc(1+strlen(string));
-    strcpy (events[nevents], string);
-    nevents++;
+
+    time(&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);
     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) {