If a new session was saved from Change Settings, a side-effect on Windows was
[u/mdw/putty] / config.c
index 9535397..336f2b6 100644 (file)
--- a/config.c
+++ b/config.c
@@ -50,6 +50,33 @@ static void protocolbuttons_handler(union control *ctrl, void *dlg,
     }
 }
 
+static void loggingbuttons_handler(union control *ctrl, void *dlg,
+                                  void *data, int event)
+{
+    int button;
+    Config *cfg = (Config *)data;
+    /* This function works just like the standard radio-button handler,
+     * but it has to fall back to "no logging" in situations where the
+     * configured logging type isn't applicable.
+     */
+    if (event == EVENT_REFRESH) {
+        for (button = 0; button < ctrl->radio.nbuttons; button++)
+            if (cfg->logtype == ctrl->radio.buttondata[button].i)
+               break;
+    
+    /* We fell off the end, so we lack the configured logging type */
+    if (button == ctrl->radio.nbuttons) {
+        button=0;
+        cfg->logtype=LGTYP_NONE;
+    }
+    dlg_radiobutton_set(ctrl, dlg, button);
+    } else if (event == EVENT_VALCHANGE) {
+        button = dlg_radiobutton_get(ctrl, dlg);
+        assert(button >= 0 && button < ctrl->radio.nbuttons);
+        cfg->logtype = ctrl->radio.buttondata[button].i;
+    }
+}
+
 static void numeric_keypad_handler(union control *ctrl, void *dlg,
                                   void *data, int event)
 {
@@ -251,7 +278,7 @@ static void sshbug_handler(union control *ctrl, void *dlg,
 struct sessionsaver_data {
     union control *editbox, *listbox, *loadbutton, *savebutton, *delbutton;
     union control *okbutton, *cancelbutton;
-    struct sesslist *sesslist;
+    struct sesslist sesslist;
     int midsession;
 };
 
@@ -270,10 +297,10 @@ static int load_selected_session(struct sessionsaver_data *ssd,
        dlg_beep(dlg);
        return 0;
     }
-    isdef = !strcmp(ssd->sesslist->sessions[i], "Default Settings");
-    load_settings(ssd->sesslist->sessions[i], !isdef, cfg);
+    isdef = !strcmp(ssd->sesslist.sessions[i], "Default Settings");
+    load_settings(ssd->sesslist.sessions[i], !isdef, cfg);
     if (!isdef) {
-       strncpy(savedsession, ssd->sesslist->sessions[i],
+       strncpy(savedsession, ssd->sesslist.sessions[i],
                SAVEDSESSION_LEN);
        savedsession[SAVEDSESSION_LEN-1] = '\0';
     } else {
@@ -317,8 +344,8 @@ static void sessionsaver_handler(union control *ctrl, void *dlg,
            int i;
            dlg_update_start(ctrl, dlg);
            dlg_listbox_clear(ctrl, dlg);
-           for (i = 0; i < ssd->sesslist->nsessions; i++)
-               dlg_listbox_add(ctrl, dlg, ssd->sesslist->sessions[i]);
+           for (i = 0; i < ssd->sesslist.nsessions; i++)
+               dlg_listbox_add(ctrl, dlg, ssd->sesslist.sessions[i]);
            dlg_update_done(ctrl, dlg);
        }
     } else if (event == EVENT_VALCHANGE) {
@@ -349,9 +376,9 @@ static void sessionsaver_handler(union control *ctrl, void *dlg,
                    dlg_beep(dlg);
                    return;
                }
-               isdef = !strcmp(ssd->sesslist->sessions[i], "Default Settings");
+               isdef = !strcmp(ssd->sesslist.sessions[i], "Default Settings");
                if (!isdef) {
-                   strncpy(savedsession, ssd->sesslist->sessions[i],
+                   strncpy(savedsession, ssd->sesslist.sessions[i],
                            SAVEDSESSION_LEN);
                    savedsession[SAVEDSESSION_LEN-1] = '\0';
                } else {
@@ -365,8 +392,8 @@ static void sessionsaver_handler(union control *ctrl, void *dlg,
                     sfree(errmsg);
                 }
             }
-           get_sesslist(ssd->sesslist, FALSE);
-           get_sesslist(ssd->sesslist, TRUE);
+           get_sesslist(&ssd->sesslist, FALSE);
+           get_sesslist(&ssd->sesslist, TRUE);
            dlg_refresh(ssd->editbox, dlg);
            dlg_refresh(ssd->listbox, dlg);
        } else if (!ssd->midsession &&
@@ -375,9 +402,9 @@ static void sessionsaver_handler(union control *ctrl, void *dlg,
            if (i <= 0) {
                dlg_beep(dlg);
            } else {
-               del_settings(ssd->sesslist->sessions[i]);
-               get_sesslist(ssd->sesslist, FALSE);
-               get_sesslist(ssd->sesslist, TRUE);
+               del_settings(ssd->sesslist.sessions[i]);
+               get_sesslist(&ssd->sesslist, FALSE);
+               get_sesslist(&ssd->sesslist, TRUE);
                dlg_refresh(ssd->listbox, dlg);
            }
        } else if (ctrl == ssd->okbutton) {
@@ -792,8 +819,8 @@ static void portfwd_handler(union control *ctrl, void *dlg,
     }
 }
 
-void setup_config_box(struct controlbox *b, struct sesslist *sesslist,
-                     int midsession, int protocol, int protcfginfo)
+void setup_config_box(struct controlbox *b, int midsession,
+                     int protocol, int protcfginfo)
 {
     struct controlset *s;
     struct sessionsaver_data *ssd;
@@ -877,7 +904,7 @@ void setup_config_box(struct controlbox *b, struct sesslist *sesslist,
                    midsession ? "Save the current session settings" :
                    "Load, save or delete a stored session");
     ctrl_columns(s, 2, 75, 25);
-    ssd->sesslist = sesslist;
+    get_sesslist(&ssd->sesslist, TRUE);
     ssd->editbox = ctrl_editbox(s, "Saved Sessions", 'e', 100,
                                HELPCTX(session_saved),
                                sessionsaver_handler, P(ssd), P(NULL));
@@ -947,7 +974,7 @@ void setup_config_box(struct controlbox *b, struct sesslist *sesslist,
            sshlogname = NULL;         /* this will disable the button */
        ctrl_radiobuttons(s, "Session logging:", NO_SHORTCUT, 1,
                          HELPCTX(logging_main),
-                         dlg_stdradiobutton_handler,
+                         loggingbuttons_handler,
                          I(offsetof(Config, logtype)),
                          "Logging turned off completely", 't', I(LGTYP_NONE),
                          "Log printable output only", 'p', I(LGTYP_ASCII),
@@ -1255,6 +1282,11 @@ void setup_config_box(struct controlbox *b, struct sesslist *sesslist,
                  'r', 100, HELPCTX(translation_codepage),
                  codepage_handler, P(NULL), P(NULL));
 
+    s = ctrl_getset(b, "Window/Translation", "tweaks", NULL);
+    ctrl_checkbox(s, "Treat CJK ambiguous characters as wide", 'w',
+                 HELPCTX(translation_cjk_ambig_wide),
+                 dlg_stdcheckbox_handler, I(offsetof(Config,cjk_ambig_wide)));
+
     str = dupprintf("Adjust how %s handles line drawing characters", appname);
     s = ctrl_getset(b, "Window/Translation", "linedraw", str);
     sfree(str);
@@ -1842,10 +1874,10 @@ void setup_config_box(struct controlbox *b, struct sesslist *sesslist,
            ctrl_droplist(s, "Requires padding on SSH-2 RSA signatures", 'p', 20,
                          HELPCTX(ssh_bugs_rsapad2),
                          sshbug_handler, I(offsetof(Config,sshbug_rsapad2)));
-           ctrl_droplist(s, "Misuses the session ID in PK auth", 'n', 20,
+           ctrl_droplist(s, "Misuses the session ID in SSH-2 PK auth", 'n', 20,
                          HELPCTX(ssh_bugs_pksessid2),
                          sshbug_handler, I(offsetof(Config,sshbug_pksessid2)));
-           ctrl_droplist(s, "Handles key re-exchange badly", 'k', 20,
+           ctrl_droplist(s, "Handles SSH-2 key re-exchange badly", 'k', 20,
                          HELPCTX(ssh_bugs_rekey2),
                          sshbug_handler, I(offsetof(Config,sshbug_rekey2)));
        }