2 * wincfg.c - the Windows-specific parts of the PuTTY configuration
\r
11 #include "storage.h"
\r
13 static void about_handler(union control *ctrl, void *dlg,
\r
14 void *data, int event)
\r
16 HWND *hwndp = (HWND *)ctrl->generic.context.p;
\r
18 if (event == EVENT_ACTION) {
\r
19 modal_about_box(*hwndp);
\r
23 static void help_handler(union control *ctrl, void *dlg,
\r
24 void *data, int event)
\r
26 HWND *hwndp = (HWND *)ctrl->generic.context.p;
\r
28 if (event == EVENT_ACTION) {
\r
33 static void variable_pitch_handler(union control *ctrl, void *dlg,
\r
34 void *data, int event)
\r
36 if (event == EVENT_REFRESH) {
\r
37 dlg_checkbox_set(ctrl, dlg, !dlg_get_fixed_pitch_flag(dlg));
\r
38 } else if (event == EVENT_VALCHANGE) {
\r
39 dlg_set_fixed_pitch_flag(dlg, !dlg_checkbox_get(ctrl, dlg));
\r
43 void win_setup_config_box(struct controlbox *b, HWND *hwndp, int has_help,
\r
44 int midsession, int protocol)
\r
46 struct controlset *s;
\r
52 * Add the About and Help buttons to the standard panel.
\r
54 s = ctrl_getset(b, "", "", "");
\r
55 c = ctrl_pushbutton(s, "About", 'a', HELPCTX(no_help),
\r
56 about_handler, P(hwndp));
\r
57 c->generic.column = 0;
\r
59 c = ctrl_pushbutton(s, "Help", 'h', HELPCTX(no_help),
\r
60 help_handler, P(hwndp));
\r
61 c->generic.column = 1;
\r
66 * Full-screen mode is a Windows peculiarity; hence
\r
67 * scrollbar_in_fullscreen is as well.
\r
69 s = ctrl_getset(b, "Window", "scrollback",
\r
70 "Control the scrollback in the window");
\r
71 ctrl_checkbox(s, "Display scrollbar in full screen mode", 'i',
\r
72 HELPCTX(window_scrollback),
\r
73 dlg_stdcheckbox_handler,
\r
74 I(offsetof(Config,scrollbar_in_fullscreen)));
\r
76 * Really this wants to go just after `Display scrollbar'. See
\r
77 * if we can find that control, and do some shuffling.
\r
81 for (i = 0; i < s->ncontrols; i++) {
\r
83 if (c->generic.type == CTRL_CHECKBOX &&
\r
84 c->generic.context.i == offsetof(Config,scrollbar)) {
\r
86 * Control i is the scrollbar checkbox.
\r
87 * Control s->ncontrols-1 is the scrollbar-in-FS one.
\r
89 if (i < s->ncontrols-2) {
\r
90 c = s->ctrls[s->ncontrols-1];
\r
91 memmove(s->ctrls+i+2, s->ctrls+i+1,
\r
92 (s->ncontrols-i-2)*sizeof(union control *));
\r
101 * Windows has the AltGr key, which has various Windows-
\r
102 * specific options.
\r
104 s = ctrl_getset(b, "Terminal/Keyboard", "features",
\r
105 "Enable extra keyboard features:");
\r
106 ctrl_checkbox(s, "AltGr acts as Compose key", 't',
\r
107 HELPCTX(keyboard_compose),
\r
108 dlg_stdcheckbox_handler, I(offsetof(Config,compose_key)));
\r
109 ctrl_checkbox(s, "Control-Alt is different from AltGr", 'd',
\r
110 HELPCTX(keyboard_ctrlalt),
\r
111 dlg_stdcheckbox_handler, I(offsetof(Config,ctrlaltkeys)));
\r
114 * Windows allows an arbitrary .WAV to be played as a bell, and
\r
115 * also the use of the PC speaker. For this we must search the
\r
116 * existing controlset for the radio-button set controlling the
\r
117 * `beep' option, and add extra buttons to it.
\r
119 * Note that although this _looks_ like a hideous hack, it's
\r
120 * actually all above board. The well-defined interface to the
\r
121 * per-platform dialog box code is the _data structures_ `union
\r
122 * control', `struct controlset' and so on; so code like this
\r
123 * that reaches into those data structures and changes bits of
\r
124 * them is perfectly legitimate and crosses no boundaries. All
\r
125 * the ctrl_* routines that create most of the controls are
\r
126 * convenient shortcuts provided on the cross-platform side of
\r
127 * the interface, and template creation code is under no actual
\r
128 * obligation to use them.
\r
130 s = ctrl_getset(b, "Terminal/Bell", "style", "Set the style of bell");
\r
133 for (i = 0; i < s->ncontrols; i++) {
\r
135 if (c->generic.type == CTRL_RADIO &&
\r
136 c->generic.context.i == offsetof(Config, beep)) {
\r
137 assert(c->generic.handler == dlg_stdradiobutton_handler);
\r
138 c->radio.nbuttons += 2;
\r
140 sresize(c->radio.buttons, c->radio.nbuttons, char *);
\r
141 c->radio.buttons[c->radio.nbuttons-1] =
\r
142 dupstr("Play a custom sound file");
\r
143 c->radio.buttons[c->radio.nbuttons-2] =
\r
144 dupstr("Beep using the PC speaker");
\r
145 c->radio.buttondata =
\r
146 sresize(c->radio.buttondata, c->radio.nbuttons, intorptr);
\r
147 c->radio.buttondata[c->radio.nbuttons-1] = I(BELL_WAVEFILE);
\r
148 c->radio.buttondata[c->radio.nbuttons-2] = I(BELL_PCSPEAKER);
\r
149 if (c->radio.shortcuts) {
\r
150 c->radio.shortcuts =
\r
151 sresize(c->radio.shortcuts, c->radio.nbuttons, char);
\r
152 c->radio.shortcuts[c->radio.nbuttons-1] = NO_SHORTCUT;
\r
153 c->radio.shortcuts[c->radio.nbuttons-2] = NO_SHORTCUT;
\r
159 ctrl_filesel(s, "Custom sound file to play as a bell:", NO_SHORTCUT,
\r
160 FILTER_WAVE_FILES, FALSE, "Select bell sound file",
\r
161 HELPCTX(bell_style),
\r
162 dlg_stdfilesel_handler, I(offsetof(Config, bell_wavefile)));
\r
165 * While we've got this box open, taskbar flashing on a bell is
\r
166 * also Windows-specific.
\r
168 ctrl_radiobuttons(s, "Taskbar/caption indication on bell:", 'i', 3,
\r
169 HELPCTX(bell_taskbar),
\r
170 dlg_stdradiobutton_handler,
\r
171 I(offsetof(Config, beep_ind)),
\r
172 "Disabled", I(B_IND_DISABLED),
\r
173 "Flashing", I(B_IND_FLASH),
\r
174 "Steady", I(B_IND_STEADY), NULL);
\r
177 * The sunken-edge border is a Windows GUI feature.
\r
179 s = ctrl_getset(b, "Window/Appearance", "border",
\r
180 "Adjust the window border");
\r
181 ctrl_checkbox(s, "Sunken-edge border (slightly thicker)", 's',
\r
182 HELPCTX(appearance_border),
\r
183 dlg_stdcheckbox_handler, I(offsetof(Config,sunken_edge)));
\r
186 * Configurable font quality settings for Windows.
\r
188 s = ctrl_getset(b, "Window/Appearance", "font",
\r
190 ctrl_checkbox(s, "Allow selection of variable-pitch fonts", NO_SHORTCUT,
\r
191 HELPCTX(appearance_font), variable_pitch_handler, I(0));
\r
192 ctrl_radiobuttons(s, "Font quality:", 'q', 2,
\r
193 HELPCTX(appearance_font),
\r
194 dlg_stdradiobutton_handler,
\r
195 I(offsetof(Config, font_quality)),
\r
196 "Antialiased", I(FQ_ANTIALIASED),
\r
197 "Non-Antialiased", I(FQ_NONANTIALIASED),
\r
198 "ClearType", I(FQ_CLEARTYPE),
\r
199 "Default", I(FQ_DEFAULT), NULL);
\r
202 * Cyrillic Lock is a horrid misfeature even on Windows, and
\r
203 * the least we can do is ensure it never makes it to any other
\r
204 * platform (at least unless someone fixes it!).
\r
206 s = ctrl_getset(b, "Window/Translation", "tweaks", NULL);
\r
207 ctrl_checkbox(s, "Caps Lock acts as Cyrillic switch", 's',
\r
208 HELPCTX(translation_cyrillic),
\r
209 dlg_stdcheckbox_handler,
\r
210 I(offsetof(Config,xlat_capslockcyr)));
\r
213 * On Windows we can use but not enumerate translation tables
\r
214 * from the operating system. Briefly document this.
\r
216 s = ctrl_getset(b, "Window/Translation", "trans",
\r
217 "Character set translation on received data");
\r
218 ctrl_text(s, "(Codepages supported by Windows but not listed here, "
\r
219 "such as CP866 on many systems, can be entered manually)",
\r
220 HELPCTX(translation_codepage));
\r
223 * Windows has the weird OEM font mode, which gives us some
\r
224 * additional options when working with line-drawing
\r
227 str = dupprintf("Adjust how %s displays line drawing characters", appname);
\r
228 s = ctrl_getset(b, "Window/Translation", "linedraw", str);
\r
232 for (i = 0; i < s->ncontrols; i++) {
\r
234 if (c->generic.type == CTRL_RADIO &&
\r
235 c->generic.context.i == offsetof(Config, vtmode)) {
\r
236 assert(c->generic.handler == dlg_stdradiobutton_handler);
\r
237 c->radio.nbuttons += 3;
\r
239 sresize(c->radio.buttons, c->radio.nbuttons, char *);
\r
240 c->radio.buttons[c->radio.nbuttons-3] =
\r
241 dupstr("Font has XWindows encoding");
\r
242 c->radio.buttons[c->radio.nbuttons-2] =
\r
243 dupstr("Use font in both ANSI and OEM modes");
\r
244 c->radio.buttons[c->radio.nbuttons-1] =
\r
245 dupstr("Use font in OEM mode only");
\r
246 c->radio.buttondata =
\r
247 sresize(c->radio.buttondata, c->radio.nbuttons, intorptr);
\r
248 c->radio.buttondata[c->radio.nbuttons-3] = I(VT_XWINDOWS);
\r
249 c->radio.buttondata[c->radio.nbuttons-2] = I(VT_OEMANSI);
\r
250 c->radio.buttondata[c->radio.nbuttons-1] = I(VT_OEMONLY);
\r
251 if (!c->radio.shortcuts) {
\r
253 c->radio.shortcuts = snewn(c->radio.nbuttons, char);
\r
254 for (j = 0; j < c->radio.nbuttons; j++)
\r
255 c->radio.shortcuts[j] = NO_SHORTCUT;
\r
257 c->radio.shortcuts = sresize(c->radio.shortcuts,
\r
258 c->radio.nbuttons, char);
\r
260 c->radio.shortcuts[c->radio.nbuttons-3] = 'x';
\r
261 c->radio.shortcuts[c->radio.nbuttons-2] = 'b';
\r
262 c->radio.shortcuts[c->radio.nbuttons-1] = 'e';
\r
269 * RTF paste is Windows-specific.
\r
271 s = ctrl_getset(b, "Window/Selection", "format",
\r
272 "Formatting of pasted characters");
\r
273 ctrl_checkbox(s, "Paste to clipboard in RTF as well as plain text", 'f',
\r
274 HELPCTX(selection_rtf),
\r
275 dlg_stdcheckbox_handler, I(offsetof(Config,rtf_paste)));
\r
278 * Windows often has no middle button, so we supply a selection
\r
279 * mode in which the more critical Paste action is available on
\r
280 * the right button instead.
\r
282 s = ctrl_getset(b, "Window/Selection", "mouse",
\r
283 "Control use of mouse");
\r
284 ctrl_radiobuttons(s, "Action of mouse buttons:", 'm', 1,
\r
285 HELPCTX(selection_buttons),
\r
286 dlg_stdradiobutton_handler,
\r
287 I(offsetof(Config, mouse_is_xterm)),
\r
288 "Windows (Middle extends, Right brings up menu)", I(2),
\r
289 "Compromise (Middle extends, Right pastes)", I(0),
\r
290 "xterm (Right extends, Middle pastes)", I(1), NULL);
\r
292 * This really ought to go at the _top_ of its box, not the
\r
293 * bottom, so we'll just do some shuffling now we've set it
\r
296 c = s->ctrls[s->ncontrols-1]; /* this should be the new control */
\r
297 memmove(s->ctrls+1, s->ctrls, (s->ncontrols-1)*sizeof(union control *));
\r
301 * Logical palettes don't even make sense anywhere except Windows.
\r
303 s = ctrl_getset(b, "Window/Colours", "general",
\r
304 "General options for colour usage");
\r
305 ctrl_checkbox(s, "Attempt to use logical palettes", 'l',
\r
306 HELPCTX(colours_logpal),
\r
307 dlg_stdcheckbox_handler, I(offsetof(Config,try_palette)));
\r
308 ctrl_checkbox(s, "Use system colours", 's',
\r
309 HELPCTX(colours_system),
\r
310 dlg_stdcheckbox_handler, I(offsetof(Config,system_colour)));
\r
314 * Resize-by-changing-font is a Windows insanity.
\r
316 s = ctrl_getset(b, "Window", "size", "Set the size of the window");
\r
317 ctrl_radiobuttons(s, "When window is resized:", 'z', 1,
\r
318 HELPCTX(window_resize),
\r
319 dlg_stdradiobutton_handler,
\r
320 I(offsetof(Config, resize_action)),
\r
321 "Change the number of rows and columns", I(RESIZE_TERM),
\r
322 "Change the size of the font", I(RESIZE_FONT),
\r
323 "Change font size only when maximised", I(RESIZE_EITHER),
\r
324 "Forbid resizing completely", I(RESIZE_DISABLED), NULL);
\r
327 * Most of the Window/Behaviour stuff is there to mimic Windows
\r
328 * conventions which PuTTY can optionally disregard. Hence,
\r
329 * most of these options are Windows-specific.
\r
331 s = ctrl_getset(b, "Window/Behaviour", "main", NULL);
\r
332 ctrl_checkbox(s, "Window closes on ALT-F4", '4',
\r
333 HELPCTX(behaviour_altf4),
\r
334 dlg_stdcheckbox_handler, I(offsetof(Config,alt_f4)));
\r
335 ctrl_checkbox(s, "System menu appears on ALT-Space", 'y',
\r
336 HELPCTX(behaviour_altspace),
\r
337 dlg_stdcheckbox_handler, I(offsetof(Config,alt_space)));
\r
338 ctrl_checkbox(s, "System menu appears on ALT alone", 'l',
\r
339 HELPCTX(behaviour_altonly),
\r
340 dlg_stdcheckbox_handler, I(offsetof(Config,alt_only)));
\r
341 ctrl_checkbox(s, "Ensure window is always on top", 'e',
\r
342 HELPCTX(behaviour_alwaysontop),
\r
343 dlg_stdcheckbox_handler, I(offsetof(Config,alwaysontop)));
\r
344 ctrl_checkbox(s, "Full screen on Alt-Enter", 'f',
\r
345 HELPCTX(behaviour_altenter),
\r
346 dlg_stdcheckbox_handler,
\r
347 I(offsetof(Config,fullscreenonaltenter)));
\r
350 * Windows supports a local-command proxy. This also means we
\r
351 * must adjust the text on the `Telnet command' control.
\r
355 s = ctrl_getset(b, "Connection/Proxy", "basics", NULL);
\r
356 for (i = 0; i < s->ncontrols; i++) {
\r
358 if (c->generic.type == CTRL_RADIO &&
\r
359 c->generic.context.i == offsetof(Config, proxy_type)) {
\r
360 assert(c->generic.handler == dlg_stdradiobutton_handler);
\r
361 c->radio.nbuttons++;
\r
363 sresize(c->radio.buttons, c->radio.nbuttons, char *);
\r
364 c->radio.buttons[c->radio.nbuttons-1] =
\r
366 c->radio.buttondata =
\r
367 sresize(c->radio.buttondata, c->radio.nbuttons, intorptr);
\r
368 c->radio.buttondata[c->radio.nbuttons-1] = I(PROXY_CMD);
\r
373 for (i = 0; i < s->ncontrols; i++) {
\r
375 if (c->generic.type == CTRL_EDITBOX &&
\r
376 c->generic.context.i ==
\r
377 offsetof(Config, proxy_telnet_command)) {
\r
378 assert(c->generic.handler == dlg_stdeditbox_handler);
\r
379 sfree(c->generic.label);
\r
380 c->generic.label = dupstr("Telnet command, or local"
\r
388 * Serial back end is available on Windows.
\r
390 if (!midsession || (protocol == PROT_SERIAL))
\r
391 ser_setup_config_box(b, midsession, 0x1F, 0x0F);
\r
394 * $XAUTHORITY is not reliable on Windows, so we provide a
\r
395 * means to override it.
\r
397 if (!midsession && backend_from_proto(PROT_SSH)) {
\r
398 s = ctrl_getset(b, "Connection/SSH/X11", "x11", "X11 forwarding");
\r
399 ctrl_filesel(s, "X authority file for local display", 't',
\r
400 NULL, FALSE, "Select X authority file",
\r
401 HELPCTX(ssh_tunnels_xauthority),
\r
402 dlg_stdfilesel_handler, I(offsetof(Config, xauthfile)));
\r