* Initial release of Alpine version 2.22.
[alpine.git] / pico / osdep / mswin.h
blob6482b525438af3edc7f6610accc245b28ce80e2c
1 /*
2 * ========================================================================
3 * Copyright 2006-2007 University of Washington
4 * Copyright 2013-2020 Eduardo Chappa
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * ========================================================================
16 #ifndef MSWIN_H
17 #define MSWIN_H
20 #define __far
21 #define _far
22 #define __export
25 * Equivalent to a windows handle.
27 typedef void *WINHAND;
30 * Mouse input events.
32 typedef struct {
33 int event;
34 int button;
35 int nRow;
36 int nColumn;
37 int keys;
38 int flags;
39 } MEvent;
43 * These define how mouse events get queued.
45 #define MSWIN_MF_REPLACING 0x1000
46 #define MSWIN_MF_REPEATING 0x2000
49 typedef struct {
50 int ch;
51 int rval;
52 LPTSTR name;
53 LPTSTR label;
54 int id;
55 } MDlgButton;
60 * Struct to tell pico how to build and what to return when
61 * it's asked to build a popup menu.
63 typedef struct _popup {
64 enum {tIndex, tQueue, tMessage, tSubMenu,
65 tSeparator, tTail} type;
66 struct { /* menu's label */
67 char *string;
68 enum {lNormal = 0, lChecked, lDisabled} style;
69 } label;
70 union {
71 UCS val; /* Queue: inserted into input queue */
72 UCS msg; /* Message: gets posted to ghTTYWnd */
73 struct _popup *submenu; /* Submenu: array of submenu entries */
74 } data;
75 struct { /* Internal data */
76 int id;
77 } internal;
78 } MPopup;
83 * Type of function expected by mswin_allowcopy and mswin_allowcopycut
84 * and used in EditDoCopyData
86 typedef int (*getc_t)(int pos);
89 * Callback used to fetch text for display in alternate window. Text
90 * can be returned as either a pointer to a null terminated block of
91 * text (a string), with CRLF deliminating lines. OR as a pointer to
92 * an array of pointers to lines, each line being a null terminated
93 * string.
95 typedef int (*gettext_t)(char *title, void **text, long *len, int *format);
98 * Type used by line up/down event handlers to move the body of the
99 * displayed text, by sort callback to get/set sort order, by
100 * header mode to get/set header state...
102 typedef int (*cbarg_t)(int action, long args);
106 * Callback used for periodic callback.
108 typedef void (*cbvoid_t)(void);
109 typedef char *(*cbstr_t)(char *);
112 #define GETTEXT_TITLELEN 128
113 #define GETTEXT_TEXT 1 /* 'text' is pointer to text. */
114 #define GETTEXT_LINES 2 /* 'text' is pointer to array of
115 * pointers to lines. */
118 #ifndef PATH_MAX
119 #define PATH_MAX 128 /* Max size of a directory path. */
120 #endif
123 * Scroll callback values. Used to be mapped in the MSWIN_RANGE_START..END
124 * range, but now are mapped directly to keydefs.h values. Except two of
125 * them which don't have map values in keydefs.h so they're still in the
126 * MSWIN_RANGE_START..END 0x7000 range.
128 #define MSWIN_KEY_SCROLLUPPAGE 0x7000
129 #define MSWIN_KEY_SCROLLDOWNPAGE 0x7001
130 #define MSWIN_KEY_SCROLLUPLINE KEY_SCRLUPL
131 #define MSWIN_KEY_SCROLLDOWNLINE KEY_SCRLDNL
132 #define MSWIN_KEY_SCROLLTO KEY_SCRLTO
134 #define MSWIN_PASTE_DISABLE 0
135 #define MSWIN_PASTE_FULL 1
136 #define MSWIN_PASTE_LINE 2
139 #define MSWIN_CURSOR_ARROW 0
140 #define MSWIN_CURSOR_BUSY 1
141 #define MSWIN_CURSOR_IBEAM 2
142 #define MSWIN_CURSOR_HAND 3
145 * Flags for mswin_displaytext
147 #define MSWIN_DT_NODELETE 0x0001 /* Don't delete text when
148 * window closes. */
149 #define MSWIN_DT_USEALTWINDOW 0x0002 /* Put text in alt window if already
150 * open. Open if not. */
151 #define MSWIN_DT_FILLFROMFILE 0x0004 /* pText_utf8 is a filename. */
154 * functions from mswin.c
158 WINHAND mswin_gethinstance();
159 WINHAND mswin_gethwnd ();
160 void mswin_killsplash();
161 void mswin_settitle(char *);
162 int mswin_getmouseevent (MEvent * pMouse);
163 void mswin_mousetrackcallback (cbarg_t cbfunc);
164 int mswin_popup(MPopup *members);
165 void mswin_keymenu_popup ();
166 void mswin_registericon(int row, int id, char *file);
167 void mswin_destroyicons();
168 void mswin_finishicons();
169 void mswin_show_icon (int x, int y, char *file);
170 void mswin_setdebug (int debug, FILE *debugfile);
171 void mswin_setnewmailwidth (int width);
172 int mswin_setdndcallback (int (*cb)());
173 int mswin_cleardndcallback (void);
174 int mswin_setresizecallback (int (*cb)());
175 int mswin_clearresizecallback (int (*cb)());
176 void mswin_setdebugoncallback (cbvoid_t cbfunc);
177 void mswin_setdebugoffcallback (cbvoid_t cbfunc);
178 int mswin_setconfigcallback (cbvoid_t cffunc);
179 int mswin_sethelpcallback (cbstr_t cbfunc);
180 int mswin_setgenhelpcallback (cbstr_t cbfunc);
181 void mswin_setclosetext (char *pCloseText);
182 int mswin_setwindow (char *fontName, char *fontSize,
183 char *fontStyle, char *windowPosition,
184 char *cursorStyle, char *fontCharSet);
185 int mswin_showwindow();
186 int mswin_getwindow (char *fontName, size_t nfontName,
187 char *fontSize, size_t nfontSize,
188 char *fontStyle, size_t nfontStyle,
189 char *windowPosition, size_t nwindowPosition,
190 char *foreColor, size_t nforeColor,
191 char *backColor, size_t nbackColor,
192 char *cursorStyle, size_t ncursorStyle,
193 char *fontCharSet, size_t nfontCharSet);
194 void mswin_noscrollupdate (int flag);
195 void mswin_setscrollrange (long page, long max);
196 void mswin_setscrollpos (long pos);
197 long mswin_getscrollpos (void);
198 long mswin_getscrollto (void);
199 void mswin_setscrollcallback (cbarg_t cbfunc);
200 void mswin_setsortcallback (cbarg_t cbfunc);
201 void mswin_setflagcallback (cbarg_t cbfunc);
202 void mswin_sethdrmodecallback (cbarg_t cbfunc);
203 void mswin_setselectedcallback (cbarg_t cbfunc);
204 void mswin_setzoomodecallback (cbarg_t cbfunc);
205 void mswin_setfkeymodecallback (cbarg_t cbfunc);
206 void mswin_setprintfont (char *fontName, char *fontSize,
207 char *fontStyle, char *fontCharSet);
208 void mswin_getprintfont (char *, size_t, char *, size_t,
209 char *, size_t, char *, size_t);
210 int mswin_yield (void);
211 int mswin_charavail (void);
212 UCS mswin_getc_fast (void);
213 void mswin_flush_input (void);
214 int mswin_showcursor (int show);
215 int mswin_showcaret (int show);
216 void mswin_trayicon (int show);
217 int mswin_move (int row, int column);
218 int mswin_getpos (int *row, int *column);
219 int mswin_getscreensize (int *row, int *column);
220 void mswin_minimize (void);
221 int mswin_putblock (char *utf8_str, int strLen);
222 int mswin_puts (char *utf8_str);
223 int mswin_puts_n (char *utf8_str, int n);
224 int mswin_putc (UCS c);
225 int mswin_outc (char c);
226 int mswin_rev (int state);
227 int mswin_getrevstate (void);
228 int mswin_bold (int state);
229 int mswin_uline (int state);
230 int mswin_eeol (void);
231 int mswin_eeop (void);
232 int mswin_beep (void);
233 void mswin_pause (int);
234 int mswin_flush (void);
235 void mswin_setcursor (int);
236 void mswin_messagebox (char *msg, int);
237 void mswin_allowpaste (int);
238 void mswin_allowcopycut (getc_t);
239 void mswin_allowcopy (getc_t);
240 void mswin_addclipboard (char *s);
241 void mswin_allowmousetrack (int);
242 int mswin_newmailicon (void);
243 void mswin_newmailtext (char *t);
244 void mswin_newmaildone (void);
245 void mswin_mclosedtext (char *t);
246 void mswin_menuitemclear (void);
247 void mswin_menuitemadd (UCS key, char *label, int menuitem,
248 int flags);
249 int mswin_setwindowmenu (int menu);
250 int mswin_print_ready (WINHAND hWnd, LPTSTR docDesc);
251 int mswin_print_done (void);
252 char * mswin_print_error (int errorcode);
253 int mswin_print_char (TCHAR c);
254 int mswin_print_char_utf8 (int c);
255 int mswin_print_text (LPTSTR text);
256 int mswin_print_text_utf8 (char *text);
257 int mswin_savefile (char *dir, int dirlen, char *fName, int nMaxFName);
258 int mswin_openfile (char *dir, int nMaxDName, char *fName, int nMaxFName, char *extlist);
259 int mswin_multopenfile (char *dir, int nMaxDName, char *fName, int nMaxFName, char *extlist);
260 char *mswin_rgbchoice(char *pOldRGB);
261 void mswin_killbuftoclip (getc_t copyfunc);
262 void pico_popup();
263 void mswin_paste_popup();
264 int mswin_fflush (FILE *f);
265 void mswin_setperiodiccallback (cbvoid_t periodiccb, long period);
266 WINHAND mswin_inst2task (WINHAND hInst);
267 int mswin_ontask_del (WINHAND hTask, char *path);
268 int mswin_exec_and_wait (char *whatsit, char *command,
269 char *infile, char *outfile,
270 int *exit_val,
271 unsigned mseaw_flags);
272 int mswin_shell_exec (char *command, WINHAND *childproc);
273 void mswin_exec_err_msg (char *what, int status, char *buf,
274 size_t buflen);
275 int mswin_onexit_del (char *path);
276 int mswin_set_quit_confirm (int);
277 void mswin_showhelpmsg (WINHAND hWnd, char **helplines);
279 typedef struct MSWIN_TEXTWINDOW MSWIN_TEXTWINDOW;
280 MSWIN_TEXTWINDOW *mswin_displaytext (char *title, char *pText, size_t textLen,
281 char **pLines, MSWIN_TEXTWINDOW *mswin_tw,
282 int flags);
283 int mswin_imaptelemetry(char *msg);
284 void mswin_enableimaptelemetry(int state);
285 int mswin_newmailwin(int is_us, char *from,
286 char *subject, char *folder);
287 int mswin_newmailwinon(void);
289 char *mswin_reg_default_browser(char *url);
290 int mswin_reg(int op, int tree, char *data, size_t size);
291 int mswin_is_def_client(int type);
292 int mswin_set_def_client(int type);
293 char **mswin_reg_dump(void);
294 int mswin_majorver();
295 int mswin_minorver();
296 char *mswin_compilation_date();
297 char *mswin_compilation_remarks();
298 char *mswin_specific_winver();
301 int mswin_usedialog (void);
302 int mswin_dialog(UCS *prompt, UCS *string, int field_len,
303 int append_current, int passwd,
304 MDlgButton *button_list, char **help, unsigned flags);
305 int mswin_select(char *utf8prompt, MDlgButton *button_list,
306 int dflt, int on_ctrl_C, char **help, unsigned flags);
307 int mswin_yesno(UCS *);
308 int mswin_yesno_utf8(char *);
310 BOOL MSWRShellCanOpen(LPTSTR key, char *cmdbuf, int clen, int allow_noreg);
311 BOOL MSWRPeek(HKEY hRootKey, LPTSTR subkey, LPTSTR valstr,
312 LPTSTR data, DWORD *dlen);
313 int mswin_store_pass_prompt(void);
314 void mswin_set_erasecreds_callback(cbvoid_t);
315 void mswin_setviewinwindcallback (cbvoid_t);
316 int mswin_setgenhelptextcallback(cbstr_t);
317 int mswin_caninput(void);
318 void mswin_beginupdate(void);
319 void mswin_endupdate(void);
320 int mswin_sethelptextcallback(cbstr_t);
321 int strucmp(char *, char *);
322 int struncmp(char *, char *, int);
324 #ifdef MSC_MALLOC
326 * These definitions will disable the SEGHEAP allocation routines, in
327 * favor of the compliler libraries usual allocators. This is useful
328 * when external debugging tools and the SEGHEAP debugging routines step
329 * on each other...
331 #define MemAlloc(X) malloc(X)
332 #define MemFree(X) free(X)
333 #define MemRealloc(X,Y) realloc(X,Y)
334 #define MemFreeAll()
335 #define MemDebug(X,Y)
336 #else
338 * Memory management stuff, from msmem.c
340 typedef unsigned long MemSize;
341 typedef void __far * MemPtr;
343 #define MemAlloc(s) _MemAlloc (s, __FILE__, __LINE__)
344 #define malloc(s) _MemAlloc (s, __FILE__, __LINE__)
345 #define MemFree(b) _MemFree (b, __FILE__, __LINE__)
346 #define free(b) _MemFree (b, __FILE__, __LINE__)
347 #define MemRealloc(b,s) _MemRealloc (b, s, __FILE__, __LINE__)
348 #define realloc(b,s) _MemRealloc (b, s, __FILE__, __LINE__)
349 #define MEM_BLOCK_SIZE_MAX 0xff00
351 void MemDebug (int debug, FILE *debugFile);
352 void __far * _MemAlloc (MemSize size, char __far * file, int line);
353 int _MemFree (void __far *block, char __far *file, int line);
354 void __far * _MemRealloc (void __far *block, MemSize size,
355 char __far * file, int line);
356 MemSize MemBlkSize (MemPtr block);
357 void MemFreeAll (void);
358 void MemFailSoon (MemSize);
359 #endif
361 /* functions from win moved to mswin.c */
362 int pico_scroll_callback (int, long);
363 #undef sleep
364 int sleep (int);
367 * Signals that are not defined by MS C
369 #define SIGHUP 1 /* Terminal hangup. */
370 #define SIGINT 2 /* Ctrl-C sequence */
371 #define SIGILL 4 /* illegal instruction - invalid function image */
372 #define SIGSEGV 11 /* segment violation */
373 #define SIGALRM 14 /* alarm clock */
374 #define SIGTERM 15 /* Software termination signal from kill */
375 #define SIGABRT 22 /* abnormal termination triggered by abort call */
376 #define SIGWINCH 28 /* Change in window size. */
379 #define fflush mswin_fflush
381 #define alarm mswin_alarm
384 * Registry setting constants
386 #define MSWR_PINE_RC 1
387 #define MSWR_PINE_DIR 2
388 #define MSWR_PINE_EXE 3
389 #define MSWR_PINE_AUX 4
390 #define MSWR_PINE_POS 5
391 #define MSWR_PINE_CONF 6
393 #define MSWR_SDC_MAIL 1
394 #define MSWR_SDC_NEWS 2
395 #define MSWR_SDC_NNTP 3
396 #define MSWR_SDC_IMAP 4
398 #define MSWR_NULL 0x00
399 #define MSWR_OP_SET 0x01
400 #define MSWR_OP_FORCE 0x02
401 #define MSWR_OP_GET 0x04
402 #define MSWR_OP_BLAST 0x08
404 #endif /* MSWIN_H */