2 * wincfg.c - the Windows-specific parts of the PuTTY configuration
13 static void about_handler(union control
*ctrl
, void *dlg
,
14 void *data
, int event
)
16 HWND
*hwndp
= (HWND
*)ctrl
->generic
.context
.p
;
18 if (event
== EVENT_ACTION
) {
19 modal_about_box(*hwndp
);
23 static void help_handler(union control
*ctrl
, void *dlg
,
24 void *data
, int event
)
26 HWND
*hwndp
= (HWND
*)ctrl
->generic
.context
.p
;
28 if (event
== EVENT_ACTION
) {
33 void win_setup_config_box(struct controlbox
*b
, HWND
*hwndp
, int has_help
,
42 * Add the About and Help buttons to the standard panel.
44 s
= ctrl_getset(b
, "", "", "");
45 c
= ctrl_pushbutton(s
, "About", 'a', HELPCTX(no_help
),
46 about_handler
, P(hwndp
));
47 c
->generic
.column
= 0;
49 c
= ctrl_pushbutton(s
, "Help", 'h', HELPCTX(no_help
),
50 help_handler
, P(hwndp
));
51 c
->generic
.column
= 1;
56 * Full-screen mode is a Windows peculiarity; hence
57 * scrollbar_in_fullscreen is as well.
59 s
= ctrl_getset(b
, "Window", "scrollback",
60 "Control the scrollback in the window");
61 ctrl_checkbox(s
, "Display scrollbar in full screen mode", 'i',
62 HELPCTX(window_scrollback
),
63 dlg_stdcheckbox_handler
,
64 I(offsetof(Config
,scrollbar_in_fullscreen
)));
66 * Really this wants to go just after `Display scrollbar'. See
67 * if we can find that control, and do some shuffling.
71 for (i
= 0; i
< s
->ncontrols
; i
++) {
73 if (c
->generic
.type
== CTRL_CHECKBOX
&&
74 c
->generic
.context
.i
== offsetof(Config
,scrollbar
)) {
76 * Control i is the scrollbar checkbox.
77 * Control s->ncontrols-1 is the scrollbar-in-FS one.
79 if (i
< s
->ncontrols
-2) {
80 c
= s
->ctrls
[s
->ncontrols
-1];
81 memmove(s
->ctrls
+i
+2, s
->ctrls
+i
+1,
82 (s
->ncontrols
-i
-2)*sizeof(union control
*));
91 * Windows has the AltGr key, which has various Windows-
94 s
= ctrl_getset(b
, "Terminal/Keyboard", "features",
95 "Enable extra keyboard features:");
96 ctrl_checkbox(s
, "AltGr acts as Compose key", 't',
97 HELPCTX(keyboard_compose
),
98 dlg_stdcheckbox_handler
, I(offsetof(Config
,compose_key
)));
99 ctrl_checkbox(s
, "Control-Alt is different from AltGr", 'd',
100 HELPCTX(keyboard_ctrlalt
),
101 dlg_stdcheckbox_handler
, I(offsetof(Config
,ctrlaltkeys
)));
104 * Windows allows an arbitrary .WAV to be played as a bell, and
105 * also the use of the PC speaker. For this we must search the
106 * existing controlset for the radio-button set controlling the
107 * `beep' option, and add extra buttons to it.
109 * Note that although this _looks_ like a hideous hack, it's
110 * actually all above board. The well-defined interface to the
111 * per-platform dialog box code is the _data structures_ `union
112 * control', `struct controlset' and so on; so code like this
113 * that reaches into those data structures and changes bits of
114 * them is perfectly legitimate and crosses no boundaries. All
115 * the ctrl_* routines that create most of the controls are
116 * convenient shortcuts provided on the cross-platform side of
117 * the interface, and template creation code is under no actual
118 * obligation to use them.
120 s
= ctrl_getset(b
, "Terminal/Bell", "style", "Set the style of bell");
123 for (i
= 0; i
< s
->ncontrols
; i
++) {
125 if (c
->generic
.type
== CTRL_RADIO
&&
126 c
->generic
.context
.i
== offsetof(Config
, beep
)) {
127 assert(c
->generic
.handler
== dlg_stdradiobutton_handler
);
128 c
->radio
.nbuttons
+= 2;
130 sresize(c
->radio
.buttons
, c
->radio
.nbuttons
, char *);
131 c
->radio
.buttons
[c
->radio
.nbuttons
-1] =
132 dupstr("Play a custom sound file");
133 c
->radio
.buttons
[c
->radio
.nbuttons
-2] =
134 dupstr("Beep using the PC speaker");
135 c
->radio
.buttondata
=
136 sresize(c
->radio
.buttondata
, c
->radio
.nbuttons
, intorptr
);
137 c
->radio
.buttondata
[c
->radio
.nbuttons
-1] = I(BELL_WAVEFILE
);
138 c
->radio
.buttondata
[c
->radio
.nbuttons
-2] = I(BELL_PCSPEAKER
);
139 if (c
->radio
.shortcuts
) {
141 sresize(c
->radio
.shortcuts
, c
->radio
.nbuttons
, char);
142 c
->radio
.shortcuts
[c
->radio
.nbuttons
-1] = NO_SHORTCUT
;
143 c
->radio
.shortcuts
[c
->radio
.nbuttons
-2] = NO_SHORTCUT
;
149 ctrl_filesel(s
, "Custom sound file to play as a bell:", NO_SHORTCUT
,
150 FILTER_WAVE_FILES
, FALSE
, "Select bell sound file",
152 dlg_stdfilesel_handler
, I(offsetof(Config
, bell_wavefile
)));
155 * While we've got this box open, taskbar flashing on a bell is
156 * also Windows-specific.
158 ctrl_radiobuttons(s
, "Taskbar/caption indication on bell:", 'i', 3,
159 HELPCTX(bell_taskbar
),
160 dlg_stdradiobutton_handler
,
161 I(offsetof(Config
, beep_ind
)),
162 "Disabled", I(B_IND_DISABLED
),
163 "Flashing", I(B_IND_FLASH
),
164 "Steady", I(B_IND_STEADY
), NULL
);
167 * The sunken-edge border is a Windows GUI feature.
169 s
= ctrl_getset(b
, "Window/Appearance", "border",
170 "Adjust the window border");
171 ctrl_checkbox(s
, "Sunken-edge border (slightly thicker)", 's',
172 HELPCTX(appearance_border
),
173 dlg_stdcheckbox_handler
, I(offsetof(Config
,sunken_edge
)));
176 * Cyrillic Lock is a horrid misfeature even on Windows, and
177 * the least we can do is ensure it never makes it to any other
178 * platform (at least unless someone fixes it!).
180 s
= ctrl_getset(b
, "Window/Translation", "input",
181 "Enable character set translation on input data");
182 ctrl_checkbox(s
, "Caps Lock acts as Cyrillic switch", 's',
183 HELPCTX(translation_cyrillic
),
184 dlg_stdcheckbox_handler
,
185 I(offsetof(Config
,xlat_capslockcyr
)));
188 * On Windows we can use but not enumerate translation tables
189 * from the operating system. Briefly document this.
191 s
= ctrl_getset(b
, "Window/Translation", "trans",
192 "Character set translation on received data");
193 ctrl_text(s
, "(Codepages supported by Windows but not listed here, "
194 "such as CP866 on many systems, can be entered manually)",
195 HELPCTX(translation_codepage
));
198 * Windows has the weird OEM font mode, which gives us some
199 * additional options when working with line-drawing
202 str
= dupprintf("Adjust how %s displays line drawing characters", appname
);
203 s
= ctrl_getset(b
, "Window/Translation", "linedraw", str
);
207 for (i
= 0; i
< s
->ncontrols
; i
++) {
209 if (c
->generic
.type
== CTRL_RADIO
&&
210 c
->generic
.context
.i
== offsetof(Config
, vtmode
)) {
211 assert(c
->generic
.handler
== dlg_stdradiobutton_handler
);
212 c
->radio
.nbuttons
+= 3;
214 sresize(c
->radio
.buttons
, c
->radio
.nbuttons
, char *);
215 c
->radio
.buttons
[c
->radio
.nbuttons
-3] =
216 dupstr("Font has XWindows encoding");
217 c
->radio
.buttons
[c
->radio
.nbuttons
-2] =
218 dupstr("Use font in both ANSI and OEM modes");
219 c
->radio
.buttons
[c
->radio
.nbuttons
-1] =
220 dupstr("Use font in OEM mode only");
221 c
->radio
.buttondata
=
222 sresize(c
->radio
.buttondata
, c
->radio
.nbuttons
, intorptr
);
223 c
->radio
.buttondata
[c
->radio
.nbuttons
-3] = I(VT_XWINDOWS
);
224 c
->radio
.buttondata
[c
->radio
.nbuttons
-2] = I(VT_OEMANSI
);
225 c
->radio
.buttondata
[c
->radio
.nbuttons
-1] = I(VT_OEMONLY
);
226 if (!c
->radio
.shortcuts
) {
228 c
->radio
.shortcuts
= snewn(c
->radio
.nbuttons
, char);
229 for (j
= 0; j
< c
->radio
.nbuttons
; j
++)
230 c
->radio
.shortcuts
[j
] = NO_SHORTCUT
;
232 c
->radio
.shortcuts
= sresize(c
->radio
.shortcuts
,
233 c
->radio
.nbuttons
, char);
235 c
->radio
.shortcuts
[c
->radio
.nbuttons
-3] = 'x';
236 c
->radio
.shortcuts
[c
->radio
.nbuttons
-2] = 'b';
237 c
->radio
.shortcuts
[c
->radio
.nbuttons
-1] = 'e';
244 * RTF paste is Windows-specific.
246 s
= ctrl_getset(b
, "Window/Selection", "format",
247 "Formatting of pasted characters");
248 ctrl_checkbox(s
, "Paste to clipboard in RTF as well as plain text", 'f',
249 HELPCTX(selection_rtf
),
250 dlg_stdcheckbox_handler
, I(offsetof(Config
,rtf_paste
)));
253 * Windows often has no middle button, so we supply a selection
254 * mode in which the more critical Paste action is available on
255 * the right button instead.
257 s
= ctrl_getset(b
, "Window/Selection", "mouse",
258 "Control use of mouse");
259 ctrl_radiobuttons(s
, "Action of mouse buttons:", 'm', 1,
260 HELPCTX(selection_buttons
),
261 dlg_stdradiobutton_handler
,
262 I(offsetof(Config
, mouse_is_xterm
)),
263 "Windows (Middle extends, Right brings up menu)", I(2),
264 "Compromise (Middle extends, Right pastes)", I(0),
265 "xterm (Right extends, Middle pastes)", I(1), NULL
);
267 * This really ought to go at the _top_ of its box, not the
268 * bottom, so we'll just do some shuffling now we've set it
271 c
= s
->ctrls
[s
->ncontrols
-1]; /* this should be the new control */
272 memmove(s
->ctrls
+1, s
->ctrls
, (s
->ncontrols
-1)*sizeof(union control
*));
276 * Logical palettes don't even make sense anywhere except Windows.
278 s
= ctrl_getset(b
, "Window/Colours", "general",
279 "General options for colour usage");
280 ctrl_checkbox(s
, "Attempt to use logical palettes", 'l',
281 HELPCTX(colours_logpal
),
282 dlg_stdcheckbox_handler
, I(offsetof(Config
,try_palette
)));
283 ctrl_checkbox(s
, "Use system colours", 's',
284 HELPCTX(colours_system
),
285 dlg_stdcheckbox_handler
, I(offsetof(Config
,system_colour
)));
289 * Resize-by-changing-font is a Windows insanity.
291 s
= ctrl_getset(b
, "Window", "size", "Set the size of the window");
292 ctrl_radiobuttons(s
, "When window is resized:", 'z', 1,
293 HELPCTX(window_resize
),
294 dlg_stdradiobutton_handler
,
295 I(offsetof(Config
, resize_action
)),
296 "Change the number of rows and columns", I(RESIZE_TERM
),
297 "Change the size of the font", I(RESIZE_FONT
),
298 "Change font size only when maximised", I(RESIZE_EITHER
),
299 "Forbid resizing completely", I(RESIZE_DISABLED
), NULL
);
302 * Most of the Window/Behaviour stuff is there to mimic Windows
303 * conventions which PuTTY can optionally disregard. Hence,
304 * most of these options are Windows-specific.
306 s
= ctrl_getset(b
, "Window/Behaviour", "main", NULL
);
307 ctrl_checkbox(s
, "Window closes on ALT-F4", '4',
308 HELPCTX(behaviour_altf4
),
309 dlg_stdcheckbox_handler
, I(offsetof(Config
,alt_f4
)));
310 ctrl_checkbox(s
, "System menu appears on ALT-Space", 'y',
311 HELPCTX(behaviour_altspace
),
312 dlg_stdcheckbox_handler
, I(offsetof(Config
,alt_space
)));
313 ctrl_checkbox(s
, "System menu appears on ALT alone", 'l',
314 HELPCTX(behaviour_altonly
),
315 dlg_stdcheckbox_handler
, I(offsetof(Config
,alt_only
)));
316 ctrl_checkbox(s
, "Ensure window is always on top", 'e',
317 HELPCTX(behaviour_alwaysontop
),
318 dlg_stdcheckbox_handler
, I(offsetof(Config
,alwaysontop
)));
319 ctrl_checkbox(s
, "Full screen on Alt-Enter", 'f',
320 HELPCTX(behaviour_altenter
),
321 dlg_stdcheckbox_handler
,
322 I(offsetof(Config
,fullscreenonaltenter
)));