Wez Furlong's patch to add xterm mouse reporting and proper mouse
[u/mdw/putty] / windlg.c
index 737305d..6f3c35c 100644 (file)
--- a/windlg.c
+++ b/windlg.c
@@ -3,6 +3,8 @@
 #include <commdlg.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <ctype.h>
+#include <time.h>
 
 #include "ssh.h"
 #include "putty.h"
@@ -13,8 +15,6 @@
 static char **events = NULL;
 static int nevents = 0, negsize = 0;
 
-static HWND logbox = NULL, abtbox = NULL;
-
 static int readytogo;
 
 void force_normal(HWND hwnd)
@@ -43,12 +43,31 @@ static void MyGetDlgItemInt (HWND hwnd, int id, int *result) {
        *result = n;
 }
 
+static void MyGetDlgItemFlt (HWND hwnd, int id, int *result, int scale) {
+    char text[80];
+    BOOL ok;
+    ok = GetDlgItemText (hwnd, id, text, sizeof(text)-1);
+    if (ok && text[0])
+       *result = (int) (scale * atof(text));
+}
+
+static void MySetDlgItemFlt (HWND hwnd, int id, double value) {
+    char text[80];
+    sprintf(text, "%g", value);
+    SetDlgItemText (hwnd, id, text);
+}
+
 static int CALLBACK LogProc (HWND hwnd, UINT msg,
                             WPARAM wParam, LPARAM lParam) {
     int i;
 
     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]);
