X-Git-Url: https://git.distorted.org.uk/~mdw/sgt/putty/blobdiff_plain/07e4d76d02456f343dfa7a8628c46ebdc72a2d44..5fac915c83c037545177b56d10e07b43a3252393:/config.c?ds=sidebyside diff --git a/config.c b/config.c index 185529cf..ed2bee66 100644 --- a/config.c +++ b/config.c @@ -110,7 +110,7 @@ static void cipherlist_handler(union control *ctrl, void *dlg, break; } } - dlg_listbox_addwithindex(ctrl, dlg, cstr, c); + dlg_listbox_addwithid(ctrl, dlg, cstr, c); } dlg_update_done(ctrl, dlg); @@ -179,9 +179,9 @@ static void sshbug_handler(union control *ctrl, void *dlg, if (event == EVENT_REFRESH) { dlg_update_start(ctrl, dlg); dlg_listbox_clear(ctrl, dlg); - dlg_listbox_addwithindex(ctrl, dlg, "Auto", AUTO); - dlg_listbox_addwithindex(ctrl, dlg, "Off", FORCE_OFF); - dlg_listbox_addwithindex(ctrl, dlg, "On", FORCE_ON); + dlg_listbox_addwithid(ctrl, dlg, "Auto", AUTO); + dlg_listbox_addwithid(ctrl, dlg, "Off", FORCE_OFF); + dlg_listbox_addwithid(ctrl, dlg, "On", FORCE_ON); switch (*(int *)ATOFFSET(data, ctrl->listbox.context.i)) { case AUTO: dlg_listbox_select(ctrl, dlg, 0); break; case FORCE_OFF: dlg_listbox_select(ctrl, dlg, 1); break; @@ -396,7 +396,7 @@ static void charclass_handler(union control *ctrl, void *dlg, } struct colour_data { - union control *listbox, *rgbtext, *button; + union control *listbox, *redit, *gedit, *bedit, *button; }; static const char *const colours[] = { @@ -429,7 +429,9 @@ static void colour_handler(union control *ctrl, void *dlg, for (i = 0; i < lenof(colours); i++) dlg_listbox_add(ctrl, dlg, colours[i]); dlg_update_done(ctrl, dlg); - dlg_text_set(cd->rgbtext, dlg, ""); + dlg_editbox_set(cd->redit, dlg, ""); + dlg_editbox_set(cd->gedit, dlg, ""); + dlg_editbox_set(cd->bedit, dlg, ""); } } else if (event == EVENT_SELCHANGE) { if (ctrl == cd->listbox) { @@ -444,6 +446,25 @@ static void colour_handler(union control *ctrl, void *dlg, b = cfg->colours[i][2]; update = TRUE; } + } else if (event == EVENT_VALCHANGE) { + if (ctrl == cd->redit || ctrl == cd->gedit || ctrl == cd->bedit) { + /* The user has changed the colour using the edit boxes. */ + char buf[80]; + int i, cval; + + dlg_editbox_get(ctrl, dlg, buf, lenof(buf)); + cval = atoi(buf) & 255; + + i = dlg_listbox_index(cd->listbox, dlg); + if (i >= 0) { + if (ctrl == cd->redit) + cfg->colours[i][0] = cval; + else if (ctrl == cd->gedit) + cfg->colours[i][1] = cval; + else if (ctrl == cd->bedit) + cfg->colours[i][2] = cval; + } + } } else if (event == EVENT_ACTION) { if (ctrl == cd->button) { int i = dlg_listbox_index(cd->listbox, dlg); @@ -480,8 +501,9 @@ static void colour_handler(union control *ctrl, void *dlg, if (update) { char buf[40]; - sprintf(buf, "%02x/%02x/%02x", r, g, b); - dlg_text_set(cd->rgbtext, dlg, buf); + sprintf(buf, "%d", r); dlg_editbox_set(cd->redit, dlg, buf); + sprintf(buf, "%d", g); dlg_editbox_set(cd->gedit, dlg, buf); + sprintf(buf, "%d", b); dlg_editbox_set(cd->bedit, dlg, buf); } } @@ -1156,10 +1178,18 @@ void setup_config_box(struct controlbox *b, struct sesslist *sesslist, cd->listbox = ctrl_listbox(s, "Select a colour to adjust:", 'u', HELPCTX(colours_config), colour_handler, P(cd)); cd->listbox->generic.column = 0; + cd->listbox->listbox.height = 7; c = ctrl_text(s, "RGB value:", HELPCTX(colours_config)); c->generic.column = 1; - cd->rgbtext = ctrl_text(s, "00/00/00", HELPCTX(colours_config)); - cd->rgbtext->generic.column = 1; + cd->redit = ctrl_editbox(s, "Red", 'r', 50, HELPCTX(colours_config), + colour_handler, P(cd), P(NULL)); + cd->redit->generic.column = 1; + cd->gedit = ctrl_editbox(s, "Green", 'n', 50, HELPCTX(colours_config), + colour_handler, P(cd), P(NULL)); + cd->gedit->generic.column = 1; + cd->bedit = ctrl_editbox(s, "Blue", 'e', 50, HELPCTX(colours_config), + colour_handler, P(cd), P(NULL)); + cd->bedit->generic.column = 1; cd->button = ctrl_pushbutton(s, "Modify", 'm', HELPCTX(colours_config), colour_handler, P(cd)); cd->button->generic.column = 1;