X-Git-Url: https://git.distorted.org.uk/~mdw/sgt/putty/blobdiff_plain/b37f2d5ba9a1d183d74c56af6fb9952fb2d08d9c..47061bb488400d53fd20deb52d51763d2caa056e:/sercfg.c diff --git a/sercfg.c b/sercfg.c index b0842ea1..fef910f3 100644 --- a/sercfg.c +++ b/sercfg.c @@ -31,10 +31,14 @@ static void serial_parity_handler(union control *ctrl, void *dlg, }; int mask = ctrl->listbox.context.i; int i, j; - Config *cfg = (Config *)data; + Conf *conf = (Conf *)data; if (event == EVENT_REFRESH) { - int oldparity = cfg->serparity;/* preserve past reentrant calls */ + /* Fetching this once at the start of the function ensures we + * remember what the right value is supposed to be when + * operations below cause reentrant calls to this function. */ + int oldparity = conf_get_int(conf, CONF_serparity); + dlg_update_start(ctrl, dlg); dlg_listbox_clear(ctrl, dlg); for (i = 0; i < lenof(parities); i++) { @@ -56,14 +60,14 @@ static void serial_parity_handler(union control *ctrl, void *dlg, oldparity = SER_PAR_NONE; } dlg_update_done(ctrl, dlg); - cfg->serparity = oldparity; /* restore */ + conf_set_int(conf, CONF_serparity, oldparity); /* restore */ } else if (event == EVENT_SELCHANGE) { int i = dlg_listbox_index(ctrl, dlg); if (i < 0) i = SER_PAR_NONE; else i = dlg_listbox_getid(ctrl, dlg, i); - cfg->serparity = i; + conf_set_int(conf, CONF_serparity, i); } } @@ -81,10 +85,14 @@ static void serial_flow_handler(union control *ctrl, void *dlg, }; int mask = ctrl->listbox.context.i; int i, j; - Config *cfg = (Config *)data; + Conf *conf = (Conf *)data; if (event == EVENT_REFRESH) { - int oldflow = cfg->serflow; /* preserve past reentrant calls */ + /* Fetching this once at the start of the function ensures we + * remember what the right value is supposed to be when + * operations below cause reentrant calls to this function. */ + int oldflow = conf_get_int(conf, CONF_serflow); + dlg_update_start(ctrl, dlg); dlg_listbox_clear(ctrl, dlg); for (i = 0; i < lenof(flows); i++) { @@ -105,14 +113,14 @@ static void serial_flow_handler(union control *ctrl, void *dlg, oldflow = SER_FLOW_NONE; } dlg_update_done(ctrl, dlg); - cfg->serflow = oldflow; /* restore */ + conf_set_int(conf, CONF_serflow, oldflow);/* restore */ } else if (event == EVENT_SELCHANGE) { int i = dlg_listbox_index(ctrl, dlg); if (i < 0) i = SER_FLOW_NONE; else i = dlg_listbox_getid(ctrl, dlg, i); - cfg->serflow = i; + conf_set_int(conf, CONF_serflow, i); } } @@ -150,7 +158,7 @@ void ser_setup_config_box(struct controlbox *b, int midsession, if (c->radio.shortcuts) { c->radio.shortcuts = sresize(c->radio.shortcuts, c->radio.nbuttons, char); - c->radio.shortcuts[c->radio.nbuttons-1] = NO_SHORTCUT; + c->radio.shortcuts[c->radio.nbuttons-1] = 'r'; } } } @@ -173,23 +181,22 @@ void ser_setup_config_box(struct controlbox *b, int midsession, "Select a serial line"); ctrl_editbox(s, "Serial line to connect to", 'l', 40, HELPCTX(serial_line), - dlg_stdeditbox_handler, I(offsetof(Config,serline)), - I(sizeof(((Config *)0)->serline))); + conf_editbox_handler, I(CONF_serline), I(1)); } s = ctrl_getset(b, "Connection/Serial", "sercfg", "Configure the serial line"); ctrl_editbox(s, "Speed (baud)", 's', 40, HELPCTX(serial_speed), - dlg_stdeditbox_handler, I(offsetof(Config,serspeed)), I(-1)); + conf_editbox_handler, I(CONF_serspeed), I(-1)); ctrl_editbox(s, "Data bits", 'b', 40, HELPCTX(serial_databits), - dlg_stdeditbox_handler,I(offsetof(Config,serdatabits)),I(-1)); + conf_editbox_handler, I(CONF_serdatabits), I(-1)); /* * Stop bits come in units of one half. */ ctrl_editbox(s, "Stop bits", 't', 40, HELPCTX(serial_stopbits), - dlg_stdeditbox_handler,I(offsetof(Config,serstopbits)),I(-2)); + conf_editbox_handler, I(CONF_serstopbits), I(-2)); ctrl_droplist(s, "Parity", 'p', 40, HELPCTX(serial_parity), serial_parity_handler, I(parity_mask));