2 * config.c - the platform-independent parts of the PuTTY
13 #define PRINTER_DISABLED_STRING "None (printing disabled)"
15 #define HOST_BOX_TITLE "Host Name (or IP address)"
16 #define PORT_BOX_TITLE "Port"
18 static void config_host_handler(union control *ctrl, void *dlg,
19 void *data, int event)
21 Config *cfg = (Config *)data;
24 * This function works just like the standard edit box handler,
25 * only it has to choose the control's label and text from two
26 * different places depending on the protocol.
28 if (event == EVENT_REFRESH) {
29 if (cfg->protocol == PROT_SERIAL) {
31 * This label text is carefully chosen to contain an n,
32 * since that's the shortcut for the host name control.
34 dlg_label_change(ctrl, dlg, "Serial line");
35 dlg_editbox_set(ctrl, dlg, cfg->serline);
37 dlg_label_change(ctrl, dlg, HOST_BOX_TITLE);
38 dlg_editbox_set(ctrl, dlg, cfg->host);
40 } else if (event == EVENT_VALCHANGE) {
41 if (cfg->protocol == PROT_SERIAL)
42 dlg_editbox_get(ctrl, dlg, cfg->serline, lenof(cfg->serline));
44 dlg_editbox_get(ctrl, dlg, cfg->host, lenof(cfg->host));
48 static void config_port_handler(union control *ctrl, void *dlg,
49 void *data, int event)
51 Config *cfg = (Config *)data;
55 * This function works just like the standard edit box handler,
56 * only it has to choose the control's label and text from two
57 * different places depending on the protocol.
59 if (event == EVENT_REFRESH) {
60 if (cfg->protocol == PROT_SERIAL) {
62 * This label text is carefully chosen to contain a p,
63 * since that's the shortcut for the port control.
65 dlg_label_change(ctrl, dlg, "Speed");
66 sprintf(buf, "%d", cfg->serspeed);
68 dlg_label_change(ctrl, dlg, PORT_BOX_TITLE);
69 sprintf(buf, "%d", cfg->port);
71 dlg_editbox_set(ctrl, dlg, buf);
72 } else if (event == EVENT_VALCHANGE) {
73 dlg_editbox_get(ctrl, dlg, buf, lenof(buf));
74 if (cfg->protocol == PROT_SERIAL)
75 cfg->serspeed = atoi(buf);
77 cfg->port = atoi(buf);
82 union control *host, *port;
86 * We export this function so that platform-specific config
87 * routines can use it to conveniently identify the protocol radio
88 * buttons in order to add to them.
90 void config_protocolbuttons_handler(union control *ctrl, void *dlg,
91 void *data, int event)
94 Config *cfg = (Config *)data;
95 struct hostport *hp = (struct hostport *)ctrl->radio.context.p;
98 * This function works just like the standard radio-button
99 * handler, except that it also has to change the setting of
100 * the port box, and refresh both host and port boxes when. We
101 * expect the context parameter to point at a hostport
102 * structure giving the `union control's for both.
104 if (event == EVENT_REFRESH) {
105 for (button = 0; button < ctrl->radio.nbuttons; button++)
106 if (cfg->protocol == ctrl->radio.buttondata[button].i)
108 /* We expected that `break' to happen, in all circumstances. */
109 assert(button < ctrl->radio.nbuttons);
110 dlg_radiobutton_set(ctrl, dlg, button);
111 } else if (event == EVENT_VALCHANGE) {
112 int oldproto = cfg->protocol;
113 button = dlg_radiobutton_get(ctrl, dlg);
114 assert(button >= 0 && button < ctrl->radio.nbuttons);
115 cfg->protocol = ctrl->radio.buttondata[button].i;
116 if (oldproto != cfg->protocol) {
117 Backend *ob = backend_from_proto(oldproto);
118 Backend *nb = backend_from_proto(cfg->protocol);
121 /* Iff the user hasn't changed the port from the protocol
122 * default (if any), update it with the new protocol's
124 * (XXX: this isn't perfect; a default can become permanent
125 * by going via the serial backend. However, it helps with
126 * the common case of tabbing through the controls in order
127 * and setting a non-default port.) */
128 if (cfg->port == ob->default_port &&
129 cfg->port > 0 && nb->default_port > 0)
130 cfg->port = nb->default_port;
132 dlg_refresh(hp->host, dlg);
133 dlg_refresh(hp->port, dlg);
137 static void loggingbuttons_handler(union control *ctrl, void *dlg,
138 void *data, int event)
141 Config *cfg = (Config *)data;
142 /* This function works just like the standard radio-button handler,
143 * but it has to fall back to "no logging" in situations where the
144 * configured logging type isn't applicable.
146 if (event == EVENT_REFRESH) {
147 for (button = 0; button < ctrl->radio.nbuttons; button++)
148 if (cfg->logtype == ctrl->radio.buttondata[button].i)
151 /* We fell off the end, so we lack the configured logging type */
152 if (button == ctrl->radio.nbuttons) {
154 cfg->logtype=LGTYP_NONE;
156 dlg_radiobutton_set(ctrl, dlg, button);
157 } else if (event == EVENT_VALCHANGE) {
158 button = dlg_radiobutton_get(ctrl, dlg);
159 assert(button >= 0 && button < ctrl->radio.nbuttons);
160 cfg->logtype = ctrl->radio.buttondata[button].i;
164 static void numeric_keypad_handler(union control *ctrl, void *dlg,
165 void *data, int event)
168 Config *cfg = (Config *)data;
170 * This function works much like the standard radio button
171 * handler, but it has to handle two fields in Config.
173 if (event == EVENT_REFRESH) {
174 if (cfg->nethack_keypad)
176 else if (cfg->app_keypad)
180 assert(button < ctrl->radio.nbuttons);
181 dlg_radiobutton_set(ctrl, dlg, button);
182 } else if (event == EVENT_VALCHANGE) {
183 button = dlg_radiobutton_get(ctrl, dlg);
184 assert(button >= 0 && button < ctrl->radio.nbuttons);
186 cfg->app_keypad = FALSE;
187 cfg->nethack_keypad = TRUE;
189 cfg->app_keypad = (button != 0);
190 cfg->nethack_keypad = FALSE;
195 static void cipherlist_handler(union control *ctrl, void *dlg,
196 void *data, int event)
198 Config *cfg = (Config *)data;
199 if (event == EVENT_REFRESH) {
202 static const struct { char *s; int c; } ciphers[] = {
203 { "3DES", CIPHER_3DES },
204 { "Blowfish", CIPHER_BLOWFISH },
205 { "DES", CIPHER_DES },
206 { "AES (SSH-2 only)", CIPHER_AES },
207 { "Arcfour (SSH-2 only)", CIPHER_ARCFOUR },
208 { "-- warn below here --", CIPHER_WARN }
211 /* Set up the "selected ciphers" box. */
212 /* (cipherlist assumed to contain all ciphers) */
213 dlg_update_start(ctrl, dlg);
214 dlg_listbox_clear(ctrl, dlg);
215 for (i = 0; i < CIPHER_MAX; i++) {
216 int c = cfg->ssh_cipherlist[i];
219 for (j = 0; j < (sizeof ciphers) / (sizeof ciphers[0]); j++) {
220 if (ciphers[j].c == c) {
225 dlg_listbox_addwithid(ctrl, dlg, cstr, c);
227 dlg_update_done(ctrl, dlg);
229 } else if (event == EVENT_VALCHANGE) {
232 /* Update array to match the list box. */
233 for (i=0; i < CIPHER_MAX; i++)
234 cfg->ssh_cipherlist[i] = dlg_listbox_getid(ctrl, dlg, i);
240 static void gsslist_handler(union control *ctrl, void *dlg,
241 void *data, int event)
243 Config *cfg = (Config *)data;
244 if (event == EVENT_REFRESH) {
247 dlg_update_start(ctrl, dlg);
248 dlg_listbox_clear(ctrl, dlg);
249 for (i = 0; i < ngsslibs; i++) {
250 int id = cfg->ssh_gsslist[i];
251 assert(id >= 0 && id < ngsslibs);
252 dlg_listbox_addwithid(ctrl, dlg, gsslibnames[id], id);
254 dlg_update_done(ctrl, dlg);
256 } else if (event == EVENT_VALCHANGE) {
259 /* Update array to match the list box. */
260 for (i=0; i < ngsslibs; i++)
261 cfg->ssh_gsslist[i] = dlg_listbox_getid(ctrl, dlg, i);
266 static void kexlist_handler(union control *ctrl, void *dlg,
267 void *data, int event)
269 Config *cfg = (Config *)data;
270 if (event == EVENT_REFRESH) {
273 static const struct { char *s; int k; } kexes[] = {
274 { "Diffie-Hellman group 1", KEX_DHGROUP1 },
275 { "Diffie-Hellman group 14", KEX_DHGROUP14 },
276 { "Diffie-Hellman group exchange", KEX_DHGEX },
277 { "RSA-based key exchange", KEX_RSA },
278 { "-- warn below here --", KEX_WARN }
281 /* Set up the "kex preference" box. */
282 /* (kexlist assumed to contain all algorithms) */
283 dlg_update_start(ctrl, dlg);
284 dlg_listbox_clear(ctrl, dlg);
285 for (i = 0; i < KEX_MAX; i++) {
286 int k = cfg->ssh_kexlist[i];
289 for (j = 0; j < (sizeof kexes) / (sizeof kexes[0]); j++) {
290 if (kexes[j].k == k) {
295 dlg_listbox_addwithid(ctrl, dlg, kstr, k);
297 dlg_update_done(ctrl, dlg);
299 } else if (event == EVENT_VALCHANGE) {
302 /* Update array to match the list box. */
303 for (i=0; i < KEX_MAX; i++)
304 cfg->ssh_kexlist[i] = dlg_listbox_getid(ctrl, dlg, i);
309 static void printerbox_handler(union control *ctrl, void *dlg,
310 void *data, int event)
312 Config *cfg = (Config *)data;
313 if (event == EVENT_REFRESH) {
317 dlg_update_start(ctrl, dlg);
319 * Some backends may wish to disable the drop-down list on
320 * this edit box. Be prepared for this.
322 if (ctrl->editbox.has_list) {
323 dlg_listbox_clear(ctrl, dlg);
324 dlg_listbox_add(ctrl, dlg, PRINTER_DISABLED_STRING);
325 pe = printer_start_enum(&nprinters);
326 for (i = 0; i < nprinters; i++)
327 dlg_listbox_add(ctrl, dlg, printer_get_name(pe, i));
328 printer_finish_enum(pe);
330 dlg_editbox_set(ctrl, dlg,
331 (*cfg->printer ? cfg->printer :
332 PRINTER_DISABLED_STRING));
333 dlg_update_done(ctrl, dlg);
334 } else if (event == EVENT_VALCHANGE) {
335 dlg_editbox_get(ctrl, dlg, cfg->printer, sizeof(cfg->printer));
336 if (!strcmp(cfg->printer, PRINTER_DISABLED_STRING))
337 *cfg->printer = '\0';
341 static void codepage_handler(union control *ctrl, void *dlg,
342 void *data, int event)
344 Config *cfg = (Config *)data;
345 if (event == EVENT_REFRESH) {
347 const char *cp, *thiscp;
348 dlg_update_start(ctrl, dlg);
349 thiscp = cp_name(decode_codepage(cfg->line_codepage));
350 dlg_listbox_clear(ctrl, dlg);
351 for (i = 0; (cp = cp_enumerate(i)) != NULL; i++)
352 dlg_listbox_add(ctrl, dlg, cp);
353 dlg_editbox_set(ctrl, dlg, thiscp);
354 strcpy(cfg->line_codepage, thiscp);
355 dlg_update_done(ctrl, dlg);
356 } else if (event == EVENT_VALCHANGE) {
357 dlg_editbox_get(ctrl, dlg, cfg->line_codepage,
358 sizeof(cfg->line_codepage));
359 strcpy(cfg->line_codepage,
360 cp_name(decode_codepage(cfg->line_codepage)));
364 static void sshbug_handler(union control *ctrl, void *dlg,
365 void *data, int event)
367 if (event == EVENT_REFRESH) {
368 dlg_update_start(ctrl, dlg);
369 dlg_listbox_clear(ctrl, dlg);
370 dlg_listbox_addwithid(ctrl, dlg, "Auto", AUTO);
371 dlg_listbox_addwithid(ctrl, dlg, "Off", FORCE_OFF);
372 dlg_listbox_addwithid(ctrl, dlg, "On", FORCE_ON);
373 switch (*(int *)ATOFFSET(data, ctrl->listbox.context.i)) {
374 case AUTO: dlg_listbox_select(ctrl, dlg, 0); break;
375 case FORCE_OFF: dlg_listbox_select(ctrl, dlg, 1); break;
376 case FORCE_ON: dlg_listbox_select(ctrl, dlg, 2); break;
378 dlg_update_done(ctrl, dlg);
379 } else if (event == EVENT_SELCHANGE) {
380 int i = dlg_listbox_index(ctrl, dlg);
384 i = dlg_listbox_getid(ctrl, dlg, i);
385 *(int *)ATOFFSET(data, ctrl->listbox.context.i) = i;
389 #define SAVEDSESSION_LEN 2048
391 struct sessionsaver_data {
392 union control *editbox, *listbox, *loadbutton, *savebutton, *delbutton;
393 union control *okbutton, *cancelbutton;
394 struct sesslist sesslist;
399 * Helper function to load the session selected in the list box, if
400 * any, as this is done in more than one place below. Returns 0 for
403 static int load_selected_session(struct sessionsaver_data *ssd,
405 void *dlg, Config *cfg, int *maybe_launch)
407 int i = dlg_listbox_index(ssd->listbox, dlg);
413 isdef = !strcmp(ssd->sesslist.sessions[i], "Default Settings");
414 load_settings(ssd->sesslist.sessions[i], cfg);
416 strncpy(savedsession, ssd->sesslist.sessions[i],
418 savedsession[SAVEDSESSION_LEN-1] = '\0';
420 *maybe_launch = TRUE;
422 savedsession[0] = '\0';
424 *maybe_launch = FALSE;
426 dlg_refresh(NULL, dlg);
427 /* Restore the selection, which might have been clobbered by
428 * changing the value of the edit box. */
429 dlg_listbox_select(ssd->listbox, dlg, i);
433 static void sessionsaver_handler(union control *ctrl, void *dlg,
434 void *data, int event)
436 Config *cfg = (Config *)data;
437 struct sessionsaver_data *ssd =
438 (struct sessionsaver_data *)ctrl->generic.context.p;
442 * The first time we're called in a new dialog, we must
443 * allocate space to store the current contents of the saved
444 * session edit box (since it must persist even when we switch
445 * panels, but is not part of the Config).
449 } else if (!dlg_get_privdata(ssd->editbox, dlg)) {
450 savedsession = (char *)
451 dlg_alloc_privdata(ssd->editbox, dlg, SAVEDSESSION_LEN);
452 savedsession[0] = '\0';
454 savedsession = dlg_get_privdata(ssd->editbox, dlg);
457 if (event == EVENT_REFRESH) {
458 if (ctrl == ssd->editbox) {
459 dlg_editbox_set(ctrl, dlg, savedsession);
460 } else if (ctrl == ssd->listbox) {
462 dlg_update_start(ctrl, dlg);
463 dlg_listbox_clear(ctrl, dlg);
464 for (i = 0; i < ssd->sesslist.nsessions; i++)
465 dlg_listbox_add(ctrl, dlg, ssd->sesslist.sessions[i]);
466 dlg_update_done(ctrl, dlg);
468 } else if (event == EVENT_VALCHANGE) {
469 int top, bottom, halfway, i;
470 if (ctrl == ssd->editbox) {
471 dlg_editbox_get(ctrl, dlg, savedsession,
473 top = ssd->sesslist.nsessions;
475 while (top-bottom > 1) {
476 halfway = (top+bottom)/2;
477 i = strcmp(savedsession, ssd->sesslist.sessions[halfway]);
484 if (top == ssd->sesslist.nsessions) {
487 dlg_listbox_select(ssd->listbox, dlg, top);
489 } else if (event == EVENT_ACTION) {
491 if (!ssd->midsession &&
492 (ctrl == ssd->listbox ||
493 (ssd->loadbutton && ctrl == ssd->loadbutton))) {
495 * The user has double-clicked a session, or hit Load.
496 * We must load the selected session, and then
497 * terminate the configuration dialog _if_ there was a
498 * double-click on the list box _and_ that session
499 * contains a hostname.
501 if (load_selected_session(ssd, savedsession, dlg, cfg, &mbl) &&
502 (mbl && ctrl == ssd->listbox && cfg_launchable(cfg))) {
503 dlg_end(dlg, 1); /* it's all over, and succeeded */
505 } else if (ctrl == ssd->savebutton) {
506 int isdef = !strcmp(savedsession, "Default Settings");
507 if (!savedsession[0]) {
508 int i = dlg_listbox_index(ssd->listbox, dlg);
513 isdef = !strcmp(ssd->sesslist.sessions[i], "Default Settings");
515 strncpy(savedsession, ssd->sesslist.sessions[i],
517 savedsession[SAVEDSESSION_LEN-1] = '\0';
519 savedsession[0] = '\0';
523 char *errmsg = save_settings(savedsession, cfg);
525 dlg_error_msg(dlg, errmsg);
529 get_sesslist(&ssd->sesslist, FALSE);
530 get_sesslist(&ssd->sesslist, TRUE);
531 dlg_refresh(ssd->editbox, dlg);
532 dlg_refresh(ssd->listbox, dlg);
533 } else if (!ssd->midsession &&
534 ssd->delbutton && ctrl == ssd->delbutton) {
535 int i = dlg_listbox_index(ssd->listbox, dlg);
539 del_settings(ssd->sesslist.sessions[i]);
540 get_sesslist(&ssd->sesslist, FALSE);
541 get_sesslist(&ssd->sesslist, TRUE);
542 dlg_refresh(ssd->listbox, dlg);
544 } else if (ctrl == ssd->okbutton) {
545 if (ssd->midsession) {
546 /* In a mid-session Change Settings, Apply is always OK. */
551 * Annoying special case. If the `Open' button is
552 * pressed while no host name is currently set, _and_
553 * the session list previously had the focus, _and_
554 * there was a session selected in that which had a
555 * valid host name in it, then load it and go.
557 if (dlg_last_focused(ctrl, dlg) == ssd->listbox &&
558 !cfg_launchable(cfg)) {
561 if (!load_selected_session(ssd, savedsession, dlg,
566 /* If at this point we have a valid session, go! */
567 if (mbl && cfg_launchable(&cfg2)) {
568 *cfg = cfg2; /* structure copy */
569 cfg->remote_cmd_ptr = NULL;
577 * Otherwise, do the normal thing: if we have a valid
578 * session, get going.
580 if (cfg_launchable(cfg)) {
584 } else if (ctrl == ssd->cancelbutton) {
590 struct charclass_data {
591 union control *listbox, *editbox, *button;
594 static void charclass_handler(union control *ctrl, void *dlg,
595 void *data, int event)
597 Config *cfg = (Config *)data;
598 struct charclass_data *ccd =
599 (struct charclass_data *)ctrl->generic.context.p;
601 if (event == EVENT_REFRESH) {
602 if (ctrl == ccd->listbox) {
604 dlg_update_start(ctrl, dlg);
605 dlg_listbox_clear(ctrl, dlg);
606 for (i = 0; i < 128; i++) {
608 sprintf(str, "%d\t(0x%02X)\t%c\t%d", i, i,
609 (i >= 0x21 && i != 0x7F) ? i : ' ', cfg->wordness[i]);
610 dlg_listbox_add(ctrl, dlg, str);
612 dlg_update_done(ctrl, dlg);
614 } else if (event == EVENT_ACTION) {
615 if (ctrl == ccd->button) {
618 dlg_editbox_get(ccd->editbox, dlg, str, sizeof(str));
620 for (i = 0; i < 128; i++) {
621 if (dlg_listbox_issel(ccd->listbox, dlg, i))
622 cfg->wordness[i] = n;
624 dlg_refresh(ccd->listbox, dlg);
630 union control *listbox, *redit, *gedit, *bedit, *button;
633 static const char *const colours[] = {
634 "Default Foreground", "Default Bold Foreground",
635 "Default Background", "Default Bold Background",
636 "Cursor Text", "Cursor Colour",
637 "ANSI Black", "ANSI Black Bold",
638 "ANSI Red", "ANSI Red Bold",
639 "ANSI Green", "ANSI Green Bold",
640 "ANSI Yellow", "ANSI Yellow Bold",
641 "ANSI Blue", "ANSI Blue Bold",
642 "ANSI Magenta", "ANSI Magenta Bold",
643 "ANSI Cyan", "ANSI Cyan Bold",
644 "ANSI White", "ANSI White Bold"
647 static void colour_handler(union control *ctrl, void *dlg,
648 void *data, int event)
650 Config *cfg = (Config *)data;
651 struct colour_data *cd =
652 (struct colour_data *)ctrl->generic.context.p;
653 int update = FALSE, clear = FALSE, r, g, b;
655 if (event == EVENT_REFRESH) {
656 if (ctrl == cd->listbox) {
658 dlg_update_start(ctrl, dlg);
659 dlg_listbox_clear(ctrl, dlg);
660 for (i = 0; i < lenof(colours); i++)
661 dlg_listbox_add(ctrl, dlg, colours[i]);
662 dlg_update_done(ctrl, dlg);
666 } else if (event == EVENT_SELCHANGE) {
667 if (ctrl == cd->listbox) {
668 /* The user has selected a colour. Update the RGB text. */
669 int i = dlg_listbox_index(ctrl, dlg);
674 r = cfg->colours[i][0];
675 g = cfg->colours[i][1];
676 b = cfg->colours[i][2];
680 } else if (event == EVENT_VALCHANGE) {
681 if (ctrl == cd->redit || ctrl == cd->gedit || ctrl == cd->bedit) {
682 /* The user has changed the colour using the edit boxes. */
686 dlg_editbox_get(ctrl, dlg, buf, lenof(buf));
688 if (cval > 255) cval = 255;
689 if (cval < 0) cval = 0;
691 i = dlg_listbox_index(cd->listbox, dlg);
693 if (ctrl == cd->redit)
694 cfg->colours[i][0] = cval;
695 else if (ctrl == cd->gedit)
696 cfg->colours[i][1] = cval;
697 else if (ctrl == cd->bedit)
698 cfg->colours[i][2] = cval;
701 } else if (event == EVENT_ACTION) {
702 if (ctrl == cd->button) {
703 int i = dlg_listbox_index(cd->listbox, dlg);
709 * Start a colour selector, which will send us an
710 * EVENT_CALLBACK when it's finished and allow us to
711 * pick up the results.
713 dlg_coloursel_start(ctrl, dlg,
718 } else if (event == EVENT_CALLBACK) {
719 if (ctrl == cd->button) {
720 int i = dlg_listbox_index(cd->listbox, dlg);
722 * Collect the results of the colour selector. Will
723 * return nonzero on success, or zero if the colour
724 * selector did nothing (user hit Cancel, for example).
726 if (dlg_coloursel_results(ctrl, dlg, &r, &g, &b)) {
727 cfg->colours[i][0] = r;
728 cfg->colours[i][1] = g;
729 cfg->colours[i][2] = b;
738 dlg_editbox_set(cd->redit, dlg, "");
739 dlg_editbox_set(cd->gedit, dlg, "");
740 dlg_editbox_set(cd->bedit, dlg, "");
743 sprintf(buf, "%d", r); dlg_editbox_set(cd->redit, dlg, buf);
744 sprintf(buf, "%d", g); dlg_editbox_set(cd->gedit, dlg, buf);
745 sprintf(buf, "%d", b); dlg_editbox_set(cd->bedit, dlg, buf);
750 struct ttymodes_data {
751 union control *modelist, *valradio, *valbox;
752 union control *addbutton, *rembutton, *listbox;
755 static void ttymodes_handler(union control *ctrl, void *dlg,
756 void *data, int event)
758 Config *cfg = (Config *)data;
759 struct ttymodes_data *td =
760 (struct ttymodes_data *)ctrl->generic.context.p;
762 if (event == EVENT_REFRESH) {
763 if (ctrl == td->listbox) {
764 char *p = cfg->ttymodes;
765 dlg_update_start(ctrl, dlg);
766 dlg_listbox_clear(ctrl, dlg);
768 int tabpos = strchr(p, '\t') - p;
769 char *disp = dupprintf("%.*s\t%s", tabpos, p,
770 (p[tabpos+1] == 'A') ? "(auto)" :
772 dlg_listbox_add(ctrl, dlg, disp);
776 dlg_update_done(ctrl, dlg);
777 } else if (ctrl == td->modelist) {
779 dlg_update_start(ctrl, dlg);
780 dlg_listbox_clear(ctrl, dlg);
781 for (i = 0; ttymodes[i]; i++)
782 dlg_listbox_add(ctrl, dlg, ttymodes[i]);
783 dlg_listbox_select(ctrl, dlg, 0); /* *shrug* */
784 dlg_update_done(ctrl, dlg);
785 } else if (ctrl == td->valradio) {
786 dlg_radiobutton_set(ctrl, dlg, 0);
788 } else if (event == EVENT_ACTION) {
789 if (ctrl == td->addbutton) {
790 int ind = dlg_listbox_index(td->modelist, dlg);
792 char type = dlg_radiobutton_get(td->valradio, dlg) ? 'V' : 'A';
794 char *p, str[lenof(cfg->ttymodes)];
795 /* Construct new entry */
796 memset(str, 0, lenof(str));
797 strncpy(str, ttymodes[ind], lenof(str)-3);
803 dlg_editbox_get(td->valbox, dlg, str+slen, lenof(str)-slen);
805 /* Find end of list, deleting any existing instance */
807 left = lenof(cfg->ttymodes);
809 int t = strchr(p, '\t') - p;
810 if (t == strlen(ttymodes[ind]) &&
811 strncmp(p, ttymodes[ind], t) == 0) {
812 memmove(p, p+strlen(p)+1, left - (strlen(p)+1));
815 left -= strlen(p) + 1;
818 /* Append new entry */
820 strncpy(p, str, left - 2);
821 dlg_refresh(td->listbox, dlg);
824 } else if (ctrl == td->rembutton) {
825 char *p = cfg->ttymodes;
826 int i = 0, len = lenof(cfg->ttymodes);
828 int multisel = dlg_listbox_index(td->listbox, dlg) < 0;
829 if (dlg_listbox_issel(td->listbox, dlg, i)) {
831 /* Populate controls with entry we're about to
832 * delete, for ease of editing.
833 * (If multiple entries were selected, don't
834 * touch the controls.) */
835 char *val = strchr(p, '\t');
839 while (ttymodes[ind]) {
840 if (strlen(ttymodes[ind]) == val-p-1 &&
841 !strncmp(ttymodes[ind], p, val-p-1))
845 dlg_listbox_select(td->modelist, dlg, ind);
846 dlg_radiobutton_set(td->valradio, dlg,
848 dlg_editbox_set(td->valbox, dlg, val+1);
851 memmove(p, p+strlen(p)+1, len - (strlen(p)+1));
855 len -= strlen(p) + 1;
859 memset(p, 0, lenof(cfg->ttymodes) - len);
860 dlg_refresh(td->listbox, dlg);
865 struct environ_data {
866 union control *varbox, *valbox, *addbutton, *rembutton, *listbox;
869 static void environ_handler(union control *ctrl, void *dlg,
870 void *data, int event)
872 Config *cfg = (Config *)data;
873 struct environ_data *ed =
874 (struct environ_data *)ctrl->generic.context.p;
876 if (event == EVENT_REFRESH) {
877 if (ctrl == ed->listbox) {
878 char *p = cfg->environmt;
879 dlg_update_start(ctrl, dlg);
880 dlg_listbox_clear(ctrl, dlg);
882 dlg_listbox_add(ctrl, dlg, p);
885 dlg_update_done(ctrl, dlg);
887 } else if (event == EVENT_ACTION) {
888 if (ctrl == ed->addbutton) {
889 char str[sizeof(cfg->environmt)];
891 dlg_editbox_get(ed->varbox, dlg, str, sizeof(str)-1);
896 p = str + strlen(str);
898 dlg_editbox_get(ed->valbox, dlg, p, sizeof(str)-1 - (p - str));
909 if ((p - cfg->environmt) + strlen(str) + 2 <
910 sizeof(cfg->environmt)) {
912 p[strlen(str) + 1] = '\0';
913 dlg_listbox_add(ed->listbox, dlg, str);
914 dlg_editbox_set(ed->varbox, dlg, "");
915 dlg_editbox_set(ed->valbox, dlg, "");
917 dlg_error_msg(dlg, "Environment too big");
919 } else if (ctrl == ed->rembutton) {
920 int i = dlg_listbox_index(ed->listbox, dlg);
926 dlg_listbox_del(ed->listbox, dlg, i);
939 /* Populate controls with the entry we're about to delete
940 * for ease of editing */
946 dlg_editbox_set(ed->varbox, dlg, str);
949 dlg_editbox_set(ed->valbox, dlg, str);
966 struct portfwd_data {
967 union control *addbutton, *rembutton, *listbox;
968 union control *sourcebox, *destbox, *direction;
970 union control *addressfamily;
974 static void portfwd_handler(union control *ctrl, void *dlg,
975 void *data, int event)
977 Config *cfg = (Config *)data;
978 struct portfwd_data *pfd =
979 (struct portfwd_data *)ctrl->generic.context.p;
981 if (event == EVENT_REFRESH) {
982 if (ctrl == pfd->listbox) {
983 char *p = cfg->portfwd;
984 dlg_update_start(ctrl, dlg);
985 dlg_listbox_clear(ctrl, dlg);
987 dlg_listbox_add(ctrl, dlg, p);
990 dlg_update_done(ctrl, dlg);
991 } else if (ctrl == pfd->direction) {
995 dlg_radiobutton_set(ctrl, dlg, 0);
997 } else if (ctrl == pfd->addressfamily) {
998 dlg_radiobutton_set(ctrl, dlg, 0);
1001 } else if (event == EVENT_ACTION) {
1002 if (ctrl == pfd->addbutton) {
1003 char str[sizeof(cfg->portfwd)];
1010 whichbutton = dlg_radiobutton_get(pfd->addressfamily, dlg);
1011 if (whichbutton == 1)
1013 else if (whichbutton == 2)
1017 whichbutton = dlg_radiobutton_get(pfd->direction, dlg);
1018 if (whichbutton == 0)
1020 else if (whichbutton == 1)
1026 dlg_editbox_get(pfd->sourcebox, dlg, str+i, sizeof(str) - i);
1028 dlg_error_msg(dlg, "You need to specify a source port number");
1031 p = str + strlen(str);
1034 dlg_editbox_get(pfd->destbox, dlg, p,
1035 sizeof(str) - (p - str));
1036 if (!*p || !strchr(p, ':')) {
1038 "You need to specify a destination address\n"
1039 "in the form \"host.name:port\"");
1046 if (strcmp(p,str) == 0) {
1047 dlg_error_msg(dlg, "Specified forwarding already exists");
1055 if ((p - cfg->portfwd) + strlen(str) + 2 <=
1056 sizeof(cfg->portfwd)) {
1058 p[strlen(str) + 1] = '\0';
1059 dlg_listbox_add(pfd->listbox, dlg, str);
1060 dlg_editbox_set(pfd->sourcebox, dlg, "");
1061 dlg_editbox_set(pfd->destbox, dlg, "");
1063 dlg_error_msg(dlg, "Too many forwardings");
1066 } else if (ctrl == pfd->rembutton) {
1067 int i = dlg_listbox_index(pfd->listbox, dlg);
1071 char *p, *q, *src, *dst;
1074 dlg_listbox_del(pfd->listbox, dlg, i);
1087 /* Populate the controls with the entry we're about to
1088 * delete, for ease of editing. */
1090 static const char *const afs = "A46";
1091 char *afp = strchr(afs, *p);
1093 int idx = afp ? afp-afs : 0;
1098 dlg_radiobutton_set(pfd->addressfamily, dlg, idx);
1102 static const char *const dirs = "LRD";
1104 dlg_radiobutton_set(pfd->direction, dlg,
1105 strchr(dirs, dir) - dirs);
1110 p = strchr(p, '\t');
1120 p = strchr(p, '\0');
1123 dlg_editbox_set(pfd->sourcebox, dlg, src);
1124 dlg_editbox_set(pfd->destbox, dlg, dst);
1138 void setup_config_box(struct controlbox *b, int midsession,
1139 int protocol, int protcfginfo)
1141 struct controlset *s;
1142 struct sessionsaver_data *ssd;
1143 struct charclass_data *ccd;
1144 struct colour_data *cd;
1145 struct ttymodes_data *td;
1146 struct environ_data *ed;
1147 struct portfwd_data *pfd;
1151 ssd = (struct sessionsaver_data *)
1152 ctrl_alloc(b, sizeof(struct sessionsaver_data));
1153 memset(ssd, 0, sizeof(*ssd));
1154 ssd->midsession = midsession;
1157 * The standard panel that appears at the bottom of all panels:
1158 * Open, Cancel, Apply etc.
1160 s = ctrl_getset(b, "", "", "");
1161 ctrl_columns(s, 5, 20, 20, 20, 20, 20);
1162 ssd->okbutton = ctrl_pushbutton(s,
1163 (midsession ? "Apply" : "Open"),
1164 (char)(midsession ? 'a' : 'o'),
1166 sessionsaver_handler, P(ssd));
1167 ssd->okbutton->button.isdefault = TRUE;
1168 ssd->okbutton->generic.column = 3;
1169 ssd->cancelbutton = ctrl_pushbutton(s, "Cancel", 'c', HELPCTX(no_help),
1170 sessionsaver_handler, P(ssd));
1171 ssd->cancelbutton->button.iscancel = TRUE;
1172 ssd->cancelbutton->generic.column = 4;
1173 /* We carefully don't close the 5-column part, so that platform-
1174 * specific add-ons can put extra buttons alongside Open and Cancel. */
1177 * The Session panel.
1179 str = dupprintf("Basic options for your %s session", appname);
1180 ctrl_settitle(b, "Session", str);
1184 struct hostport *hp = (struct hostport *)
1185 ctrl_alloc(b, sizeof(struct hostport));
1187 s = ctrl_getset(b, "Session", "hostport",
1188 "Specify the destination you want to connect to");
1189 ctrl_columns(s, 2, 75, 25);
1190 c = ctrl_editbox(s, HOST_BOX_TITLE, 'n', 100,
1191 HELPCTX(session_hostname),
1192 config_host_handler, I(0), I(0));
1193 c->generic.column = 0;
1195 c = ctrl_editbox(s, PORT_BOX_TITLE, 'p', 100,
1196 HELPCTX(session_hostname),
1197 config_port_handler, I(0), I(0));
1198 c->generic.column = 1;
1200 ctrl_columns(s, 1, 100);
1202 if (!backend_from_proto(PROT_SSH)) {
1203 ctrl_radiobuttons(s, "Connection type:", NO_SHORTCUT, 3,
1204 HELPCTX(session_hostname),
1205 config_protocolbuttons_handler, P(hp),
1206 "Raw", 'w', I(PROT_RAW),
1207 "Telnet", 't', I(PROT_TELNET),
1208 "Rlogin", 'i', I(PROT_RLOGIN),
1211 ctrl_radiobuttons(s, "Connection type:", NO_SHORTCUT, 4,
1212 HELPCTX(session_hostname),
1213 config_protocolbuttons_handler, P(hp),
1214 "Raw", 'w', I(PROT_RAW),
1215 "Telnet", 't', I(PROT_TELNET),
1216 "Rlogin", 'i', I(PROT_RLOGIN),
1217 "SSH", 's', I(PROT_SSH),
1223 * The Load/Save panel is available even in mid-session.
1225 s = ctrl_getset(b, "Session", "savedsessions",
1226 midsession ? "Save the current session settings" :
1227 "Load, save or delete a stored session");
1228 ctrl_columns(s, 2, 75, 25);
1229 get_sesslist(&ssd->sesslist, TRUE);
1230 ssd->editbox = ctrl_editbox(s, "Saved Sessions", 'e', 100,
1231 HELPCTX(session_saved),
1232 sessionsaver_handler, P(ssd), P(NULL));
1233 ssd->editbox->generic.column = 0;
1234 /* Reset columns so that the buttons are alongside the list, rather
1235 * than alongside that edit box. */
1236 ctrl_columns(s, 1, 100);
1237 ctrl_columns(s, 2, 75, 25);
1238 ssd->listbox = ctrl_listbox(s, NULL, NO_SHORTCUT,
1239 HELPCTX(session_saved),
1240 sessionsaver_handler, P(ssd));
1241 ssd->listbox->generic.column = 0;
1242 ssd->listbox->listbox.height = 7;
1244 ssd->loadbutton = ctrl_pushbutton(s, "Load", 'l',
1245 HELPCTX(session_saved),
1246 sessionsaver_handler, P(ssd));
1247 ssd->loadbutton->generic.column = 1;
1249 /* We can't offer the Load button mid-session, as it would allow the
1250 * user to load and subsequently save settings they can't see. (And
1251 * also change otherwise immutable settings underfoot; that probably
1252 * shouldn't be a problem, but.) */
1253 ssd->loadbutton = NULL;
1255 /* "Save" button is permitted mid-session. */
1256 ssd->savebutton = ctrl_pushbutton(s, "Save", 'v',
1257 HELPCTX(session_saved),
1258 sessionsaver_handler, P(ssd));
1259 ssd->savebutton->generic.column = 1;
1261 ssd->delbutton = ctrl_pushbutton(s, "Delete", 'd',
1262 HELPCTX(session_saved),
1263 sessionsaver_handler, P(ssd));
1264 ssd->delbutton->generic.column = 1;
1266 /* Disable the Delete button mid-session too, for UI consistency. */
1267 ssd->delbutton = NULL;
1269 ctrl_columns(s, 1, 100);
1271 s = ctrl_getset(b, "Session", "otheropts", NULL);
1272 c = ctrl_radiobuttons(s, "Close window on exit:", 'x', 4,
1273 HELPCTX(session_coe),
1274 dlg_stdradiobutton_handler,
1275 I(offsetof(Config, close_on_exit)),
1276 "Always", I(FORCE_ON),
1277 "Never", I(FORCE_OFF),
1278 "Only on clean exit", I(AUTO), NULL);
1281 * The Session/Logging panel.
1283 ctrl_settitle(b, "Session/Logging", "Options controlling session logging");
1285 s = ctrl_getset(b, "Session/Logging", "main", NULL);
1287 * The logging buttons change depending on whether SSH packet
1288 * logging can sensibly be available.
1291 char *sshlogname, *sshrawlogname;
1292 if ((midsession && protocol == PROT_SSH) ||
1293 (!midsession && backend_from_proto(PROT_SSH))) {
1294 sshlogname = "SSH packets";
1295 sshrawlogname = "SSH packets and raw data";
1297 sshlogname = NULL; /* this will disable both buttons */
1298 sshrawlogname = NULL; /* this will just placate optimisers */
1300 ctrl_radiobuttons(s, "Session logging:", NO_SHORTCUT, 2,
1301 HELPCTX(logging_main),
1302 loggingbuttons_handler,
1303 I(offsetof(Config, logtype)),
1304 "None", 't', I(LGTYP_NONE),
1305 "Printable output", 'p', I(LGTYP_ASCII),
1306 "All session output", 'l', I(LGTYP_DEBUG),
1307 sshlogname, 's', I(LGTYP_PACKETS),
1308 sshrawlogname, 'r', I(LGTYP_SSHRAW),
1311 ctrl_filesel(s, "Log file name:", 'f',
1312 NULL, TRUE, "Select session log file name",
1313 HELPCTX(logging_filename),
1314 dlg_stdfilesel_handler, I(offsetof(Config, logfilename)));
1315 ctrl_text(s, "(Log file name can contain &Y, &M, &D for date,"
1316 " &T for time, and &H for host name)",
1317 HELPCTX(logging_filename));
1318 ctrl_radiobuttons(s, "What to do if the log file already exists:", 'e', 1,
1319 HELPCTX(logging_exists),
1320 dlg_stdradiobutton_handler, I(offsetof(Config,logxfovr)),
1321 "Always overwrite it", I(LGXF_OVR),
1322 "Always append to the end of it", I(LGXF_APN),
1323 "Ask the user every time", I(LGXF_ASK), NULL);
1324 ctrl_checkbox(s, "Flush log file frequently", 'u',
1325 HELPCTX(logging_flush),
1326 dlg_stdcheckbox_handler, I(offsetof(Config,logflush)));
1328 if ((midsession && protocol == PROT_SSH) ||
1329 (!midsession && backend_from_proto(PROT_SSH))) {
1330 s = ctrl_getset(b, "Session/Logging", "ssh",
1331 "Options specific to SSH packet logging");
1332 ctrl_checkbox(s, "Omit known password fields", 'k',
1333 HELPCTX(logging_ssh_omit_password),
1334 dlg_stdcheckbox_handler, I(offsetof(Config,logomitpass)));
1335 ctrl_checkbox(s, "Omit session data", 'd',
1336 HELPCTX(logging_ssh_omit_data),
1337 dlg_stdcheckbox_handler, I(offsetof(Config,logomitdata)));
1341 * The Terminal panel.
1343 ctrl_settitle(b, "Terminal", "Options controlling the terminal emulation");
1345 s = ctrl_getset(b, "Terminal", "general", "Set various terminal options");
1346 ctrl_checkbox(s, "Auto wrap mode initially on", 'w',
1347 HELPCTX(terminal_autowrap),
1348 dlg_stdcheckbox_handler, I(offsetof(Config,wrap_mode)));
1349 ctrl_checkbox(s, "DEC Origin Mode initially on", 'd',
1350 HELPCTX(terminal_decom),
1351 dlg_stdcheckbox_handler, I(offsetof(Config,dec_om)));
1352 ctrl_checkbox(s, "Implicit CR in every LF", 'r',
1353 HELPCTX(terminal_lfhascr),
1354 dlg_stdcheckbox_handler, I(offsetof(Config,lfhascr)));
1355 ctrl_checkbox(s, "Implicit LF in every CR", 'f',
1356 HELPCTX(terminal_crhaslf),
1357 dlg_stdcheckbox_handler, I(offsetof(Config,crhaslf)));
1358 ctrl_checkbox(s, "Use background colour to erase screen", 'e',
1359 HELPCTX(terminal_bce),
1360 dlg_stdcheckbox_handler, I(offsetof(Config,bce)));
1361 ctrl_checkbox(s, "Enable blinking text", 'n',
1362 HELPCTX(terminal_blink),
1363 dlg_stdcheckbox_handler, I(offsetof(Config,blinktext)));
1364 ctrl_editbox(s, "Answerback to ^E:", 's', 100,
1365 HELPCTX(terminal_answerback),
1366 dlg_stdeditbox_handler, I(offsetof(Config,answerback)),
1367 I(sizeof(((Config *)0)->answerback)));
1369 s = ctrl_getset(b, "Terminal", "ldisc", "Line discipline options");
1370 ctrl_radiobuttons(s, "Local echo:", 'l', 3,
1371 HELPCTX(terminal_localecho),
1372 dlg_stdradiobutton_handler,I(offsetof(Config,localecho)),
1374 "Force on", I(FORCE_ON),
1375 "Force off", I(FORCE_OFF), NULL);
1376 ctrl_radiobuttons(s, "Local line editing:", 't', 3,
1377 HELPCTX(terminal_localedit),
1378 dlg_stdradiobutton_handler,I(offsetof(Config,localedit)),
1380 "Force on", I(FORCE_ON),
1381 "Force off", I(FORCE_OFF), NULL);
1383 s = ctrl_getset(b, "Terminal", "printing", "Remote-controlled printing");
1384 ctrl_combobox(s, "Printer to send ANSI printer output to:", 'p', 100,
1385 HELPCTX(terminal_printing),
1386 printerbox_handler, P(NULL), P(NULL));
1389 * The Terminal/Keyboard panel.
1391 ctrl_settitle(b, "Terminal/Keyboard",
1392 "Options controlling the effects of keys");
1394 s = ctrl_getset(b, "Terminal/Keyboard", "mappings",
1395 "Change the sequences sent by:");
1396 ctrl_radiobuttons(s, "The Backspace key", 'b', 2,
1397 HELPCTX(keyboard_backspace),
1398 dlg_stdradiobutton_handler,
1399 I(offsetof(Config, bksp_is_delete)),
1400 "Control-H", I(0), "Control-? (127)", I(1), NULL);
1401 ctrl_radiobuttons(s, "The Home and End keys", 'e', 2,
1402 HELPCTX(keyboard_homeend),
1403 dlg_stdradiobutton_handler,
1404 I(offsetof(Config, rxvt_homeend)),
1405 "Standard", I(0), "rxvt", I(1), NULL);
1406 ctrl_radiobuttons(s, "The Function keys and keypad", 'f', 3,
1407 HELPCTX(keyboard_funkeys),
1408 dlg_stdradiobutton_handler,
1409 I(offsetof(Config, funky_type)),
1410 "ESC[n~", I(0), "Linux", I(1), "Xterm R6", I(2),
1411 "VT400", I(3), "VT100+", I(4), "SCO", I(5), NULL);
1413 s = ctrl_getset(b, "Terminal/Keyboard", "appkeypad",
1414 "Application keypad settings:");
1415 ctrl_radiobuttons(s, "Initial state of cursor keys:", 'r', 3,
1416 HELPCTX(keyboard_appcursor),
1417 dlg_stdradiobutton_handler,
1418 I(offsetof(Config, app_cursor)),
1419 "Normal", I(0), "Application", I(1), NULL);
1420 ctrl_radiobuttons(s, "Initial state of numeric keypad:", 'n', 3,
1421 HELPCTX(keyboard_appkeypad),
1422 numeric_keypad_handler, P(NULL),
1423 "Normal", I(0), "Application", I(1), "NetHack", I(2),
1427 * The Terminal/Bell panel.
1429 ctrl_settitle(b, "Terminal/Bell",
1430 "Options controlling the terminal bell");
1432 s = ctrl_getset(b, "Terminal/Bell", "style", "Set the style of bell");
1433 ctrl_radiobuttons(s, "Action to happen when a bell occurs:", 'b', 1,
1434 HELPCTX(bell_style),
1435 dlg_stdradiobutton_handler, I(offsetof(Config, beep)),
1436 "None (bell disabled)", I(BELL_DISABLED),
1437 "Make default system alert sound", I(BELL_DEFAULT),
1438 "Visual bell (flash window)", I(BELL_VISUAL), NULL);
1440 s = ctrl_getset(b, "Terminal/Bell", "overload",
1441 "Control the bell overload behaviour");
1442 ctrl_checkbox(s, "Bell is temporarily disabled when over-used", 'd',
1443 HELPCTX(bell_overload),
1444 dlg_stdcheckbox_handler, I(offsetof(Config,bellovl)));
1445 ctrl_editbox(s, "Over-use means this many bells...", 'm', 20,
1446 HELPCTX(bell_overload),
1447 dlg_stdeditbox_handler, I(offsetof(Config,bellovl_n)), I(-1));
1448 ctrl_editbox(s, "... in this many seconds", 't', 20,
1449 HELPCTX(bell_overload),
1450 dlg_stdeditbox_handler, I(offsetof(Config,bellovl_t)),
1452 ctrl_text(s, "The bell is re-enabled after a few seconds of silence.",
1453 HELPCTX(bell_overload));
1454 ctrl_editbox(s, "Seconds of silence required", 's', 20,
1455 HELPCTX(bell_overload),
1456 dlg_stdeditbox_handler, I(offsetof(Config,bellovl_s)),
1460 * The Terminal/Features panel.
1462 ctrl_settitle(b, "Terminal/Features",
1463 "Enabling and disabling advanced terminal features");
1465 s = ctrl_getset(b, "Terminal/Features", "main", NULL);
1466 ctrl_checkbox(s, "Disable application cursor keys mode", 'u',
1467 HELPCTX(features_application),
1468 dlg_stdcheckbox_handler, I(offsetof(Config,no_applic_c)));
1469 ctrl_checkbox(s, "Disable application keypad mode", 'k',
1470 HELPCTX(features_application),
1471 dlg_stdcheckbox_handler, I(offsetof(Config,no_applic_k)));
1472 ctrl_checkbox(s, "Disable xterm-style mouse reporting", 'x',
1473 HELPCTX(features_mouse),
1474 dlg_stdcheckbox_handler, I(offsetof(Config,no_mouse_rep)));
1475 ctrl_checkbox(s, "Disable remote-controlled terminal resizing", 's',
1476 HELPCTX(features_resize),
1477 dlg_stdcheckbox_handler,
1478 I(offsetof(Config,no_remote_resize)));
1479 ctrl_checkbox(s, "Disable switching to alternate terminal screen", 'w',
1480 HELPCTX(features_altscreen),
1481 dlg_stdcheckbox_handler, I(offsetof(Config,no_alt_screen)));
1482 ctrl_checkbox(s, "Disable remote-controlled window title changing", 't',
1483 HELPCTX(features_retitle),
1484 dlg_stdcheckbox_handler,
1485 I(offsetof(Config,no_remote_wintitle)));
1486 ctrl_radiobuttons(s, "Response to remote title query (SECURITY):", 'q', 3,
1487 HELPCTX(features_qtitle),
1488 dlg_stdradiobutton_handler,
1489 I(offsetof(Config,remote_qtitle_action)),
1490 "None", I(TITLE_NONE),
1491 "Empty string", I(TITLE_EMPTY),
1492 "Window title", I(TITLE_REAL), NULL);
1493 ctrl_checkbox(s, "Disable destructive backspace on server sending ^?",'b',
1494 HELPCTX(features_dbackspace),
1495 dlg_stdcheckbox_handler, I(offsetof(Config,no_dbackspace)));
1496 ctrl_checkbox(s, "Disable remote-controlled character set configuration",
1497 'r', HELPCTX(features_charset), dlg_stdcheckbox_handler,
1498 I(offsetof(Config,no_remote_charset)));
1499 ctrl_checkbox(s, "Disable Arabic text shaping",
1500 'l', HELPCTX(features_arabicshaping), dlg_stdcheckbox_handler,
1501 I(offsetof(Config, arabicshaping)));
1502 ctrl_checkbox(s, "Disable bidirectional text display",
1503 'd', HELPCTX(features_bidi), dlg_stdcheckbox_handler,
1504 I(offsetof(Config, bidi)));
1509 str = dupprintf("Options controlling %s's window", appname);
1510 ctrl_settitle(b, "Window", str);
1513 s = ctrl_getset(b, "Window", "size", "Set the size of the window");
1514 ctrl_columns(s, 2, 50, 50);
1515 c = ctrl_editbox(s, "Columns", 'm', 100,
1516 HELPCTX(window_size),
1517 dlg_stdeditbox_handler, I(offsetof(Config,width)), I(-1));
1518 c->generic.column = 0;
1519 c = ctrl_editbox(s, "Rows", 'r', 100,
1520 HELPCTX(window_size),
1521 dlg_stdeditbox_handler, I(offsetof(Config,height)),I(-1));
1522 c->generic.column = 1;
1523 ctrl_columns(s, 1, 100);
1525 s = ctrl_getset(b, "Window", "scrollback",
1526 "Control the scrollback in the window");
1527 ctrl_editbox(s, "Lines of scrollback", 's', 50,
1528 HELPCTX(window_scrollback),
1529 dlg_stdeditbox_handler, I(offsetof(Config,savelines)), I(-1));
1530 ctrl_checkbox(s, "Display scrollbar", 'd',
1531 HELPCTX(window_scrollback),
1532 dlg_stdcheckbox_handler, I(offsetof(Config,scrollbar)));
1533 ctrl_checkbox(s, "Reset scrollback on keypress", 'k',
1534 HELPCTX(window_scrollback),
1535 dlg_stdcheckbox_handler, I(offsetof(Config,scroll_on_key)));
1536 ctrl_checkbox(s, "Reset scrollback on display activity", 'p',
1537 HELPCTX(window_scrollback),
1538 dlg_stdcheckbox_handler, I(offsetof(Config,scroll_on_disp)));
1539 ctrl_checkbox(s, "Push erased text into scrollback", 'e',
1540 HELPCTX(window_erased),
1541 dlg_stdcheckbox_handler,
1542 I(offsetof(Config,erase_to_scrollback)));
1545 * The Window/Appearance panel.
1547 str = dupprintf("Configure the appearance of %s's window", appname);
1548 ctrl_settitle(b, "Window/Appearance", str);
1551 s = ctrl_getset(b, "Window/Appearance", "cursor",
1552 "Adjust the use of the cursor");
1553 ctrl_radiobuttons(s, "Cursor appearance:", NO_SHORTCUT, 3,
1554 HELPCTX(appearance_cursor),
1555 dlg_stdradiobutton_handler,
1556 I(offsetof(Config, cursor_type)),
1558 "Underline", 'u', I(1),
1559 "Vertical line", 'v', I(2), NULL);
1560 ctrl_checkbox(s, "Cursor blinks", 'b',
1561 HELPCTX(appearance_cursor),
1562 dlg_stdcheckbox_handler, I(offsetof(Config,blink_cur)));
1564 s = ctrl_getset(b, "Window/Appearance", "font",
1566 ctrl_fontsel(s, "Font used in the terminal window", 'n',
1567 HELPCTX(appearance_font),
1568 dlg_stdfontsel_handler, I(offsetof(Config, font)));
1570 s = ctrl_getset(b, "Window/Appearance", "mouse",
1571 "Adjust the use of the mouse pointer");
1572 ctrl_checkbox(s, "Hide mouse pointer when typing in window", 'p',
1573 HELPCTX(appearance_hidemouse),
1574 dlg_stdcheckbox_handler, I(offsetof(Config,hide_mouseptr)));
1576 s = ctrl_getset(b, "Window/Appearance", "border",
1577 "Adjust the window border");
1578 ctrl_editbox(s, "Gap between text and window edge:", 'e', 20,
1579 HELPCTX(appearance_border),
1580 dlg_stdeditbox_handler,
1581 I(offsetof(Config,window_border)), I(-1));
1584 * The Window/Behaviour panel.
1586 str = dupprintf("Configure the behaviour of %s's window", appname);
1587 ctrl_settitle(b, "Window/Behaviour", str);
1590 s = ctrl_getset(b, "Window/Behaviour", "title",
1591 "Adjust the behaviour of the window title");
1592 ctrl_editbox(s, "Window title:", 't', 100,
1593 HELPCTX(appearance_title),
1594 dlg_stdeditbox_handler, I(offsetof(Config,wintitle)),
1595 I(sizeof(((Config *)0)->wintitle)));
1596 ctrl_checkbox(s, "Separate window and icon titles", 'i',
1597 HELPCTX(appearance_title),
1598 dlg_stdcheckbox_handler,
1599 I(CHECKBOX_INVERT | offsetof(Config,win_name_always)));
1601 s = ctrl_getset(b, "Window/Behaviour", "main", NULL);
1602 ctrl_checkbox(s, "Warn before closing window", 'w',
1603 HELPCTX(behaviour_closewarn),
1604 dlg_stdcheckbox_handler, I(offsetof(Config,warn_on_close)));
1607 * The Window/Translation panel.
1609 ctrl_settitle(b, "Window/Translation",
1610 "Options controlling character set translation");
1612 s = ctrl_getset(b, "Window/Translation", "trans",
1613 "Character set translation");
1614 ctrl_combobox(s, "Remote character set:",
1615 'r', 100, HELPCTX(translation_codepage),
1616 codepage_handler, P(NULL), P(NULL));
1618 s = ctrl_getset(b, "Window/Translation", "tweaks", NULL);
1619 ctrl_checkbox(s, "Treat CJK ambiguous characters as wide", 'w',
1620 HELPCTX(translation_cjk_ambig_wide),
1621 dlg_stdcheckbox_handler, I(offsetof(Config,cjk_ambig_wide)));
1623 str = dupprintf("Adjust how %s handles line drawing characters", appname);
1624 s = ctrl_getset(b, "Window/Translation", "linedraw", str);
1626 ctrl_radiobuttons(s, "Handling of line drawing characters:", NO_SHORTCUT,1,
1627 HELPCTX(translation_linedraw),
1628 dlg_stdradiobutton_handler,
1629 I(offsetof(Config, vtmode)),
1630 "Use Unicode line drawing code points",'u',I(VT_UNICODE),
1631 "Poor man's line drawing (+, - and |)",'p',I(VT_POORMAN),
1633 ctrl_checkbox(s, "Copy and paste line drawing characters as lqqqk",'d',
1634 HELPCTX(selection_linedraw),
1635 dlg_stdcheckbox_handler, I(offsetof(Config,rawcnp)));
1638 * The Window/Selection panel.
1640 ctrl_settitle(b, "Window/Selection", "Options controlling copy and paste");
1642 s = ctrl_getset(b, "Window/Selection", "mouse",
1643 "Control use of mouse");
1644 ctrl_checkbox(s, "Shift overrides application's use of mouse", 'p',
1645 HELPCTX(selection_shiftdrag),
1646 dlg_stdcheckbox_handler, I(offsetof(Config,mouse_override)));
1647 ctrl_radiobuttons(s,
1648 "Default selection mode (Alt+drag does the other one):",
1650 HELPCTX(selection_rect),
1651 dlg_stdradiobutton_handler,
1652 I(offsetof(Config, rect_select)),
1653 "Normal", 'n', I(0),
1654 "Rectangular block", 'r', I(1), NULL);
1656 s = ctrl_getset(b, "Window/Selection", "charclass",
1657 "Control the select-one-word-at-a-time mode");
1658 ccd = (struct charclass_data *)
1659 ctrl_alloc(b, sizeof(struct charclass_data));
1660 ccd->listbox = ctrl_listbox(s, "Character classes:", 'e',
1661 HELPCTX(selection_charclasses),
1662 charclass_handler, P(ccd));
1663 ccd->listbox->listbox.multisel = 1;
1664 ccd->listbox->listbox.ncols = 4;
1665 ccd->listbox->listbox.percentages = snewn(4, int);
1666 ccd->listbox->listbox.percentages[0] = 15;
1667 ccd->listbox->listbox.percentages[1] = 25;
1668 ccd->listbox->listbox.percentages[2] = 20;
1669 ccd->listbox->listbox.percentages[3] = 40;
1670 ctrl_columns(s, 2, 67, 33);
1671 ccd->editbox = ctrl_editbox(s, "Set to class", 't', 50,
1672 HELPCTX(selection_charclasses),
1673 charclass_handler, P(ccd), P(NULL));
1674 ccd->editbox->generic.column = 0;
1675 ccd->button = ctrl_pushbutton(s, "Set", 's',
1676 HELPCTX(selection_charclasses),
1677 charclass_handler, P(ccd));
1678 ccd->button->generic.column = 1;
1679 ctrl_columns(s, 1, 100);
1682 * The Window/Colours panel.
1684 ctrl_settitle(b, "Window/Colours", "Options controlling use of colours");
1686 s = ctrl_getset(b, "Window/Colours", "general",
1687 "General options for colour usage");
1688 ctrl_checkbox(s, "Allow terminal to specify ANSI colours", 'i',
1689 HELPCTX(colours_ansi),
1690 dlg_stdcheckbox_handler, I(offsetof(Config,ansi_colour)));
1691 ctrl_checkbox(s, "Allow terminal to use xterm 256-colour mode", '2',
1692 HELPCTX(colours_xterm256), dlg_stdcheckbox_handler,
1693 I(offsetof(Config,xterm_256_colour)));
1694 ctrl_checkbox(s, "Bolded text is a different colour", 'b',
1695 HELPCTX(colours_bold),
1696 dlg_stdcheckbox_handler, I(offsetof(Config,bold_colour)));
1698 str = dupprintf("Adjust the precise colours %s displays", appname);
1699 s = ctrl_getset(b, "Window/Colours", "adjust", str);
1701 ctrl_text(s, "Select a colour from the list, and then click the"
1702 " Modify button to change its appearance.",
1703 HELPCTX(colours_config));
1704 ctrl_columns(s, 2, 67, 33);
1705 cd = (struct colour_data *)ctrl_alloc(b, sizeof(struct colour_data));
1706 cd->listbox = ctrl_listbox(s, "Select a colour to adjust:", 'u',
1707 HELPCTX(colours_config), colour_handler, P(cd));
1708 cd->listbox->generic.column = 0;
1709 cd->listbox->listbox.height = 7;
1710 c = ctrl_text(s, "RGB value:", HELPCTX(colours_config));
1711 c->generic.column = 1;
1712 cd->redit = ctrl_editbox(s, "Red", 'r', 50, HELPCTX(colours_config),
1713 colour_handler, P(cd), P(NULL));
1714 cd->redit->generic.column = 1;
1715 cd->gedit = ctrl_editbox(s, "Green", 'n', 50, HELPCTX(colours_config),
1716 colour_handler, P(cd), P(NULL));
1717 cd->gedit->generic.column = 1;
1718 cd->bedit = ctrl_editbox(s, "Blue", 'e', 50, HELPCTX(colours_config),
1719 colour_handler, P(cd), P(NULL));
1720 cd->bedit->generic.column = 1;
1721 cd->button = ctrl_pushbutton(s, "Modify", 'm', HELPCTX(colours_config),
1722 colour_handler, P(cd));
1723 cd->button->generic.column = 1;
1724 ctrl_columns(s, 1, 100);
1727 * The Connection panel. This doesn't show up if we're in a
1728 * non-network utility such as pterm. We tell this by being
1729 * passed a protocol < 0.
1731 if (protocol >= 0) {
1732 ctrl_settitle(b, "Connection", "Options controlling the connection");
1734 s = ctrl_getset(b, "Connection", "keepalive",
1735 "Sending of null packets to keep session active");
1736 ctrl_editbox(s, "Seconds between keepalives (0 to turn off)", 'k', 20,
1737 HELPCTX(connection_keepalive),
1738 dlg_stdeditbox_handler, I(offsetof(Config,ping_interval)),
1742 s = ctrl_getset(b, "Connection", "tcp",
1743 "Low-level TCP connection options");
1744 ctrl_checkbox(s, "Disable Nagle's algorithm (TCP_NODELAY option)",
1745 'n', HELPCTX(connection_nodelay),
1746 dlg_stdcheckbox_handler,
1747 I(offsetof(Config,tcp_nodelay)));
1748 ctrl_checkbox(s, "Enable TCP keepalives (SO_KEEPALIVE option)",
1749 'p', HELPCTX(connection_tcpkeepalive),
1750 dlg_stdcheckbox_handler,
1751 I(offsetof(Config,tcp_keepalives)));
1753 s = ctrl_getset(b, "Connection", "ipversion",
1754 "Internet protocol version");
1755 ctrl_radiobuttons(s, NULL, NO_SHORTCUT, 3,
1756 HELPCTX(connection_ipversion),
1757 dlg_stdradiobutton_handler,
1758 I(offsetof(Config, addressfamily)),
1759 "Auto", 'u', I(ADDRTYPE_UNSPEC),
1760 "IPv4", '4', I(ADDRTYPE_IPV4),
1761 "IPv6", '6', I(ADDRTYPE_IPV6),
1766 char *label = backend_from_proto(PROT_SSH) ?
1767 "Logical name of remote host (e.g. for SSH key lookup):" :
1768 "Logical name of remote host:";
1769 s = ctrl_getset(b, "Connection", "identity",
1770 "Logical name of remote host");
1771 ctrl_editbox(s, label, 'm', 100,
1772 HELPCTX(connection_loghost),
1773 dlg_stdeditbox_handler, I(offsetof(Config,loghost)),
1774 I(sizeof(((Config *)0)->loghost)));
1779 * A sub-panel Connection/Data, containing options that
1780 * decide on data to send to the server.
1783 ctrl_settitle(b, "Connection/Data", "Data to send to the server");
1785 s = ctrl_getset(b, "Connection/Data", "login",
1787 ctrl_editbox(s, "Auto-login username", 'u', 50,
1788 HELPCTX(connection_username),
1789 dlg_stdeditbox_handler, I(offsetof(Config,username)),
1790 I(sizeof(((Config *)0)->username)));
1792 /* We assume the local username is sufficiently stable
1793 * to include on the dialog box. */
1794 char *user = get_username();
1795 char *userlabel = dupprintf("Use system username (%s)",
1798 ctrl_radiobuttons(s, "When username is not specified:", 'n', 4,
1799 HELPCTX(connection_username_from_env),
1800 dlg_stdradiobutton_handler,
1801 I(offsetof(Config, username_from_env)),
1808 s = ctrl_getset(b, "Connection/Data", "term",
1809 "Terminal details");
1810 ctrl_editbox(s, "Terminal-type string", 't', 50,
1811 HELPCTX(connection_termtype),
1812 dlg_stdeditbox_handler, I(offsetof(Config,termtype)),
1813 I(sizeof(((Config *)0)->termtype)));
1814 ctrl_editbox(s, "Terminal speeds", 's', 50,
1815 HELPCTX(connection_termspeed),
1816 dlg_stdeditbox_handler, I(offsetof(Config,termspeed)),
1817 I(sizeof(((Config *)0)->termspeed)));
1819 s = ctrl_getset(b, "Connection/Data", "env",
1820 "Environment variables");
1821 ctrl_columns(s, 2, 80, 20);
1822 ed = (struct environ_data *)
1823 ctrl_alloc(b, sizeof(struct environ_data));
1824 ed->varbox = ctrl_editbox(s, "Variable", 'v', 60,
1825 HELPCTX(telnet_environ),
1826 environ_handler, P(ed), P(NULL));
1827 ed->varbox->generic.column = 0;
1828 ed->valbox = ctrl_editbox(s, "Value", 'l', 60,
1829 HELPCTX(telnet_environ),
1830 environ_handler, P(ed), P(NULL));
1831 ed->valbox->generic.column = 0;
1832 ed->addbutton = ctrl_pushbutton(s, "Add", 'd',
1833 HELPCTX(telnet_environ),
1834 environ_handler, P(ed));
1835 ed->addbutton->generic.column = 1;
1836 ed->rembutton = ctrl_pushbutton(s, "Remove", 'r',
1837 HELPCTX(telnet_environ),
1838 environ_handler, P(ed));
1839 ed->rembutton->generic.column = 1;
1840 ctrl_columns(s, 1, 100);
1841 ed->listbox = ctrl_listbox(s, NULL, NO_SHORTCUT,
1842 HELPCTX(telnet_environ),
1843 environ_handler, P(ed));
1844 ed->listbox->listbox.height = 3;
1845 ed->listbox->listbox.ncols = 2;
1846 ed->listbox->listbox.percentages = snewn(2, int);
1847 ed->listbox->listbox.percentages[0] = 30;
1848 ed->listbox->listbox.percentages[1] = 70;
1855 * The Connection/Proxy panel.
1857 ctrl_settitle(b, "Connection/Proxy",
1858 "Options controlling proxy usage");
1860 s = ctrl_getset(b, "Connection/Proxy", "basics", NULL);
1861 ctrl_radiobuttons(s, "Proxy type:", 't', 3,
1862 HELPCTX(proxy_type),
1863 dlg_stdradiobutton_handler,
1864 I(offsetof(Config, proxy_type)),
1865 "None", I(PROXY_NONE),
1866 "SOCKS 4", I(PROXY_SOCKS4),
1867 "SOCKS 5", I(PROXY_SOCKS5),
1868 "HTTP", I(PROXY_HTTP),
1869 "Telnet", I(PROXY_TELNET),
1871 ctrl_columns(s, 2, 80, 20);
1872 c = ctrl_editbox(s, "Proxy hostname", 'y', 100,
1873 HELPCTX(proxy_main),
1874 dlg_stdeditbox_handler,
1875 I(offsetof(Config,proxy_host)),
1876 I(sizeof(((Config *)0)->proxy_host)));
1877 c->generic.column = 0;
1878 c = ctrl_editbox(s, "Port", 'p', 100,
1879 HELPCTX(proxy_main),
1880 dlg_stdeditbox_handler,
1881 I(offsetof(Config,proxy_port)),
1883 c->generic.column = 1;
1884 ctrl_columns(s, 1, 100);
1885 ctrl_editbox(s, "Exclude Hosts/IPs", 'e', 100,
1886 HELPCTX(proxy_exclude),
1887 dlg_stdeditbox_handler,
1888 I(offsetof(Config,proxy_exclude_list)),
1889 I(sizeof(((Config *)0)->proxy_exclude_list)));
1890 ctrl_checkbox(s, "Consider proxying local host connections", 'x',
1891 HELPCTX(proxy_exclude),
1892 dlg_stdcheckbox_handler,
1893 I(offsetof(Config,even_proxy_localhost)));
1894 ctrl_radiobuttons(s, "Do DNS name lookup at proxy end:", 'd', 3,
1896 dlg_stdradiobutton_handler,
1897 I(offsetof(Config, proxy_dns)),
1900 "Yes", I(FORCE_ON), NULL);
1901 ctrl_editbox(s, "Username", 'u', 60,
1902 HELPCTX(proxy_auth),
1903 dlg_stdeditbox_handler,
1904 I(offsetof(Config,proxy_username)),
1905 I(sizeof(((Config *)0)->proxy_username)));
1906 c = ctrl_editbox(s, "Password", 'w', 60,
1907 HELPCTX(proxy_auth),
1908 dlg_stdeditbox_handler,
1909 I(offsetof(Config,proxy_password)),
1910 I(sizeof(((Config *)0)->proxy_password)));
1911 c->editbox.password = 1;
1912 ctrl_editbox(s, "Telnet command", 'm', 100,
1913 HELPCTX(proxy_command),
1914 dlg_stdeditbox_handler,
1915 I(offsetof(Config,proxy_telnet_command)),
1916 I(sizeof(((Config *)0)->proxy_telnet_command)));
1920 * The Telnet panel exists in the base config box, and in a
1921 * mid-session reconfig box _if_ we're using Telnet.
1923 if (!midsession || protocol == PROT_TELNET) {
1925 * The Connection/Telnet panel.
1927 ctrl_settitle(b, "Connection/Telnet",
1928 "Options controlling Telnet connections");
1930 s = ctrl_getset(b, "Connection/Telnet", "protocol",
1931 "Telnet protocol adjustments");
1934 ctrl_radiobuttons(s, "Handling of OLD_ENVIRON ambiguity:",
1936 HELPCTX(telnet_oldenviron),
1937 dlg_stdradiobutton_handler,
1938 I(offsetof(Config, rfc_environ)),
1939 "BSD (commonplace)", 'b', I(0),
1940 "RFC 1408 (unusual)", 'f', I(1), NULL);
1941 ctrl_radiobuttons(s, "Telnet negotiation mode:", 't', 2,
1942 HELPCTX(telnet_passive),
1943 dlg_stdradiobutton_handler,
1944 I(offsetof(Config, passive_telnet)),
1945 "Passive", I(1), "Active", I(0), NULL);
1947 ctrl_checkbox(s, "Keyboard sends Telnet special commands", 'k',
1948 HELPCTX(telnet_specialkeys),
1949 dlg_stdcheckbox_handler,
1950 I(offsetof(Config,telnet_keyboard)));
1951 ctrl_checkbox(s, "Return key sends Telnet New Line instead of ^M",
1952 'm', HELPCTX(telnet_newline),
1953 dlg_stdcheckbox_handler,
1954 I(offsetof(Config,telnet_newline)));
1960 * The Connection/Rlogin panel.
1962 ctrl_settitle(b, "Connection/Rlogin",
1963 "Options controlling Rlogin connections");
1965 s = ctrl_getset(b, "Connection/Rlogin", "data",
1966 "Data to send to the server");
1967 ctrl_editbox(s, "Local username:", 'l', 50,
1968 HELPCTX(rlogin_localuser),
1969 dlg_stdeditbox_handler, I(offsetof(Config,localusername)),
1970 I(sizeof(((Config *)0)->localusername)));
1975 * All the SSH stuff is omitted in PuTTYtel, or in a reconfig
1976 * when we're not doing SSH.
1979 if (backend_from_proto(PROT_SSH) && (!midsession || protocol == PROT_SSH)) {
1982 * The Connection/SSH panel.
1984 ctrl_settitle(b, "Connection/SSH",
1985 "Options controlling SSH connections");
1987 if (midsession && protcfginfo == 1) {
1988 s = ctrl_getset(b, "Connection/SSH", "disclaimer", NULL);
1989 ctrl_text(s, "Nothing on this panel may be reconfigured in mid-"
1990 "session; it is only here so that sub-panels of it can "
1991 "exist without looking strange.", HELPCTX(no_help));
1996 s = ctrl_getset(b, "Connection/SSH", "data",
1997 "Data to send to the server");
1998 ctrl_editbox(s, "Remote command:", 'r', 100,
1999 HELPCTX(ssh_command),
2000 dlg_stdeditbox_handler, I(offsetof(Config,remote_cmd)),
2001 I(sizeof(((Config *)0)->remote_cmd)));
2003 s = ctrl_getset(b, "Connection/SSH", "protocol", "Protocol options");
2004 ctrl_checkbox(s, "Don't start a shell or command at all", 'n',
2005 HELPCTX(ssh_noshell),
2006 dlg_stdcheckbox_handler,
2007 I(offsetof(Config,ssh_no_shell)));
2010 if (!midsession || protcfginfo != 1) {
2011 s = ctrl_getset(b, "Connection/SSH", "protocol", "Protocol options");
2013 ctrl_checkbox(s, "Enable compression", 'e',
2014 HELPCTX(ssh_compress),
2015 dlg_stdcheckbox_handler,
2016 I(offsetof(Config,compression)));
2020 s = ctrl_getset(b, "Connection/SSH", "protocol", "Protocol options");
2022 ctrl_radiobuttons(s, "Preferred SSH protocol version:", NO_SHORTCUT, 4,
2023 HELPCTX(ssh_protocol),
2024 dlg_stdradiobutton_handler,
2025 I(offsetof(Config, sshprot)),
2026 "1 only", 'l', I(0),
2029 "2 only", 'y', I(3), NULL);
2032 if (!midsession || protcfginfo != 1) {
2033 s = ctrl_getset(b, "Connection/SSH", "encryption", "Encryption options");
2034 c = ctrl_draglist(s, "Encryption cipher selection policy:", 's',
2035 HELPCTX(ssh_ciphers),
2036 cipherlist_handler, P(NULL));
2037 c->listbox.height = 6;
2039 ctrl_checkbox(s, "Enable legacy use of single-DES in SSH-2", 'i',
2040 HELPCTX(ssh_ciphers),
2041 dlg_stdcheckbox_handler,
2042 I(offsetof(Config,ssh2_des_cbc)));
2046 * The Connection/SSH/Kex panel. (Owing to repeat key
2047 * exchange, this is all meaningful in mid-session _if_
2048 * we're using SSH-2 or haven't decided yet.)
2050 if (protcfginfo != 1) {
2051 ctrl_settitle(b, "Connection/SSH/Kex",
2052 "Options controlling SSH key exchange");
2054 s = ctrl_getset(b, "Connection/SSH/Kex", "main",
2055 "Key exchange algorithm options");
2056 c = ctrl_draglist(s, "Algorithm selection policy:", 's',
2057 HELPCTX(ssh_kexlist),
2058 kexlist_handler, P(NULL));
2059 c->listbox.height = 5;
2061 s = ctrl_getset(b, "Connection/SSH/Kex", "repeat",
2062 "Options controlling key re-exchange");
2064 ctrl_editbox(s, "Max minutes before rekey (0 for no limit)", 't', 20,
2065 HELPCTX(ssh_kex_repeat),
2066 dlg_stdeditbox_handler,
2067 I(offsetof(Config,ssh_rekey_time)),
2069 ctrl_editbox(s, "Max data before rekey (0 for no limit)", 'x', 20,
2070 HELPCTX(ssh_kex_repeat),
2071 dlg_stdeditbox_handler,
2072 I(offsetof(Config,ssh_rekey_data)),
2074 ctrl_text(s, "(Use 1M for 1 megabyte, 1G for 1 gigabyte etc)",
2075 HELPCTX(ssh_kex_repeat));
2081 * The Connection/SSH/Auth panel.
2083 ctrl_settitle(b, "Connection/SSH/Auth",
2084 "Options controlling SSH authentication");
2086 s = ctrl_getset(b, "Connection/SSH/Auth", "main", NULL);
2087 ctrl_checkbox(s, "Bypass authentication entirely (SSH-2 only)", 'b',
2088 HELPCTX(ssh_auth_bypass),
2089 dlg_stdcheckbox_handler,
2090 I(offsetof(Config,ssh_no_userauth)));
2091 ctrl_checkbox(s, "Display pre-authentication banner (SSH-2 only)",
2092 'd', HELPCTX(ssh_auth_banner),
2093 dlg_stdcheckbox_handler,
2094 I(offsetof(Config,ssh_show_banner)));
2096 s = ctrl_getset(b, "Connection/SSH/Auth", "methods",
2097 "Authentication methods");
2098 ctrl_checkbox(s, "Attempt authentication using Pageant", 'p',
2099 HELPCTX(ssh_auth_pageant),
2100 dlg_stdcheckbox_handler,
2101 I(offsetof(Config,tryagent)));
2102 ctrl_checkbox(s, "Attempt TIS or CryptoCard auth (SSH-1)", 'm',
2103 HELPCTX(ssh_auth_tis),
2104 dlg_stdcheckbox_handler,
2105 I(offsetof(Config,try_tis_auth)));
2106 ctrl_checkbox(s, "Attempt \"keyboard-interactive\" auth (SSH-2)",
2107 'i', HELPCTX(ssh_auth_ki),
2108 dlg_stdcheckbox_handler,
2109 I(offsetof(Config,try_ki_auth)));
2111 s = ctrl_getset(b, "Connection/SSH/Auth", "params",
2112 "Authentication parameters");
2113 ctrl_checkbox(s, "Allow agent forwarding", 'f',
2114 HELPCTX(ssh_auth_agentfwd),
2115 dlg_stdcheckbox_handler, I(offsetof(Config,agentfwd)));
2116 ctrl_checkbox(s, "Allow attempted changes of username in SSH-2", NO_SHORTCUT,
2117 HELPCTX(ssh_auth_changeuser),
2118 dlg_stdcheckbox_handler,
2119 I(offsetof(Config,change_username)));
2120 ctrl_filesel(s, "Private key file for authentication:", 'k',
2121 FILTER_KEY_FILES, FALSE, "Select private key file",
2122 HELPCTX(ssh_auth_privkey),
2123 dlg_stdfilesel_handler, I(offsetof(Config, keyfile)));
2127 * Connection/SSH/Auth/GSSAPI, which sadly won't fit on
2128 * the main Auth panel.
2130 ctrl_settitle(b, "Connection/SSH/Auth/GSSAPI",
2131 "Options controlling GSSAPI authentication");
2132 s = ctrl_getset(b, "Connection/SSH/Auth/GSSAPI", "gssapi", NULL);
2134 ctrl_checkbox(s, "Attempt GSSAPI authentication (SSH-2 only)",
2135 't', HELPCTX(ssh_gssapi),
2136 dlg_stdcheckbox_handler,
2137 I(offsetof(Config,try_gssapi_auth)));
2139 ctrl_checkbox(s, "Allow GSSAPI credential delegation", 'l',
2140 HELPCTX(ssh_gssapi_delegation),
2141 dlg_stdcheckbox_handler,
2142 I(offsetof(Config,gssapifwd)));
2145 * GSSAPI library selection.
2148 c = ctrl_draglist(s, "Preference order for GSSAPI libraries:",
2149 'p', HELPCTX(ssh_gssapi_libraries),
2150 gsslist_handler, P(NULL));
2151 c->listbox.height = ngsslibs;
2154 * I currently assume that if more than one GSS
2155 * library option is available, then one of them is
2156 * 'user-supplied' and so we should present the
2157 * following file selector. This is at least half-
2158 * reasonable, because if we're using statically
2159 * linked GSSAPI then there will only be one option
2160 * and no way to load from a user-supplied library,
2161 * whereas if we're using dynamic libraries then
2162 * there will almost certainly be some default
2163 * option in addition to a user-supplied path. If
2164 * anyone ever ports PuTTY to a system on which
2165 * dynamic-library GSSAPI is available but there is
2166 * absolutely no consensus on where to keep the
2167 * libraries, there'll need to be a flag alongside
2168 * ngsslibs to control whether the file selector is
2172 ctrl_filesel(s, "User-supplied GSSAPI library path:", 's',
2173 FILTER_DYNLIB_FILES, FALSE, "Select library file",
2174 HELPCTX(ssh_gssapi_libraries),
2175 dlg_stdfilesel_handler,
2176 I(offsetof(Config, ssh_gss_custom)));
2183 * The Connection/SSH/TTY panel.
2185 ctrl_settitle(b, "Connection/SSH/TTY", "Remote terminal settings");
2187 s = ctrl_getset(b, "Connection/SSH/TTY", "sshtty", NULL);
2188 ctrl_checkbox(s, "Don't allocate a pseudo-terminal", 'p',
2190 dlg_stdcheckbox_handler,
2191 I(offsetof(Config,nopty)));
2193 s = ctrl_getset(b, "Connection/SSH/TTY", "ttymodes",
2195 td = (struct ttymodes_data *)
2196 ctrl_alloc(b, sizeof(struct ttymodes_data));
2197 ctrl_columns(s, 2, 75, 25);
2198 c = ctrl_text(s, "Terminal modes to send:", HELPCTX(ssh_ttymodes));
2199 c->generic.column = 0;
2200 td->rembutton = ctrl_pushbutton(s, "Remove", 'r',
2201 HELPCTX(ssh_ttymodes),
2202 ttymodes_handler, P(td));
2203 td->rembutton->generic.column = 1;
2204 td->rembutton->generic.tabdelay = 1;
2205 ctrl_columns(s, 1, 100);
2206 td->listbox = ctrl_listbox(s, NULL, NO_SHORTCUT,
2207 HELPCTX(ssh_ttymodes),
2208 ttymodes_handler, P(td));
2209 td->listbox->listbox.multisel = 1;
2210 td->listbox->listbox.height = 4;
2211 td->listbox->listbox.ncols = 2;
2212 td->listbox->listbox.percentages = snewn(2, int);
2213 td->listbox->listbox.percentages[0] = 40;
2214 td->listbox->listbox.percentages[1] = 60;
2215 ctrl_tabdelay(s, td->rembutton);
2216 ctrl_columns(s, 2, 75, 25);
2217 td->modelist = ctrl_droplist(s, "Mode:", 'm', 67,
2218 HELPCTX(ssh_ttymodes),
2219 ttymodes_handler, P(td));
2220 td->modelist->generic.column = 0;
2221 td->addbutton = ctrl_pushbutton(s, "Add", 'd',
2222 HELPCTX(ssh_ttymodes),
2223 ttymodes_handler, P(td));
2224 td->addbutton->generic.column = 1;
2225 td->addbutton->generic.tabdelay = 1;
2226 ctrl_columns(s, 1, 100); /* column break */
2227 /* Bit of a hack to get the value radio buttons and
2228 * edit-box on the same row. */
2229 ctrl_columns(s, 3, 25, 50, 25);
2230 c = ctrl_text(s, "Value:", HELPCTX(ssh_ttymodes));
2231 c->generic.column = 0;
2232 td->valradio = ctrl_radiobuttons(s, NULL, NO_SHORTCUT, 2,
2233 HELPCTX(ssh_ttymodes),
2234 ttymodes_handler, P(td),
2235 "Auto", NO_SHORTCUT, P(NULL),
2236 "This:", NO_SHORTCUT, P(NULL),
2238 td->valradio->generic.column = 1;
2239 td->valbox = ctrl_editbox(s, NULL, NO_SHORTCUT, 100,
2240 HELPCTX(ssh_ttymodes),
2241 ttymodes_handler, P(td), P(NULL));
2242 td->valbox->generic.column = 2;
2243 ctrl_tabdelay(s, td->addbutton);
2249 * The Connection/SSH/X11 panel.
2251 ctrl_settitle(b, "Connection/SSH/X11",
2252 "Options controlling SSH X11 forwarding");
2254 s = ctrl_getset(b, "Connection/SSH/X11", "x11", "X11 forwarding");
2255 ctrl_checkbox(s, "Enable X11 forwarding", 'e',
2256 HELPCTX(ssh_tunnels_x11),
2257 dlg_stdcheckbox_handler,I(offsetof(Config,x11_forward)));
2258 ctrl_editbox(s, "X display location", 'x', 50,
2259 HELPCTX(ssh_tunnels_x11),
2260 dlg_stdeditbox_handler, I(offsetof(Config,x11_display)),
2261 I(sizeof(((Config *)0)->x11_display)));
2262 ctrl_radiobuttons(s, "Remote X11 authentication protocol", 'u', 2,
2263 HELPCTX(ssh_tunnels_x11auth),
2264 dlg_stdradiobutton_handler,
2265 I(offsetof(Config, x11_auth)),
2266 "MIT-Magic-Cookie-1", I(X11_MIT),
2267 "XDM-Authorization-1", I(X11_XDM), NULL);
2271 * The Tunnels panel _is_ still available in mid-session.
2273 ctrl_settitle(b, "Connection/SSH/Tunnels",
2274 "Options controlling SSH port forwarding");
2276 s = ctrl_getset(b, "Connection/SSH/Tunnels", "portfwd",
2278 ctrl_checkbox(s, "Local ports accept connections from other hosts",'t',
2279 HELPCTX(ssh_tunnels_portfwd_localhost),
2280 dlg_stdcheckbox_handler,
2281 I(offsetof(Config,lport_acceptall)));
2282 ctrl_checkbox(s, "Remote ports do the same (SSH-2 only)", 'p',
2283 HELPCTX(ssh_tunnels_portfwd_localhost),
2284 dlg_stdcheckbox_handler,
2285 I(offsetof(Config,rport_acceptall)));
2287 ctrl_columns(s, 3, 55, 20, 25);
2288 c = ctrl_text(s, "Forwarded ports:", HELPCTX(ssh_tunnels_portfwd));
2289 c->generic.column = COLUMN_FIELD(0,2);
2290 /* You want to select from the list, _then_ hit Remove. So tab order
2291 * should be that way round. */
2292 pfd = (struct portfwd_data *)ctrl_alloc(b,sizeof(struct portfwd_data));
2293 pfd->rembutton = ctrl_pushbutton(s, "Remove", 'r',
2294 HELPCTX(ssh_tunnels_portfwd),
2295 portfwd_handler, P(pfd));
2296 pfd->rembutton->generic.column = 2;
2297 pfd->rembutton->generic.tabdelay = 1;
2298 pfd->listbox = ctrl_listbox(s, NULL, NO_SHORTCUT,
2299 HELPCTX(ssh_tunnels_portfwd),
2300 portfwd_handler, P(pfd));
2301 pfd->listbox->listbox.height = 3;
2302 pfd->listbox->listbox.ncols = 2;
2303 pfd->listbox->listbox.percentages = snewn(2, int);
2304 pfd->listbox->listbox.percentages[0] = 20;
2305 pfd->listbox->listbox.percentages[1] = 80;
2306 ctrl_tabdelay(s, pfd->rembutton);
2307 ctrl_text(s, "Add new forwarded port:", HELPCTX(ssh_tunnels_portfwd));
2308 /* You want to enter source, destination and type, _then_ hit Add.
2309 * Again, we adjust the tab order to reflect this. */
2310 pfd->addbutton = ctrl_pushbutton(s, "Add", 'd',
2311 HELPCTX(ssh_tunnels_portfwd),
2312 portfwd_handler, P(pfd));
2313 pfd->addbutton->generic.column = 2;
2314 pfd->addbutton->generic.tabdelay = 1;
2315 pfd->sourcebox = ctrl_editbox(s, "Source port", 's', 40,
2316 HELPCTX(ssh_tunnels_portfwd),
2317 portfwd_handler, P(pfd), P(NULL));
2318 pfd->sourcebox->generic.column = 0;
2319 pfd->destbox = ctrl_editbox(s, "Destination", 'i', 67,
2320 HELPCTX(ssh_tunnels_portfwd),
2321 portfwd_handler, P(pfd), P(NULL));
2322 pfd->direction = ctrl_radiobuttons(s, NULL, NO_SHORTCUT, 3,
2323 HELPCTX(ssh_tunnels_portfwd),
2324 portfwd_handler, P(pfd),
2325 "Local", 'l', P(NULL),
2326 "Remote", 'm', P(NULL),
2327 "Dynamic", 'y', P(NULL),
2330 pfd->addressfamily =
2331 ctrl_radiobuttons(s, NULL, NO_SHORTCUT, 3,
2332 HELPCTX(ssh_tunnels_portfwd_ipversion),
2333 portfwd_handler, P(pfd),
2334 "Auto", 'u', I(ADDRTYPE_UNSPEC),
2335 "IPv4", '4', I(ADDRTYPE_IPV4),
2336 "IPv6", '6', I(ADDRTYPE_IPV6),
2339 ctrl_tabdelay(s, pfd->addbutton);
2340 ctrl_columns(s, 1, 100);
2344 * The Connection/SSH/Bugs panel.
2346 ctrl_settitle(b, "Connection/SSH/Bugs",
2347 "Workarounds for SSH server bugs");
2349 s = ctrl_getset(b, "Connection/SSH/Bugs", "main",
2350 "Detection of known bugs in SSH servers");
2351 ctrl_droplist(s, "Chokes on SSH-1 ignore messages", 'i', 20,
2352 HELPCTX(ssh_bugs_ignore1),
2353 sshbug_handler, I(offsetof(Config,sshbug_ignore1)));
2354 ctrl_droplist(s, "Refuses all SSH-1 password camouflage", 's', 20,
2355 HELPCTX(ssh_bugs_plainpw1),
2356 sshbug_handler, I(offsetof(Config,sshbug_plainpw1)));
2357 ctrl_droplist(s, "Chokes on SSH-1 RSA authentication", 'r', 20,
2358 HELPCTX(ssh_bugs_rsa1),
2359 sshbug_handler, I(offsetof(Config,sshbug_rsa1)));
2360 ctrl_droplist(s, "Chokes on SSH-2 ignore messages", '2', 20,
2361 HELPCTX(ssh_bugs_ignore2),
2362 sshbug_handler, I(offsetof(Config,sshbug_ignore2)));
2363 ctrl_droplist(s, "Miscomputes SSH-2 HMAC keys", 'm', 20,
2364 HELPCTX(ssh_bugs_hmac2),
2365 sshbug_handler, I(offsetof(Config,sshbug_hmac2)));
2366 ctrl_droplist(s, "Miscomputes SSH-2 encryption keys", 'e', 20,
2367 HELPCTX(ssh_bugs_derivekey2),
2368 sshbug_handler, I(offsetof(Config,sshbug_derivekey2)));
2369 ctrl_droplist(s, "Requires padding on SSH-2 RSA signatures", 'p', 20,
2370 HELPCTX(ssh_bugs_rsapad2),
2371 sshbug_handler, I(offsetof(Config,sshbug_rsapad2)));
2372 ctrl_droplist(s, "Misuses the session ID in SSH-2 PK auth", 'n', 20,
2373 HELPCTX(ssh_bugs_pksessid2),
2374 sshbug_handler, I(offsetof(Config,sshbug_pksessid2)));
2375 ctrl_droplist(s, "Handles SSH-2 key re-exchange badly", 'k', 20,
2376 HELPCTX(ssh_bugs_rekey2),
2377 sshbug_handler, I(offsetof(Config,sshbug_rekey2)));
2378 ctrl_droplist(s, "Ignores SSH-2 maximum packet size", 'x', 20,
2379 HELPCTX(ssh_bugs_maxpkt2),
2380 sshbug_handler, I(offsetof(Config,sshbug_maxpkt2)));