2 * winstuff.h: Windows-specific inter-module stuff.
5 #ifndef PUTTY_WINSTUFF_H
6 #define PUTTY_WINSTUFF_H
8 #include <stdio.h> /* for FILENAME_MAX */
15 char path
[FILENAME_MAX
];
17 #define f_open(filename, mode) ( fopen((filename).path, (mode)) )
26 #define BOXFLAGS DLGWINDOWEXTRA
27 #define BOXRESULT DLGWINDOWEXTRA + 4
31 * Global variables. Most modules declare these `extern', but
32 * window.c will do `#define PUTTY_DO_GLOBALS' before including this
33 * module, and so will get them properly defined.
36 #ifdef PUTTY_DO_GLOBALS
45 typedef struct config_tag Config
;
46 typedef struct backend_tag Backend
;
47 typedef struct terminal_tag Terminal
;
50 #define PUTTY_REG_POS "Software\\SimonTatham\\PuTTY"
51 #define PUTTY_REG_PARENT "Software\\SimonTatham"
52 #define PUTTY_REG_PARENT_CHILD "PuTTY"
53 #define PUTTY_REG_GPARENT "Software"
54 #define PUTTY_REG_GPARENT_CHILD "SimonTatham"
56 #define GETTICKCOUNT GetTickCount
57 #define CURSORBLINK GetCaretBlinkTime()
58 #define TICKSPERSEC 1000 /* GetTickCount returns milliseconds */
60 #define DEFAULT_CODEPAGE CP_ACP
65 * Window handles for the dialog boxes that can be running during a
71 * The all-important instance handle.
73 GLOBAL HINSTANCE hinst
;
76 * Details of the help file.
78 GLOBAL
char *help_path
;
79 GLOBAL
int help_has_contents
;
82 * The terminal and logging context are notionally local to the
83 * Windows front end, but they must be shared between window.c and
84 * windlg.c. Likewise the saved-sessions list.
86 GLOBAL Terminal
*term
;
90 * I've just looked in the windows standard headr files for WM_USER, there
91 * are hundreds of flags defined using the form WM_USER+123 so I've
92 * renumbered this NETEVENT value and the two in window.c
94 #define WM_XUSER (WM_USER + 0x2000)
95 #define WM_NETEVENT (WM_XUSER + 5)
98 * On Windows, we send MA_2CLK as the only event marking the second
99 * press of a mouse button. Compare unix.h.
101 #define MULTICLICK_ONLY_EVENT 1
104 * On Windows, data written to the clipboard must be NUL-terminated.
106 #define SELECTION_NUL_TERMINATED 1
109 * On Windows, copying to the clipboard terminates lines with CRLF.
111 #define SEL_NL { 13, 10 }
114 * sk_getxdmdata() does not exist under Windows (not that I
115 * couldn't write it if I wanted to, but I haven't bothered), so
116 * it's a macro which always returns FALSE. With any luck this will
117 * cause the compiler to notice it can optimise away the
118 * implementation of XDM-AUTHORIZATION-1 in x11fwd.c :-)
120 #define sk_getxdmdata(socket, ip, port) (0)
123 * File-selector filter strings used in the config box. On Windows,
124 * these strings are of exactly the type needed to go in
125 * `lpstrFilter' in an OPENFILENAME structure.
127 #define FILTER_KEY_FILES ("PuTTY Private Key Files (*.ppk)\0*.ppk\0" \
128 "All Files (*.*)\0*\0\0\0")
129 #define FILTER_WAVE_FILES ("Wave Files (*.wav)\0*.WAV\0" \
130 "All Files (*.*)\0*\0\0\0")
133 * Exports from winctrls.c.
142 int boxystart
, boxid
;
147 * Exports from winutils.c.
149 void split_into_argv(char *, int *, char ***, char ***);
152 * Private structure for prefslist state. Only in the header file
153 * so that we can delegate allocation to callers.
156 int listid
, upbid
, dnbid
;
163 * This structure is passed to event handler functions as the `dlg'
164 * parameter, and hence is passed back to winctrls access functions.
167 HWND hwnd
; /* the hwnd of the dialog box */
168 struct winctrls
*controltrees
[8]; /* can have several of these */
170 char *wintitle
; /* title of actual window */
171 char *errtitle
; /* title of error sub-messageboxes */
172 void *data
; /* data to pass in refresh events */
173 union control
*focused
, *lastfocused
; /* which ctrl has focus now/before */
174 char shortcuts
[128]; /* track which shortcuts in use */
175 int coloursel_wanted
; /* has an event handler asked for
176 * a colour selector? */
177 struct { unsigned char r
, g
, b
, ok
; } coloursel_result
; /* 0-255 */
178 tree234
*privdata
; /* stores per-control private data */
179 int ended
, endresult
; /* has the dialog been ended? */
183 * Exports from winctrls.c.
185 void ctlposinit(struct ctlpos
*cp
, HWND hwnd
,
186 int leftborder
, int rightborder
, int topborder
);
187 HWND
doctl(struct ctlpos
*cp
, RECT r
,
188 char *wclass
, int wstyle
, int exstyle
, char *wtext
, int wid
);
189 void bartitle(struct ctlpos
*cp
, char *name
, int id
);
190 void beginbox(struct ctlpos
*cp
, char *name
, int idbox
);
191 void endbox(struct ctlpos
*cp
);
192 void multiedit(struct ctlpos
*cp
, int password
, ...);
193 void radioline(struct ctlpos
*cp
, char *text
, int id
, int nacross
, ...);
194 void bareradioline(struct ctlpos
*cp
, int nacross
, ...);
195 void radiobig(struct ctlpos
*cp
, char *text
, int id
, ...);
196 void checkbox(struct ctlpos
*cp
, char *text
, int id
);
197 void statictext(struct ctlpos
*cp
, char *text
, int lines
, int id
);
198 void staticbtn(struct ctlpos
*cp
, char *stext
, int sid
,
199 char *btext
, int bid
);
200 void static2btn(struct ctlpos
*cp
, char *stext
, int sid
,
201 char *btext1
, int bid1
, char *btext2
, int bid2
);
202 void staticedit(struct ctlpos
*cp
, char *stext
,
203 int sid
, int eid
, int percentedit
);
204 void staticddl(struct ctlpos
*cp
, char *stext
,
205 int sid
, int lid
, int percentlist
);
206 void combobox(struct ctlpos
*cp
, char *text
, int staticid
, int listid
);
207 void staticpassedit(struct ctlpos
*cp
, char *stext
,
208 int sid
, int eid
, int percentedit
);
209 void bigeditctrl(struct ctlpos
*cp
, char *stext
,
210 int sid
, int eid
, int lines
);
211 void ersatztab(struct ctlpos
*cp
, char *stext
, int sid
, int lid
, int s2id
);
212 void editbutton(struct ctlpos
*cp
, char *stext
, int sid
,
213 int eid
, char *btext
, int bid
);
214 void sesssaver(struct ctlpos
*cp
, char *text
,
215 int staticid
, int editid
, int listid
, ...);
216 void envsetter(struct ctlpos
*cp
, char *stext
, int sid
,
217 char *e1stext
, int e1sid
, int e1id
,
218 char *e2stext
, int e2sid
, int e2id
,
219 int listid
, char *b1text
, int b1id
, char *b2text
, int b2id
);
220 void charclass(struct ctlpos
*cp
, char *stext
, int sid
, int listid
,
221 char *btext
, int bid
, int eid
, char *s2text
, int s2id
);
222 void colouredit(struct ctlpos
*cp
, char *stext
, int sid
, int listid
,
223 char *btext
, int bid
, ...);
224 void prefslist(struct prefslist
*hdl
, struct ctlpos
*cp
, int lines
,
225 char *stext
, int sid
, int listid
, int upbid
, int dnbid
);
226 int handle_prefslist(struct prefslist
*hdl
,
227 int *array
, int maxmemb
,
228 int is_dlmsg
, HWND hwnd
,
229 WPARAM wParam
, LPARAM lParam
);
230 void progressbar(struct ctlpos
*cp
, int id
);
231 void fwdsetter(struct ctlpos
*cp
, int listid
, char *stext
, int sid
,
232 char *e1stext
, int e1sid
, int e1id
,
233 char *e2stext
, int e2sid
, int e2id
,
234 char *btext
, int bid
,
235 char *r1text
, int r1id
, char *r2text
, int r2id
);
237 #define MAX_SHORTCUTS_PER_CTRL 16
240 * This structure is what's stored for each `union control' in the
241 * portable-dialog interface.
246 * The control may have several components at the Windows
247 * level, with different dialog IDs. To avoid needing N
248 * separate platformsidectrl structures (which could be stored
249 * separately in a tree234 so that lookup by ID worked), we
250 * impose the constraint that those IDs must be in a contiguous
256 * Remember what keyboard shortcuts were used by this control,
257 * so that when we remove it again we can take them out of the
258 * list in the dlgparam.
260 char shortcuts
[MAX_SHORTCUTS_PER_CTRL
];
262 * Some controls need a piece of allocated memory in which to
263 * store temporary data about the control.
268 * And this structure holds a set of the above, in two separate
269 * tree234s so that it can find an item by `union control' or by
273 tree234
*byctrl
, *byid
;
278 void winctrl_init(struct winctrls
*);
279 void winctrl_cleanup(struct winctrls
*);
280 void winctrl_add(struct winctrls
*, struct winctrl
*);
281 void winctrl_remove(struct winctrls
*, struct winctrl
*);
282 struct winctrl
*winctrl_findbyctrl(struct winctrls
*, union control
*);
283 struct winctrl
*winctrl_findbyid(struct winctrls
*, int);
284 struct winctrl
*winctrl_findbyindex(struct winctrls
*, int);
285 void winctrl_layout(struct dlgparam
*dp
, struct winctrls
*wc
,
286 struct ctlpos
*cp
, struct controlset
*s
, int *id
);
287 int winctrl_handle_command(struct dlgparam
*dp
, UINT msg
,
288 WPARAM wParam
, LPARAM lParam
);
289 void winctrl_rem_shortcuts(struct dlgparam
*dp
, struct winctrl
*c
);
290 int winctrl_context_help(struct dlgparam
*dp
, HWND hwnd
, int id
);
292 void dp_init(struct dlgparam
*dp
);
293 void dp_add_tree(struct dlgparam
*dp
, struct winctrls
*tree
);
294 void dp_cleanup(struct dlgparam
*dp
);
297 * Exports from wincfg.c.
299 void win_setup_config_box(struct controlbox
*b
, HWND
*hwndp
, int has_help
,
303 * Exports from windlg.c.
305 void defuse_showwindow(void);
307 int do_reconfig(HWND
);
308 void showeventlog(HWND
);
309 void showabout(HWND
);
310 void force_normal(HWND hwnd
);
311 void modal_about_box(HWND hwnd
);
312 void show_help(HWND hwnd
);
315 * Exports from winmisc.c.
318 int SaneDialogBox(HINSTANCE hinst
,
321 DLGPROC lpDialogFunc
);
323 void SaneEndDialog(HWND hwnd
, int ret
);
326 * Exports from sizetip.c.
328 void UpdateSizeTip(HWND src
, int cx
, int cy
);
329 void EnableSizeTip(int bEnable
);
332 * Exports from unicode.c.
335 void init_ucs(Config
*, struct unicode_data
*);
338 * pageantc.c needs to schedule callbacks for asynchronous agent
339 * requests. This has to be done differently in GUI and console, so
340 * there's an exported function used for the purpose.
342 * Also, we supply FLAG_SYNCAGENT to force agent requests to be
343 * synchronous in pscp and psftp.
345 void agent_schedule_callback(void (*callback
)(void *, void *, int),
346 void *callback_ctx
, void *data
, int len
);
347 #define FLAG_SYNCAGENT 0x1000