@@ -56,7 +75,9 @@ static int CALLBACK LogProc (HWND hwnd, UINT msg,
       case WM_COMMAND:
        switch (LOWORD(wParam)) {
          case IDOK:
+         case IDCANCEL:
            logbox = NULL;
+            SetActiveWindow(GetParent(hwnd));
            DestroyWindow (hwnd);
            return 0;
           case IDN_COPY:
@@ -66,6 +87,11 @@ static int CALLBACK LogProc (HWND hwnd, UINT msg,
                 int *selitems;
                 selcount = SendDlgItemMessage(hwnd, IDN_LIST,
                                               LB_GETSELCOUNT, 0, 0);
+                if (selcount == 0) {   /* don't even try to copy zero items */
+                    MessageBeep(0);
+                    break;
+                }
+                    
                 selitems = smalloc(selcount * sizeof(int));
                 if (selitems) {
                     int count = SendDlgItemMessage(hwnd, IDN_LIST,
@@ -111,6 +137,7 @@ static int CALLBACK LogProc (HWND hwnd, UINT msg,
        return 0;
       case WM_CLOSE:
        logbox = NULL;
+        SetActiveWindow(GetParent(hwnd));
        DestroyWindow (hwnd);
        return 0;
     }
@@ -145,8 +172,8 @@ static int CALLBACK AboutProc (HWND hwnd, UINT msg,
       case WM_COMMAND:
        switch (LOWORD(wParam)) {
          case IDOK:
-           abtbox = NULL;
-           DestroyWindow (hwnd);
+          case IDCANCEL:
+            EndDialog(hwnd, TRUE);
            return 0;
          case IDA_LICENCE:
            EnableWindow(hwnd, 0);
@@ -155,11 +182,17 @@ 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:
-       abtbox = NULL;
-       DestroyWindow (hwnd);
+        EndDialog(hwnd, TRUE);
        return 0;
     }
     return 0;
@@ -198,8 +231,27 @@ enum { IDCX_ABOUT = IDC_ABOUT, IDCX_TVSTATIC, IDCX_TREEVIEW, controlstartvalue,
     IDC_SESSSAVE,
     IDC_SESSDEL,
     IDC_CLOSEEXIT,
+    IDC_COEALWAYS,
+    IDC_COENEVER,
+    IDC_COENORMAL,
     sessionpanelend,
 
+    loggingpanelstart,
+    IDC_TITLE_LOGGING,
+    IDC_BOX_LOGGING1,
+    IDC_LSTATSTATIC,
+    IDC_LSTATOFF,
+    IDC_LSTATASCII,
+    IDC_LSTATRAW,
+    IDC_LGFSTATIC,
+    IDC_LGFEDIT,
+    IDC_LGFBUTTON,
+    IDC_LSTATXIST,
+    IDC_LSTATXOVR,
+    IDC_LSTATXAPN,
+    IDC_LSTATXASK,
+    loggingpanelend,
+
     keyboardpanelstart,
     IDC_TITLE_KEYBOARD,
     IDC_BOX_KEYBOARD1,
@@ -216,6 +268,8 @@ enum { IDCX_ABOUT = IDC_ABOUT, IDCX_TVSTATIC, IDCX_TREEVIEW, controlstartvalue,
     IDC_FUNCLINUX,
     IDC_FUNCXTERM,
     IDC_FUNCVT400,
+    IDC_FUNCVT100P,
+    IDC_FUNCSCO,
     IDC_KPSTATIC,
     IDC_KPNORMAL,
     IDC_KPAPPLIC,
@@ -226,6 +280,7 @@ enum { IDCX_ABOUT = IDC_ABOUT, IDCX_TVSTATIC, IDCX_TREEVIEW, controlstartvalue,
     IDC_CURNORMAL,
     IDC_CURAPPLIC,
     IDC_COMPOSEKEY,
+    IDC_CTRLALTKEYS,
     keyboardpanelend,
 
     terminalpanelstart,
@@ -235,19 +290,42 @@ enum { IDCX_ABOUT = IDC_ABOUT, IDCX_TVSTATIC, IDCX_TREEVIEW, controlstartvalue,
     IDC_WRAPMODE,
     IDC_DECOM,
     IDC_LFHASCR,
-    IDC_BEEP,
     IDC_BCE,
     IDC_BLINKTEXT,
-    IDC_LDISCTERM,
-    IDC_LSTATSTATIC,
-    IDC_LSTATOFF,
-    IDC_LSTATASCII,
-    IDC_LSTATRAW,
-    IDC_LGFSTATIC,
-    IDC_LGFEDIT,
-    IDC_LGFBUTTON,
+    IDC_ANSWERBACK,
+    IDC_ANSWEREDIT,
+    IDC_ECHOSTATIC,
+    IDC_ECHOBACKEND,
+    IDC_ECHOYES,
+    IDC_ECHONO,
+    IDC_EDITSTATIC,
+    IDC_EDITBACKEND,
+    IDC_EDITYES,
+    IDC_EDITNO,
     terminalpanelend,
 
+    bellpanelstart,
+    IDC_TITLE_BELL,
+    IDC_BOX_BELL1,
+    IDC_BOX_BELL2,
+    IDC_BELLSTATIC,
+    IDC_BELL_DISABLED,
+    IDC_BELL_DEFAULT,
+    IDC_BELL_WAVEFILE,
+    IDC_BELL_VISUAL,
+    IDC_BELL_WAVESTATIC,
+    IDC_BELL_WAVEEDIT,
+    IDC_BELL_WAVEBROWSE,
+    IDC_BELLOVL,
+    IDC_BELLOVLNSTATIC,
+    IDC_BELLOVLN,
+    IDC_BELLOVLTSTATIC,
+    IDC_BELLOVLT,
+    IDC_BELLOVLEXPLAIN,
+    IDC_BELLOVLSSTATIC,
+    IDC_BELLOVLS,
+    bellpanelend,
+
     windowpanelstart,
     IDC_TITLE_WINDOW,
     IDC_BOX_WINDOW1,
@@ -276,6 +354,7 @@ enum { IDCX_ABOUT = IDC_ABOUT, IDCX_TVSTATIC, IDCX_TREEVIEW, controlstartvalue,
     IDC_BOX_APPEARANCE2,
     IDC_BOX_APPEARANCE3,
     IDC_BOX_APPEARANCE4,
+    IDC_BOX_APPEARANCE5,
     IDC_CURSORSTATIC,
     IDC_CURBLOCK,
     IDC_CURUNDER,
@@ -287,6 +366,7 @@ enum { IDCX_ABOUT = IDC_ABOUT, IDCX_TVSTATIC, IDCX_TREEVIEW, controlstartvalue,
     IDC_WINEDIT,
     IDC_WINNAME,
     IDC_HIDEMOUSE,
+    IDC_SUNKENEDGE,
     appearancepanelend,
 
     connectionpanelstart,
@@ -340,6 +420,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,
@@ -358,6 +439,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,
@@ -366,6 +448,7 @@ enum { IDCX_ABOUT = IDC_ABOUT, IDCX_TVSTATIC, IDCX_TREEVIEW, controlstartvalue,
     IDC_CCSET,
     IDC_CCSTATIC2,
     IDC_CCEDIT,
+    IDC_RAWCNP,
     selectionpanelend,
 
     colourspanelstart,
@@ -440,9 +523,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) {
@@ -472,11 +554,13 @@ static void init_dlg_ctrls(HWND hwnd) {
                      cfg.bksp_is_delete ? IDC_DEL127 : IDC_DEL008);
     CheckRadioButton (hwnd, IDC_HOMETILDE, IDC_HOMERXVT,
                      cfg.rxvt_homeend ? IDC_HOMERXVT : IDC_HOMETILDE);
-    CheckRadioButton (hwnd, IDC_FUNCTILDE, IDC_FUNCVT400,
+    CheckRadioButton (hwnd, IDC_FUNCTILDE, IDC_FUNCSCO,
                       cfg.funky_type == 0 ? IDC_FUNCTILDE :
                       cfg.funky_type == 1 ? IDC_FUNCLINUX :
                       cfg.funky_type == 2 ? IDC_FUNCXTERM :
                       cfg.funky_type == 3 ? IDC_FUNCVT400 :
+                      cfg.funky_type == 4 ? IDC_FUNCVT100P :
+                      cfg.funky_type == 5 ? IDC_FUNCSCO :
                       IDC_FUNCTILDE );
     CheckDlgButton (hwnd, IDC_NOAPPLICC, cfg.no_applic_c);
     CheckDlgButton (hwnd, IDC_NOAPPLICK, cfg.no_applic_k);
@@ -489,7 +573,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_LDISCTERM, cfg.ldisc_term);
+    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);
@@ -502,20 +593,33 @@ static void init_dlg_ctrls(HWND hwnd) {
     SetDlgItemInt (hwnd, IDC_SAVEEDIT, cfg.savelines, FALSE);
     fmtfont (fontstatic);
     SetDlgItemText (hwnd, IDC_FONTSTATIC, fontstatic);
-    CheckDlgButton (hwnd, IDC_BEEP, cfg.beep);
+    CheckRadioButton (hwnd, IDC_BELL_DISABLED, IDC_BELL_VISUAL,
+                     cfg.beep==BELL_DISABLED ? IDC_BELL_DISABLED :
+                     cfg.beep==BELL_DEFAULT ? IDC_BELL_DEFAULT :
+                     cfg.beep==BELL_WAVEFILE ? IDC_BELL_WAVEFILE :
+                     cfg.beep==BELL_VISUAL ? IDC_BELL_VISUAL : IDC_BELL_DEFAULT);
+    SetDlgItemText (hwnd, IDC_BELL_WAVEEDIT, cfg.bell_wavefile);
+    CheckDlgButton (hwnd, IDC_BELLOVL, cfg.bellovl);
+    SetDlgItemInt (hwnd, IDC_BELLOVLN, cfg.bellovl_n, FALSE);
+    MySetDlgItemFlt (hwnd, IDC_BELLOVLT, cfg.bellovl_t / 1000.0);
+    MySetDlgItemFlt (hwnd, IDC_BELLOVLS, cfg.bellovl_s / 1000.0);
+
     CheckDlgButton (hwnd, IDC_BCE, cfg.bce);
     CheckDlgButton (hwnd, IDC_BLINKTEXT, cfg.blinktext);
 
     SetDlgItemText (hwnd, IDC_WINEDIT, cfg.wintitle);
     CheckDlgButton (hwnd, IDC_WINNAME, cfg.win_name_always);
     CheckDlgButton (hwnd, IDC_HIDEMOUSE, cfg.hide_mouseptr);
+    CheckDlgButton (hwnd, IDC_SUNKENEDGE, cfg.sunken_edge);
     CheckRadioButton (hwnd, IDC_CURBLOCK, IDC_CURVERT,
                      cfg.cursor_type==0 ? IDC_CURBLOCK :
                      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_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);
@@ -528,6 +632,10 @@ static void init_dlg_ctrls(HWND hwnd) {
                     cfg.logtype == 0 ? IDC_LSTATOFF :
                     cfg.logtype == 1 ? IDC_LSTATASCII :
                     IDC_LSTATRAW);
+    CheckRadioButton(hwnd, IDC_LSTATXOVR, IDC_LSTATXASK,
+                    cfg.logxfovr == LGXF_OVR ? IDC_LSTATXOVR :
+                    cfg.logxfovr == LGXF_ASK ? IDC_LSTATXASK :
+                    IDC_LSTATXAPN);
     {
        char *p = cfg.environmt;
        while (*p) {
@@ -545,9 +653,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);
@@ -557,6 +666,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,
@@ -637,7 +747,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] nprthelsdx */
+       /* 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",
@@ -653,12 +763,12 @@ static void create_controls(HWND hwnd, int dlgtype, int panel) {
                 radioline(&cp, "Protocol:", IDC_PROTSTATIC, 4,
                           "&Raw", IDC_PROTRAW,
                           "&Telnet", IDC_PROTTELNET,
-                          "R&login", IDC_PROTRLOGIN, NULL);
+                          "Rlog&in", IDC_PROTRLOGIN, NULL);
             } else {
                 radioline(&cp, "Protocol:", IDC_PROTSTATIC, 4,
                           "&Raw", IDC_PROTRAW,
                           "&Telnet", IDC_PROTTELNET,
-                          "R&login", IDC_PROTRLOGIN,
+                          "Rlog&in", IDC_PROTRLOGIN,
 #ifdef FWHACK
                           "SS&H/hack",
 #else
@@ -677,12 +787,38 @@ 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);
+    }
+
+    if (panel == loggingpanelstart) {
+        /* The Logging panel. Accelerators used: [acgo] tplfwe */
+        struct ctlpos cp;
+        ctlposinit(&cp, hwnd, 80, 3, 13);
+        bartitle(&cp, "Options controlling session logging",
+                 IDC_TITLE_LOGGING);
+        beginbox(&cp, NULL, IDC_BOX_LOGGING1);
+        radiobig(&cp,
+                 "Session logging:", IDC_LSTATSTATIC,
+                 "Logging &turned off completely", IDC_LSTATOFF,
+                 "Log &printable output only", IDC_LSTATASCII,
+                 "&Log all session output", IDC_LSTATRAW, NULL);
+        editbutton(&cp, "Log &file name:",
+                   IDC_LGFSTATIC, IDC_LGFEDIT, "Bro&wse...",
+                   IDC_LGFBUTTON);
+        radiobig(&cp,
+                 "What to do if the log file already &exists:", IDC_LSTATXIST,
+                 "Always overwrite it", IDC_LSTATXOVR,
+                 "Always append to the end of it", IDC_LSTATXAPN,
+                 "Ask the user every time", IDC_LSTATXASK, NULL);
         endbox(&cp);
     }
 
     if (panel == terminalpanelstart) {
-        /* The Terminal panel. Accelerators used: [acgo] &dflbenuw */
+        /* The Terminal panel. Accelerators used: [acgo] wdlen hts */
         struct ctlpos cp;
         ctlposinit(&cp, hwnd, 80, 3, 13);
         bartitle(&cp, "Options controlling the terminal emulation",
@@ -692,70 +828,110 @@ static void create_controls(HWND hwnd, int dlgtype, int panel) {
         checkbox(&cp, "Auto &wrap mode initially on", IDC_WRAPMODE);
         checkbox(&cp, "&DEC Origin Mode initially on", IDC_DECOM);
         checkbox(&cp, "Implicit CR in every &LF", IDC_LFHASCR);
-        checkbox(&cp, "&Beep enabled", IDC_BEEP);
         checkbox(&cp, "Use background colour to &erase screen", IDC_BCE);
         checkbox(&cp, "Enable bli&nking text", IDC_BLINKTEXT);
-        checkbox(&cp, "&Use local terminal line discipline", IDC_LDISCTERM);
+        multiedit(&cp,
+                  "An&swerback to ^E:", IDC_ANSWERBACK,
+                  IDC_ANSWEREDIT, 100, NULL);
         endbox(&cp);
 
-        beginbox(&cp, "Control session logging",
+        beginbox(&cp, "Line discipline options",
                  IDC_BOX_TERMINAL2);
+        radioline(&cp, "Local ec&ho:", IDC_ECHOSTATIC, 3,
+                  "Auto", IDC_ECHOBACKEND,
+                  "Force on", IDC_ECHOYES,
+                  "Force off", IDC_ECHONO, NULL);
+        radioline(&cp, "Local line edi&ting:", IDC_EDITSTATIC, 3,
+                  "Auto", IDC_EDITBACKEND,
+                  "Force on", IDC_EDITYES,
+                  "Force off", IDC_EDITNO, NULL);
+        endbox(&cp);
+    }
+
+    if (panel == bellpanelstart) {
+        /* The Bell panel. Accelerators used: [acgo] bdsm wt */
+        struct ctlpos cp;
+        ctlposinit(&cp, hwnd, 80, 3, 13);
+        bartitle(&cp, "Options controlling the terminal bell",
+                 IDC_TITLE_BELL);
+        beginbox(&cp, "Set the style of bell",
+                 IDC_BOX_BELL1);
         radiobig(&cp,
-                 "Session logging:", IDC_LSTATSTATIC,
-                 "Logging turned &off completely", IDC_LSTATOFF,
-                 "Log printable output only", IDC_LSTATASCII,
-                 "Log all session output", IDC_LSTATRAW, NULL);
-        editbutton(&cp, "Log &file name:",
-                   IDC_LGFSTATIC, IDC_LGFEDIT, "Bro&wse...",
-                   IDC_LGFBUTTON);
+                 "Action to happen when a &bell occurs:", IDC_BELLSTATIC,
+                 "None (bell disabled)", IDC_BELL_DISABLED,
+                 "Play Windows Default Sound", IDC_BELL_DEFAULT,
+                 "Play a custom sound file", IDC_BELL_WAVEFILE,
+                 "Visual bell (flash window)", IDC_BELL_VISUAL, NULL);
+       editbutton(&cp, "Custom sound file to play as a bell:",
+                  IDC_BELL_WAVESTATIC, IDC_BELL_WAVEEDIT,
+                  "Bro&wse...", IDC_BELL_WAVEBROWSE);
+        endbox(&cp);
+       beginbox(&cp, "Control the bell overload behaviour",
+                IDC_BOX_BELL2);
+       checkbox(&cp, "Bell is temporarily &disabled when over-used",
+                IDC_BELLOVL);
+       staticedit(&cp, "Over-use means this &many bells...",
+                  IDC_BELLOVLNSTATIC, IDC_BELLOVLN, 20);
+       staticedit(&cp, "... in &this many seconds",
+                  IDC_BELLOVLTSTATIC, IDC_BELLOVLT, 20);
+       statictext(&cp, "The bell is re-enabled after a few seconds of silence.",
+                  IDC_BELLOVLEXPLAIN);
+       staticedit(&cp, "Seconds of &silence required",
+                  IDC_BELLOVLSSTATIC, IDC_BELLOVLS, 20);
         endbox(&cp);
     }
 
     if (panel == keyboardpanelstart) {
-        /* The Keyboard panel. Accelerators used: [acgo] h?srvlxvnpmietu */
+        /* 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);
+                */
         beginbox(&cp, "Change the sequences sent by:",
                  IDC_BOX_KEYBOARD1);
-        radioline(&cp, "The Backspace key", IDC_DELSTATIC, 2,
-                  "Control-&H", IDC_DEL008,
-                  "Control-&? (127)", IDC_DEL127, NULL);
-        radioline(&cp, "The Home and End keys", IDC_HOMESTATIC, 2,
-                  "&Standard", IDC_HOMETILDE,
-                  "&rxvt", IDC_HOMERXVT, NULL);
-        radioline(&cp, "The Function keys and keypad", IDC_FUNCSTATIC, 4,
-                  "ESC[n&~", IDC_FUNCTILDE,
-                  "&Linux", IDC_FUNCLINUX,
-                  "&Xterm R6", IDC_FUNCXTERM,
-                  "&VT400", IDC_FUNCVT400, NULL);
+        radioline(&cp, "The &Backspace key", IDC_DELSTATIC, 2,
+                  "Control-H", IDC_DEL008,
+                  "Control-? (127)", IDC_DEL127, NULL);
+        radioline(&cp, "The &Home and End keys", IDC_HOMESTATIC, 2,
+                  "Standard", IDC_HOMETILDE,
+                  "rxvt", IDC_HOMERXVT, NULL);
+        radioline(&cp, "The &Function keys and keypad", IDC_FUNCSTATIC, 3,
+                  "ESC[n~", IDC_FUNCTILDE,
+                  "Linux", IDC_FUNCLINUX,
+                  "Xterm R6", IDC_FUNCXTERM,
+                 "VT400", IDC_FUNCVT400,
+                  "VT100+", IDC_FUNCVT100P,
+                 "SCO", IDC_FUNCSCO, NULL);
         endbox(&cp);
         beginbox(&cp, "Application keypad settings:",
                  IDC_BOX_KEYBOARD2);
         checkbox(&cp,
                  "Application c&ursor keys totally disabled",
                  IDC_NOAPPLICC);
-        radioline(&cp, "Initial state of cursor keys:", IDC_CURSTATIC, 2,
-                  "&Normal", IDC_CURNORMAL,
-                  "A&pplication", IDC_CURAPPLIC, NULL);
+        radioline(&cp, "Initial state of cu&rsor keys:", IDC_CURSTATIC, 2,
+                  "Normal", IDC_CURNORMAL,
+                  "Application", IDC_CURAPPLIC, NULL);
         checkbox(&cp,
                  "Application ke&ypad keys totally disabled",
                  IDC_NOAPPLICK);
-        radioline(&cp, "Initial state of numeric keypad:", IDC_KPSTATIC, 3,
-                  "Nor&mal", IDC_KPNORMAL,
-                  "Appl&ication", IDC_KPAPPLIC,
-                  "N&etHack", IDC_KPNH, NULL);
+        radioline(&cp, "Initial state of &numeric keypad:", IDC_KPSTATIC, 3,
+                  "Normal", IDC_KPNORMAL,
+                  "Application", IDC_KPAPPLIC,
+                  "NetHack", IDC_KPNH, NULL);
         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);
     }
 
     if (panel == windowpanelstart) {
-        /* The Window panel. Accelerators used: [acgo] bsdkw4ylpt */
+        /* The Window panel. Accelerators used: [acgo] rmz sdkp w4ylt */
         struct ctlpos cp;
         ctlposinit(&cp, hwnd, 80, 3, 13);
         bartitle(&cp, "Options controlling PuTTY's window",
@@ -766,7 +942,7 @@ static void create_controls(HWND hwnd, int dlgtype, int panel) {
                   "&Rows", IDC_ROWSSTATIC, IDC_ROWSEDIT, 50,
                   "Colu&mns", IDC_COLSSTATIC, IDC_COLSEDIT, 50,
                   NULL);
-        checkbox(&cp, "Loc&k window size against resizing", IDC_LOCKSIZE);
+        checkbox(&cp, "Lock window size against resi&zing", IDC_LOCKSIZE);
         endbox(&cp);
         beginbox(&cp, "Control the scrollback in the window",
                  IDC_BOX_WINDOW2);
@@ -787,7 +963,7 @@ static void create_controls(HWND hwnd, int dlgtype, int panel) {
     }
 
     if (panel == appearancepanelstart) {
-        /* The Appearance panel. Accelerators used: [acgo] rmkhtibluv */
+        /* 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",
@@ -817,10 +993,15 @@ static void create_controls(HWND hwnd, int dlgtype, int panel) {
         checkbox(&cp, "Hide mouse &pointer when typing in window",
                  IDC_HIDEMOUSE);
         endbox(&cp);
+        beginbox(&cp, "Adjust the window border",
+                 IDC_BOX_APPEARANCE5);
+        checkbox(&cp, "&Sunken-edge border (slightly thicker)",
+                 IDC_SUNKENEDGE);
+        endbox(&cp);
     }
 
     if (panel == translationpanelstart) {
-        /* The Translation panel. Accelerators used: [acgo] xbepnkis */
+        /* The Translation panel. Accelerators used: [acgo] xbep t s */
         struct ctlpos cp;
         ctlposinit(&cp, hwnd, 80, 3, 13);
         bartitle(&cp, "Options controlling character set translation",
@@ -838,11 +1019,11 @@ static void create_controls(HWND hwnd, int dlgtype, int panel) {
         beginbox(&cp, "Enable character set translation on received data",
                  IDC_BOX_TRANSLATION2);
         radiobig(&cp,
-                 "Character set translation:", IDC_XLATSTATIC,
-                 "&None", IDC_NOXLAT,
-                 "&KOI8 / Win-1251", IDC_KOI8WIN1251,
-                 "&ISO-8859-2 / Win-1250", IDC_88592WIN1250,
-                 "&ISO-8859-2 / CP852", IDC_88592CP852, NULL);
+                 "Character set &translation:", IDC_XLATSTATIC,
+                 "None", IDC_NOXLAT,
+                 "KOI8 / Win-1251", IDC_KOI8WIN1251,
+                 "ISO-8859-2 / Win-1250", IDC_88592WIN1250,
+                 "ISO-8859-2 / CP852", IDC_88592CP852, NULL);
         endbox(&cp);
         beginbox(&cp, "Enable character set translation on input data",
                  IDC_BOX_TRANSLATION3);
@@ -852,21 +1033,26 @@ static void create_controls(HWND hwnd, int dlgtype, int panel) {
     }
 
     if (panel == selectionpanelstart) {
-        /* The Selection panel. Accelerators used: [acgo] wxst */
+        /* The Selection panel. Accelerators used: [acgo] d 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);
-        charclass(&cp, "Character classes:", IDC_CCSTATIC, IDC_CCLIST,
+                 IDC_BOX_SELECTION3);
+        charclass(&cp, "C&haracter classes:", IDC_CCSTATIC, IDC_CCLIST,
                   "&Set", IDC_CCSET, IDC_CCEDIT,
                   "&to class", IDC_CCSTATIC2);
         endbox(&cp);
@@ -909,12 +1095,12 @@ static void create_controls(HWND hwnd, int dlgtype, int panel) {
         beginbox(&cp, "Sending of null packets to keep session active",
                  IDC_BOX_CONNECTION2);
         staticedit(&cp, "Seconds between &keepalives (0 to turn off)",
-                   IDC_PINGSTATIC, IDC_PINGEDIT, 25);
+                   IDC_PINGSTATIC, IDC_PINGEDIT, 20);
         endbox(&cp);
     }
 
     if (panel == telnetpanelstart) {
-        /* The Telnet panel. Accelerators used: [acgo] svldrbf */
+        /* The Telnet panel. Accelerators used: [acgo] svldr bf */
         struct ctlpos cp;
         ctlposinit(&cp, hwnd, 80, 3, 13);
         if (dlgtype == 0) {
@@ -952,7 +1138,7 @@ static void create_controls(HWND hwnd, int dlgtype, int panel) {
     }
 
     if (panel == sshpanelstart) {
-        /* The SSH panel. Accelerators used: [acgo] rmakwp123bd */
+        /* The SSH panel. Accelerators used: [acgo] rmfkw pe123bds i */
         struct ctlpos cp;
         ctlposinit(&cp, hwnd, 80, 3, 13);
         if (dlgtype == 0) {
@@ -967,7 +1153,7 @@ static void create_controls(HWND hwnd, int dlgtype, int panel) {
                      IDC_BOX_SSH2);
             checkbox(&cp, "Atte&mpt TIS or CryptoCard authentication",
                      IDC_AUTHTIS);
-            checkbox(&cp, "Allow &agent forwarding", IDC_AGENTFWD);
+            checkbox(&cp, "Allow agent &forwarding", IDC_AGENTFWD);
             editbutton(&cp, "Private &key file for authentication:",
                        IDC_PKSTATIC, IDC_PKEDIT, "Bro&wse...", IDC_PKBUTTON);
             endbox(&cp);
@@ -978,11 +1164,13 @@ 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);
-            checkbox(&cp, "Imitate SSH 2 MAC bug in commercial <= v2.3.x",
+                      "&DES", IDC_CIPHERDES,
+                      "AE&S", IDC_CIPHERAES,
+                      NULL);
+            checkbox(&cp, "&Imitate SSH 2 MAC bug in commercial <= v2.3.x",
                      IDC_BUGGYMAC);
             endbox(&cp);
         }
@@ -1081,8 +1269,10 @@ static int GenericMainDlgProc (HWND hwnd, UINT msg,
         * Set up the tree view contents.
         */
         hsession = treeview_insert(&tvfaff, 0, "Session");
+        treeview_insert(&tvfaff, 1, "Logging");
         treeview_insert(&tvfaff, 0, "Terminal");
         treeview_insert(&tvfaff, 1, "Keyboard");
+        treeview_insert(&tvfaff, 1, "Bell");
         treeview_insert(&tvfaff, 0, "Window");
         treeview_insert(&tvfaff, 1, "Appearance");
         treeview_insert(&tvfaff, 1, "Translation");
@@ -1092,9 +1282,10 @@ static int GenericMainDlgProc (HWND hwnd, UINT msg,
         if (dlgtype == 0) {
             treeview_insert(&tvfaff, 1, "Telnet");
             treeview_insert(&tvfaff, 1, "Rlogin");
-            if (backends[3].backend != NULL)
+            if (backends[3].backend != NULL) {
                 treeview_insert(&tvfaff, 1, "SSH");
-            treeview_insert(&tvfaff, 2, "Tunnels");
+                treeview_insert(&tvfaff, 2, "Tunnels");
+            }
         }
 
         /*
@@ -1143,10 +1334,14 @@ static int GenericMainDlgProc (HWND hwnd, UINT msg,
             }
            if (!strcmp(buffer, "Session"))
                create_controls(hwnd, dlgtype, sessionpanelstart);
+           if (!strcmp(buffer, "Logging"))
+               create_controls(hwnd, dlgtype, loggingpanelstart);
            if (!strcmp(buffer, "Keyboard"))
                create_controls(hwnd, dlgtype, keyboardpanelstart);
            if (!strcmp(buffer, "Terminal"))
                create_controls(hwnd, dlgtype, terminalpanelstart);
+           if (!strcmp(buffer, "Bell"))
+               create_controls(hwnd, dlgtype, bellpanelstart);
            if (!strcmp(buffer, "Window"))
                create_controls(hwnd, dlgtype, windowpanelstart);
            if (!strcmp(buffer, "Appearance"))
@@ -1335,21 +1530,22 @@ static int GenericMainDlgProc (HWND hwnd, UINT msg,
                HIWORD(wParam) == BN_DOUBLECLICKED)
                cfg.rxvt_homeend = IsDlgButtonChecked (hwnd, IDC_HOMERXVT);
            break;
-         case IDC_FUNCXTERM:
-           if (HIWORD(wParam) == BN_CLICKED ||
-               HIWORD(wParam) == BN_DOUBLECLICKED)
-               cfg.funky_type = 2;
-           break;
-         case IDC_FUNCVT400:
-           if (HIWORD(wParam) == BN_CLICKED ||
-               HIWORD(wParam) == BN_DOUBLECLICKED)
-               cfg.funky_type = 3;
-           break;
          case IDC_FUNCTILDE:
          case IDC_FUNCLINUX:
+         case IDC_FUNCXTERM:
+         case IDC_FUNCVT400:
+         case IDC_FUNCVT100P:
+         case IDC_FUNCSCO:
            if (HIWORD(wParam) == BN_CLICKED ||
                HIWORD(wParam) == BN_DOUBLECLICKED)
-               cfg.funky_type = IsDlgButtonChecked (hwnd, IDC_FUNCLINUX);
+               switch (LOWORD(wParam)) {
+                 case IDC_FUNCTILDE: cfg.funky_type = 0; break;
+                 case IDC_FUNCLINUX: cfg.funky_type = 1; break;
+                 case IDC_FUNCXTERM: cfg.funky_type = 2; break;
+                 case IDC_FUNCVT400: cfg.funky_type = 3; break;
+                 case IDC_FUNCVT100P: cfg.funky_type = 4; break;
+                 case IDC_FUNCSCO: cfg.funky_type = 5; break;
+               }
            break;
          case IDC_KPNORMAL:
          case IDC_KPAPPLIC:
@@ -1397,10 +1593,30 @@ static int GenericMainDlgProc (HWND hwnd, UINT msg,
                HIWORD(wParam) == BN_DOUBLECLICKED)
                cfg.alt_only = IsDlgButtonChecked (hwnd, IDC_ALTONLY);
            break;
-         case IDC_LDISCTERM:
+         case IDC_ECHOBACKEND:
+         case IDC_ECHOYES:
+         case IDC_ECHONO:
            if (HIWORD(wParam) == BN_CLICKED ||
-               HIWORD(wParam) == BN_DOUBLECLICKED)
-               cfg.ldisc_term = IsDlgButtonChecked (hwnd, IDC_LDISCTERM);
+               HIWORD(wParam) == BN_DOUBLECLICKED) {
+               if (LOWORD(wParam)==IDC_ECHOBACKEND) cfg.localecho=LD_BACKEND;
+               if (LOWORD(wParam)==IDC_ECHOYES) cfg.localecho=LD_YES;
+               if (LOWORD(wParam)==IDC_ECHONO) cfg.localecho=LD_NO;
+            }
+           break;
+         case IDC_EDITBACKEND:
+         case IDC_EDITYES:
+         case IDC_EDITNO:
+           if (HIWORD(wParam) == BN_CLICKED ||
+               HIWORD(wParam) == BN_DOUBLECLICKED) {
+               if (LOWORD(wParam)==IDC_EDITBACKEND) cfg.localedit=LD_BACKEND;
+               if (LOWORD(wParam)==IDC_EDITYES) cfg.localedit=LD_YES;
+               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 ||
@@ -1422,6 +1638,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)
@@ -1473,16 +1694,67 @@ 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);
            }
            break;
-         case IDC_BEEP:
+         case IDC_BELL_DISABLED:
+         case IDC_BELL_DEFAULT:
+         case IDC_BELL_WAVEFILE:
+         case IDC_BELL_VISUAL:
+           if (HIWORD(wParam) == BN_CLICKED ||
+               HIWORD(wParam) == BN_DOUBLECLICKED) {
+               if (LOWORD(wParam)==IDC_BELL_DISABLED) cfg.beep = BELL_DISABLED;
+               if (LOWORD(wParam)==IDC_BELL_DEFAULT) cfg.beep = BELL_DEFAULT;
+               if (LOWORD(wParam)==IDC_BELL_WAVEFILE) cfg.beep = BELL_WAVEFILE;
+               if (LOWORD(wParam)==IDC_BELL_VISUAL) cfg.beep = BELL_VISUAL;
+            }
+           break;
+         case IDC_BELL_WAVEBROWSE:
+            memset(&of, 0, sizeof(of));
+#ifdef OPENFILENAME_SIZE_VERSION_400
+            of.lStructSize = OPENFILENAME_SIZE_VERSION_400;
+#else
+            of.lStructSize = sizeof(of);
+#endif
+            of.hwndOwner = hwnd;
+            of.lpstrFilter = "Wave Files\0*.WAV\0AllFiles\0*\0\0\0";
+            of.lpstrCustomFilter = NULL;
+            of.nFilterIndex = 1;
+            of.lpstrFile = filename; strcpy(filename, cfg.bell_wavefile);
+            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);
+                SetDlgItemText (hwnd, IDC_BELL_WAVEEDIT, cfg.bell_wavefile);
+            }
+           break;
+         case IDC_BELL_WAVEEDIT:
+           if (HIWORD(wParam) == EN_CHANGE)
+               GetDlgItemText (hwnd, IDC_BELL_WAVEEDIT, cfg.bell_wavefile,
+                               sizeof(cfg.bell_wavefile)-1);
+           break;
+         case IDC_BELLOVL:
            if (HIWORD(wParam) == BN_CLICKED ||
                HIWORD(wParam) == BN_DOUBLECLICKED)
-               cfg.beep = IsDlgButtonChecked (hwnd, IDC_BEEP);
+               cfg.bellovl = IsDlgButtonChecked (hwnd, IDC_BELLOVL);
            break;
+          case IDC_BELLOVLN:
+            if (HIWORD(wParam) == EN_CHANGE)
+                MyGetDlgItemInt (hwnd, IDC_BELLOVLN, &cfg.bellovl_n);
+            break;
+          case IDC_BELLOVLT:
+            if (HIWORD(wParam) == EN_CHANGE)
+                MyGetDlgItemFlt (hwnd, IDC_BELLOVLT, &cfg.bellovl_t, 1000);
+            break;
+          case IDC_BELLOVLS:
+            if (HIWORD(wParam) == EN_CHANGE)
+                MyGetDlgItemFlt (hwnd, IDC_BELLOVLS, &cfg.bellovl_s, 1000);
+            break;
          case IDC_BLINKTEXT:
            if (HIWORD(wParam) == BN_CLICKED ||
                HIWORD(wParam) == BN_DOUBLECLICKED)
@@ -1503,6 +1775,11 @@ static int GenericMainDlgProc (HWND hwnd, UINT msg,
                HIWORD(wParam) == BN_DOUBLECLICKED)
                cfg.hide_mouseptr = IsDlgButtonChecked (hwnd, IDC_HIDEMOUSE);
            break;
+         case IDC_SUNKENEDGE:
+           if (HIWORD(wParam) == BN_CLICKED ||
+               HIWORD(wParam) == BN_DOUBLECLICKED)
+               cfg.sunken_edge = IsDlgButtonChecked (hwnd, IDC_SUNKENEDGE);
+           break;
          case IDC_CURBLOCK:
            if (HIWORD(wParam) == BN_CLICKED ||
                HIWORD(wParam) == BN_DOUBLECLICKED)
@@ -1538,11 +1815,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)
@@ -1569,15 +1851,15 @@ static int GenericMainDlgProc (HWND hwnd, UINT msg,
             of.lpstrFilter = "All Files\0*\0\0\0";
             of.lpstrCustomFilter = NULL;
             of.nFilterIndex = 1;
-            of.lpstrFile = filename; strcpy(filename, cfg.keyfile);
+            of.lpstrFile = filename; strcpy(filename, cfg.logfilename);
             of.nMaxFile = sizeof(filename);
             of.lpstrFileTitle = NULL;
             of.lpstrInitialDir = NULL;
             of.lpstrTitle = "Select session log file";
             of.Flags = 0;
             if (GetSaveFileName(&of)) {
-                strcpy(cfg.keyfile, filename);
-                SetDlgItemText (hwnd, IDC_LGFEDIT, cfg.keyfile);
+                strcpy(cfg.logfilename, filename);
+                SetDlgItemText (hwnd, IDC_LGFEDIT, cfg.logfilename);
             }
            break;
          case IDC_LSTATOFF:
@@ -1590,6 +1872,16 @@ static int GenericMainDlgProc (HWND hwnd, UINT msg,
                if (IsDlgButtonChecked (hwnd, IDC_LSTATRAW)) cfg.logtype = 2;
            }
            break;
+         case IDC_LSTATXASK:
+         case IDC_LSTATXAPN:
+         case IDC_LSTATXOVR:
+           if (HIWORD(wParam) == BN_CLICKED ||
+               HIWORD(wParam) == BN_DOUBLECLICKED) {
+               if (IsDlgButtonChecked (hwnd, IDC_LSTATXASK)) cfg.logxfovr = LGXF_ASK;
+               if (IsDlgButtonChecked (hwnd, IDC_LSTATXAPN)) cfg.logxfovr = LGXF_APN;
+               if (IsDlgButtonChecked (hwnd, IDC_LSTATXOVR)) cfg.logxfovr = LGXF_OVR;
+           }
+           break;
          case IDC_TSEDIT:
          case IDC_R_TSEDIT:
            if (HIWORD(wParam) == EN_CHANGE)
@@ -1702,6 +1994,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))
@@ -1710,6 +2003,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:
@@ -1759,6 +2054,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);
@@ -1911,8 +2208,6 @@ static int GenericMainDlgProc (HWND hwnd, UINT msg,
 
 static int CALLBACK MainDlgProc (HWND hwnd, UINT msg,
                                 WPARAM wParam, LPARAM lParam) {
-    static HWND page = NULL;
-
     if (msg == WM_COMMAND && LOWORD(wParam) == IDOK) {
     }
     if (msg == WM_COMMAND && LOWORD(wParam) == IDCX_ABOUT) {
@@ -1927,7 +2222,6 @@ static int CALLBACK MainDlgProc (HWND hwnd, UINT msg,
 
 static int CALLBACK ReconfDlgProc (HWND hwnd, UINT msg,
                                   WPARAM wParam, LPARAM lParam) {
-    static HWND page;
     return GenericMainDlgProc (hwnd, msg, wParam, lParam, 1);
 }
 
@@ -1970,20 +2264,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) {
@@ -1992,14 +2294,11 @@ void showeventlog (HWND hwnd) {
                               hwnd, LogProc);
        ShowWindow (logbox, SW_SHOWNORMAL);
     }
+    SetActiveWindow(logbox);
 }
 
 void showabout (HWND hwnd) {
-    if (!abtbox) {
-       abtbox = CreateDialog (hinst, MAKEINTRESOURCE(IDD_ABOUTBOX),
-                              hwnd, AboutProc);
-       ShowWindow (abtbox, SW_SHOWNORMAL);
-    }
+    DialogBox(hinst, MAKEINTRESOURCE(IDD_ABOUTBOX),hwnd, AboutProc);
 }
 
 void verify_ssh_host_key(char *host, int port, char *keytype,
@@ -2085,6 +2384,9 @@ int askappend(char *filename) {
        "or Cancel to disable logging.";
     char message[sizeof(msgtemplate) + FILENAME_MAX];
     int mbret;
+    if ( cfg.logxfovr != LGXF_ASK ) {
+       return ( (cfg.logxfovr==LGXF_OVR) ? 2 : 1);
+    }
     sprintf(message, msgtemplate, FILENAME_MAX, filename);
 
     mbret = MessageBox(NULL, message, mbtitle,