2 * config.c - the platform-independent parts of the PuTTY
13 #define PRINTER_DISABLED_STRING "None (printing disabled)"
15 static void protocolbuttons_handler(union control *ctrl, void *dlg,
16 void *data, int event)
19 Config *cfg = (Config *)data;
21 * This function works just like the standard radio-button
22 * handler, except that it also has to change the setting of
23 * the port box. We expect the context parameter to point at
24 * the `union control' structure for the port box.
26 if (event == EVENT_REFRESH) {
27 for (button = 0; button < ctrl->radio.nbuttons; button++)
28 if (cfg->protocol == ctrl->radio.buttondata[button].i)
30 /* We expected that `break' to happen, in all circumstances. */
31 assert(button < ctrl->radio.nbuttons);
32 dlg_radiobutton_set(ctrl, dlg, button);
33 } else if (event == EVENT_VALCHANGE) {
34 int oldproto = cfg->protocol;
35 button = dlg_radiobutton_get(ctrl, dlg);
36 assert(button >= 0 && button < ctrl->radio.nbuttons);
37 cfg->protocol = ctrl->radio.buttondata[button].i;
38 if (oldproto != cfg->protocol) {
40 switch (cfg->protocol) {
41 case PROT_SSH: defport = 22; break;
42 case PROT_TELNET: defport = 23; break;
43 case PROT_RLOGIN: defport = 513; break;
45 if (defport > 0 && cfg->port != defport) {
47 dlg_refresh((union control *)ctrl->radio.context.p, dlg);
53 static void numeric_keypad_handler(union control *ctrl, void *dlg,
54 void *data, int event)
57 Config *cfg = (Config *)data;
59 * This function works much like the standard radio button
60 * handler, but it has to handle two fields in Config.
62 if (event == EVENT_REFRESH) {
63 if (cfg->nethack_keypad)
65 else if (cfg->app_keypad)
69 assert(button < ctrl->radio.nbuttons);
70 dlg_radiobutton_set(ctrl, dlg, button);
71 } else if (event == EVENT_VALCHANGE) {
72 button = dlg_radiobutton_get(ctrl, dlg);
73 assert(button >= 0 && button < ctrl->radio.nbuttons);
75 cfg->app_keypad = FALSE;
76 cfg->nethack_keypad = TRUE;
78 cfg->app_keypad = (button != 0);
79 cfg->nethack_keypad = FALSE;
84 static void cipherlist_handler(union control *ctrl, void *dlg,
85 void *data, int event)
87 Config *cfg = (Config *)data;
88 if (event == EVENT_REFRESH) {
91 static const struct { char *s; int c; } ciphers[] = {
92 { "3DES", CIPHER_3DES },
93 { "Blowfish", CIPHER_BLOWFISH },
94 { "DES", CIPHER_DES },
95 { "AES (SSH 2 only)", CIPHER_AES },
96 { "-- warn below here --", CIPHER_WARN }
99 /* Set up the "selected ciphers" box. */
100 /* (cipherlist assumed to contain all ciphers) */
101 dlg_update_start(ctrl, dlg);
102 dlg_listbox_clear(ctrl, dlg);
103 for (i = 0; i < CIPHER_MAX; i++) {
104 int c = cfg->ssh_cipherlist[i];
107 for (j = 0; j < (sizeof ciphers) / (sizeof ciphers[0]); j++) {
108 if (ciphers[j].c == c) {
113 dlg_listbox_addwithid(ctrl, dlg, cstr, c);
115 dlg_update_done(ctrl, dlg);
117 } else if (event == EVENT_VALCHANGE) {
120 /* Update array to match the list box. */
121 for (i=0; i < CIPHER_MAX; i++)
122 cfg->ssh_cipherlist[i] = dlg_listbox_getid(ctrl, dlg, i);
127 static void kexlist_handler(union control *ctrl, void *dlg,
128 void *data, int event)
130 Config *cfg = (Config *)data;
131 if (event == EVENT_REFRESH) {
134 static const struct { char *s; int k; } kexes[] = {
135 { "Diffie-Hellman group 1", KEX_DHGROUP1 },
136 { "Diffie-Hellman group 14", KEX_DHGROUP14 },
137 { "Diffie-Hellman group exchange", KEX_DHGEX },
138 { "-- warn below here --", KEX_WARN }
141 /* Set up the "kex preference" box. */
142 /* (kexlist assumed to contain all algorithms) */
143 dlg_update_start(ctrl, dlg);
144 dlg_listbox_clear(ctrl, dlg);
145 for (i = 0; i < KEX_MAX; i++) {
146 int k = cfg->ssh_kexlist[i];
149 for (j = 0; j < (sizeof kexes) / (sizeof kexes[0]); j++) {
150 if (kexes[j].k == k) {
155 dlg_listbox_addwithid(ctrl, dlg, kstr, k);
157 dlg_update_done(ctrl, dlg);
159 } else if (event == EVENT_VALCHANGE) {
162 /* Update array to match the list box. */
163 for (i=0; i < KEX_MAX; i++)
164 cfg->ssh_kexlist[i] = dlg_listbox_getid(ctrl, dlg, i);
169 static void printerbox_handler(union control *ctrl, void *dlg,
170 void *data, int event)
172 Config *cfg = (Config *)data;
173 if (event == EVENT_REFRESH) {
177 dlg_update_start(ctrl, dlg);
179 * Some backends may wish to disable the drop-down list on
180 * this edit box. Be prepared for this.
182 if (ctrl->editbox.has_list) {
183 dlg_listbox_clear(ctrl, dlg);
184 dlg_listbox_add(ctrl, dlg, PRINTER_DISABLED_STRING);
185 pe = printer_start_enum(&nprinters);
186 for (i = 0; i < nprinters; i++)
187 dlg_listbox_add(ctrl, dlg, printer_get_name(pe, i));
188 printer_finish_enum(pe);
190 dlg_editbox_set(ctrl, dlg,
191 (*cfg->printer ? cfg->printer :
192 PRINTER_DISABLED_STRING));
193 dlg_update_done(ctrl, dlg);
194 } else if (event == EVENT_VALCHANGE) {
195 dlg_editbox_get(ctrl, dlg, cfg->printer, sizeof(cfg->printer));
196 if (!strcmp(cfg->printer, PRINTER_DISABLED_STRING))
197 *cfg->printer = '\0';
201 static void codepage_handler(union control *ctrl, void *dlg,
202 void *data, int event)
204 Config *cfg = (Config *)data;
205 if (event == EVENT_REFRESH) {
208 dlg_update_start(ctrl, dlg);
209 strcpy(cfg->line_codepage,
210 cp_name(decode_codepage(cfg->line_codepage)));
211 dlg_listbox_clear(ctrl, dlg);
212 for (i = 0; (cp = cp_enumerate(i)) != NULL; i++)
213 dlg_listbox_add(ctrl, dlg, cp);
214 dlg_editbox_set(ctrl, dlg, cfg->line_codepage);
215 dlg_update_done(ctrl, dlg);
216 } else if (event == EVENT_VALCHANGE) {
217 dlg_editbox_get(ctrl, dlg, cfg->line_codepage,
218 sizeof(cfg->line_codepage));
219 strcpy(cfg->line_codepage,
220 cp_name(decode_codepage(cfg->line_codepage)));
224 static void sshbug_handler(union control *ctrl, void *dlg,
225 void *data, int event)
227 if (event == EVENT_REFRESH) {
228 dlg_update_start(ctrl, dlg);
229 dlg_listbox_clear(ctrl, dlg);
230 dlg_listbox_addwithid(ctrl, dlg, "Auto", AUTO);
231 dlg_listbox_addwithid(ctrl, dlg, "Off", FORCE_OFF);
232 dlg_listbox_addwithid(ctrl, dlg, "On", FORCE_ON);
233 switch (*(int *)ATOFFSET(data, ctrl->listbox.context.i)) {
234 case AUTO: dlg_listbox_select(ctrl, dlg, 0); break;
235 case FORCE_OFF: dlg_listbox_select(ctrl, dlg, 1); break;
236 case FORCE_ON: dlg_listbox_select(ctrl, dlg, 2); break;
238 dlg_update_done(ctrl, dlg);
239 } else if (event == EVENT_SELCHANGE) {
240 int i = dlg_listbox_index(ctrl, dlg);
244 i = dlg_listbox_getid(ctrl, dlg, i);
245 *(int *)ATOFFSET(data, ctrl->listbox.context.i) = i;
249 #define SAVEDSESSION_LEN 2048
251 struct sessionsaver_data {
252 union control *editbox, *listbox, *loadbutton, *savebutton, *delbutton;
253 union control *okbutton, *cancelbutton;
254 struct sesslist *sesslist;
258 * Helper function to load the session selected in the list box, if
259 * any, as this is done in more than one place below. Returns 0 for
262 static int load_selected_session(struct sessionsaver_data *ssd,
264 void *dlg, Config *cfg)
266 int i = dlg_listbox_index(ssd->listbox, dlg);
272 isdef = !strcmp(ssd->sesslist->sessions[i], "Default Settings");
273 load_settings(ssd->sesslist->sessions[i], !isdef, cfg);
275 strncpy(savedsession, ssd->sesslist->sessions[i],
277 savedsession[SAVEDSESSION_LEN-1] = '\0';
279 savedsession[0] = '\0';
281 dlg_refresh(NULL, dlg);
282 /* Restore the selection, which might have been clobbered by
283 * changing the value of the edit box. */
284 dlg_listbox_select(ssd->listbox, dlg, i);
288 static void sessionsaver_handler(union control *ctrl, void *dlg,
289 void *data, int event)
291 Config *cfg = (Config *)data;
292 struct sessionsaver_data *ssd =
293 (struct sessionsaver_data *)ctrl->generic.context.p;
297 * The first time we're called in a new dialog, we must
298 * allocate space to store the current contents of the saved
299 * session edit box (since it must persist even when we switch
300 * panels, but is not part of the Config).
302 * Of course, this doesn't need to be done mid-session.
306 } else if (!dlg_get_privdata(ssd->editbox, dlg)) {
307 savedsession = (char *)
308 dlg_alloc_privdata(ssd->editbox, dlg, SAVEDSESSION_LEN);
309 savedsession[0] = '\0';
311 savedsession = dlg_get_privdata(ssd->editbox, dlg);
314 if (event == EVENT_REFRESH) {
315 if (ctrl == ssd->editbox) {
316 dlg_editbox_set(ctrl, dlg, savedsession);
317 } else if (ctrl == ssd->listbox) {
319 dlg_update_start(ctrl, dlg);
320 dlg_listbox_clear(ctrl, dlg);
321 for (i = 0; i < ssd->sesslist->nsessions; i++)
322 dlg_listbox_add(ctrl, dlg, ssd->sesslist->sessions[i]);
323 dlg_update_done(ctrl, dlg);
325 } else if (event == EVENT_VALCHANGE) {
326 if (ctrl == ssd->editbox) {
327 dlg_editbox_get(ctrl, dlg, savedsession,
330 } else if (event == EVENT_ACTION) {
331 if (ctrl == ssd->listbox || ctrl == ssd->loadbutton) {
333 * The user has double-clicked a session, or hit Load.
334 * We must load the selected session, and then
335 * terminate the configuration dialog _if_ there was a
336 * double-click on the list box _and_ that session
337 * contains a hostname.
339 if (load_selected_session(ssd, savedsession, dlg, cfg) &&
340 (ctrl == ssd->listbox && cfg->host[0])) {
341 dlg_end(dlg, 1); /* it's all over, and succeeded */
343 } else if (ctrl == ssd->savebutton) {
344 int isdef = !strcmp(savedsession, "Default Settings");
345 if (!savedsession[0]) {
346 int i = dlg_listbox_index(ssd->listbox, dlg);
351 isdef = !strcmp(ssd->sesslist->sessions[i], "Default Settings");
353 strncpy(savedsession, ssd->sesslist->sessions[i],
355 savedsession[SAVEDSESSION_LEN-1] = '\0';
357 savedsession[0] = '\0';
361 char *errmsg = save_settings(savedsession, !isdef, cfg);
363 dlg_error_msg(dlg, errmsg);
367 get_sesslist(ssd->sesslist, FALSE);
368 get_sesslist(ssd->sesslist, TRUE);
369 dlg_refresh(ssd->editbox, dlg);
370 dlg_refresh(ssd->listbox, dlg);
371 } else if (ctrl == ssd->delbutton) {
372 int i = dlg_listbox_index(ssd->listbox, dlg);
376 del_settings(ssd->sesslist->sessions[i]);
377 get_sesslist(ssd->sesslist, FALSE);
378 get_sesslist(ssd->sesslist, TRUE);
379 dlg_refresh(ssd->listbox, dlg);
381 } else if (ctrl == ssd->okbutton) {
383 /* In a mid-session Change Settings, Apply is always OK. */
388 * Annoying special case. If the `Open' button is
389 * pressed while no host name is currently set, _and_
390 * the session list previously had the focus, _and_
391 * there was a session selected in that which had a
392 * valid host name in it, then load it and go.
394 if (dlg_last_focused(ctrl, dlg) == ssd->listbox && !*cfg->host) {
396 if (!load_selected_session(ssd, savedsession, dlg, &cfg2)) {
400 /* If at this point we have a valid session, go! */
402 *cfg = cfg2; /* structure copy */
403 cfg->remote_cmd_ptr = cfg->remote_cmd; /* nasty */
411 * Otherwise, do the normal thing: if we have a valid
412 * session, get going.
418 } else if (ctrl == ssd->cancelbutton) {
424 struct charclass_data {
425 union control *listbox, *editbox, *button;
428 static void charclass_handler(union control *ctrl, void *dlg,
429 void *data, int event)
431 Config *cfg = (Config *)data;
432 struct charclass_data *ccd =
433 (struct charclass_data *)ctrl->generic.context.p;
435 if (event == EVENT_REFRESH) {
436 if (ctrl == ccd->listbox) {
438 dlg_update_start(ctrl, dlg);
439 dlg_listbox_clear(ctrl, dlg);
440 for (i = 0; i < 128; i++) {
442 sprintf(str, "%d\t(0x%02X)\t%c\t%d", i, i,
443 (i >= 0x21 && i != 0x7F) ? i : ' ', cfg->wordness[i]);
444 dlg_listbox_add(ctrl, dlg, str);
446 dlg_update_done(ctrl, dlg);
448 } else if (event == EVENT_ACTION) {
449 if (ctrl == ccd->button) {
452 dlg_editbox_get(ccd->editbox, dlg, str, sizeof(str));
454 for (i = 0; i < 128; i++) {
455 if (dlg_listbox_issel(ccd->listbox, dlg, i))
456 cfg->wordness[i] = n;
458 dlg_refresh(ccd->listbox, dlg);
464 union control *listbox, *redit, *gedit, *bedit, *button;
467 static const char *const colours[] = {
468 "Default Foreground", "Default Bold Foreground",
469 "Default Background", "Default Bold Background",
470 "Cursor Text", "Cursor Colour",
471 "ANSI Black", "ANSI Black Bold",
472 "ANSI Red", "ANSI Red Bold",
473 "ANSI Green", "ANSI Green Bold",
474 "ANSI Yellow", "ANSI Yellow Bold",
475 "ANSI Blue", "ANSI Blue Bold",
476 "ANSI Magenta", "ANSI Magenta Bold",
477 "ANSI Cyan", "ANSI Cyan Bold",
478 "ANSI White", "ANSI White Bold"
481 static void colour_handler(union control *ctrl, void *dlg,
482 void *data, int event)
484 Config *cfg = (Config *)data;
485 struct colour_data *cd =
486 (struct colour_data *)ctrl->generic.context.p;
487 int update = FALSE, r, g, b;
489 if (event == EVENT_REFRESH) {
490 if (ctrl == cd->listbox) {
492 dlg_update_start(ctrl, dlg);
493 dlg_listbox_clear(ctrl, dlg);
494 for (i = 0; i < lenof(colours); i++)
495 dlg_listbox_add(ctrl, dlg, colours[i]);
496 dlg_update_done(ctrl, dlg);
497 dlg_editbox_set(cd->redit, dlg, "");
498 dlg_editbox_set(cd->gedit, dlg, "");
499 dlg_editbox_set(cd->bedit, dlg, "");
501 } else if (event == EVENT_SELCHANGE) {
502 if (ctrl == cd->listbox) {
503 /* The user has selected a colour. Update the RGB text. */
504 int i = dlg_listbox_index(ctrl, dlg);
509 r = cfg->colours[i][0];
510 g = cfg->colours[i][1];
511 b = cfg->colours[i][2];
514 } else if (event == EVENT_VALCHANGE) {
515 if (ctrl == cd->redit || ctrl == cd->gedit || ctrl == cd->bedit) {
516 /* The user has changed the colour using the edit boxes. */
520 dlg_editbox_get(ctrl, dlg, buf, lenof(buf));
521 cval = atoi(buf) & 255;
523 i = dlg_listbox_index(cd->listbox, dlg);
525 if (ctrl == cd->redit)
526 cfg->colours[i][0] = cval;
527 else if (ctrl == cd->gedit)
528 cfg->colours[i][1] = cval;
529 else if (ctrl == cd->bedit)
530 cfg->colours[i][2] = cval;
533 } else if (event == EVENT_ACTION) {
534 if (ctrl == cd->button) {
535 int i = dlg_listbox_index(cd->listbox, dlg);
541 * Start a colour selector, which will send us an
542 * EVENT_CALLBACK when it's finished and allow us to
543 * pick up the results.
545 dlg_coloursel_start(ctrl, dlg,
550 } else if (event == EVENT_CALLBACK) {
551 if (ctrl == cd->button) {
552 int i = dlg_listbox_index(cd->listbox, dlg);
554 * Collect the results of the colour selector. Will
555 * return nonzero on success, or zero if the colour
556 * selector did nothing (user hit Cancel, for example).
558 if (dlg_coloursel_results(ctrl, dlg, &r, &g, &b)) {
559 cfg->colours[i][0] = r;
560 cfg->colours[i][1] = g;
561 cfg->colours[i][2] = b;
569 sprintf(buf, "%d", r); dlg_editbox_set(cd->redit, dlg, buf);
570 sprintf(buf, "%d", g); dlg_editbox_set(cd->gedit, dlg, buf);
571 sprintf(buf, "%d", b); dlg_editbox_set(cd->bedit, dlg, buf);
575 struct environ_data {
576 union control *varbox, *valbox, *addbutton, *rembutton, *listbox;
579 static void environ_handler(union control *ctrl, void *dlg,
580 void *data, int event)
582 Config *cfg = (Config *)data;
583 struct environ_data *ed =
584 (struct environ_data *)ctrl->generic.context.p;
586 if (event == EVENT_REFRESH) {
587 if (ctrl == ed->listbox) {
588 char *p = cfg->environmt;
589 dlg_update_start(ctrl, dlg);
590 dlg_listbox_clear(ctrl, dlg);
592 dlg_listbox_add(ctrl, dlg, p);
595 dlg_update_done(ctrl, dlg);
597 } else if (event == EVENT_ACTION) {
598 if (ctrl == ed->addbutton) {
599 char str[sizeof(cfg->environmt)];
601 dlg_editbox_get(ed->varbox, dlg, str, sizeof(str)-1);
606 p = str + strlen(str);
608 dlg_editbox_get(ed->valbox, dlg, p, sizeof(str)-1 - (p - str));
619 if ((p - cfg->environmt) + strlen(str) + 2 <
620 sizeof(cfg->environmt)) {
622 p[strlen(str) + 1] = '\0';
623 dlg_listbox_add(ed->listbox, dlg, str);
624 dlg_editbox_set(ed->varbox, dlg, "");
625 dlg_editbox_set(ed->valbox, dlg, "");
627 dlg_error_msg(dlg, "Environment too big");
629 } else if (ctrl == ed->rembutton) {
630 int i = dlg_listbox_index(ed->listbox, dlg);
636 dlg_listbox_del(ed->listbox, dlg, i);
664 struct portfwd_data {
665 union control *addbutton, *rembutton, *listbox;
666 union control *sourcebox, *destbox, *direction;
669 static void portfwd_handler(union control *ctrl, void *dlg,
670 void *data, int event)
672 Config *cfg = (Config *)data;
673 struct portfwd_data *pfd =
674 (struct portfwd_data *)ctrl->generic.context.p;
676 if (event == EVENT_REFRESH) {
677 if (ctrl == pfd->listbox) {
678 char *p = cfg->portfwd;
679 dlg_update_start(ctrl, dlg);
680 dlg_listbox_clear(ctrl, dlg);
682 dlg_listbox_add(ctrl, dlg, p);
685 dlg_update_done(ctrl, dlg);
686 } else if (ctrl == pfd->direction) {
690 dlg_radiobutton_set(ctrl, dlg, 0);
692 } else if (event == EVENT_ACTION) {
693 if (ctrl == pfd->addbutton) {
694 char str[sizeof(cfg->portfwd)];
696 int whichbutton = dlg_radiobutton_get(pfd->direction, dlg);
697 if (whichbutton == 0)
699 else if (whichbutton == 1)
703 dlg_editbox_get(pfd->sourcebox, dlg, str+1, sizeof(str) - 2);
705 dlg_error_msg(dlg, "You need to specify a source port number");
708 p = str + strlen(str);
711 dlg_editbox_get(pfd->destbox, dlg, p,
712 sizeof(str)-1 - (p - str));
713 if (!*p || !strchr(p, ':')) {
715 "You need to specify a destination address\n"
716 "in the form \"host.name:port\"");
727 if ((p - cfg->portfwd) + strlen(str) + 2 <
728 sizeof(cfg->portfwd)) {
730 p[strlen(str) + 1] = '\0';
731 dlg_listbox_add(pfd->listbox, dlg, str);
732 dlg_editbox_set(pfd->sourcebox, dlg, "");
733 dlg_editbox_set(pfd->destbox, dlg, "");
735 dlg_error_msg(dlg, "Too many forwardings");
737 } else if (ctrl == pfd->rembutton) {
738 int i = dlg_listbox_index(pfd->listbox, dlg);
744 dlg_listbox_del(pfd->listbox, dlg, i);
772 void setup_config_box(struct controlbox *b, struct sesslist *sesslist,
773 int midsession, int protocol)
775 struct controlset *s;
776 struct sessionsaver_data *ssd;
777 struct charclass_data *ccd;
778 struct colour_data *cd;
779 struct environ_data *ed;
780 struct portfwd_data *pfd;
784 ssd = (struct sessionsaver_data *)
785 ctrl_alloc(b, sizeof(struct sessionsaver_data));
786 memset(ssd, 0, sizeof(*ssd));
787 ssd->sesslist = (midsession ? NULL : sesslist);
790 * The standard panel that appears at the bottom of all panels:
791 * Open, Cancel, Apply etc.
793 s = ctrl_getset(b, "", "", "");
794 ctrl_columns(s, 5, 20, 20, 20, 20, 20);
795 ssd->okbutton = ctrl_pushbutton(s,
796 (midsession ? "Apply" : "Open"),
797 (char)(midsession ? 'a' : 'o'),
799 sessionsaver_handler, P(ssd));
800 ssd->okbutton->button.isdefault = TRUE;
801 ssd->okbutton->generic.column = 3;
802 ssd->cancelbutton = ctrl_pushbutton(s, "Cancel", 'c', HELPCTX(no_help),
803 sessionsaver_handler, P(ssd));
804 ssd->cancelbutton->button.iscancel = TRUE;
805 ssd->cancelbutton->generic.column = 4;
806 /* We carefully don't close the 5-column part, so that platform-
807 * specific add-ons can put extra buttons alongside Open and Cancel. */
812 str = dupprintf("Basic options for your %s session", appname);
813 ctrl_settitle(b, "Session", str);
817 s = ctrl_getset(b, "Session", "hostport",
818 "Specify your connection by host name or IP address");
819 ctrl_columns(s, 2, 75, 25);
820 c = ctrl_editbox(s, "Host Name (or IP address)", 'n', 100,
821 HELPCTX(session_hostname),
822 dlg_stdeditbox_handler, I(offsetof(Config,host)),
823 I(sizeof(((Config *)0)->host)));
824 c->generic.column = 0;
825 c = ctrl_editbox(s, "Port", 'p', 100, HELPCTX(session_hostname),
826 dlg_stdeditbox_handler,
827 I(offsetof(Config,port)), I(-1));
828 c->generic.column = 1;
829 ctrl_columns(s, 1, 100);
830 if (backends[3].name == NULL) {
831 ctrl_radiobuttons(s, "Protocol:", NO_SHORTCUT, 3,
832 HELPCTX(session_hostname),
833 protocolbuttons_handler, P(c),
834 "Raw", 'r', I(PROT_RAW),
835 "Telnet", 't', I(PROT_TELNET),
836 "Rlogin", 'i', I(PROT_RLOGIN),
839 ctrl_radiobuttons(s, "Protocol:", NO_SHORTCUT, 4,
840 HELPCTX(session_hostname),
841 protocolbuttons_handler, P(c),
842 "Raw", 'r', I(PROT_RAW),
843 "Telnet", 't', I(PROT_TELNET),
844 "Rlogin", 'i', I(PROT_RLOGIN),
845 "SSH", 's', I(PROT_SSH),
849 s = ctrl_getset(b, "Session", "savedsessions",
850 "Load, save or delete a stored session");
851 ctrl_columns(s, 2, 75, 25);
852 ssd->sesslist = sesslist;
853 ssd->editbox = ctrl_editbox(s, "Saved Sessions", 'e', 100,
854 HELPCTX(session_saved),
855 sessionsaver_handler, P(ssd), P(NULL));
856 ssd->editbox->generic.column = 0;
857 /* Reset columns so that the buttons are alongside the list, rather
858 * than alongside that edit box. */
859 ctrl_columns(s, 1, 100);
860 ctrl_columns(s, 2, 75, 25);
861 ssd->listbox = ctrl_listbox(s, NULL, NO_SHORTCUT,
862 HELPCTX(session_saved),
863 sessionsaver_handler, P(ssd));
864 ssd->listbox->generic.column = 0;
865 ssd->listbox->listbox.height = 7;
866 ssd->loadbutton = ctrl_pushbutton(s, "Load", 'l',
867 HELPCTX(session_saved),
868 sessionsaver_handler, P(ssd));
869 ssd->loadbutton->generic.column = 1;
870 ssd->savebutton = ctrl_pushbutton(s, "Save", 'v',
871 HELPCTX(session_saved),
872 sessionsaver_handler, P(ssd));
873 ssd->savebutton->generic.column = 1;
874 ssd->delbutton = ctrl_pushbutton(s, "Delete", 'd',
875 HELPCTX(session_saved),
876 sessionsaver_handler, P(ssd));
877 ssd->delbutton->generic.column = 1;
878 ctrl_columns(s, 1, 100);
881 s = ctrl_getset(b, "Session", "otheropts", NULL);
882 c = ctrl_radiobuttons(s, "Close window on exit:", 'w', 4,
883 HELPCTX(session_coe),
884 dlg_stdradiobutton_handler,
885 I(offsetof(Config, close_on_exit)),
886 "Always", I(FORCE_ON),
887 "Never", I(FORCE_OFF),
888 "Only on clean exit", I(AUTO), NULL);
891 * The Session/Logging panel.
893 ctrl_settitle(b, "Session/Logging", "Options controlling session logging");
895 s = ctrl_getset(b, "Session/Logging", "main", NULL);
897 * The logging buttons change depending on whether SSH packet
898 * logging can sensibly be available.
902 if ((midsession && protocol == PROT_SSH) ||
903 (!midsession && backends[3].name != NULL))
904 sshlogname = "Log SSH packet data";
906 sshlogname = NULL; /* this will disable the button */
907 ctrl_radiobuttons(s, "Session logging:", NO_SHORTCUT, 1,
908 HELPCTX(logging_main),
909 dlg_stdradiobutton_handler,
910 I(offsetof(Config, logtype)),
911 "Logging turned off completely", 't', I(LGTYP_NONE),
912 "Log printable output only", 'p', I(LGTYP_ASCII),
913 "Log all session output", 'l', I(LGTYP_DEBUG),
914 sshlogname, 's', I(LGTYP_PACKETS),
917 ctrl_filesel(s, "Log file name:", 'f',
918 NULL, TRUE, "Select session log file name",
919 HELPCTX(logging_filename),
920 dlg_stdfilesel_handler, I(offsetof(Config, logfilename)));
921 ctrl_text(s, "(Log file name can contain &Y, &M, &D for date,"
922 " &T for time, and &H for host name)",
923 HELPCTX(logging_filename));
924 ctrl_radiobuttons(s, "What to do if the log file already exists:", 'e', 1,
925 HELPCTX(logging_exists),
926 dlg_stdradiobutton_handler, I(offsetof(Config,logxfovr)),
927 "Always overwrite it", I(LGXF_OVR),
928 "Always append to the end of it", I(LGXF_APN),
929 "Ask the user every time", I(LGXF_ASK), NULL);
930 ctrl_checkbox(s, "Flush log file frequently", 'u',
931 HELPCTX(logging_flush),
932 dlg_stdcheckbox_handler, I(offsetof(Config,logflush)));
934 if ((midsession && protocol == PROT_SSH) ||
935 (!midsession && backends[3].name != NULL)) {
936 s = ctrl_getset(b, "Session/Logging", "ssh",
937 "Options specific to SSH packet logging");
938 ctrl_checkbox(s, "Omit known password fields", 'k',
939 HELPCTX(logging_ssh_omit_password),
940 dlg_stdcheckbox_handler, I(offsetof(Config,logomitpass)));
941 ctrl_checkbox(s, "Omit session data", 'd',
942 HELPCTX(logging_ssh_omit_data),
943 dlg_stdcheckbox_handler, I(offsetof(Config,logomitdata)));
947 * The Terminal panel.
949 ctrl_settitle(b, "Terminal", "Options controlling the terminal emulation");
951 s = ctrl_getset(b, "Terminal", "general", "Set various terminal options");
952 ctrl_checkbox(s, "Auto wrap mode initially on", 'w',
953 HELPCTX(terminal_autowrap),
954 dlg_stdcheckbox_handler, I(offsetof(Config,wrap_mode)));
955 ctrl_checkbox(s, "DEC Origin Mode initially on", 'd',
956 HELPCTX(terminal_decom),
957 dlg_stdcheckbox_handler, I(offsetof(Config,dec_om)));
958 ctrl_checkbox(s, "Implicit CR in every LF", 'r',
959 HELPCTX(terminal_lfhascr),
960 dlg_stdcheckbox_handler, I(offsetof(Config,lfhascr)));
961 ctrl_checkbox(s, "Use background colour to erase screen", 'e',
962 HELPCTX(terminal_bce),
963 dlg_stdcheckbox_handler, I(offsetof(Config,bce)));
964 ctrl_checkbox(s, "Enable blinking text", 'n',
965 HELPCTX(terminal_blink),
966 dlg_stdcheckbox_handler, I(offsetof(Config,blinktext)));
967 ctrl_editbox(s, "Answerback to ^E:", 's', 100,
968 HELPCTX(terminal_answerback),
969 dlg_stdeditbox_handler, I(offsetof(Config,answerback)),
970 I(sizeof(((Config *)0)->answerback)));
972 s = ctrl_getset(b, "Terminal", "ldisc", "Line discipline options");
973 ctrl_radiobuttons(s, "Local echo:", 'l', 3,
974 HELPCTX(terminal_localecho),
975 dlg_stdradiobutton_handler,I(offsetof(Config,localecho)),
977 "Force on", I(FORCE_ON),
978 "Force off", I(FORCE_OFF), NULL);
979 ctrl_radiobuttons(s, "Local line editing:", 't', 3,
980 HELPCTX(terminal_localedit),
981 dlg_stdradiobutton_handler,I(offsetof(Config,localedit)),
983 "Force on", I(FORCE_ON),
984 "Force off", I(FORCE_OFF), NULL);
986 s = ctrl_getset(b, "Terminal", "printing", "Remote-controlled printing");
987 ctrl_combobox(s, "Printer to send ANSI printer output to:", 'p', 100,
988 HELPCTX(terminal_printing),
989 printerbox_handler, P(NULL), P(NULL));
992 * The Terminal/Keyboard panel.
994 ctrl_settitle(b, "Terminal/Keyboard",
995 "Options controlling the effects of keys");
997 s = ctrl_getset(b, "Terminal/Keyboard", "mappings",
998 "Change the sequences sent by:");
999 ctrl_radiobuttons(s, "The Backspace key", 'b', 2,
1000 HELPCTX(keyboard_backspace),
1001 dlg_stdradiobutton_handler,
1002 I(offsetof(Config, bksp_is_delete)),
1003 "Control-H", I(0), "Control-? (127)", I(1), NULL);
1004 ctrl_radiobuttons(s, "The Home and End keys", 'e', 2,
1005 HELPCTX(keyboard_homeend),
1006 dlg_stdradiobutton_handler,
1007 I(offsetof(Config, rxvt_homeend)),
1008 "Standard", I(0), "rxvt", I(1), NULL);
1009 ctrl_radiobuttons(s, "The Function keys and keypad", 'f', 3,
1010 HELPCTX(keyboard_funkeys),
1011 dlg_stdradiobutton_handler,
1012 I(offsetof(Config, funky_type)),
1013 "ESC[n~", I(0), "Linux", I(1), "Xterm R6", I(2),
1014 "VT400", I(3), "VT100+", I(4), "SCO", I(5), NULL);
1016 s = ctrl_getset(b, "Terminal/Keyboard", "appkeypad",
1017 "Application keypad settings:");
1018 ctrl_radiobuttons(s, "Initial state of cursor keys:", 'r', 3,
1019 HELPCTX(keyboard_appcursor),
1020 dlg_stdradiobutton_handler,
1021 I(offsetof(Config, app_cursor)),
1022 "Normal", I(0), "Application", I(1), NULL);
1023 ctrl_radiobuttons(s, "Initial state of numeric keypad:", 'n', 3,
1024 HELPCTX(keyboard_appkeypad),
1025 numeric_keypad_handler, P(NULL),
1026 "Normal", I(0), "Application", I(1), "NetHack", I(2),
1030 * The Terminal/Bell panel.
1032 ctrl_settitle(b, "Terminal/Bell",
1033 "Options controlling the terminal bell");
1035 s = ctrl_getset(b, "Terminal/Bell", "style", "Set the style of bell");
1036 ctrl_radiobuttons(s, "Action to happen when a bell occurs:", 'b', 1,
1037 HELPCTX(bell_style),
1038 dlg_stdradiobutton_handler, I(offsetof(Config, beep)),
1039 "None (bell disabled)", I(BELL_DISABLED),
1040 "Make default system alert sound", I(BELL_DEFAULT),
1041 "Visual bell (flash window)", I(BELL_VISUAL), NULL);
1043 s = ctrl_getset(b, "Terminal/Bell", "overload",
1044 "Control the bell overload behaviour");
1045 ctrl_checkbox(s, "Bell is temporarily disabled when over-used", 'd',
1046 HELPCTX(bell_overload),
1047 dlg_stdcheckbox_handler, I(offsetof(Config,bellovl)));
1048 ctrl_editbox(s, "Over-use means this many bells...", 'm', 20,
1049 HELPCTX(bell_overload),
1050 dlg_stdeditbox_handler, I(offsetof(Config,bellovl_n)), I(-1));
1051 ctrl_editbox(s, "... in this many seconds", 't', 20,
1052 HELPCTX(bell_overload),
1053 dlg_stdeditbox_handler, I(offsetof(Config,bellovl_t)),
1055 ctrl_text(s, "The bell is re-enabled after a few seconds of silence.",
1056 HELPCTX(bell_overload));
1057 ctrl_editbox(s, "Seconds of silence required", 's', 20,
1058 HELPCTX(bell_overload),
1059 dlg_stdeditbox_handler, I(offsetof(Config,bellovl_s)),
1063 * The Terminal/Features panel.
1065 ctrl_settitle(b, "Terminal/Features",
1066 "Enabling and disabling advanced terminal features");
1068 s = ctrl_getset(b, "Terminal/Features", "main", NULL);
1069 ctrl_checkbox(s, "Disable application cursor keys mode", 'u',
1070 HELPCTX(features_application),
1071 dlg_stdcheckbox_handler, I(offsetof(Config,no_applic_c)));
1072 ctrl_checkbox(s, "Disable application keypad mode", 'k',
1073 HELPCTX(features_application),
1074 dlg_stdcheckbox_handler, I(offsetof(Config,no_applic_k)));
1075 ctrl_checkbox(s, "Disable xterm-style mouse reporting", 'x',
1076 HELPCTX(features_mouse),
1077 dlg_stdcheckbox_handler, I(offsetof(Config,no_mouse_rep)));
1078 ctrl_checkbox(s, "Disable remote-controlled terminal resizing", 's',
1079 HELPCTX(features_resize),
1080 dlg_stdcheckbox_handler,
1081 I(offsetof(Config,no_remote_resize)));
1082 ctrl_checkbox(s, "Disable switching to alternate terminal screen", 'w',
1083 HELPCTX(features_altscreen),
1084 dlg_stdcheckbox_handler, I(offsetof(Config,no_alt_screen)));
1085 ctrl_checkbox(s, "Disable remote-controlled window title changing", 't',
1086 HELPCTX(features_retitle),
1087 dlg_stdcheckbox_handler,
1088 I(offsetof(Config,no_remote_wintitle)));
1089 ctrl_checkbox(s, "Disable remote window title querying (SECURITY)",
1090 'q', HELPCTX(features_qtitle), dlg_stdcheckbox_handler,
1091 I(offsetof(Config,no_remote_qtitle)));
1092 ctrl_checkbox(s, "Disable destructive backspace on server sending ^?",'b',
1093 HELPCTX(features_dbackspace),
1094 dlg_stdcheckbox_handler, I(offsetof(Config,no_dbackspace)));
1095 ctrl_checkbox(s, "Disable remote-controlled character set configuration",
1096 'r', HELPCTX(features_charset), dlg_stdcheckbox_handler,
1097 I(offsetof(Config,no_remote_charset)));
1098 ctrl_checkbox(s, "Disable Arabic text shaping",
1099 'l', HELPCTX(features_arabicshaping), dlg_stdcheckbox_handler,
1100 I(offsetof(Config, arabicshaping)));
1101 ctrl_checkbox(s, "Disable bidirectional text display",
1102 'd', HELPCTX(features_bidi), dlg_stdcheckbox_handler,
1103 I(offsetof(Config, bidi)));
1108 str = dupprintf("Options controlling %s's window", appname);
1109 ctrl_settitle(b, "Window", str);
1112 s = ctrl_getset(b, "Window", "size", "Set the size of the window");
1113 ctrl_columns(s, 2, 50, 50);
1114 c = ctrl_editbox(s, "Rows", 'r', 100,
1115 HELPCTX(window_size),
1116 dlg_stdeditbox_handler, I(offsetof(Config,height)),I(-1));
1117 c->generic.column = 0;
1118 c = ctrl_editbox(s, "Columns", 'm', 100,
1119 HELPCTX(window_size),
1120 dlg_stdeditbox_handler, I(offsetof(Config,width)), I(-1));
1121 c->generic.column = 1;
1122 ctrl_columns(s, 1, 100);
1124 s = ctrl_getset(b, "Window", "scrollback",
1125 "Control the scrollback in the window");
1126 ctrl_editbox(s, "Lines of scrollback", 's', 50,
1127 HELPCTX(window_scrollback),
1128 dlg_stdeditbox_handler, I(offsetof(Config,savelines)), I(-1));
1129 ctrl_checkbox(s, "Display scrollbar", 'd',
1130 HELPCTX(window_scrollback),
1131 dlg_stdcheckbox_handler, I(offsetof(Config,scrollbar)));
1132 ctrl_checkbox(s, "Reset scrollback on keypress", 'k',
1133 HELPCTX(window_scrollback),
1134 dlg_stdcheckbox_handler, I(offsetof(Config,scroll_on_key)));
1135 ctrl_checkbox(s, "Reset scrollback on display activity", 'p',
1136 HELPCTX(window_scrollback),
1137 dlg_stdcheckbox_handler, I(offsetof(Config,scroll_on_disp)));
1138 ctrl_checkbox(s, "Push erased text into scrollback", 'e',
1139 HELPCTX(window_erased),
1140 dlg_stdcheckbox_handler,
1141 I(offsetof(Config,erase_to_scrollback)));
1144 * The Window/Appearance panel.
1146 str = dupprintf("Configure the appearance of %s's window", appname);
1147 ctrl_settitle(b, "Window/Appearance", str);
1150 s = ctrl_getset(b, "Window/Appearance", "cursor",
1151 "Adjust the use of the cursor");
1152 ctrl_radiobuttons(s, "Cursor appearance:", NO_SHORTCUT, 3,
1153 HELPCTX(appearance_cursor),
1154 dlg_stdradiobutton_handler,
1155 I(offsetof(Config, cursor_type)),
1157 "Underline", 'u', I(1),
1158 "Vertical line", 'v', I(2), NULL);
1159 ctrl_checkbox(s, "Cursor blinks", 'b',
1160 HELPCTX(appearance_cursor),
1161 dlg_stdcheckbox_handler, I(offsetof(Config,blink_cur)));
1163 s = ctrl_getset(b, "Window/Appearance", "font",
1165 ctrl_fontsel(s, "Font used in the terminal window", 'n',
1166 HELPCTX(appearance_font),
1167 dlg_stdfontsel_handler, I(offsetof(Config, font)));
1169 s = ctrl_getset(b, "Window/Appearance", "mouse",
1170 "Adjust the use of the mouse pointer");
1171 ctrl_checkbox(s, "Hide mouse pointer when typing in window", 'p',
1172 HELPCTX(appearance_hidemouse),
1173 dlg_stdcheckbox_handler, I(offsetof(Config,hide_mouseptr)));
1175 s = ctrl_getset(b, "Window/Appearance", "border",
1176 "Adjust the window border");
1177 ctrl_editbox(s, "Gap between text and window edge:", NO_SHORTCUT, 20,
1178 HELPCTX(appearance_border),
1179 dlg_stdeditbox_handler,
1180 I(offsetof(Config,window_border)), I(-1));
1183 * The Window/Behaviour panel.
1185 str = dupprintf("Configure the behaviour of %s's window", appname);
1186 ctrl_settitle(b, "Window/Behaviour", str);
1189 s = ctrl_getset(b, "Window/Behaviour", "title",
1190 "Adjust the behaviour of the window title");
1191 ctrl_editbox(s, "Window title:", 't', 100,
1192 HELPCTX(appearance_title),
1193 dlg_stdeditbox_handler, I(offsetof(Config,wintitle)),
1194 I(sizeof(((Config *)0)->wintitle)));
1195 ctrl_checkbox(s, "Separate window and icon titles", 'i',
1196 HELPCTX(appearance_title),
1197 dlg_stdcheckbox_handler,
1198 I(CHECKBOX_INVERT | offsetof(Config,win_name_always)));
1200 s = ctrl_getset(b, "Window/Behaviour", "main", NULL);
1201 ctrl_checkbox(s, "Warn before closing window", 'w',
1202 HELPCTX(behaviour_closewarn),
1203 dlg_stdcheckbox_handler, I(offsetof(Config,warn_on_close)));
1206 * The Window/Translation panel.
1208 ctrl_settitle(b, "Window/Translation",
1209 "Options controlling character set translation");
1211 s = ctrl_getset(b, "Window/Translation", "trans",
1212 "Character set translation on received data");
1213 ctrl_combobox(s, "Received data assumed to be in which character set:",
1214 'r', 100, HELPCTX(translation_codepage),
1215 codepage_handler, P(NULL), P(NULL));
1217 str = dupprintf("Adjust how %s handles line drawing characters", appname);
1218 s = ctrl_getset(b, "Window/Translation", "linedraw", str);
1220 ctrl_radiobuttons(s, "Handling of line drawing characters:", NO_SHORTCUT,1,
1221 HELPCTX(translation_linedraw),
1222 dlg_stdradiobutton_handler,
1223 I(offsetof(Config, vtmode)),
1224 "Use Unicode line drawing code points",'u',I(VT_UNICODE),
1225 "Poor man's line drawing (+, - and |)",'p',I(VT_POORMAN),
1227 ctrl_checkbox(s, "Copy and paste line drawing characters as lqqqk",'d',
1228 HELPCTX(selection_linedraw),
1229 dlg_stdcheckbox_handler, I(offsetof(Config,rawcnp)));
1232 * The Window/Selection panel.
1234 ctrl_settitle(b, "Window/Selection", "Options controlling copy and paste");
1236 s = ctrl_getset(b, "Window/Selection", "mouse",
1237 "Control use of mouse");
1238 ctrl_checkbox(s, "Shift overrides application's use of mouse", 'p',
1239 HELPCTX(selection_shiftdrag),
1240 dlg_stdcheckbox_handler, I(offsetof(Config,mouse_override)));
1241 ctrl_radiobuttons(s,
1242 "Default selection mode (Alt+drag does the other one):",
1244 HELPCTX(selection_rect),
1245 dlg_stdradiobutton_handler,
1246 I(offsetof(Config, rect_select)),
1247 "Normal", 'n', I(0),
1248 "Rectangular block", 'r', I(1), NULL);
1250 s = ctrl_getset(b, "Window/Selection", "charclass",
1251 "Control the select-one-word-at-a-time mode");
1252 ccd = (struct charclass_data *)
1253 ctrl_alloc(b, sizeof(struct charclass_data));
1254 ccd->listbox = ctrl_listbox(s, "Character classes:", 'e',
1255 HELPCTX(selection_charclasses),
1256 charclass_handler, P(ccd));
1257 ccd->listbox->listbox.multisel = 1;
1258 ccd->listbox->listbox.ncols = 4;
1259 ccd->listbox->listbox.percentages = snewn(4, int);
1260 ccd->listbox->listbox.percentages[0] = 15;
1261 ccd->listbox->listbox.percentages[1] = 25;
1262 ccd->listbox->listbox.percentages[2] = 20;
1263 ccd->listbox->listbox.percentages[3] = 40;
1264 ctrl_columns(s, 2, 67, 33);
1265 ccd->editbox = ctrl_editbox(s, "Set to class", 't', 50,
1266 HELPCTX(selection_charclasses),
1267 charclass_handler, P(ccd), P(NULL));
1268 ccd->editbox->generic.column = 0;
1269 ccd->button = ctrl_pushbutton(s, "Set", 's',
1270 HELPCTX(selection_charclasses),
1271 charclass_handler, P(ccd));
1272 ccd->button->generic.column = 1;
1273 ctrl_columns(s, 1, 100);
1276 * The Window/Colours panel.
1278 ctrl_settitle(b, "Window/Colours", "Options controlling use of colours");
1280 s = ctrl_getset(b, "Window/Colours", "general",
1281 "General options for colour usage");
1282 ctrl_checkbox(s, "Allow terminal to specify ANSI colours", 'i',
1283 HELPCTX(colours_ansi),
1284 dlg_stdcheckbox_handler, I(offsetof(Config,ansi_colour)));
1285 ctrl_checkbox(s, "Allow terminal to use xterm 256-colour mode", '2',
1286 HELPCTX(colours_xterm256), dlg_stdcheckbox_handler,
1287 I(offsetof(Config,xterm_256_colour)));
1288 ctrl_checkbox(s, "Bolded text is a different colour", 'b',
1289 HELPCTX(colours_bold),
1290 dlg_stdcheckbox_handler, I(offsetof(Config,bold_colour)));
1292 str = dupprintf("Adjust the precise colours %s displays", appname);
1293 s = ctrl_getset(b, "Window/Colours", "adjust", str);
1295 ctrl_text(s, "Select a colour from the list, and then click the"
1296 " Modify button to change its appearance.",
1297 HELPCTX(colours_config));
1298 ctrl_columns(s, 2, 67, 33);
1299 cd = (struct colour_data *)ctrl_alloc(b, sizeof(struct colour_data));
1300 cd->listbox = ctrl_listbox(s, "Select a colour to adjust:", 'u',
1301 HELPCTX(colours_config), colour_handler, P(cd));
1302 cd->listbox->generic.column = 0;
1303 cd->listbox->listbox.height = 7;
1304 c = ctrl_text(s, "RGB value:", HELPCTX(colours_config));
1305 c->generic.column = 1;
1306 cd->redit = ctrl_editbox(s, "Red", 'r', 50, HELPCTX(colours_config),
1307 colour_handler, P(cd), P(NULL));
1308 cd->redit->generic.column = 1;
1309 cd->gedit = ctrl_editbox(s, "Green", 'n', 50, HELPCTX(colours_config),
1310 colour_handler, P(cd), P(NULL));
1311 cd->gedit->generic.column = 1;
1312 cd->bedit = ctrl_editbox(s, "Blue", 'e', 50, HELPCTX(colours_config),
1313 colour_handler, P(cd), P(NULL));
1314 cd->bedit->generic.column = 1;
1315 cd->button = ctrl_pushbutton(s, "Modify", 'm', HELPCTX(colours_config),
1316 colour_handler, P(cd));
1317 cd->button->generic.column = 1;
1318 ctrl_columns(s, 1, 100);
1321 * The Connection panel. This doesn't show up if we're in a
1322 * non-network utility such as pterm. We tell this by being
1323 * passed a protocol < 0.
1325 if (protocol >= 0) {
1326 ctrl_settitle(b, "Connection", "Options controlling the connection");
1329 s = ctrl_getset(b, "Connection", "data",
1330 "Data to send to the server");
1331 ctrl_editbox(s, "Terminal-type string", 't', 50,
1332 HELPCTX(connection_termtype),
1333 dlg_stdeditbox_handler, I(offsetof(Config,termtype)),
1334 I(sizeof(((Config *)0)->termtype)));
1335 ctrl_editbox(s, "Terminal speeds", 's', 50,
1336 HELPCTX(connection_termspeed),
1337 dlg_stdeditbox_handler, I(offsetof(Config,termspeed)),
1338 I(sizeof(((Config *)0)->termspeed)));
1339 ctrl_editbox(s, "Auto-login username", 'u', 50,
1340 HELPCTX(connection_username),
1341 dlg_stdeditbox_handler, I(offsetof(Config,username)),
1342 I(sizeof(((Config *)0)->username)));
1344 ctrl_text(s, "Environment variables:", HELPCTX(telnet_environ));
1345 ctrl_columns(s, 2, 80, 20);
1346 ed = (struct environ_data *)
1347 ctrl_alloc(b, sizeof(struct environ_data));
1348 ed->varbox = ctrl_editbox(s, "Variable", 'v', 60,
1349 HELPCTX(telnet_environ),
1350 environ_handler, P(ed), P(NULL));
1351 ed->varbox->generic.column = 0;
1352 ed->valbox = ctrl_editbox(s, "Value", 'l', 60,
1353 HELPCTX(telnet_environ),
1354 environ_handler, P(ed), P(NULL));
1355 ed->valbox->generic.column = 0;
1356 ed->addbutton = ctrl_pushbutton(s, "Add", 'd',
1357 HELPCTX(telnet_environ),
1358 environ_handler, P(ed));
1359 ed->addbutton->generic.column = 1;
1360 ed->rembutton = ctrl_pushbutton(s, "Remove", 'r',
1361 HELPCTX(telnet_environ),
1362 environ_handler, P(ed));
1363 ed->rembutton->generic.column = 1;
1364 ctrl_columns(s, 1, 100);
1365 ed->listbox = ctrl_listbox(s, NULL, NO_SHORTCUT,
1366 HELPCTX(telnet_environ),
1367 environ_handler, P(ed));
1368 ed->listbox->listbox.height = 3;
1369 ed->listbox->listbox.ncols = 2;
1370 ed->listbox->listbox.percentages = snewn(2, int);
1371 ed->listbox->listbox.percentages[0] = 30;
1372 ed->listbox->listbox.percentages[1] = 70;
1375 s = ctrl_getset(b, "Connection", "keepalive",
1376 "Sending of null packets to keep session active");
1377 ctrl_editbox(s, "Seconds between keepalives (0 to turn off)", 'k', 20,
1378 HELPCTX(connection_keepalive),
1379 dlg_stdeditbox_handler, I(offsetof(Config,ping_interval)),
1383 s = ctrl_getset(b, "Connection", "tcp",
1384 "Low-level TCP connection options");
1385 ctrl_checkbox(s, "Disable Nagle's algorithm (TCP_NODELAY option)",
1386 'n', HELPCTX(connection_nodelay),
1387 dlg_stdcheckbox_handler,
1388 I(offsetof(Config,tcp_nodelay)));
1389 ctrl_checkbox(s, "Enable TCP keepalives (SO_KEEPALIVE option)",
1390 'p', HELPCTX(connection_tcpkeepalive),
1391 dlg_stdcheckbox_handler,
1392 I(offsetof(Config,tcp_keepalives)));
1399 * The Connection/Proxy panel.
1401 ctrl_settitle(b, "Connection/Proxy",
1402 "Options controlling proxy usage");
1404 s = ctrl_getset(b, "Connection/Proxy", "basics", NULL);
1405 ctrl_radiobuttons(s, "Proxy type:", 't', 3,
1406 HELPCTX(proxy_type),
1407 dlg_stdradiobutton_handler,
1408 I(offsetof(Config, proxy_type)),
1409 "None", I(PROXY_NONE),
1410 "SOCKS 4", I(PROXY_SOCKS4),
1411 "SOCKS 5", I(PROXY_SOCKS5),
1412 "HTTP", I(PROXY_HTTP),
1413 "Telnet", I(PROXY_TELNET),
1415 ctrl_columns(s, 2, 80, 20);
1416 c = ctrl_editbox(s, "Proxy hostname", 'y', 100,
1417 HELPCTX(proxy_main),
1418 dlg_stdeditbox_handler,
1419 I(offsetof(Config,proxy_host)),
1420 I(sizeof(((Config *)0)->proxy_host)));
1421 c->generic.column = 0;
1422 c = ctrl_editbox(s, "Port", 'p', 100,
1423 HELPCTX(proxy_main),
1424 dlg_stdeditbox_handler,
1425 I(offsetof(Config,proxy_port)),
1427 c->generic.column = 1;
1428 ctrl_columns(s, 1, 100);
1429 ctrl_editbox(s, "Exclude Hosts/IPs", 'e', 100,
1430 HELPCTX(proxy_exclude),
1431 dlg_stdeditbox_handler,
1432 I(offsetof(Config,proxy_exclude_list)),
1433 I(sizeof(((Config *)0)->proxy_exclude_list)));
1434 ctrl_checkbox(s, "Consider proxying local host connections", 'x',
1435 HELPCTX(proxy_exclude),
1436 dlg_stdcheckbox_handler,
1437 I(offsetof(Config,even_proxy_localhost)));
1438 ctrl_radiobuttons(s, "Do DNS name lookup at proxy end:", 'd', 3,
1440 dlg_stdradiobutton_handler,
1441 I(offsetof(Config, proxy_dns)),
1444 "Yes", I(FORCE_ON), NULL);
1445 ctrl_editbox(s, "Username", 'u', 60,
1446 HELPCTX(proxy_auth),
1447 dlg_stdeditbox_handler,
1448 I(offsetof(Config,proxy_username)),
1449 I(sizeof(((Config *)0)->proxy_username)));
1450 c = ctrl_editbox(s, "Password", 'w', 60,
1451 HELPCTX(proxy_auth),
1452 dlg_stdeditbox_handler,
1453 I(offsetof(Config,proxy_password)),
1454 I(sizeof(((Config *)0)->proxy_password)));
1455 c->editbox.password = 1;
1456 ctrl_editbox(s, "Telnet command", 'm', 100,
1457 HELPCTX(proxy_command),
1458 dlg_stdeditbox_handler,
1459 I(offsetof(Config,proxy_telnet_command)),
1460 I(sizeof(((Config *)0)->proxy_telnet_command)));
1464 * The Telnet panel exists in the base config box, and in a
1465 * mid-session reconfig box _if_ we're using Telnet.
1467 if (!midsession || protocol == PROT_TELNET) {
1469 * The Connection/Telnet panel.
1471 ctrl_settitle(b, "Connection/Telnet",
1472 "Options controlling Telnet connections");
1474 s = ctrl_getset(b, "Connection/Telnet", "protocol",
1475 "Telnet protocol adjustments");
1478 ctrl_radiobuttons(s, "Handling of OLD_ENVIRON ambiguity:",
1480 HELPCTX(telnet_oldenviron),
1481 dlg_stdradiobutton_handler,
1482 I(offsetof(Config, rfc_environ)),
1483 "BSD (commonplace)", 'b', I(0),
1484 "RFC 1408 (unusual)", 'f', I(1), NULL);
1485 ctrl_radiobuttons(s, "Telnet negotiation mode:", 't', 2,
1486 HELPCTX(telnet_passive),
1487 dlg_stdradiobutton_handler,
1488 I(offsetof(Config, passive_telnet)),
1489 "Passive", I(1), "Active", I(0), NULL);
1491 ctrl_checkbox(s, "Keyboard sends Telnet special commands", 'k',
1492 HELPCTX(telnet_specialkeys),
1493 dlg_stdcheckbox_handler,
1494 I(offsetof(Config,telnet_keyboard)));
1495 ctrl_checkbox(s, "Return key sends Telnet New Line instead of ^M",
1496 'm', HELPCTX(telnet_newline),
1497 dlg_stdcheckbox_handler,
1498 I(offsetof(Config,telnet_newline)));
1504 * The Connection/Rlogin panel.
1506 ctrl_settitle(b, "Connection/Rlogin",
1507 "Options controlling Rlogin connections");
1509 s = ctrl_getset(b, "Connection/Rlogin", "data",
1510 "Data to send to the server");
1511 ctrl_editbox(s, "Local username:", 'l', 50,
1512 HELPCTX(rlogin_localuser),
1513 dlg_stdeditbox_handler, I(offsetof(Config,localusername)),
1514 I(sizeof(((Config *)0)->localusername)));
1519 * All the SSH stuff is omitted in PuTTYtel.
1522 if (!midsession && backends[3].name != NULL) {
1525 * The Connection/SSH panel.
1527 ctrl_settitle(b, "Connection/SSH",
1528 "Options controlling SSH connections");
1530 s = ctrl_getset(b, "Connection/SSH", "data",
1531 "Data to send to the server");
1532 ctrl_editbox(s, "Remote command:", 'r', 100,
1533 HELPCTX(ssh_command),
1534 dlg_stdeditbox_handler, I(offsetof(Config,remote_cmd)),
1535 I(sizeof(((Config *)0)->remote_cmd)));
1537 s = ctrl_getset(b, "Connection/SSH", "protocol", "Protocol options");
1538 ctrl_checkbox(s, "Don't allocate a pseudo-terminal", 'p',
1540 dlg_stdcheckbox_handler,
1541 I(offsetof(Config,nopty)));
1542 ctrl_checkbox(s, "Don't start a shell or command at all", 'n',
1543 HELPCTX(ssh_noshell),
1544 dlg_stdcheckbox_handler,
1545 I(offsetof(Config,ssh_no_shell)));
1546 ctrl_checkbox(s, "Enable compression", 'e',
1547 HELPCTX(ssh_compress),
1548 dlg_stdcheckbox_handler,
1549 I(offsetof(Config,compression)));
1550 ctrl_radiobuttons(s, "Preferred SSH protocol version:", NO_SHORTCUT, 4,
1551 HELPCTX(ssh_protocol),
1552 dlg_stdradiobutton_handler,
1553 I(offsetof(Config, sshprot)),
1554 "1 only", 'l', I(0),
1557 "2 only", 'y', I(3), NULL);
1559 s = ctrl_getset(b, "Connection/SSH", "encryption", "Encryption options");
1560 c = ctrl_draglist(s, "Encryption cipher selection policy:", 's',
1561 HELPCTX(ssh_ciphers),
1562 cipherlist_handler, P(NULL));
1563 c->listbox.height = 6;
1565 ctrl_checkbox(s, "Enable legacy use of single-DES in SSH 2", 'i',
1566 HELPCTX(ssh_ciphers),
1567 dlg_stdcheckbox_handler,
1568 I(offsetof(Config,ssh2_des_cbc)));
1571 * The Connection/SSH/Kex panel.
1573 ctrl_settitle(b, "Connection/SSH/Kex",
1574 "Options controlling SSH key exchange");
1576 s = ctrl_getset(b, "Connection/SSH/Kex", "main",
1577 "Key exchange algorithm options");
1578 c = ctrl_draglist(s, "Algorithm selection policy", 's',
1579 HELPCTX(ssh_kexlist),
1580 kexlist_handler, P(NULL));
1581 c->listbox.height = 5;
1584 s = ctrl_getset(b, "Connection/SSH/Kex", "repeat",
1585 "Options controlling key re-exchange");
1586 /* FIXME: at least time and data size */
1590 * The Connection/SSH/Auth panel.
1592 ctrl_settitle(b, "Connection/SSH/Auth",
1593 "Options controlling SSH authentication");
1595 s = ctrl_getset(b, "Connection/SSH/Auth", "methods",
1596 "Authentication methods");
1597 ctrl_checkbox(s, "Attempt TIS or CryptoCard auth (SSH1)", 'm',
1598 HELPCTX(ssh_auth_tis),
1599 dlg_stdcheckbox_handler,
1600 I(offsetof(Config,try_tis_auth)));
1601 ctrl_checkbox(s, "Attempt \"keyboard-interactive\" auth (SSH2)",
1602 'i', HELPCTX(ssh_auth_ki),
1603 dlg_stdcheckbox_handler,
1604 I(offsetof(Config,try_ki_auth)));
1606 s = ctrl_getset(b, "Connection/SSH/Auth", "params",
1607 "Authentication parameters");
1608 ctrl_checkbox(s, "Allow agent forwarding", 'f',
1609 HELPCTX(ssh_auth_agentfwd),
1610 dlg_stdcheckbox_handler, I(offsetof(Config,agentfwd)));
1611 ctrl_checkbox(s, "Allow attempted changes of username in SSH2", 'u',
1612 HELPCTX(ssh_auth_changeuser),
1613 dlg_stdcheckbox_handler,
1614 I(offsetof(Config,change_username)));
1615 ctrl_filesel(s, "Private key file for authentication:", 'k',
1616 FILTER_KEY_FILES, FALSE, "Select private key file",
1617 HELPCTX(ssh_auth_privkey),
1618 dlg_stdfilesel_handler, I(offsetof(Config, keyfile)));
1621 * The Connection/SSH/Tunnels panel.
1623 ctrl_settitle(b, "Connection/SSH/Tunnels",
1624 "Options controlling SSH tunnelling");
1626 s = ctrl_getset(b, "Connection/SSH/Tunnels", "x11", "X11 forwarding");
1627 ctrl_checkbox(s, "Enable X11 forwarding", 'e',
1628 HELPCTX(ssh_tunnels_x11),
1629 dlg_stdcheckbox_handler,I(offsetof(Config,x11_forward)));
1630 ctrl_editbox(s, "X display location", 'x', 50,
1631 HELPCTX(ssh_tunnels_x11),
1632 dlg_stdeditbox_handler, I(offsetof(Config,x11_display)),
1633 I(sizeof(((Config *)0)->x11_display)));
1634 ctrl_radiobuttons(s, "Remote X11 authentication protocol", 'u', 2,
1635 HELPCTX(ssh_tunnels_x11auth),
1636 dlg_stdradiobutton_handler,
1637 I(offsetof(Config, x11_auth)),
1638 "MIT-Magic-Cookie-1", I(X11_MIT),
1639 "XDM-Authorization-1", I(X11_XDM), NULL);
1641 s = ctrl_getset(b, "Connection/SSH/Tunnels", "portfwd",
1643 ctrl_checkbox(s, "Local ports accept connections from other hosts",'t',
1644 HELPCTX(ssh_tunnels_portfwd_localhost),
1645 dlg_stdcheckbox_handler,
1646 I(offsetof(Config,lport_acceptall)));
1647 ctrl_checkbox(s, "Remote ports do the same (SSH v2 only)", 'p',
1648 HELPCTX(ssh_tunnels_portfwd_localhost),
1649 dlg_stdcheckbox_handler,
1650 I(offsetof(Config,rport_acceptall)));
1652 ctrl_columns(s, 3, 55, 20, 25);
1653 c = ctrl_text(s, "Forwarded ports:", HELPCTX(ssh_tunnels_portfwd));
1654 c->generic.column = COLUMN_FIELD(0,2);
1655 /* You want to select from the list, _then_ hit Remove. So tab order
1656 * should be that way round. */
1657 pfd = (struct portfwd_data *)ctrl_alloc(b,sizeof(struct portfwd_data));
1658 pfd->rembutton = ctrl_pushbutton(s, "Remove", 'r',
1659 HELPCTX(ssh_tunnels_portfwd),
1660 portfwd_handler, P(pfd));
1661 pfd->rembutton->generic.column = 2;
1662 pfd->rembutton->generic.tabdelay = 1;
1663 pfd->listbox = ctrl_listbox(s, NULL, NO_SHORTCUT,
1664 HELPCTX(ssh_tunnels_portfwd),
1665 portfwd_handler, P(pfd));
1666 pfd->listbox->listbox.height = 3;
1667 pfd->listbox->listbox.ncols = 2;
1668 pfd->listbox->listbox.percentages = snewn(2, int);
1669 pfd->listbox->listbox.percentages[0] = 20;
1670 pfd->listbox->listbox.percentages[1] = 80;
1671 ctrl_tabdelay(s, pfd->rembutton);
1672 ctrl_text(s, "Add new forwarded port:", HELPCTX(ssh_tunnels_portfwd));
1673 /* You want to enter source, destination and type, _then_ hit Add.
1674 * Again, we adjust the tab order to reflect this. */
1675 pfd->addbutton = ctrl_pushbutton(s, "Add", 'd',
1676 HELPCTX(ssh_tunnels_portfwd),
1677 portfwd_handler, P(pfd));
1678 pfd->addbutton->generic.column = 2;
1679 pfd->addbutton->generic.tabdelay = 1;
1680 pfd->sourcebox = ctrl_editbox(s, "Source port", 's', 40,
1681 HELPCTX(ssh_tunnels_portfwd),
1682 portfwd_handler, P(pfd), P(NULL));
1683 pfd->sourcebox->generic.column = 0;
1684 pfd->destbox = ctrl_editbox(s, "Destination", 'i', 67,
1685 HELPCTX(ssh_tunnels_portfwd),
1686 portfwd_handler, P(pfd), P(NULL));
1687 pfd->direction = ctrl_radiobuttons(s, NULL, NO_SHORTCUT, 3,
1688 HELPCTX(ssh_tunnels_portfwd),
1689 portfwd_handler, P(pfd),
1690 "Local", 'l', P(NULL),
1691 "Remote", 'm', P(NULL),
1692 "Dynamic", 'y', P(NULL),
1694 ctrl_tabdelay(s, pfd->addbutton);
1695 ctrl_columns(s, 1, 100);
1698 * The Connection/SSH/Bugs panel.
1700 ctrl_settitle(b, "Connection/SSH/Bugs",
1701 "Workarounds for SSH server bugs");
1703 s = ctrl_getset(b, "Connection/SSH/Bugs", "main",
1704 "Detection of known bugs in SSH servers");
1705 ctrl_droplist(s, "Chokes on SSH1 ignore messages", 'i', 20,
1706 HELPCTX(ssh_bugs_ignore1),
1707 sshbug_handler, I(offsetof(Config,sshbug_ignore1)));
1708 ctrl_droplist(s, "Refuses all SSH1 password camouflage", 's', 20,
1709 HELPCTX(ssh_bugs_plainpw1),
1710 sshbug_handler, I(offsetof(Config,sshbug_plainpw1)));
1711 ctrl_droplist(s, "Chokes on SSH1 RSA authentication", 'r', 20,
1712 HELPCTX(ssh_bugs_rsa1),
1713 sshbug_handler, I(offsetof(Config,sshbug_rsa1)));
1714 ctrl_droplist(s, "Miscomputes SSH2 HMAC keys", 'm', 20,
1715 HELPCTX(ssh_bugs_hmac2),
1716 sshbug_handler, I(offsetof(Config,sshbug_hmac2)));
1717 ctrl_droplist(s, "Miscomputes SSH2 encryption keys", 'e', 20,
1718 HELPCTX(ssh_bugs_derivekey2),
1719 sshbug_handler, I(offsetof(Config,sshbug_derivekey2)));
1720 ctrl_droplist(s, "Requires padding on SSH2 RSA signatures", 'p', 20,
1721 HELPCTX(ssh_bugs_rsapad2),
1722 sshbug_handler, I(offsetof(Config,sshbug_rsapad2)));
1723 ctrl_droplist(s, "Misuses the session ID in PK auth", 'n', 20,
1724 HELPCTX(ssh_bugs_pksessid2),
1725 sshbug_handler, I(offsetof(Config,sshbug_pksessid2)));