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) {
118 switch (cfg->protocol) {
119 case PROT_SSH: defport = 22; break;
120 case PROT_TELNET: defport = 23; break;
121 case PROT_RLOGIN: defport = 513; break;
123 if (defport > 0 && cfg->port != defport) {
127 dlg_refresh(hp->host, dlg);
128 dlg_refresh(hp->port, dlg);
132 static void loggingbuttons_handler(union control *ctrl, void *dlg,
133 void *data, int event)
136 Config *cfg = (Config *)data;
137 /* This function works just like the standard radio-button handler,
138 * but it has to fall back to "no logging" in situations where the
139 * configured logging type isn't applicable.
141 if (event == EVENT_REFRESH) {
142 for (button = 0; button < ctrl->radio.nbuttons; button++)
143 if (cfg->logtype == ctrl->radio.buttondata[button].i)
146 /* We fell off the end, so we lack the configured logging type */
147 if (button == ctrl->radio.nbuttons) {
149 cfg->logtype=LGTYP_NONE;
151 dlg_radiobutton_set(ctrl, dlg, button);
152 } else if (event == EVENT_VALCHANGE) {
153 button = dlg_radiobutton_get(ctrl, dlg);
154 assert(button >= 0 && button < ctrl->radio.nbuttons);
155 cfg->logtype = ctrl->radio.buttondata[button].i;
159 static void numeric_keypad_handler(union control *ctrl, void *dlg,
160 void *data, int event)
163 Config *cfg = (Config *)data;
165 * This function works much like the standard radio button
166 * handler, but it has to handle two fields in Config.
168 if (event == EVENT_REFRESH) {
169 if (cfg->nethack_keypad)
171 else if (cfg->app_keypad)
175 assert(button < ctrl->radio.nbuttons);
176 dlg_radiobutton_set(ctrl, dlg, button);
177 } else if (event == EVENT_VALCHANGE) {
178 button = dlg_radiobutton_get(ctrl, dlg);
179 assert(button >= 0 && button < ctrl->radio.nbuttons);
181 cfg->app_keypad = FALSE;
182 cfg->nethack_keypad = TRUE;
184 cfg->app_keypad = (button != 0);
185 cfg->nethack_keypad = FALSE;
190 static void cipherlist_handler(union control *ctrl, void *dlg,
191 void *data, int event)
193 Config *cfg = (Config *)data;
194 if (event == EVENT_REFRESH) {
197 static const struct { char *s; int c; } ciphers[] = {
198 { "3DES", CIPHER_3DES },
199 { "Blowfish", CIPHER_BLOWFISH },
200 { "DES", CIPHER_DES },
201 { "AES (SSH-2 only)", CIPHER_AES },
202 { "Arcfour (SSH-2 only)", CIPHER_ARCFOUR },
203 { "-- warn below here --", CIPHER_WARN }
206 /* Set up the "selected ciphers" box. */
207 /* (cipherlist assumed to contain all ciphers) */
208 dlg_update_start(ctrl, dlg);
209 dlg_listbox_clear(ctrl, dlg);
210 for (i = 0; i < CIPHER_MAX; i++) {
211 int c = cfg->ssh_cipherlist[i];
214 for (j = 0; j < (sizeof ciphers) / (sizeof ciphers[0]); j++) {
215 if (ciphers[j].c == c) {
220 dlg_listbox_addwithid(ctrl, dlg, cstr, c);
222 dlg_update_done(ctrl, dlg);
224 } else if (event == EVENT_VALCHANGE) {
227 /* Update array to match the list box. */
228 for (i=0; i < CIPHER_MAX; i++)
229 cfg->ssh_cipherlist[i] = dlg_listbox_getid(ctrl, dlg, i);
234 static void kexlist_handler(union control *ctrl, void *dlg,
235 void *data, int event)
237 Config *cfg = (Config *)data;
238 if (event == EVENT_REFRESH) {
241 static const struct { char *s; int k; } kexes[] = {
242 { "Diffie-Hellman group 1", KEX_DHGROUP1 },
243 { "Diffie-Hellman group 14", KEX_DHGROUP14 },
244 { "Diffie-Hellman group exchange", KEX_DHGEX },
245 { "-- warn below here --", KEX_WARN }
248 /* Set up the "kex preference" box. */
249 /* (kexlist assumed to contain all algorithms) */
250 dlg_update_start(ctrl, dlg);
251 dlg_listbox_clear(ctrl, dlg);
252 for (i = 0; i < KEX_MAX; i++) {
253 int k = cfg->ssh_kexlist[i];
256 for (j = 0; j < (sizeof kexes) / (sizeof kexes[0]); j++) {
257 if (kexes[j].k == k) {
262 dlg_listbox_addwithid(ctrl, dlg, kstr, k);
264 dlg_update_done(ctrl, dlg);
266 } else if (event == EVENT_VALCHANGE) {
269 /* Update array to match the list box. */
270 for (i=0; i < KEX_MAX; i++)
271 cfg->ssh_kexlist[i] = dlg_listbox_getid(ctrl, dlg, i);
276 static void printerbox_handler(union control *ctrl, void *dlg,
277 void *data, int event)
279 Config *cfg = (Config *)data;
280 if (event == EVENT_REFRESH) {
284 dlg_update_start(ctrl, dlg);
286 * Some backends may wish to disable the drop-down list on
287 * this edit box. Be prepared for this.
289 if (ctrl->editbox.has_list) {
290 dlg_listbox_clear(ctrl, dlg);
291 dlg_listbox_add(ctrl, dlg, PRINTER_DISABLED_STRING);
292 pe = printer_start_enum(&nprinters);
293 for (i = 0; i < nprinters; i++)
294 dlg_listbox_add(ctrl, dlg, printer_get_name(pe, i));
295 printer_finish_enum(pe);
297 dlg_editbox_set(ctrl, dlg,
298 (*cfg->printer ? cfg->printer :
299 PRINTER_DISABLED_STRING));
300 dlg_update_done(ctrl, dlg);
301 } else if (event == EVENT_VALCHANGE) {
302 dlg_editbox_get(ctrl, dlg, cfg->printer, sizeof(cfg->printer));
303 if (!strcmp(cfg->printer, PRINTER_DISABLED_STRING))
304 *cfg->printer = '\0';
308 static void codepage_handler(union control *ctrl, void *dlg,
309 void *data, int event)
311 Config *cfg = (Config *)data;
312 if (event == EVENT_REFRESH) {
315 dlg_update_start(ctrl, dlg);
316 strcpy(cfg->line_codepage,
317 cp_name(decode_codepage(cfg->line_codepage)));
318 dlg_listbox_clear(ctrl, dlg);
319 for (i = 0; (cp = cp_enumerate(i)) != NULL; i++)
320 dlg_listbox_add(ctrl, dlg, cp);
321 dlg_editbox_set(ctrl, dlg, cfg->line_codepage);
322 dlg_update_done(ctrl, dlg);
323 } else if (event == EVENT_VALCHANGE) {
324 dlg_editbox_get(ctrl, dlg, cfg->line_codepage,
325 sizeof(cfg->line_codepage));
326 strcpy(cfg->line_codepage,
327 cp_name(decode_codepage(cfg->line_codepage)));
331 static void sshbug_handler(union control *ctrl, void *dlg,
332 void *data, int event)
334 if (event == EVENT_REFRESH) {
335 dlg_update_start(ctrl, dlg);
336 dlg_listbox_clear(ctrl, dlg);
337 dlg_listbox_addwithid(ctrl, dlg, "Auto", AUTO);
338 dlg_listbox_addwithid(ctrl, dlg, "Off", FORCE_OFF);
339 dlg_listbox_addwithid(ctrl, dlg, "On", FORCE_ON);
340 switch (*(int *)ATOFFSET(data, ctrl->listbox.context.i)) {
341 case AUTO: dlg_listbox_select(ctrl, dlg, 0); break;
342 case FORCE_OFF: dlg_listbox_select(ctrl, dlg, 1); break;
343 case FORCE_ON: dlg_listbox_select(ctrl, dlg, 2); break;
345 dlg_update_done(ctrl, dlg);
346 } else if (event == EVENT_SELCHANGE) {
347 int i = dlg_listbox_index(ctrl, dlg);
351 i = dlg_listbox_getid(ctrl, dlg, i);
352 *(int *)ATOFFSET(data, ctrl->listbox.context.i) = i;
356 #define SAVEDSESSION_LEN 2048
358 struct sessionsaver_data {
359 union control *editbox, *listbox, *loadbutton, *savebutton, *delbutton;
360 union control *okbutton, *cancelbutton;
361 struct sesslist sesslist;
366 * Helper function to load the session selected in the list box, if
367 * any, as this is done in more than one place below. Returns 0 for
370 static int load_selected_session(struct sessionsaver_data *ssd,
372 void *dlg, Config *cfg)
374 int i = dlg_listbox_index(ssd->listbox, dlg);
380 isdef = !strcmp(ssd->sesslist.sessions[i], "Default Settings");
381 load_settings(ssd->sesslist.sessions[i], !isdef, cfg);
383 strncpy(savedsession, ssd->sesslist.sessions[i],
385 savedsession[SAVEDSESSION_LEN-1] = '\0';
387 savedsession[0] = '\0';
389 dlg_refresh(NULL, dlg);
390 /* Restore the selection, which might have been clobbered by
391 * changing the value of the edit box. */
392 dlg_listbox_select(ssd->listbox, dlg, i);
396 static void sessionsaver_handler(union control *ctrl, void *dlg,
397 void *data, int event)
399 Config *cfg = (Config *)data;
400 struct sessionsaver_data *ssd =
401 (struct sessionsaver_data *)ctrl->generic.context.p;
405 * The first time we're called in a new dialog, we must
406 * allocate space to store the current contents of the saved
407 * session edit box (since it must persist even when we switch
408 * panels, but is not part of the Config).
412 } else if (!dlg_get_privdata(ssd->editbox, dlg)) {
413 savedsession = (char *)
414 dlg_alloc_privdata(ssd->editbox, dlg, SAVEDSESSION_LEN);
415 savedsession[0] = '\0';
417 savedsession = dlg_get_privdata(ssd->editbox, dlg);
420 if (event == EVENT_REFRESH) {
421 if (ctrl == ssd->editbox) {
422 dlg_editbox_set(ctrl, dlg, savedsession);
423 } else if (ctrl == ssd->listbox) {
425 dlg_update_start(ctrl, dlg);
426 dlg_listbox_clear(ctrl, dlg);
427 for (i = 0; i < ssd->sesslist.nsessions; i++)
428 dlg_listbox_add(ctrl, dlg, ssd->sesslist.sessions[i]);
429 dlg_update_done(ctrl, dlg);
431 } else if (event == EVENT_VALCHANGE) {
432 int top, bottom, halfway, i;
433 if (ctrl == ssd->editbox) {
434 dlg_editbox_get(ctrl, dlg, savedsession,
436 top = ssd->sesslist.nsessions;
438 while (top-bottom > 1) {
439 halfway = (top+bottom)/2;
440 i = strcmp(savedsession, ssd->sesslist.sessions[halfway]);
447 if (top == ssd->sesslist.nsessions) {
450 dlg_listbox_select(ssd->listbox, dlg, top);
452 } else if (event == EVENT_ACTION) {
453 if (!ssd->midsession &&
454 (ctrl == ssd->listbox ||
455 (ssd->loadbutton && ctrl == ssd->loadbutton))) {
457 * The user has double-clicked a session, or hit Load.
458 * We must load the selected session, and then
459 * terminate the configuration dialog _if_ there was a
460 * double-click on the list box _and_ that session
461 * contains a hostname.
463 if (load_selected_session(ssd, savedsession, dlg, cfg) &&
464 (ctrl == ssd->listbox && cfg_launchable(cfg))) {
465 dlg_end(dlg, 1); /* it's all over, and succeeded */
467 } else if (ctrl == ssd->savebutton) {
468 int isdef = !strcmp(savedsession, "Default Settings");
469 if (!savedsession[0]) {
470 int i = dlg_listbox_index(ssd->listbox, dlg);
475 isdef = !strcmp(ssd->sesslist.sessions[i], "Default Settings");
477 strncpy(savedsession, ssd->sesslist.sessions[i],
479 savedsession[SAVEDSESSION_LEN-1] = '\0';
481 savedsession[0] = '\0';
485 char *errmsg = save_settings(savedsession, !isdef, cfg);
487 dlg_error_msg(dlg, errmsg);
491 get_sesslist(&ssd->sesslist, FALSE);
492 get_sesslist(&ssd->sesslist, TRUE);
493 dlg_refresh(ssd->editbox, dlg);
494 dlg_refresh(ssd->listbox, dlg);
495 } else if (!ssd->midsession &&
496 ssd->delbutton && ctrl == ssd->delbutton) {
497 int i = dlg_listbox_index(ssd->listbox, dlg);
501 del_settings(ssd->sesslist.sessions[i]);
502 get_sesslist(&ssd->sesslist, FALSE);
503 get_sesslist(&ssd->sesslist, TRUE);
504 dlg_refresh(ssd->listbox, dlg);
506 } else if (ctrl == ssd->okbutton) {
507 if (ssd->midsession) {
508 /* In a mid-session Change Settings, Apply is always OK. */
513 * Annoying special case. If the `Open' button is
514 * pressed while no host name is currently set, _and_
515 * the session list previously had the focus, _and_
516 * there was a session selected in that which had a
517 * valid host name in it, then load it and go.
519 if (dlg_last_focused(ctrl, dlg) == ssd->listbox &&
520 !cfg_launchable(cfg)) {
522 if (!load_selected_session(ssd, savedsession, dlg, &cfg2)) {
526 /* If at this point we have a valid session, go! */
528 *cfg = cfg2; /* structure copy */
529 cfg->remote_cmd_ptr = NULL;
537 * Otherwise, do the normal thing: if we have a valid
538 * session, get going.
540 if (cfg_launchable(cfg)) {
544 } else if (ctrl == ssd->cancelbutton) {
550 struct charclass_data {
551 union control *listbox, *editbox, *button;
554 static void charclass_handler(union control *ctrl, void *dlg,
555 void *data, int event)
557 Config *cfg = (Config *)data;
558 struct charclass_data *ccd =
559 (struct charclass_data *)ctrl->generic.context.p;
561 if (event == EVENT_REFRESH) {
562 if (ctrl == ccd->listbox) {
564 dlg_update_start(ctrl, dlg);
565 dlg_listbox_clear(ctrl, dlg);
566 for (i = 0; i < 128; i++) {
568 sprintf(str, "%d\t(0x%02X)\t%c\t%d", i, i,
569 (i >= 0x21 && i != 0x7F) ? i : ' ', cfg->wordness[i]);
570 dlg_listbox_add(ctrl, dlg, str);
572 dlg_update_done(ctrl, dlg);
574 } else if (event == EVENT_ACTION) {
575 if (ctrl == ccd->button) {
578 dlg_editbox_get(ccd->editbox, dlg, str, sizeof(str));
580 for (i = 0; i < 128; i++) {
581 if (dlg_listbox_issel(ccd->listbox, dlg, i))
582 cfg->wordness[i] = n;
584 dlg_refresh(ccd->listbox, dlg);
590 union control *listbox, *redit, *gedit, *bedit, *button;
593 static const char *const colours[] = {
594 "Default Foreground", "Default Bold Foreground",
595 "Default Background", "Default Bold Background",
596 "Cursor Text", "Cursor Colour",
597 "ANSI Black", "ANSI Black Bold",
598 "ANSI Red", "ANSI Red Bold",
599 "ANSI Green", "ANSI Green Bold",
600 "ANSI Yellow", "ANSI Yellow Bold",
601 "ANSI Blue", "ANSI Blue Bold",
602 "ANSI Magenta", "ANSI Magenta Bold",
603 "ANSI Cyan", "ANSI Cyan Bold",
604 "ANSI White", "ANSI White Bold"
607 static void colour_handler(union control *ctrl, void *dlg,
608 void *data, int event)
610 Config *cfg = (Config *)data;
611 struct colour_data *cd =
612 (struct colour_data *)ctrl->generic.context.p;
613 int update = FALSE, r, g, b;
615 if (event == EVENT_REFRESH) {
616 if (ctrl == cd->listbox) {
618 dlg_update_start(ctrl, dlg);
619 dlg_listbox_clear(ctrl, dlg);
620 for (i = 0; i < lenof(colours); i++)
621 dlg_listbox_add(ctrl, dlg, colours[i]);
622 dlg_update_done(ctrl, dlg);
623 dlg_editbox_set(cd->redit, dlg, "");
624 dlg_editbox_set(cd->gedit, dlg, "");
625 dlg_editbox_set(cd->bedit, dlg, "");
627 } else if (event == EVENT_SELCHANGE) {
628 if (ctrl == cd->listbox) {
629 /* The user has selected a colour. Update the RGB text. */
630 int i = dlg_listbox_index(ctrl, dlg);
635 r = cfg->colours[i][0];
636 g = cfg->colours[i][1];
637 b = cfg->colours[i][2];
640 } else if (event == EVENT_VALCHANGE) {
641 if (ctrl == cd->redit || ctrl == cd->gedit || ctrl == cd->bedit) {
642 /* The user has changed the colour using the edit boxes. */
646 dlg_editbox_get(ctrl, dlg, buf, lenof(buf));
648 if (cval > 255) cval = 255;
649 if (cval < 0) cval = 0;
651 i = dlg_listbox_index(cd->listbox, dlg);
653 if (ctrl == cd->redit)
654 cfg->colours[i][0] = cval;
655 else if (ctrl == cd->gedit)
656 cfg->colours[i][1] = cval;
657 else if (ctrl == cd->bedit)
658 cfg->colours[i][2] = cval;
661 } else if (event == EVENT_ACTION) {
662 if (ctrl == cd->button) {
663 int i = dlg_listbox_index(cd->listbox, dlg);
669 * Start a colour selector, which will send us an
670 * EVENT_CALLBACK when it's finished and allow us to
671 * pick up the results.
673 dlg_coloursel_start(ctrl, dlg,
678 } else if (event == EVENT_CALLBACK) {
679 if (ctrl == cd->button) {
680 int i = dlg_listbox_index(cd->listbox, dlg);
682 * Collect the results of the colour selector. Will
683 * return nonzero on success, or zero if the colour
684 * selector did nothing (user hit Cancel, for example).
686 if (dlg_coloursel_results(ctrl, dlg, &r, &g, &b)) {
687 cfg->colours[i][0] = r;
688 cfg->colours[i][1] = g;
689 cfg->colours[i][2] = b;
697 sprintf(buf, "%d", r); dlg_editbox_set(cd->redit, dlg, buf);
698 sprintf(buf, "%d", g); dlg_editbox_set(cd->gedit, dlg, buf);
699 sprintf(buf, "%d", b); dlg_editbox_set(cd->bedit, dlg, buf);
703 struct ttymodes_data {
704 union control *modelist, *valradio, *valbox;
705 union control *addbutton, *rembutton, *listbox;
708 static void ttymodes_handler(union control *ctrl, void *dlg,
709 void *data, int event)
711 Config *cfg = (Config *)data;
712 struct ttymodes_data *td =
713 (struct ttymodes_data *)ctrl->generic.context.p;
715 if (event == EVENT_REFRESH) {
716 if (ctrl == td->listbox) {
717 char *p = cfg->ttymodes;
718 dlg_update_start(ctrl, dlg);
719 dlg_listbox_clear(ctrl, dlg);
721 int tabpos = strchr(p, '\t') - p;
722 char *disp = dupprintf("%.*s\t%s", tabpos, p,
723 (p[tabpos+1] == 'A') ? "(auto)" :
725 dlg_listbox_add(ctrl, dlg, disp);
729 dlg_update_done(ctrl, dlg);
730 } else if (ctrl == td->modelist) {
732 dlg_update_start(ctrl, dlg);
733 dlg_listbox_clear(ctrl, dlg);
734 for (i = 0; ttymodes[i]; i++)
735 dlg_listbox_add(ctrl, dlg, ttymodes[i]);
736 dlg_listbox_select(ctrl, dlg, 0); /* *shrug* */
737 dlg_update_done(ctrl, dlg);
738 } else if (ctrl == td->valradio) {
739 dlg_radiobutton_set(ctrl, dlg, 0);
741 } else if (event == EVENT_ACTION) {
742 if (ctrl == td->addbutton) {
743 int ind = dlg_listbox_index(td->modelist, dlg);
745 char type = dlg_radiobutton_get(td->valradio, dlg) ? 'V' : 'A';
747 char *p, str[lenof(cfg->ttymodes)];
748 /* Construct new entry */
749 memset(str, 0, lenof(str));
750 strncpy(str, ttymodes[ind], lenof(str)-3);
756 dlg_editbox_get(td->valbox, dlg, str+slen, lenof(str)-slen);
758 /* Find end of list, deleting any existing instance */
760 left = lenof(cfg->ttymodes);
762 int t = strchr(p, '\t') - p;
763 if (t == strlen(ttymodes[ind]) &&
764 strncmp(p, ttymodes[ind], t) == 0) {
765 memmove(p, p+strlen(p)+1, left - (strlen(p)+1));
768 left -= strlen(p) + 1;
771 /* Append new entry */
773 strncpy(p, str, left - 2);
774 dlg_refresh(td->listbox, dlg);
777 } else if (ctrl == td->rembutton) {
778 char *p = cfg->ttymodes;
779 int i = 0, len = lenof(cfg->ttymodes);
781 if (dlg_listbox_issel(td->listbox, dlg, i)) {
782 memmove(p, p+strlen(p)+1, len - (strlen(p)+1));
786 len -= strlen(p) + 1;
790 memset(p, 0, lenof(cfg->ttymodes) - len);
791 dlg_refresh(td->listbox, dlg);
796 struct environ_data {
797 union control *varbox, *valbox, *addbutton, *rembutton, *listbox;
800 static void environ_handler(union control *ctrl, void *dlg,
801 void *data, int event)
803 Config *cfg = (Config *)data;
804 struct environ_data *ed =
805 (struct environ_data *)ctrl->generic.context.p;
807 if (event == EVENT_REFRESH) {
808 if (ctrl == ed->listbox) {
809 char *p = cfg->environmt;
810 dlg_update_start(ctrl, dlg);
811 dlg_listbox_clear(ctrl, dlg);
813 dlg_listbox_add(ctrl, dlg, p);
816 dlg_update_done(ctrl, dlg);
818 } else if (event == EVENT_ACTION) {
819 if (ctrl == ed->addbutton) {
820 char str[sizeof(cfg->environmt)];
822 dlg_editbox_get(ed->varbox, dlg, str, sizeof(str)-1);
827 p = str + strlen(str);
829 dlg_editbox_get(ed->valbox, dlg, p, sizeof(str)-1 - (p - str));
840 if ((p - cfg->environmt) + strlen(str) + 2 <
841 sizeof(cfg->environmt)) {
843 p[strlen(str) + 1] = '\0';
844 dlg_listbox_add(ed->listbox, dlg, str);
845 dlg_editbox_set(ed->varbox, dlg, "");
846 dlg_editbox_set(ed->valbox, dlg, "");
848 dlg_error_msg(dlg, "Environment too big");
850 } else if (ctrl == ed->rembutton) {
851 int i = dlg_listbox_index(ed->listbox, dlg);
857 dlg_listbox_del(ed->listbox, dlg, i);
885 struct portfwd_data {
886 union control *addbutton, *rembutton, *listbox;
887 union control *sourcebox, *destbox, *direction;
889 union control *addressfamily;
893 static void portfwd_handler(union control *ctrl, void *dlg,
894 void *data, int event)
896 Config *cfg = (Config *)data;
897 struct portfwd_data *pfd =
898 (struct portfwd_data *)ctrl->generic.context.p;
900 if (event == EVENT_REFRESH) {
901 if (ctrl == pfd->listbox) {
902 char *p = cfg->portfwd;
903 dlg_update_start(ctrl, dlg);
904 dlg_listbox_clear(ctrl, dlg);
906 dlg_listbox_add(ctrl, dlg, p);
909 dlg_update_done(ctrl, dlg);
910 } else if (ctrl == pfd->direction) {
914 dlg_radiobutton_set(ctrl, dlg, 0);
916 } else if (ctrl == pfd->addressfamily) {
917 dlg_radiobutton_set(ctrl, dlg, 0);
920 } else if (event == EVENT_ACTION) {
921 if (ctrl == pfd->addbutton) {
922 char str[sizeof(cfg->portfwd)];
929 whichbutton = dlg_radiobutton_get(pfd->addressfamily, dlg);
930 if (whichbutton == 1)
932 else if (whichbutton == 2)
936 whichbutton = dlg_radiobutton_get(pfd->direction, dlg);
937 if (whichbutton == 0)
939 else if (whichbutton == 1)
945 dlg_editbox_get(pfd->sourcebox, dlg, str+i, sizeof(str) - i);
947 dlg_error_msg(dlg, "You need to specify a source port number");
950 p = str + strlen(str);
953 dlg_editbox_get(pfd->destbox, dlg, p,
954 sizeof(str) - (p - str));
955 if (!*p || !strchr(p, ':')) {
957 "You need to specify a destination address\n"
958 "in the form \"host.name:port\"");
969 if ((p - cfg->portfwd) + strlen(str) + 2 <=
970 sizeof(cfg->portfwd)) {
972 p[strlen(str) + 1] = '\0';
973 dlg_listbox_add(pfd->listbox, dlg, str);
974 dlg_editbox_set(pfd->sourcebox, dlg, "");
975 dlg_editbox_set(pfd->destbox, dlg, "");
977 dlg_error_msg(dlg, "Too many forwardings");
979 } else if (ctrl == pfd->rembutton) {
980 int i = dlg_listbox_index(pfd->listbox, dlg);
986 dlg_listbox_del(pfd->listbox, dlg, i);
1014 void setup_config_box(struct controlbox *b, int midsession,
1015 int protocol, int protcfginfo)
1017 struct controlset *s;
1018 struct sessionsaver_data *ssd;
1019 struct charclass_data *ccd;
1020 struct colour_data *cd;
1021 struct ttymodes_data *td;
1022 struct environ_data *ed;
1023 struct portfwd_data *pfd;
1027 ssd = (struct sessionsaver_data *)
1028 ctrl_alloc(b, sizeof(struct sessionsaver_data));
1029 memset(ssd, 0, sizeof(*ssd));
1030 ssd->midsession = midsession;
1033 * The standard panel that appears at the bottom of all panels:
1034 * Open, Cancel, Apply etc.
1036 s = ctrl_getset(b, "", "", "");
1037 ctrl_columns(s, 5, 20, 20, 20, 20, 20);
1038 ssd->okbutton = ctrl_pushbutton(s,
1039 (midsession ? "Apply" : "Open"),
1040 (char)(midsession ? 'a' : 'o'),
1042 sessionsaver_handler, P(ssd));
1043 ssd->okbutton->button.isdefault = TRUE;
1044 ssd->okbutton->generic.column = 3;
1045 ssd->cancelbutton = ctrl_pushbutton(s, "Cancel", 'c', HELPCTX(no_help),
1046 sessionsaver_handler, P(ssd));
1047 ssd->cancelbutton->button.iscancel = TRUE;
1048 ssd->cancelbutton->generic.column = 4;
1049 /* We carefully don't close the 5-column part, so that platform-
1050 * specific add-ons can put extra buttons alongside Open and Cancel. */
1053 * The Session panel.
1055 str = dupprintf("Basic options for your %s session", appname);
1056 ctrl_settitle(b, "Session", str);
1060 struct hostport *hp = (struct hostport *)
1061 ctrl_alloc(b, sizeof(struct hostport));
1064 s = ctrl_getset(b, "Session", "hostport",
1065 "Specify the destination you want to connect to");
1066 ctrl_columns(s, 2, 75, 25);
1067 c = ctrl_editbox(s, HOST_BOX_TITLE, 'n', 100,
1068 HELPCTX(session_hostname),
1069 config_host_handler, I(0), I(0));
1070 c->generic.column = 0;
1072 c = ctrl_editbox(s, PORT_BOX_TITLE, 'p', 100,
1073 HELPCTX(session_hostname),
1074 config_port_handler, I(0), I(0));
1075 c->generic.column = 1;
1077 ctrl_columns(s, 1, 100);
1080 for (i = 0; backends[i].name; i++)
1081 if (backends[i].protocol == PROT_SSH) {
1086 ctrl_radiobuttons(s, "Connection type:", NO_SHORTCUT, 3,
1087 HELPCTX(session_hostname),
1088 config_protocolbuttons_handler, P(hp),
1089 "Raw", 'r', I(PROT_RAW),
1090 "Telnet", 't', I(PROT_TELNET),
1091 "Rlogin", 'i', I(PROT_RLOGIN),
1094 ctrl_radiobuttons(s, "Connection type:", NO_SHORTCUT, 4,
1095 HELPCTX(session_hostname),
1096 config_protocolbuttons_handler, P(hp),
1097 "Raw", 'r', I(PROT_RAW),
1098 "Telnet", 't', I(PROT_TELNET),
1099 "Rlogin", 'i', I(PROT_RLOGIN),
1100 "SSH", 's', I(PROT_SSH),
1106 * The Load/Save panel is available even in mid-session.
1108 s = ctrl_getset(b, "Session", "savedsessions",
1109 midsession ? "Save the current session settings" :
1110 "Load, save or delete a stored session");
1111 ctrl_columns(s, 2, 75, 25);
1112 get_sesslist(&ssd->sesslist, TRUE);
1113 ssd->editbox = ctrl_editbox(s, "Saved Sessions", 'e', 100,
1114 HELPCTX(session_saved),
1115 sessionsaver_handler, P(ssd), P(NULL));
1116 ssd->editbox->generic.column = 0;
1117 /* Reset columns so that the buttons are alongside the list, rather
1118 * than alongside that edit box. */
1119 ctrl_columns(s, 1, 100);
1120 ctrl_columns(s, 2, 75, 25);
1121 ssd->listbox = ctrl_listbox(s, NULL, NO_SHORTCUT,
1122 HELPCTX(session_saved),
1123 sessionsaver_handler, P(ssd));
1124 ssd->listbox->generic.column = 0;
1125 ssd->listbox->listbox.height = 7;
1127 ssd->loadbutton = ctrl_pushbutton(s, "Load", 'l',
1128 HELPCTX(session_saved),
1129 sessionsaver_handler, P(ssd));
1130 ssd->loadbutton->generic.column = 1;
1132 /* We can't offer the Load button mid-session, as it would allow the
1133 * user to load and subsequently save settings they can't see. (And
1134 * also change otherwise immutable settings underfoot; that probably
1135 * shouldn't be a problem, but.) */
1136 ssd->loadbutton = NULL;
1138 /* "Save" button is permitted mid-session. */
1139 ssd->savebutton = ctrl_pushbutton(s, "Save", 'v',
1140 HELPCTX(session_saved),
1141 sessionsaver_handler, P(ssd));
1142 ssd->savebutton->generic.column = 1;
1144 ssd->delbutton = ctrl_pushbutton(s, "Delete", 'd',
1145 HELPCTX(session_saved),
1146 sessionsaver_handler, P(ssd));
1147 ssd->delbutton->generic.column = 1;
1149 /* Disable the Delete button mid-session too, for UI consistency. */
1150 ssd->delbutton = NULL;
1152 ctrl_columns(s, 1, 100);
1154 s = ctrl_getset(b, "Session", "otheropts", NULL);
1155 c = ctrl_radiobuttons(s, "Close window on exit:", 'w', 4,
1156 HELPCTX(session_coe),
1157 dlg_stdradiobutton_handler,
1158 I(offsetof(Config, close_on_exit)),
1159 "Always", I(FORCE_ON),
1160 "Never", I(FORCE_OFF),
1161 "Only on clean exit", I(AUTO), NULL);
1164 * The Session/Logging panel.
1166 ctrl_settitle(b, "Session/Logging", "Options controlling session logging");
1168 s = ctrl_getset(b, "Session/Logging", "main", NULL);
1170 * The logging buttons change depending on whether SSH packet
1171 * logging can sensibly be available.
1175 if ((midsession && protocol == PROT_SSH) ||
1176 (!midsession && backends[3].name != NULL))
1177 sshlogname = "Log SSH packet data";
1179 sshlogname = NULL; /* this will disable the button */
1180 ctrl_radiobuttons(s, "Session logging:", NO_SHORTCUT, 1,
1181 HELPCTX(logging_main),
1182 loggingbuttons_handler,
1183 I(offsetof(Config, logtype)),
1184 "Logging turned off completely", 't', I(LGTYP_NONE),
1185 "Log printable output only", 'p', I(LGTYP_ASCII),
1186 "Log all session output", 'l', I(LGTYP_DEBUG),
1187 sshlogname, 's', I(LGTYP_PACKETS),
1190 ctrl_filesel(s, "Log file name:", 'f',
1191 NULL, TRUE, "Select session log file name",
1192 HELPCTX(logging_filename),
1193 dlg_stdfilesel_handler, I(offsetof(Config, logfilename)));
1194 ctrl_text(s, "(Log file name can contain &Y, &M, &D for date,"
1195 " &T for time, and &H for host name)",
1196 HELPCTX(logging_filename));
1197 ctrl_radiobuttons(s, "What to do if the log file already exists:", 'e', 1,
1198 HELPCTX(logging_exists),
1199 dlg_stdradiobutton_handler, I(offsetof(Config,logxfovr)),
1200 "Always overwrite it", I(LGXF_OVR),
1201 "Always append to the end of it", I(LGXF_APN),
1202 "Ask the user every time", I(LGXF_ASK), NULL);
1203 ctrl_checkbox(s, "Flush log file frequently", 'u',
1204 HELPCTX(logging_flush),
1205 dlg_stdcheckbox_handler, I(offsetof(Config,logflush)));
1207 if ((midsession && protocol == PROT_SSH) ||
1208 (!midsession && backends[3].name != NULL)) {
1209 s = ctrl_getset(b, "Session/Logging", "ssh",
1210 "Options specific to SSH packet logging");
1211 ctrl_checkbox(s, "Omit known password fields", 'k',
1212 HELPCTX(logging_ssh_omit_password),
1213 dlg_stdcheckbox_handler, I(offsetof(Config,logomitpass)));
1214 ctrl_checkbox(s, "Omit session data", 'd',
1215 HELPCTX(logging_ssh_omit_data),
1216 dlg_stdcheckbox_handler, I(offsetof(Config,logomitdata)));
1220 * The Terminal panel.
1222 ctrl_settitle(b, "Terminal", "Options controlling the terminal emulation");
1224 s = ctrl_getset(b, "Terminal", "general", "Set various terminal options");
1225 ctrl_checkbox(s, "Auto wrap mode initially on", 'w',
1226 HELPCTX(terminal_autowrap),
1227 dlg_stdcheckbox_handler, I(offsetof(Config,wrap_mode)));
1228 ctrl_checkbox(s, "DEC Origin Mode initially on", 'd',
1229 HELPCTX(terminal_decom),
1230 dlg_stdcheckbox_handler, I(offsetof(Config,dec_om)));
1231 ctrl_checkbox(s, "Implicit CR in every LF", 'r',
1232 HELPCTX(terminal_lfhascr),
1233 dlg_stdcheckbox_handler, I(offsetof(Config,lfhascr)));
1234 ctrl_checkbox(s, "Use background colour to erase screen", 'e',
1235 HELPCTX(terminal_bce),
1236 dlg_stdcheckbox_handler, I(offsetof(Config,bce)));
1237 ctrl_checkbox(s, "Enable blinking text", 'n',
1238 HELPCTX(terminal_blink),
1239 dlg_stdcheckbox_handler, I(offsetof(Config,blinktext)));
1240 ctrl_editbox(s, "Answerback to ^E:", 's', 100,
1241 HELPCTX(terminal_answerback),
1242 dlg_stdeditbox_handler, I(offsetof(Config,answerback)),
1243 I(sizeof(((Config *)0)->answerback)));
1245 s = ctrl_getset(b, "Terminal", "ldisc", "Line discipline options");
1246 ctrl_radiobuttons(s, "Local echo:", 'l', 3,
1247 HELPCTX(terminal_localecho),
1248 dlg_stdradiobutton_handler,I(offsetof(Config,localecho)),
1250 "Force on", I(FORCE_ON),
1251 "Force off", I(FORCE_OFF), NULL);
1252 ctrl_radiobuttons(s, "Local line editing:", 't', 3,
1253 HELPCTX(terminal_localedit),
1254 dlg_stdradiobutton_handler,I(offsetof(Config,localedit)),
1256 "Force on", I(FORCE_ON),
1257 "Force off", I(FORCE_OFF), NULL);
1259 s = ctrl_getset(b, "Terminal", "printing", "Remote-controlled printing");
1260 ctrl_combobox(s, "Printer to send ANSI printer output to:", 'p', 100,
1261 HELPCTX(terminal_printing),
1262 printerbox_handler, P(NULL), P(NULL));
1265 * The Terminal/Keyboard panel.
1267 ctrl_settitle(b, "Terminal/Keyboard",
1268 "Options controlling the effects of keys");
1270 s = ctrl_getset(b, "Terminal/Keyboard", "mappings",
1271 "Change the sequences sent by:");
1272 ctrl_radiobuttons(s, "The Backspace key", 'b', 2,
1273 HELPCTX(keyboard_backspace),
1274 dlg_stdradiobutton_handler,
1275 I(offsetof(Config, bksp_is_delete)),
1276 "Control-H", I(0), "Control-? (127)", I(1), NULL);
1277 ctrl_radiobuttons(s, "The Home and End keys", 'e', 2,
1278 HELPCTX(keyboard_homeend),
1279 dlg_stdradiobutton_handler,
1280 I(offsetof(Config, rxvt_homeend)),
1281 "Standard", I(0), "rxvt", I(1), NULL);
1282 ctrl_radiobuttons(s, "The Function keys and keypad", 'f', 3,
1283 HELPCTX(keyboard_funkeys),
1284 dlg_stdradiobutton_handler,
1285 I(offsetof(Config, funky_type)),
1286 "ESC[n~", I(0), "Linux", I(1), "Xterm R6", I(2),
1287 "VT400", I(3), "VT100+", I(4), "SCO", I(5), NULL);
1289 s = ctrl_getset(b, "Terminal/Keyboard", "appkeypad",
1290 "Application keypad settings:");
1291 ctrl_radiobuttons(s, "Initial state of cursor keys:", 'r', 3,
1292 HELPCTX(keyboard_appcursor),
1293 dlg_stdradiobutton_handler,
1294 I(offsetof(Config, app_cursor)),
1295 "Normal", I(0), "Application", I(1), NULL);
1296 ctrl_radiobuttons(s, "Initial state of numeric keypad:", 'n', 3,
1297 HELPCTX(keyboard_appkeypad),
1298 numeric_keypad_handler, P(NULL),
1299 "Normal", I(0), "Application", I(1), "NetHack", I(2),
1303 * The Terminal/Bell panel.
1305 ctrl_settitle(b, "Terminal/Bell",
1306 "Options controlling the terminal bell");
1308 s = ctrl_getset(b, "Terminal/Bell", "style", "Set the style of bell");
1309 ctrl_radiobuttons(s, "Action to happen when a bell occurs:", 'b', 1,
1310 HELPCTX(bell_style),
1311 dlg_stdradiobutton_handler, I(offsetof(Config, beep)),
1312 "None (bell disabled)", I(BELL_DISABLED),
1313 "Make default system alert sound", I(BELL_DEFAULT),
1314 "Visual bell (flash window)", I(BELL_VISUAL), NULL);
1316 s = ctrl_getset(b, "Terminal/Bell", "overload",
1317 "Control the bell overload behaviour");
1318 ctrl_checkbox(s, "Bell is temporarily disabled when over-used", 'd',
1319 HELPCTX(bell_overload),
1320 dlg_stdcheckbox_handler, I(offsetof(Config,bellovl)));
1321 ctrl_editbox(s, "Over-use means this many bells...", 'm', 20,
1322 HELPCTX(bell_overload),
1323 dlg_stdeditbox_handler, I(offsetof(Config,bellovl_n)), I(-1));
1324 ctrl_editbox(s, "... in this many seconds", 't', 20,
1325 HELPCTX(bell_overload),
1326 dlg_stdeditbox_handler, I(offsetof(Config,bellovl_t)),
1328 ctrl_text(s, "The bell is re-enabled after a few seconds of silence.",
1329 HELPCTX(bell_overload));
1330 ctrl_editbox(s, "Seconds of silence required", 's', 20,
1331 HELPCTX(bell_overload),
1332 dlg_stdeditbox_handler, I(offsetof(Config,bellovl_s)),
1336 * The Terminal/Features panel.
1338 ctrl_settitle(b, "Terminal/Features",
1339 "Enabling and disabling advanced terminal features");
1341 s = ctrl_getset(b, "Terminal/Features", "main", NULL);
1342 ctrl_checkbox(s, "Disable application cursor keys mode", 'u',
1343 HELPCTX(features_application),
1344 dlg_stdcheckbox_handler, I(offsetof(Config,no_applic_c)));
1345 ctrl_checkbox(s, "Disable application keypad mode", 'k',
1346 HELPCTX(features_application),
1347 dlg_stdcheckbox_handler, I(offsetof(Config,no_applic_k)));
1348 ctrl_checkbox(s, "Disable xterm-style mouse reporting", 'x',
1349 HELPCTX(features_mouse),
1350 dlg_stdcheckbox_handler, I(offsetof(Config,no_mouse_rep)));
1351 ctrl_checkbox(s, "Disable remote-controlled terminal resizing", 's',
1352 HELPCTX(features_resize),
1353 dlg_stdcheckbox_handler,
1354 I(offsetof(Config,no_remote_resize)));
1355 ctrl_checkbox(s, "Disable switching to alternate terminal screen", 'w',
1356 HELPCTX(features_altscreen),
1357 dlg_stdcheckbox_handler, I(offsetof(Config,no_alt_screen)));
1358 ctrl_checkbox(s, "Disable remote-controlled window title changing", 't',
1359 HELPCTX(features_retitle),
1360 dlg_stdcheckbox_handler,
1361 I(offsetof(Config,no_remote_wintitle)));
1362 ctrl_checkbox(s, "Disable remote window title querying (SECURITY)",
1363 'q', HELPCTX(features_qtitle), dlg_stdcheckbox_handler,
1364 I(offsetof(Config,no_remote_qtitle)));
1365 ctrl_checkbox(s, "Disable destructive backspace on server sending ^?",'b',
1366 HELPCTX(features_dbackspace),
1367 dlg_stdcheckbox_handler, I(offsetof(Config,no_dbackspace)));
1368 ctrl_checkbox(s, "Disable remote-controlled character set configuration",
1369 'r', HELPCTX(features_charset), dlg_stdcheckbox_handler,
1370 I(offsetof(Config,no_remote_charset)));
1371 ctrl_checkbox(s, "Disable Arabic text shaping",
1372 'l', HELPCTX(features_arabicshaping), dlg_stdcheckbox_handler,
1373 I(offsetof(Config, arabicshaping)));
1374 ctrl_checkbox(s, "Disable bidirectional text display",
1375 'd', HELPCTX(features_bidi), dlg_stdcheckbox_handler,
1376 I(offsetof(Config, bidi)));
1381 str = dupprintf("Options controlling %s's window", appname);
1382 ctrl_settitle(b, "Window", str);
1385 s = ctrl_getset(b, "Window", "size", "Set the size of the window");
1386 ctrl_columns(s, 2, 50, 50);
1387 c = ctrl_editbox(s, "Rows", 'r', 100,
1388 HELPCTX(window_size),
1389 dlg_stdeditbox_handler, I(offsetof(Config,height)),I(-1));
1390 c->generic.column = 0;
1391 c = ctrl_editbox(s, "Columns", 'm', 100,
1392 HELPCTX(window_size),
1393 dlg_stdeditbox_handler, I(offsetof(Config,width)), I(-1));
1394 c->generic.column = 1;
1395 ctrl_columns(s, 1, 100);
1397 s = ctrl_getset(b, "Window", "scrollback",
1398 "Control the scrollback in the window");
1399 ctrl_editbox(s, "Lines of scrollback", 's', 50,
1400 HELPCTX(window_scrollback),
1401 dlg_stdeditbox_handler, I(offsetof(Config,savelines)), I(-1));
1402 ctrl_checkbox(s, "Display scrollbar", 'd',
1403 HELPCTX(window_scrollback),
1404 dlg_stdcheckbox_handler, I(offsetof(Config,scrollbar)));
1405 ctrl_checkbox(s, "Reset scrollback on keypress", 'k',
1406 HELPCTX(window_scrollback),
1407 dlg_stdcheckbox_handler, I(offsetof(Config,scroll_on_key)));
1408 ctrl_checkbox(s, "Reset scrollback on display activity", 'p',
1409 HELPCTX(window_scrollback),
1410 dlg_stdcheckbox_handler, I(offsetof(Config,scroll_on_disp)));
1411 ctrl_checkbox(s, "Push erased text into scrollback", 'e',
1412 HELPCTX(window_erased),
1413 dlg_stdcheckbox_handler,
1414 I(offsetof(Config,erase_to_scrollback)));
1417 * The Window/Appearance panel.
1419 str = dupprintf("Configure the appearance of %s's window", appname);
1420 ctrl_settitle(b, "Window/Appearance", str);
1423 s = ctrl_getset(b, "Window/Appearance", "cursor",
1424 "Adjust the use of the cursor");
1425 ctrl_radiobuttons(s, "Cursor appearance:", NO_SHORTCUT, 3,
1426 HELPCTX(appearance_cursor),
1427 dlg_stdradiobutton_handler,
1428 I(offsetof(Config, cursor_type)),
1430 "Underline", 'u', I(1),
1431 "Vertical line", 'v', I(2), NULL);
1432 ctrl_checkbox(s, "Cursor blinks", 'b',
1433 HELPCTX(appearance_cursor),
1434 dlg_stdcheckbox_handler, I(offsetof(Config,blink_cur)));
1436 s = ctrl_getset(b, "Window/Appearance", "font",
1438 ctrl_fontsel(s, "Font used in the terminal window", 'n',
1439 HELPCTX(appearance_font),
1440 dlg_stdfontsel_handler, I(offsetof(Config, font)));
1442 s = ctrl_getset(b, "Window/Appearance", "mouse",
1443 "Adjust the use of the mouse pointer");
1444 ctrl_checkbox(s, "Hide mouse pointer when typing in window", 'p',
1445 HELPCTX(appearance_hidemouse),
1446 dlg_stdcheckbox_handler, I(offsetof(Config,hide_mouseptr)));
1448 s = ctrl_getset(b, "Window/Appearance", "border",
1449 "Adjust the window border");
1450 ctrl_editbox(s, "Gap between text and window edge:", 'e', 20,
1451 HELPCTX(appearance_border),
1452 dlg_stdeditbox_handler,
1453 I(offsetof(Config,window_border)), I(-1));
1456 * The Window/Behaviour panel.
1458 str = dupprintf("Configure the behaviour of %s's window", appname);
1459 ctrl_settitle(b, "Window/Behaviour", str);
1462 s = ctrl_getset(b, "Window/Behaviour", "title",
1463 "Adjust the behaviour of the window title");
1464 ctrl_editbox(s, "Window title:", 't', 100,
1465 HELPCTX(appearance_title),
1466 dlg_stdeditbox_handler, I(offsetof(Config,wintitle)),
1467 I(sizeof(((Config *)0)->wintitle)));
1468 ctrl_checkbox(s, "Separate window and icon titles", 'i',
1469 HELPCTX(appearance_title),
1470 dlg_stdcheckbox_handler,
1471 I(CHECKBOX_INVERT | offsetof(Config,win_name_always)));
1473 s = ctrl_getset(b, "Window/Behaviour", "main", NULL);
1474 ctrl_checkbox(s, "Warn before closing window", 'w',
1475 HELPCTX(behaviour_closewarn),
1476 dlg_stdcheckbox_handler, I(offsetof(Config,warn_on_close)));
1479 * The Window/Translation panel.
1481 ctrl_settitle(b, "Window/Translation",
1482 "Options controlling character set translation");
1484 s = ctrl_getset(b, "Window/Translation", "trans",
1485 "Character set translation on received data");
1486 ctrl_combobox(s, "Received data assumed to be in which character set:",
1487 'r', 100, HELPCTX(translation_codepage),
1488 codepage_handler, P(NULL), P(NULL));
1490 s = ctrl_getset(b, "Window/Translation", "tweaks", NULL);
1491 ctrl_checkbox(s, "Treat CJK ambiguous characters as wide", 'w',
1492 HELPCTX(translation_cjk_ambig_wide),
1493 dlg_stdcheckbox_handler, I(offsetof(Config,cjk_ambig_wide)));
1495 str = dupprintf("Adjust how %s handles line drawing characters", appname);
1496 s = ctrl_getset(b, "Window/Translation", "linedraw", str);
1498 ctrl_radiobuttons(s, "Handling of line drawing characters:", NO_SHORTCUT,1,
1499 HELPCTX(translation_linedraw),
1500 dlg_stdradiobutton_handler,
1501 I(offsetof(Config, vtmode)),
1502 "Use Unicode line drawing code points",'u',I(VT_UNICODE),
1503 "Poor man's line drawing (+, - and |)",'p',I(VT_POORMAN),
1505 ctrl_checkbox(s, "Copy and paste line drawing characters as lqqqk",'d',
1506 HELPCTX(selection_linedraw),
1507 dlg_stdcheckbox_handler, I(offsetof(Config,rawcnp)));
1510 * The Window/Selection panel.
1512 ctrl_settitle(b, "Window/Selection", "Options controlling copy and paste");
1514 s = ctrl_getset(b, "Window/Selection", "mouse",
1515 "Control use of mouse");
1516 ctrl_checkbox(s, "Shift overrides application's use of mouse", 'p',
1517 HELPCTX(selection_shiftdrag),
1518 dlg_stdcheckbox_handler, I(offsetof(Config,mouse_override)));
1519 ctrl_radiobuttons(s,
1520 "Default selection mode (Alt+drag does the other one):",
1522 HELPCTX(selection_rect),
1523 dlg_stdradiobutton_handler,
1524 I(offsetof(Config, rect_select)),
1525 "Normal", 'n', I(0),
1526 "Rectangular block", 'r', I(1), NULL);
1528 s = ctrl_getset(b, "Window/Selection", "charclass",
1529 "Control the select-one-word-at-a-time mode");
1530 ccd = (struct charclass_data *)
1531 ctrl_alloc(b, sizeof(struct charclass_data));
1532 ccd->listbox = ctrl_listbox(s, "Character classes:", 'e',
1533 HELPCTX(selection_charclasses),
1534 charclass_handler, P(ccd));
1535 ccd->listbox->listbox.multisel = 1;
1536 ccd->listbox->listbox.ncols = 4;
1537 ccd->listbox->listbox.percentages = snewn(4, int);
1538 ccd->listbox->listbox.percentages[0] = 15;
1539 ccd->listbox->listbox.percentages[1] = 25;
1540 ccd->listbox->listbox.percentages[2] = 20;
1541 ccd->listbox->listbox.percentages[3] = 40;
1542 ctrl_columns(s, 2, 67, 33);
1543 ccd->editbox = ctrl_editbox(s, "Set to class", 't', 50,
1544 HELPCTX(selection_charclasses),
1545 charclass_handler, P(ccd), P(NULL));
1546 ccd->editbox->generic.column = 0;
1547 ccd->button = ctrl_pushbutton(s, "Set", 's',
1548 HELPCTX(selection_charclasses),
1549 charclass_handler, P(ccd));
1550 ccd->button->generic.column = 1;
1551 ctrl_columns(s, 1, 100);
1554 * The Window/Colours panel.
1556 ctrl_settitle(b, "Window/Colours", "Options controlling use of colours");
1558 s = ctrl_getset(b, "Window/Colours", "general",
1559 "General options for colour usage");
1560 ctrl_checkbox(s, "Allow terminal to specify ANSI colours", 'i',
1561 HELPCTX(colours_ansi),
1562 dlg_stdcheckbox_handler, I(offsetof(Config,ansi_colour)));
1563 ctrl_checkbox(s, "Allow terminal to use xterm 256-colour mode", '2',
1564 HELPCTX(colours_xterm256), dlg_stdcheckbox_handler,
1565 I(offsetof(Config,xterm_256_colour)));
1566 ctrl_checkbox(s, "Bolded text is a different colour", 'b',
1567 HELPCTX(colours_bold),
1568 dlg_stdcheckbox_handler, I(offsetof(Config,bold_colour)));
1570 str = dupprintf("Adjust the precise colours %s displays", appname);
1571 s = ctrl_getset(b, "Window/Colours", "adjust", str);
1573 ctrl_text(s, "Select a colour from the list, and then click the"
1574 " Modify button to change its appearance.",
1575 HELPCTX(colours_config));
1576 ctrl_columns(s, 2, 67, 33);
1577 cd = (struct colour_data *)ctrl_alloc(b, sizeof(struct colour_data));
1578 cd->listbox = ctrl_listbox(s, "Select a colour to adjust:", 'u',
1579 HELPCTX(colours_config), colour_handler, P(cd));
1580 cd->listbox->generic.column = 0;
1581 cd->listbox->listbox.height = 7;
1582 c = ctrl_text(s, "RGB value:", HELPCTX(colours_config));
1583 c->generic.column = 1;
1584 cd->redit = ctrl_editbox(s, "Red", 'r', 50, HELPCTX(colours_config),
1585 colour_handler, P(cd), P(NULL));
1586 cd->redit->generic.column = 1;
1587 cd->gedit = ctrl_editbox(s, "Green", 'n', 50, HELPCTX(colours_config),
1588 colour_handler, P(cd), P(NULL));
1589 cd->gedit->generic.column = 1;
1590 cd->bedit = ctrl_editbox(s, "Blue", 'e', 50, HELPCTX(colours_config),
1591 colour_handler, P(cd), P(NULL));
1592 cd->bedit->generic.column = 1;
1593 cd->button = ctrl_pushbutton(s, "Modify", 'm', HELPCTX(colours_config),
1594 colour_handler, P(cd));
1595 cd->button->generic.column = 1;
1596 ctrl_columns(s, 1, 100);
1599 * The Connection panel. This doesn't show up if we're in a
1600 * non-network utility such as pterm. We tell this by being
1601 * passed a protocol < 0.
1603 if (protocol >= 0) {
1604 ctrl_settitle(b, "Connection", "Options controlling the connection");
1606 s = ctrl_getset(b, "Connection", "keepalive",
1607 "Sending of null packets to keep session active");
1608 ctrl_editbox(s, "Seconds between keepalives (0 to turn off)", 'k', 20,
1609 HELPCTX(connection_keepalive),
1610 dlg_stdeditbox_handler, I(offsetof(Config,ping_interval)),
1614 s = ctrl_getset(b, "Connection", "tcp",
1615 "Low-level TCP connection options");
1616 ctrl_checkbox(s, "Disable Nagle's algorithm (TCP_NODELAY option)",
1617 'n', HELPCTX(connection_nodelay),
1618 dlg_stdcheckbox_handler,
1619 I(offsetof(Config,tcp_nodelay)));
1620 ctrl_checkbox(s, "Enable TCP keepalives (SO_KEEPALIVE option)",
1621 'p', HELPCTX(connection_tcpkeepalive),
1622 dlg_stdcheckbox_handler,
1623 I(offsetof(Config,tcp_keepalives)));
1625 s = ctrl_getset(b, "Connection", "ipversion",
1626 "Internet protocol version");
1627 ctrl_radiobuttons(s, NULL, NO_SHORTCUT, 3,
1628 HELPCTX(connection_ipversion),
1629 dlg_stdradiobutton_handler,
1630 I(offsetof(Config, addressfamily)),
1631 "Auto", 'u', I(ADDRTYPE_UNSPEC),
1632 "IPv4", '4', I(ADDRTYPE_IPV4),
1633 "IPv6", '6', I(ADDRTYPE_IPV6),
1639 * A sub-panel Connection/Data, containing options that
1640 * decide on data to send to the server.
1643 ctrl_settitle(b, "Connection/Data", "Data to send to the server");
1645 s = ctrl_getset(b, "Connection/Data", "login",
1647 ctrl_editbox(s, "Auto-login username", 'u', 50,
1648 HELPCTX(connection_username),
1649 dlg_stdeditbox_handler, I(offsetof(Config,username)),
1650 I(sizeof(((Config *)0)->username)));
1652 s = ctrl_getset(b, "Connection/Data", "term",
1653 "Terminal details");
1654 ctrl_editbox(s, "Terminal-type string", 't', 50,
1655 HELPCTX(connection_termtype),
1656 dlg_stdeditbox_handler, I(offsetof(Config,termtype)),
1657 I(sizeof(((Config *)0)->termtype)));
1658 ctrl_editbox(s, "Terminal speeds", 's', 50,
1659 HELPCTX(connection_termspeed),
1660 dlg_stdeditbox_handler, I(offsetof(Config,termspeed)),
1661 I(sizeof(((Config *)0)->termspeed)));
1663 s = ctrl_getset(b, "Connection/Data", "env",
1664 "Environment variables");
1665 ctrl_columns(s, 2, 80, 20);
1666 ed = (struct environ_data *)
1667 ctrl_alloc(b, sizeof(struct environ_data));
1668 ed->varbox = ctrl_editbox(s, "Variable", 'v', 60,
1669 HELPCTX(telnet_environ),
1670 environ_handler, P(ed), P(NULL));
1671 ed->varbox->generic.column = 0;
1672 ed->valbox = ctrl_editbox(s, "Value", 'l', 60,
1673 HELPCTX(telnet_environ),
1674 environ_handler, P(ed), P(NULL));
1675 ed->valbox->generic.column = 0;
1676 ed->addbutton = ctrl_pushbutton(s, "Add", 'd',
1677 HELPCTX(telnet_environ),
1678 environ_handler, P(ed));
1679 ed->addbutton->generic.column = 1;
1680 ed->rembutton = ctrl_pushbutton(s, "Remove", 'r',
1681 HELPCTX(telnet_environ),
1682 environ_handler, P(ed));
1683 ed->rembutton->generic.column = 1;
1684 ctrl_columns(s, 1, 100);
1685 ed->listbox = ctrl_listbox(s, NULL, NO_SHORTCUT,
1686 HELPCTX(telnet_environ),
1687 environ_handler, P(ed));
1688 ed->listbox->listbox.height = 3;
1689 ed->listbox->listbox.ncols = 2;
1690 ed->listbox->listbox.percentages = snewn(2, int);
1691 ed->listbox->listbox.percentages[0] = 30;
1692 ed->listbox->listbox.percentages[1] = 70;
1699 * The Connection/Proxy panel.
1701 ctrl_settitle(b, "Connection/Proxy",
1702 "Options controlling proxy usage");
1704 s = ctrl_getset(b, "Connection/Proxy", "basics", NULL);
1705 ctrl_radiobuttons(s, "Proxy type:", 't', 3,
1706 HELPCTX(proxy_type),
1707 dlg_stdradiobutton_handler,
1708 I(offsetof(Config, proxy_type)),
1709 "None", I(PROXY_NONE),
1710 "SOCKS 4", I(PROXY_SOCKS4),
1711 "SOCKS 5", I(PROXY_SOCKS5),
1712 "HTTP", I(PROXY_HTTP),
1713 "Telnet", I(PROXY_TELNET),
1715 ctrl_columns(s, 2, 80, 20);
1716 c = ctrl_editbox(s, "Proxy hostname", 'y', 100,
1717 HELPCTX(proxy_main),
1718 dlg_stdeditbox_handler,
1719 I(offsetof(Config,proxy_host)),
1720 I(sizeof(((Config *)0)->proxy_host)));
1721 c->generic.column = 0;
1722 c = ctrl_editbox(s, "Port", 'p', 100,
1723 HELPCTX(proxy_main),
1724 dlg_stdeditbox_handler,
1725 I(offsetof(Config,proxy_port)),
1727 c->generic.column = 1;
1728 ctrl_columns(s, 1, 100);
1729 ctrl_editbox(s, "Exclude Hosts/IPs", 'e', 100,
1730 HELPCTX(proxy_exclude),
1731 dlg_stdeditbox_handler,
1732 I(offsetof(Config,proxy_exclude_list)),
1733 I(sizeof(((Config *)0)->proxy_exclude_list)));
1734 ctrl_checkbox(s, "Consider proxying local host connections", 'x',
1735 HELPCTX(proxy_exclude),
1736 dlg_stdcheckbox_handler,
1737 I(offsetof(Config,even_proxy_localhost)));
1738 ctrl_radiobuttons(s, "Do DNS name lookup at proxy end:", 'd', 3,
1740 dlg_stdradiobutton_handler,
1741 I(offsetof(Config, proxy_dns)),
1744 "Yes", I(FORCE_ON), NULL);
1745 ctrl_editbox(s, "Username", 'u', 60,
1746 HELPCTX(proxy_auth),
1747 dlg_stdeditbox_handler,
1748 I(offsetof(Config,proxy_username)),
1749 I(sizeof(((Config *)0)->proxy_username)));
1750 c = ctrl_editbox(s, "Password", 'w', 60,
1751 HELPCTX(proxy_auth),
1752 dlg_stdeditbox_handler,
1753 I(offsetof(Config,proxy_password)),
1754 I(sizeof(((Config *)0)->proxy_password)));
1755 c->editbox.password = 1;
1756 ctrl_editbox(s, "Telnet command", 'm', 100,
1757 HELPCTX(proxy_command),
1758 dlg_stdeditbox_handler,
1759 I(offsetof(Config,proxy_telnet_command)),
1760 I(sizeof(((Config *)0)->proxy_telnet_command)));
1764 * The Telnet panel exists in the base config box, and in a
1765 * mid-session reconfig box _if_ we're using Telnet.
1767 if (!midsession || protocol == PROT_TELNET) {
1769 * The Connection/Telnet panel.
1771 ctrl_settitle(b, "Connection/Telnet",
1772 "Options controlling Telnet connections");
1774 s = ctrl_getset(b, "Connection/Telnet", "protocol",
1775 "Telnet protocol adjustments");
1778 ctrl_radiobuttons(s, "Handling of OLD_ENVIRON ambiguity:",
1780 HELPCTX(telnet_oldenviron),
1781 dlg_stdradiobutton_handler,
1782 I(offsetof(Config, rfc_environ)),
1783 "BSD (commonplace)", 'b', I(0),
1784 "RFC 1408 (unusual)", 'f', I(1), NULL);
1785 ctrl_radiobuttons(s, "Telnet negotiation mode:", 't', 2,
1786 HELPCTX(telnet_passive),
1787 dlg_stdradiobutton_handler,
1788 I(offsetof(Config, passive_telnet)),
1789 "Passive", I(1), "Active", I(0), NULL);
1791 ctrl_checkbox(s, "Keyboard sends Telnet special commands", 'k',
1792 HELPCTX(telnet_specialkeys),
1793 dlg_stdcheckbox_handler,
1794 I(offsetof(Config,telnet_keyboard)));
1795 ctrl_checkbox(s, "Return key sends Telnet New Line instead of ^M",
1796 'm', HELPCTX(telnet_newline),
1797 dlg_stdcheckbox_handler,
1798 I(offsetof(Config,telnet_newline)));
1804 * The Connection/Rlogin panel.
1806 ctrl_settitle(b, "Connection/Rlogin",
1807 "Options controlling Rlogin connections");
1809 s = ctrl_getset(b, "Connection/Rlogin", "data",
1810 "Data to send to the server");
1811 ctrl_editbox(s, "Local username:", 'l', 50,
1812 HELPCTX(rlogin_localuser),
1813 dlg_stdeditbox_handler, I(offsetof(Config,localusername)),
1814 I(sizeof(((Config *)0)->localusername)));
1819 * All the SSH stuff is omitted in PuTTYtel, or in a reconfig
1820 * when we're not doing SSH.
1823 if (backends[3].name != NULL && (!midsession || protocol == PROT_SSH)) {
1826 * The Connection/SSH panel.
1828 ctrl_settitle(b, "Connection/SSH",
1829 "Options controlling SSH connections");
1831 if (midsession && protcfginfo == 1) {
1832 s = ctrl_getset(b, "Connection/SSH", "disclaimer", NULL);
1833 ctrl_text(s, "Nothing on this panel may be reconfigured in mid-"
1834 "session; it is only here so that sub-panels of it can "
1835 "exist without looking strange.", HELPCTX(no_help));
1840 s = ctrl_getset(b, "Connection/SSH", "data",
1841 "Data to send to the server");
1842 ctrl_editbox(s, "Remote command:", 'r', 100,
1843 HELPCTX(ssh_command),
1844 dlg_stdeditbox_handler, I(offsetof(Config,remote_cmd)),
1845 I(sizeof(((Config *)0)->remote_cmd)));
1847 s = ctrl_getset(b, "Connection/SSH", "protocol", "Protocol options");
1848 ctrl_checkbox(s, "Don't start a shell or command at all", 'n',
1849 HELPCTX(ssh_noshell),
1850 dlg_stdcheckbox_handler,
1851 I(offsetof(Config,ssh_no_shell)));
1854 if (!midsession || protcfginfo != 1) {
1855 s = ctrl_getset(b, "Connection/SSH", "protocol", "Protocol options");
1857 ctrl_checkbox(s, "Enable compression", 'e',
1858 HELPCTX(ssh_compress),
1859 dlg_stdcheckbox_handler,
1860 I(offsetof(Config,compression)));
1864 s = ctrl_getset(b, "Connection/SSH", "protocol", "Protocol options");
1866 ctrl_radiobuttons(s, "Preferred SSH protocol version:", NO_SHORTCUT, 4,
1867 HELPCTX(ssh_protocol),
1868 dlg_stdradiobutton_handler,
1869 I(offsetof(Config, sshprot)),
1870 "1 only", 'l', I(0),
1873 "2 only", 'y', I(3), NULL);
1876 if (!midsession || protcfginfo != 1) {
1877 s = ctrl_getset(b, "Connection/SSH", "encryption", "Encryption options");
1878 c = ctrl_draglist(s, "Encryption cipher selection policy:", 's',
1879 HELPCTX(ssh_ciphers),
1880 cipherlist_handler, P(NULL));
1881 c->listbox.height = 6;
1883 ctrl_checkbox(s, "Enable legacy use of single-DES in SSH-2", 'i',
1884 HELPCTX(ssh_ciphers),
1885 dlg_stdcheckbox_handler,
1886 I(offsetof(Config,ssh2_des_cbc)));
1890 * The Connection/SSH/Kex panel. (Owing to repeat key
1891 * exchange, this is all meaningful in mid-session _if_
1892 * we're using SSH-2 or haven't decided yet.)
1894 if (protcfginfo != 1) {
1895 ctrl_settitle(b, "Connection/SSH/Kex",
1896 "Options controlling SSH key exchange");
1898 s = ctrl_getset(b, "Connection/SSH/Kex", "main",
1899 "Key exchange algorithm options");
1900 c = ctrl_draglist(s, "Algorithm selection policy:", 's',
1901 HELPCTX(ssh_kexlist),
1902 kexlist_handler, P(NULL));
1903 c->listbox.height = 5;
1905 s = ctrl_getset(b, "Connection/SSH/Kex", "repeat",
1906 "Options controlling key re-exchange");
1908 ctrl_editbox(s, "Max minutes before rekey (0 for no limit)", 't', 20,
1909 HELPCTX(ssh_kex_repeat),
1910 dlg_stdeditbox_handler,
1911 I(offsetof(Config,ssh_rekey_time)),
1913 ctrl_editbox(s, "Max data before rekey (0 for no limit)", 'x', 20,
1914 HELPCTX(ssh_kex_repeat),
1915 dlg_stdeditbox_handler,
1916 I(offsetof(Config,ssh_rekey_data)),
1918 ctrl_text(s, "(Use 1M for 1 megabyte, 1G for 1 gigabyte etc)",
1919 HELPCTX(ssh_kex_repeat));
1925 * The Connection/SSH/Auth panel.
1927 ctrl_settitle(b, "Connection/SSH/Auth",
1928 "Options controlling SSH authentication");
1930 s = ctrl_getset(b, "Connection/SSH/Auth", "main", NULL);
1931 ctrl_checkbox(s, "Bypass authentication entirely (SSH-2 only)", 'b',
1932 HELPCTX(ssh_auth_bypass),
1933 dlg_stdcheckbox_handler,
1934 I(offsetof(Config,ssh_no_userauth)));
1936 s = ctrl_getset(b, "Connection/SSH/Auth", "methods",
1937 "Authentication methods");
1938 ctrl_checkbox(s, "Attempt authentication using Pageant", 'p',
1939 HELPCTX(ssh_auth_pageant),
1940 dlg_stdcheckbox_handler,
1941 I(offsetof(Config,tryagent)));
1942 ctrl_checkbox(s, "Attempt TIS or CryptoCard auth (SSH-1)", 'm',
1943 HELPCTX(ssh_auth_tis),
1944 dlg_stdcheckbox_handler,
1945 I(offsetof(Config,try_tis_auth)));
1946 ctrl_checkbox(s, "Attempt \"keyboard-interactive\" auth (SSH-2)",
1947 'i', HELPCTX(ssh_auth_ki),
1948 dlg_stdcheckbox_handler,
1949 I(offsetof(Config,try_ki_auth)));
1951 s = ctrl_getset(b, "Connection/SSH/Auth", "params",
1952 "Authentication parameters");
1953 ctrl_checkbox(s, "Allow agent forwarding", 'f',
1954 HELPCTX(ssh_auth_agentfwd),
1955 dlg_stdcheckbox_handler, I(offsetof(Config,agentfwd)));
1956 ctrl_checkbox(s, "Allow attempted changes of username in SSH-2", 'u',
1957 HELPCTX(ssh_auth_changeuser),
1958 dlg_stdcheckbox_handler,
1959 I(offsetof(Config,change_username)));
1960 ctrl_filesel(s, "Private key file for authentication:", 'k',
1961 FILTER_KEY_FILES, FALSE, "Select private key file",
1962 HELPCTX(ssh_auth_privkey),
1963 dlg_stdfilesel_handler, I(offsetof(Config, keyfile)));
1968 * The Connection/SSH/TTY panel.
1970 ctrl_settitle(b, "Connection/SSH/TTY", "Remote terminal settings");
1972 s = ctrl_getset(b, "Connection/SSH/TTY", "sshtty", NULL);
1973 ctrl_checkbox(s, "Don't allocate a pseudo-terminal", 'p',
1975 dlg_stdcheckbox_handler,
1976 I(offsetof(Config,nopty)));
1978 s = ctrl_getset(b, "Connection/SSH/TTY", "ttymodes",
1980 td = (struct ttymodes_data *)
1981 ctrl_alloc(b, sizeof(struct ttymodes_data));
1982 ctrl_columns(s, 2, 75, 25);
1983 c = ctrl_text(s, "Terminal modes to send:", HELPCTX(ssh_ttymodes));
1984 c->generic.column = 0;
1985 td->rembutton = ctrl_pushbutton(s, "Remove", 'r',
1986 HELPCTX(ssh_ttymodes),
1987 ttymodes_handler, P(td));
1988 td->rembutton->generic.column = 1;
1989 td->rembutton->generic.tabdelay = 1;
1990 ctrl_columns(s, 1, 100);
1991 td->listbox = ctrl_listbox(s, NULL, NO_SHORTCUT,
1992 HELPCTX(ssh_ttymodes),
1993 ttymodes_handler, P(td));
1994 td->listbox->listbox.multisel = 1;
1995 td->listbox->listbox.height = 4;
1996 td->listbox->listbox.ncols = 2;
1997 td->listbox->listbox.percentages = snewn(2, int);
1998 td->listbox->listbox.percentages[0] = 40;
1999 td->listbox->listbox.percentages[1] = 60;
2000 ctrl_tabdelay(s, td->rembutton);
2001 ctrl_columns(s, 2, 75, 25);
2002 td->modelist = ctrl_droplist(s, "Mode:", 'm', 67,
2003 HELPCTX(ssh_ttymodes),
2004 ttymodes_handler, P(td));
2005 td->modelist->generic.column = 0;
2006 td->addbutton = ctrl_pushbutton(s, "Add", 'd',
2007 HELPCTX(ssh_ttymodes),
2008 ttymodes_handler, P(td));
2009 td->addbutton->generic.column = 1;
2010 td->addbutton->generic.tabdelay = 1;
2011 ctrl_columns(s, 1, 100); /* column break */
2012 /* Bit of a hack to get the value radio buttons and
2013 * edit-box on the same row. */
2014 ctrl_columns(s, 3, 25, 50, 25);
2015 c = ctrl_text(s, "Value:", HELPCTX(ssh_ttymodes));
2016 c->generic.column = 0;
2017 td->valradio = ctrl_radiobuttons(s, NULL, NO_SHORTCUT, 2,
2018 HELPCTX(ssh_ttymodes),
2019 ttymodes_handler, P(td),
2020 "Auto", NO_SHORTCUT, P(NULL),
2021 "This:", NO_SHORTCUT, P(NULL),
2023 td->valradio->generic.column = 1;
2024 td->valbox = ctrl_editbox(s, NULL, NO_SHORTCUT, 100,
2025 HELPCTX(ssh_ttymodes),
2026 ttymodes_handler, P(td), P(NULL));
2027 td->valbox->generic.column = 2;
2028 ctrl_tabdelay(s, td->addbutton);
2034 * The Connection/SSH/X11 panel.
2036 ctrl_settitle(b, "Connection/SSH/X11",
2037 "Options controlling SSH X11 forwarding");
2039 s = ctrl_getset(b, "Connection/SSH/X11", "x11", "X11 forwarding");
2040 ctrl_checkbox(s, "Enable X11 forwarding", 'e',
2041 HELPCTX(ssh_tunnels_x11),
2042 dlg_stdcheckbox_handler,I(offsetof(Config,x11_forward)));
2043 ctrl_editbox(s, "X display location", 'x', 50,
2044 HELPCTX(ssh_tunnels_x11),
2045 dlg_stdeditbox_handler, I(offsetof(Config,x11_display)),
2046 I(sizeof(((Config *)0)->x11_display)));
2047 ctrl_radiobuttons(s, "Remote X11 authentication protocol", 'u', 2,
2048 HELPCTX(ssh_tunnels_x11auth),
2049 dlg_stdradiobutton_handler,
2050 I(offsetof(Config, x11_auth)),
2051 "MIT-Magic-Cookie-1", I(X11_MIT),
2052 "XDM-Authorization-1", I(X11_XDM), NULL);
2056 * The Tunnels panel _is_ still available in mid-session.
2058 ctrl_settitle(b, "Connection/SSH/Tunnels",
2059 "Options controlling SSH port forwarding");
2061 s = ctrl_getset(b, "Connection/SSH/Tunnels", "portfwd",
2063 ctrl_checkbox(s, "Local ports accept connections from other hosts",'t',
2064 HELPCTX(ssh_tunnels_portfwd_localhost),
2065 dlg_stdcheckbox_handler,
2066 I(offsetof(Config,lport_acceptall)));
2067 ctrl_checkbox(s, "Remote ports do the same (SSH-2 only)", 'p',
2068 HELPCTX(ssh_tunnels_portfwd_localhost),
2069 dlg_stdcheckbox_handler,
2070 I(offsetof(Config,rport_acceptall)));
2072 ctrl_columns(s, 3, 55, 20, 25);
2073 c = ctrl_text(s, "Forwarded ports:", HELPCTX(ssh_tunnels_portfwd));
2074 c->generic.column = COLUMN_FIELD(0,2);
2075 /* You want to select from the list, _then_ hit Remove. So tab order
2076 * should be that way round. */
2077 pfd = (struct portfwd_data *)ctrl_alloc(b,sizeof(struct portfwd_data));
2078 pfd->rembutton = ctrl_pushbutton(s, "Remove", 'r',
2079 HELPCTX(ssh_tunnels_portfwd),
2080 portfwd_handler, P(pfd));
2081 pfd->rembutton->generic.column = 2;
2082 pfd->rembutton->generic.tabdelay = 1;
2083 pfd->listbox = ctrl_listbox(s, NULL, NO_SHORTCUT,
2084 HELPCTX(ssh_tunnels_portfwd),
2085 portfwd_handler, P(pfd));
2086 pfd->listbox->listbox.height = 3;
2087 pfd->listbox->listbox.ncols = 2;
2088 pfd->listbox->listbox.percentages = snewn(2, int);
2089 pfd->listbox->listbox.percentages[0] = 20;
2090 pfd->listbox->listbox.percentages[1] = 80;
2091 ctrl_tabdelay(s, pfd->rembutton);
2092 ctrl_text(s, "Add new forwarded port:", HELPCTX(ssh_tunnels_portfwd));
2093 /* You want to enter source, destination and type, _then_ hit Add.
2094 * Again, we adjust the tab order to reflect this. */
2095 pfd->addbutton = ctrl_pushbutton(s, "Add", 'd',
2096 HELPCTX(ssh_tunnels_portfwd),
2097 portfwd_handler, P(pfd));
2098 pfd->addbutton->generic.column = 2;
2099 pfd->addbutton->generic.tabdelay = 1;
2100 pfd->sourcebox = ctrl_editbox(s, "Source port", 's', 40,
2101 HELPCTX(ssh_tunnels_portfwd),
2102 portfwd_handler, P(pfd), P(NULL));
2103 pfd->sourcebox->generic.column = 0;
2104 pfd->destbox = ctrl_editbox(s, "Destination", 'i', 67,
2105 HELPCTX(ssh_tunnels_portfwd),
2106 portfwd_handler, P(pfd), P(NULL));
2107 pfd->direction = ctrl_radiobuttons(s, NULL, NO_SHORTCUT, 3,
2108 HELPCTX(ssh_tunnels_portfwd),
2109 portfwd_handler, P(pfd),
2110 "Local", 'l', P(NULL),
2111 "Remote", 'm', P(NULL),
2112 "Dynamic", 'y', P(NULL),
2115 pfd->addressfamily =
2116 ctrl_radiobuttons(s, NULL, NO_SHORTCUT, 3,
2117 HELPCTX(ssh_tunnels_portfwd_ipversion),
2118 portfwd_handler, P(pfd),
2119 "Auto", 'u', I(ADDRTYPE_UNSPEC),
2120 "IPv4", '4', I(ADDRTYPE_IPV4),
2121 "IPv6", '6', I(ADDRTYPE_IPV6),
2124 ctrl_tabdelay(s, pfd->addbutton);
2125 ctrl_columns(s, 1, 100);
2129 * The Connection/SSH/Bugs panel.
2131 ctrl_settitle(b, "Connection/SSH/Bugs",
2132 "Workarounds for SSH server bugs");
2134 s = ctrl_getset(b, "Connection/SSH/Bugs", "main",
2135 "Detection of known bugs in SSH servers");
2136 ctrl_droplist(s, "Chokes on SSH-1 ignore messages", 'i', 20,
2137 HELPCTX(ssh_bugs_ignore1),
2138 sshbug_handler, I(offsetof(Config,sshbug_ignore1)));
2139 ctrl_droplist(s, "Refuses all SSH-1 password camouflage", 's', 20,
2140 HELPCTX(ssh_bugs_plainpw1),
2141 sshbug_handler, I(offsetof(Config,sshbug_plainpw1)));
2142 ctrl_droplist(s, "Chokes on SSH-1 RSA authentication", 'r', 20,
2143 HELPCTX(ssh_bugs_rsa1),
2144 sshbug_handler, I(offsetof(Config,sshbug_rsa1)));
2145 ctrl_droplist(s, "Miscomputes SSH-2 HMAC keys", 'm', 20,
2146 HELPCTX(ssh_bugs_hmac2),
2147 sshbug_handler, I(offsetof(Config,sshbug_hmac2)));
2148 ctrl_droplist(s, "Miscomputes SSH-2 encryption keys", 'e', 20,
2149 HELPCTX(ssh_bugs_derivekey2),
2150 sshbug_handler, I(offsetof(Config,sshbug_derivekey2)));
2151 ctrl_droplist(s, "Requires padding on SSH-2 RSA signatures", 'p', 20,
2152 HELPCTX(ssh_bugs_rsapad2),
2153 sshbug_handler, I(offsetof(Config,sshbug_rsapad2)));
2154 ctrl_droplist(s, "Misuses the session ID in SSH-2 PK auth", 'n', 20,
2155 HELPCTX(ssh_bugs_pksessid2),
2156 sshbug_handler, I(offsetof(Config,sshbug_pksessid2)));
2157 ctrl_droplist(s, "Handles SSH-2 key re-exchange badly", 'k', 20,
2158 HELPCTX(ssh_bugs_rekey2),
2159 sshbug_handler, I(offsetof(Config,sshbug_rekey2)));