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", "tweaks", NULL
);
181 ctrl_checkbox(s
, "Caps Lock acts as Cyrillic switch", 's',
182 HELPCTX(translation_cyrillic
),
183 dlg_stdcheckbox_handler
,
184 I(offsetof(Config
,xlat_capslockcyr
)));
187 * On Windows we can use but not enumerate translation tables
188 * from the operating system. Briefly document this.
190 s
= ctrl_getset(b
, "Window/Translation", "trans",
191 "Character set translation on received data");
192 ctrl_text(s
, "(Codepages supported by Windows but not listed here, "
193 "such as CP866 on many systems, can be entered manually)",
194 HELPCTX(translation_codepage
));
197 * Windows has the weird OEM font mode, which gives us some
198 * additional options when working with line-drawing
201 str
= dupprintf("Adjust how %s displays line drawing characters", appname
);
202 s
= ctrl_getset(b
, "Window/Translation", "linedraw", str
);
206 for (i
= 0; i
< s
->ncontrols
; i
++) {
208 if (c
->generic
.type
== CTRL_RADIO
&&
209 c
->generic
.context
.i
== offsetof(Config
, vtmode
)) {
210 assert(c
->generic
.handler
== dlg_stdradiobutton_handler
);
211 c
->radio
.nbuttons
+= 3;
213 sresize(c
->radio
.buttons
, c
->radio
.nbuttons
, char *);
214 c
->radio
.buttons
[c
->radio
.nbuttons
-3] =
215 dupstr("Font has XWindows encoding");
216 c
->radio
.buttons
[c
->radio
.nbuttons
-2] =
217 dupstr("Use font in both ANSI and OEM modes");
218 c
->radio
.buttons
[c
->radio
.nbuttons
-1] =
219 dupstr("Use font in OEM mode only");
220 c
->radio
.buttondata
=
221 sresize(c
->radio
.buttondata
, c
->radio
.nbuttons
, intorptr
);
222 c
->radio
.buttondata
[c
->radio
.nbuttons
-3] = I(VT_XWINDOWS
);
223 c
->radio
.buttondata
[c
->radio
.nbuttons
-2] = I(VT_OEMANSI
);
224 c
->radio
.buttondata
[c
->radio
.nbuttons
-1] = I(VT_OEMONLY
);
225 if (!c
->radio
.shortcuts
) {
227 c
->radio
.shortcuts
= snewn(c
->radio
.nbuttons
, char);
228 for (j
= 0; j
< c
->radio
.nbuttons
; j
++)
229 c
->radio
.shortcuts
[j
] = NO_SHORTCUT
;
231 c
->radio
.shortcuts
= sresize(c
->radio
.shortcuts
,
232 c
->radio
.nbuttons
, char);
234 c
->radio
.shortcuts
[c
->radio
.nbuttons
-3] = 'x';
235 c
->radio
.shortcuts
[c
->radio
.nbuttons
-2] = 'b';
236 c
->radio
.shortcuts
[c
->radio
.nbuttons
-1] = 'e';
243 * RTF paste is Windows-specific.
245 s
= ctrl_getset(b
, "Window/Selection", "format",
246 "Formatting of pasted characters");
247 ctrl_checkbox(s
, "Paste to clipboard in RTF as well as plain text", 'f',
248 HELPCTX(selection_rtf
),
249 dlg_stdcheckbox_handler
, I(offsetof(Config
,rtf_paste
)));
252 * Windows often has no middle button, so we supply a selection
253 * mode in which the more critical Paste action is available on
254 * the right button instead.
256 s
= ctrl_getset(b
, "Window/Selection", "mouse",
257 "Control use of mouse");
258 ctrl_radiobuttons(s
, "Action of mouse buttons:", 'm', 1,
259 HELPCTX(selection_buttons
),
260 dlg_stdradiobutton_handler
,
261 I(offsetof(Config
, mouse_is_xterm
)),
262 "Windows (Middle extends, Right brings up menu)", I(2),
263 "Compromise (Middle extends, Right pastes)", I(0),
264 "xterm (Right extends, Middle pastes)", I(1), NULL
);
266 * This really ought to go at the _top_ of its box, not the
267 * bottom, so we'll just do some shuffling now we've set it
270 c
= s
->ctrls
[s
->ncontrols
-1]; /* this should be the new control */
271 memmove(s
->ctrls
+1, s
->ctrls
, (s
->ncontrols
-1)*sizeof(union control
*));
275 * Logical palettes don't even make sense anywhere except Windows.
277 s
= ctrl_getset(b
, "Window/Colours", "general",
278 "General options for colour usage");
279 ctrl_checkbox(s
, "Attempt to use logical palettes", 'l',
280 HELPCTX(colours_logpal
),
281 dlg_stdcheckbox_handler
, I(offsetof(Config
,try_palette
)));
282 ctrl_checkbox(s
, "Use system colours", 's',
283 HELPCTX(colours_system
),
284 dlg_stdcheckbox_handler
, I(offsetof(Config
,system_colour
)));
288 * Resize-by-changing-font is a Windows insanity.
290 s
= ctrl_getset(b
, "Window", "size", "Set the size of the window");
291 ctrl_radiobuttons(s
, "When window is resized:", 'z', 1,
292 HELPCTX(window_resize
),
293 dlg_stdradiobutton_handler
,
294 I(offsetof(Config
, resize_action
)),
295 "Change the number of rows and columns", I(RESIZE_TERM
),
296 "Change the size of the font", I(RESIZE_FONT
),
297 "Change font size only when maximised", I(RESIZE_EITHER
),
298 "Forbid resizing completely", I(RESIZE_DISABLED
), NULL
);
301 * Most of the Window/Behaviour stuff is there to mimic Windows
302 * conventions which PuTTY can optionally disregard. Hence,
303 * most of these options are Windows-specific.
305 s
= ctrl_getset(b
, "Window/Behaviour", "main", NULL
);
306 ctrl_checkbox(s
, "Window closes on ALT-F4", '4',
307 HELPCTX(behaviour_altf4
),
308 dlg_stdcheckbox_handler
, I(offsetof(Config
,alt_f4
)));
309 ctrl_checkbox(s
, "System menu appears on ALT-Space", 'y',
310 HELPCTX(behaviour_altspace
),
311 dlg_stdcheckbox_handler
, I(offsetof(Config
,alt_space
)));
312 ctrl_checkbox(s
, "System menu appears on ALT alone", 'l',
313 HELPCTX(behaviour_altonly
),
314 dlg_stdcheckbox_handler
, I(offsetof(Config
,alt_only
)));
315 ctrl_checkbox(s
, "Ensure window is always on top", 'e',
316 HELPCTX(behaviour_alwaysontop
),
317 dlg_stdcheckbox_handler
, I(offsetof(Config
,alwaysontop
)));
318 ctrl_checkbox(s
, "Full screen on Alt-Enter", 'f',
319 HELPCTX(behaviour_altenter
),
320 dlg_stdcheckbox_handler
,
321 I(offsetof(Config
,fullscreenonaltenter
)));