]> asedeno.scripts.mit.edu Git - PuTTY.git/blob - unix/uxcfg.c
Ctrl+rightclick now pops up a context menu in Unix PuTTY and pterm.
[PuTTY.git] / unix / uxcfg.c
1 /*
2  * uxcfg.c - the Unix-specific parts of the PuTTY configuration
3  * box.
4  */
5
6 #include <assert.h>
7 #include <stdlib.h>
8
9 #include "putty.h"
10 #include "dialog.h"
11 #include "storage.h"
12
13 static void about_handler(union control *ctrl, void *dlg,
14                           void *data, int event)
15 {
16     if (event == EVENT_ACTION) {
17         about_box();
18     }
19 }
20
21 void unix_setup_config_box(struct controlbox *b, int midsession)
22 {
23     struct controlset *s, *s2;
24     union control *c;
25     int i;
26
27     if (!midsession) {
28         /*
29          * Add the About button to the standard panel.
30          */
31         s = ctrl_getset(b, "", "", "");
32         c = ctrl_pushbutton(s, "About", 'a', HELPCTX(no_help),
33                             about_handler, P(NULL));
34         c->generic.column = 0;
35     }
36
37     /*
38      * The Config structure contains two Unix-specific elements
39      * which are not configured in here: stamp_utmp and
40      * login_shell. This is because pterm does not put up a
41      * configuration box right at the start, which is the only time
42      * when these elements would be useful to configure.
43      */
44
45     /*
46      * GTK makes it rather easier to put the scrollbar on the left
47      * than Windows does!
48      */
49     s = ctrl_getset(b, "Window", "scrollback",
50                     "Control the scrollback in the window");
51     ctrl_checkbox(s, "Scrollbar on left", 'l',
52                   HELPCTX(no_help),
53                   dlg_stdcheckbox_handler,
54                   I(offsetof(Config,scrollbar_on_left)));
55     /*
56      * Really this wants to go just after `Display scrollbar'. See
57      * if we can find that control, and do some shuffling.
58      */
59     for (i = 0; i < s->ncontrols; i++) {
60         c = s->ctrls[i];
61         if (c->generic.type == CTRL_CHECKBOX &&
62             c->generic.context.i == offsetof(Config,scrollbar)) {
63             /*
64              * Control i is the scrollbar checkbox.
65              * Control s->ncontrols-1 is the scrollbar-on-left one.
66              */
67             if (i < s->ncontrols-2) {
68                 c = s->ctrls[s->ncontrols-1];
69                 memmove(s->ctrls+i+2, s->ctrls+i+1,
70                         (s->ncontrols-i-2)*sizeof(union control *));
71                 s->ctrls[i+1] = c;
72             }
73             break;
74         }
75     }
76
77     /*
78      * X requires three more fonts: bold, wide, and wide-bold; also
79      * we need the fiddly shadow-bold-offset control. This would
80      * make the Window/Appearance panel rather unwieldy and large,
81      * so I think the sensible thing here is to _move_ this
82      * controlset into a separate Window/Fonts panel!
83      */
84     s2 = ctrl_getset(b, "Window/Appearance", "font",
85                      "Font settings");
86     /* Remove this controlset from b. */
87     for (i = 0; i < b->nctrlsets; i++) {
88         if (b->ctrlsets[i] == s2) {
89             memmove(b->ctrlsets+i, b->ctrlsets+i+1,
90                     (b->nctrlsets-i-1) * sizeof(*b->ctrlsets));
91             b->nctrlsets--;
92             break;
93         }
94     }
95     ctrl_settitle(b, "Window/Fonts", "Options controlling font usage");
96     s = ctrl_getset(b, "Window/Fonts", "font",
97                     "Fonts for displaying non-bold text");
98     ctrl_fontsel(s, "Font used for ordinary text", 'f',
99                  HELPCTX(no_help),
100                  dlg_stdfontsel_handler, I(offsetof(Config,font)));
101     ctrl_fontsel(s, "Font used for wide (CJK) text", 'w',
102                  HELPCTX(no_help),
103                  dlg_stdfontsel_handler, I(offsetof(Config,widefont)));
104     s = ctrl_getset(b, "Window/Fonts", "fontbold",
105                     "Fonts for displaying bolded text");
106     ctrl_fontsel(s, "Font used for bolded text", 'b',
107                  HELPCTX(no_help),
108                  dlg_stdfontsel_handler, I(offsetof(Config,boldfont)));
109     ctrl_fontsel(s, "Font used for bold wide text", 'i',
110                  HELPCTX(no_help),
111                  dlg_stdfontsel_handler, I(offsetof(Config,wideboldfont)));
112     ctrl_text(s, "If you leave the bold font selectors blank, bold text"
113               " will be displayed by overprinting (\"shadow bold\"). Note"
114               " that this only applies if you have not requested bolding"
115               " to be done by changing the text colour.",
116               HELPCTX(no_help));
117     ctrl_editbox(s, "Horizontal offset for shadow bold:", 'z', 20,
118                  HELPCTX(no_help), dlg_stdeditbox_handler,
119                  I(offsetof(Config,shadowboldoffset)), I(-1));
120 }