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)) )
27 * Global variables. Most modules declare these `extern', but
28 * window.c will do `#define PUTTY_DO_GLOBALS' before including this
29 * module, and so will get them properly defined.
32 #ifdef PUTTY_DO_GLOBALS
41 typedef struct config_tag Config
;
42 typedef struct backend_tag Backend
;
43 typedef struct terminal_tag Terminal
;
46 #define PUTTY_REG_POS "Software\\SimonTatham\\PuTTY"
47 #define PUTTY_REG_PARENT "Software\\SimonTatham"
48 #define PUTTY_REG_PARENT_CHILD "PuTTY"
49 #define PUTTY_REG_GPARENT "Software"
50 #define PUTTY_REG_GPARENT_CHILD "SimonTatham"
52 #define GETTICKCOUNT GetTickCount
53 #define CURSORBLINK GetCaretBlinkTime()
54 #define TICKSPERSEC 1000 /* GetTickCount returns milliseconds */
56 #define DEFAULT_CODEPAGE CP_ACP
61 * Window handles for the dialog boxes that can be running during a
67 * The all-important instance handle.
69 GLOBAL HINSTANCE hinst
;
72 * Details of the help file.
74 GLOBAL
char *help_path
;
75 GLOBAL
int help_has_contents
;
78 * The terminal and logging context are notionally local to the
79 * Windows front end, but they must be shared between window.c and
80 * windlg.c. Likewise the saved-sessions list.
82 GLOBAL Terminal
*term
;
86 * I've just looked in the windows standard headr files for WM_USER, there
87 * are hundreds of flags defined using the form WM_USER+123 so I've
88 * renumbered this NETEVENT value and the two in window.c
90 #define WM_XUSER (WM_USER + 0x2000)
91 #define WM_NETEVENT (WM_XUSER + 5)
94 * On Windows, we send MA_2CLK as the only event marking the second
95 * press of a mouse button. Compare unix.h.
97 #define MULTICLICK_ONLY_EVENT 1
100 * On Windows, data written to the clipboard must be NUL-terminated.
102 #define SELECTION_NUL_TERMINATED 1
105 * On Windows, copying to the clipboard terminates lines with CRLF.
107 #define SEL_NL { 13, 10 }
110 * sk_getxdmdata() does not exist under Windows (not that I
111 * couldn't write it if I wanted to, but I haven't bothered), so
112 * it's a macro which always returns FALSE. With any luck this will
113 * cause the compiler to notice it can optimise away the
114 * implementation of XDM-AUTHORIZATION-1 in x11fwd.c :-)
116 #define sk_getxdmdata(socket, ip, port) (0)
119 * File-selector filter strings used in the config box. On Windows,
120 * these strings are of exactly the type needed to go in
121 * `lpstrFilter' in an OPENFILENAME structure.
123 #define FILTER_KEY_FILES ("PuTTY Private Key Files (*.ppk)\0*.ppk\0" \
124 "All Files (*.*)\0*\0\0\0")
125 #define FILTER_WAVE_FILES ("Wave Files (*.wav)\0*.WAV\0" \
126 "All Files (*.*)\0*\0\0\0")
129 * Exports from winctrls.c.
138 int boxystart
, boxid
;
143 * Exports from winutils.c.
145 void split_into_argv(char *, int *, char ***, char ***);
148 * Private structure for prefslist state. Only in the header file
149 * so that we can delegate allocation to callers.
152 int listid
, upbid
, dnbid
;
159 * This structure is passed to event handler functions as the `dlg'
160 * parameter, and hence is passed back to winctrls access functions.
163 HWND hwnd
; /* the hwnd of the dialog box */
164 struct winctrls
*controltrees
[8]; /* can have several of these */
166 char *wintitle
; /* title of actual window */
167 char *errtitle
; /* title of error sub-messageboxes */
168 void *data
; /* data to pass in refresh events */
169 union control
*focused
, *lastfocused
; /* which ctrl has focus now/before */
170 char shortcuts
[128]; /* track which shortcuts in use */
171 int coloursel_wanted
; /* has an event handler asked for
172 * a colour selector? */
173 struct { unsigned char r
, g
, b
, ok
; } coloursel_result
; /* 0-255 */
174 tree234
*privdata
; /* stores per-control private data */
175 int ended
, endresult
; /* has the dialog been ended? */
179 * Exports from winctrls.c.
181 void ctlposinit(struct ctlpos
*cp
, HWND hwnd
,
182 int leftborder
, int rightborder
, int topborder
);
183 HWND
doctl(struct ctlpos
*cp
, RECT r
,
184 char *wclass
, int wstyle
, int exstyle
, char *wtext
, int wid
);
185 void bartitle(struct ctlpos
*cp
, char *name
, int id
);
186 void beginbox(struct ctlpos
*cp
, char *name
, int idbox
);
187 void endbox(struct ctlpos
*cp
);
188 void multiedit(struct ctlpos
*cp
, int password
, ...);
189 void radioline(struct ctlpos
*cp
, char *text
, int id
, int nacross
, ...);
190 void bareradioline(struct ctlpos
*cp
, int nacross
, ...);
191 void radiobig(struct ctlpos
*cp
, char *text
, int id
, ...);
192 void checkbox(struct ctlpos
*cp
, char *text
, int id
);
193 void statictext(struct ctlpos
*cp
, char *text
, int lines
, int id
);
194 void staticbtn(struct ctlpos
*cp
, char *stext
, int sid
,
195 char *btext
, int bid
);
196 void static2btn(struct ctlpos
*cp
, char *stext
, int sid
,
197 char *btext1
, int bid1
, char *btext2
, int bid2
);
198 void staticedit(struct ctlpos
*cp
, char *stext
,
199 int sid
, int eid
, int percentedit
);
200 void staticddl(struct ctlpos
*cp
, char *stext
,
201 int sid
, int lid
, int percentlist
);
202 void combobox(struct ctlpos
*cp
, char *text
, int staticid
, int listid
);
203 void staticpassedit(struct ctlpos
*cp
, char *stext
,
204 int sid
, int eid
, int percentedit
);
205 void bigeditctrl(struct ctlpos
*cp
, char *stext
,
206 int sid
, int eid
, int lines
);
207 void ersatztab(struct ctlpos
*cp
, char *stext
, int sid
, int lid
, int s2id
);
208 void editbutton(struct ctlpos
*cp
, char *stext
, int sid
,
209 int eid
, char *btext
, int bid
);
210 void sesssaver(struct ctlpos
*cp
, char *text
,
211 int staticid
, int editid
, int listid
, ...);
212 void envsetter(struct ctlpos
*cp
, char *stext
, int sid
,
213 char *e1stext
, int e1sid
, int e1id
,
214 char *e2stext
, int e2sid
, int e2id
,
215 int listid
, char *b1text
, int b1id
, char *b2text
, int b2id
);
216 void charclass(struct ctlpos
*cp
, char *stext
, int sid
, int listid
,
217 char *btext
, int bid
, int eid
, char *s2text
, int s2id
);
218 void colouredit(struct ctlpos
*cp
, char *stext
, int sid
, int listid
,
219 char *btext
, int bid
, ...);
220 void prefslist(struct prefslist
*hdl
, struct ctlpos
*cp
, int lines
,
221 char *stext
, int sid
, int listid
, int upbid
, int dnbid
);
222 int handle_prefslist(struct prefslist
*hdl
,
223 int *array
, int maxmemb
,
224 int is_dlmsg
, HWND hwnd
,
225 WPARAM wParam
, LPARAM lParam
);
226 void progressbar(struct ctlpos
*cp
, int id
);
227 void fwdsetter(struct ctlpos
*cp
, int listid
, char *stext
, int sid
,
228 char *e1stext
, int e1sid
, int e1id
,
229 char *e2stext
, int e2sid
, int e2id
,
230 char *btext
, int bid
,
231 char *r1text
, int r1id
, char *r2text
, int r2id
);
233 #define MAX_SHORTCUTS_PER_CTRL 16
236 * This structure is what's stored for each `union control' in the
237 * portable-dialog interface.
242 * The control may have several components at the Windows
243 * level, with different dialog IDs. To avoid needing N
244 * separate platformsidectrl structures (which could be stored
245 * separately in a tree234 so that lookup by ID worked), we
246 * impose the constraint that those IDs must be in a contiguous
252 * Remember what keyboard shortcuts were used by this control,
253 * so that when we remove it again we can take them out of the
254 * list in the dlgparam.
256 char shortcuts
[MAX_SHORTCUTS_PER_CTRL
];
258 * Some controls need a piece of allocated memory in which to
259 * store temporary data about the control.
264 * And this structure holds a set of the above, in two separate
265 * tree234s so that it can find an item by `union control' or by
269 tree234
*byctrl
, *byid
;
274 void winctrl_init(struct winctrls
*);
275 void winctrl_cleanup(struct winctrls
*);
276 void winctrl_add(struct winctrls
*, struct winctrl
*);
277 void winctrl_remove(struct winctrls
*, struct winctrl
*);
278 struct winctrl
*winctrl_findbyctrl(struct winctrls
*, union control
*);
279 struct winctrl
*winctrl_findbyid(struct winctrls
*, int);
280 struct winctrl
*winctrl_findbyindex(struct winctrls
*, int);
281 void winctrl_layout(struct dlgparam
*dp
, struct winctrls
*wc
,
282 struct ctlpos
*cp
, struct controlset
*s
, int *id
);
283 int winctrl_handle_command(struct dlgparam
*dp
, UINT msg
,
284 WPARAM wParam
, LPARAM lParam
);
285 void winctrl_rem_shortcuts(struct dlgparam
*dp
, struct winctrl
*c
);
286 int winctrl_context_help(struct dlgparam
*dp
, HWND hwnd
, int id
);
288 void dp_init(struct dlgparam
*dp
);
289 void dp_add_tree(struct dlgparam
*dp
, struct winctrls
*tree
);
290 void dp_cleanup(struct dlgparam
*dp
);
293 * Exports from wincfg.c.
295 void win_setup_config_box(struct controlbox
*b
, HWND
*hwndp
, int has_help
,
299 * Exports from windlg.c.
301 void defuse_showwindow(void);
303 int do_reconfig(HWND
);
304 void showeventlog(HWND
);
305 void showabout(HWND
);
306 void force_normal(HWND hwnd
);
307 void modal_about_box(HWND hwnd
);
308 void show_help(HWND hwnd
);
311 * Exports from sizetip.c.
313 void UpdateSizeTip(HWND src
, int cx
, int cy
);
314 void EnableSizeTip(int bEnable
);
317 * Exports from unicode.c.
320 void init_ucs(Config
*, struct unicode_data
*);
323 * pageantc.c needs to schedule callbacks for asynchronous agent
324 * requests. This has to be done differently in GUI and console, so
325 * there's an exported function used for the purpose.
327 * Also, we supply FLAG_SYNCAGENT to force agent requests to be
328 * synchronous in pscp and psftp.
330 void agent_schedule_callback(void (*callback
)(void *, void *, int),
331 void *callback_ctx
, void *data
, int len
);
332 #define FLAG_SYNCAGENT 0x1000