xref: /freebsd/contrib/dialog/dialog.h (revision a96ef4501919d7ac08e94e98dc34b0bdd744802b)
1 /*
2  *  $Id: dialog.h,v 1.304 2021/01/17 16:58:22 tom Exp $
3  *
4  *  dialog.h -- common declarations for all dialog modules
5  *
6  *  Copyright 2000-2020,2021	Thomas E. Dickey
7  *
8  *  This program is free software; you can redistribute it and/or modify
9  *  it under the terms of the GNU Lesser General Public License, version 2.1
10  *  as published by the Free Software Foundation.
11  *
12  *  This program is distributed in the hope that it will be useful, but
13  *  WITHOUT ANY WARRANTY; without even the implied warranty of
14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  *  Lesser General Public License for more details.
16  *
17  *  You should have received a copy of the GNU Lesser General Public
18  *  License along with this program; if not, write to
19  *	Free Software Foundation, Inc.
20  *	51 Franklin St., Fifth Floor
21  *	Boston, MA 02110, USA.
22  *
23  *  An earlier version of this program lists as authors
24  *	Savio Lam (lam836@cs.cuhk.hk)
25  */
26 
27 #ifndef DIALOG_H_included
28 #define DIALOG_H_included 1
29 /* *INDENT-OFF* */
30 
31 #include <dlg_config.h>
32 
33 #ifdef __hpux
34 #define __HP_CURSES_COMPAT	/* workaround for getattrs, etc. */
35 #endif
36 
37 #include <sys/types.h>
38 #include <fcntl.h>
39 #include <unistd.h>
40 #include <ctype.h>
41 #include <stdlib.h>
42 #include <stdarg.h>
43 #include <string.h>
44 #include <signal.h>	/* fork() etc. */
45 #include <math.h>	/* sqrt() */
46 
47 /* header conflict with Solaris xpg4 versus <sys/regset.h> */
48 #if defined(ERR) && (ERR == 13)
49 #undef ERR
50 #endif
51 
52 #if defined(HAVE_NCURSESW_NCURSES_H)
53 #include <ncursesw/ncurses.h>
54 #elif defined(HAVE_NCURSES_NCURSES_H)
55 #include <ncurses/ncurses.h>
56 #elif defined(HAVE_NCURSES_CURSES_H)
57 #include <ncurses/curses.h>
58 #elif defined(HAVE_NCURSES_H)
59 #include <ncurses.h>
60 #else
61 #include <curses.h>
62 #if defined(HAVE_UNCTRL_H)
63 #include <unctrl.h> /* most curses.h headers include this, some do not */
64 #endif
65 #endif
66 
67 /* Solaris xpg4 renames these */
68 #ifndef KEY_MAX
69 #ifdef __KEY_MAX
70 #define KEY_MAX __KEY_MAX
71 #endif
72 #endif
73 
74 #ifndef KEY_MIN
75 #ifdef __KEY_MIN
76 #define KEY_MIN __KEY_MIN
77 #endif
78 #endif
79 
80 /* possible conflicts with <term.h> which may be included in <curses.h> */
81 #ifdef color_names
82 #undef color_names
83 #endif
84 
85 #ifdef buttons
86 #undef buttons
87 #endif
88 
89 #ifdef ENABLE_NLS
90 #include <libintl.h>
91 #include <langinfo.h>
92 #define _(s) dgettext(PACKAGE, s)
93 #else
94 #undef _
95 #define _(s) s
96 #endif
97 
98 #ifndef GCC_PRINTFLIKE
99 #define GCC_PRINTFLIKE(fmt,var) /*nothing*/
100 #endif
101 
102 #ifndef GCC_NORETURN
103 #define GCC_NORETURN /*nothing*/
104 #endif
105 
106 #ifndef GCC_UNUSED
107 #define GCC_UNUSED /*nothing*/
108 #endif
109 
110 #ifndef HAVE_WGET_WCH
111 #undef USE_WIDE_CURSES
112 #endif
113 
114 /*
115  * FIXME: a configure check would be useful
116  */
117 #ifdef __hpux
118 #undef ACS_UARROW
119 #undef ACS_DARROW
120 #undef ACS_BLOCK
121 #endif
122 
123 /*
124  * Change these if you want
125  */
126 #define USE_SHADOW TRUE
127 #define USE_COLORS TRUE
128 
129 /*
130  * These allow using the print-formatting code before curses is initialized.
131  */
132 #define DLG_COLS  (COLS  ? COLS  : dialog_state.screen_width)
133 #define DLG_LINES (LINES ? LINES : dialog_state.screen_height)
134 
135 /*
136  * Define the usable size of a window, discounting the area needed for shadow.
137  */
138 #ifdef HAVE_COLOR
139 #define SCOLS	(DLG_COLS  - (dialog_state.use_shadow ? SHADOW_COLS : 0))
140 #define SLINES	(DLG_LINES - (dialog_state.use_shadow ? SHADOW_ROWS : 0))
141 #else
142 #define SCOLS	COLS
143 #define SLINES	LINES
144 #endif
145 
146 /*
147  * These are the default values for exit-codes, which can be overridden by
148  * environment variables, e.g., $DIALOG_CANCEL for DLG_EXIT_CANCEL.
149  */
150 #define DLG_EXIT_ESC		255
151 #define DLG_EXIT_UNKNOWN	-2	/* never return this (internal use) */
152 #define DLG_EXIT_ERROR		-1	/* the shell sees this as 255 */
153 #define DLG_EXIT_OK		0
154 #define DLG_EXIT_CANCEL		1
155 #define DLG_EXIT_HELP		2
156 #define DLG_EXIT_EXTRA		3
157 #define DLG_EXIT_ITEM_HELP	4	/* actually DLG_EXIT_HELP */
158 #define DLG_EXIT_TIMEOUT	5
159 
160 #define DLG_CTRL(n)	((n) & 0x1f)	/* CTRL is preferred, but conflicts */
161 
162 #define CHR_LEAVE	DLG_CTRL('D')
163 #define CHR_HELP	DLG_CTRL('E')
164 #define CHR_BACKSPACE	DLG_CTRL('H')
165 #define CHR_REPAINT	DLG_CTRL('L')
166 #define CHR_NEXT	DLG_CTRL('N')
167 #define CHR_PREVIOUS	DLG_CTRL('P')
168 #define CHR_KILL	DLG_CTRL('U')
169 #define CHR_TRACE	DLG_CTRL('T')
170 #define CHR_LITERAL	DLG_CTRL('V')
171 #define CHR_SPACE 	' '
172 #define CHR_DELETE	127
173 
174 #define ESC		27
175 #define TAB		DLG_CTRL('I')
176 
177 #define MARGIN 1	/* width of the line drawn around each box */
178 #define GUTTER 2	/* minimum columns between name/description in menu */
179 #define SHADOW_ROWS 1	/* rows to reserve for window's shadow */
180 #define SHADOW_COLS 2	/* columns to reserve for window's shadow */
181 #define ARROWS_COL  5	/* distance from left margin to up/down arrows */
182 
183 #define MAX_LEN 2048
184 #define BUF_SIZE (10L*1024)
185 
186 #undef  MIN
187 #define MIN(x,y) ((x) < (y) ? (x) : (y))
188 
189 #undef  MAX
190 #define MAX(x,y) ((x) > (y) ? (x) : (y))
191 
192 #define DEFAULT_SEPARATE_STR "\t"
193 #define DEFAULT_ASPECT_RATIO 9
194 /* how many spaces is a tab long (default)? */
195 #define TAB_LEN 8
196 #define WTIMEOUT_VAL        10	/* minimum amount of time needed for curses */
197 #define WTIMEOUT_OFF        -1	/* value to disable timeout */
198 
199 #ifndef A_CHARTEXT
200 #define A_CHARTEXT 0xff
201 #endif
202 
203 #define CharOf(ch)  ((ch) & 0xff)
204 
205 #ifndef ACS_ULCORNER
206 #define ACS_ULCORNER '+'
207 #endif
208 #ifndef ACS_LLCORNER
209 #define ACS_LLCORNER '+'
210 #endif
211 #ifndef ACS_URCORNER
212 #define ACS_URCORNER '+'
213 #endif
214 #ifndef ACS_LRCORNER
215 #define ACS_LRCORNER '+'
216 #endif
217 #ifndef ACS_HLINE
218 #define ACS_HLINE '-'
219 #endif
220 #ifndef ACS_VLINE
221 #define ACS_VLINE '|'
222 #endif
223 #ifndef ACS_LTEE
224 #define ACS_LTEE '+'
225 #endif
226 #ifndef ACS_RTEE
227 #define ACS_RTEE '+'
228 #endif
229 #ifndef ACS_UARROW
230 #define ACS_UARROW '^'
231 #endif
232 #ifndef ACS_DARROW
233 #define ACS_DARROW 'v'
234 #endif
235 #ifndef ACS_BLOCK
236 #define ACS_BLOCK '#'
237 #endif
238 
239 /* these definitions may work for antique versions of curses */
240 #ifndef HAVE_GETBEGYX
241 #undef  getbegyx
242 #define getbegyx(win,y,x)	(y = (win)?(win)->_begy:ERR, x = (win)?(win)->_begx:ERR)
243 #endif
244 
245 #ifndef HAVE_GETMAXYX
246 #undef  getmaxyx
247 #define getmaxyx(win,y,x)	(y = (win)?(win)->_maxy:ERR, x = (win)?(win)->_maxx:ERR)
248 #endif
249 
250 #ifndef HAVE_GETPARYX
251 #undef  getparyx
252 #define getparyx(win,y,x)	(y = (win)?(win)->_pary:ERR, x = (win)?(win)->_parx:ERR)
253 #endif
254 
255 #if !defined(HAVE_WGETPARENT) && defined(HAVE_WINDOW__PARENT)
256 #undef  wgetparent
257 #define wgetparent(win)		((win) ? (win)->_parent : 0)
258 #endif
259 
260 #if !defined(HAVE_WSYNCUP)
261 #undef wsyncup
262 #define wsyncup(win) /* nothing */
263 #endif
264 
265 #if !defined(HAVE_WCURSYNCUP)
266 #undef wcursyncup
267 #define wcursyncup(win) /* nothing */
268 #endif
269 
270 #ifdef __cplusplus
271 extern "C" {
272 #endif
273 
274 /* these definitions may be needed for bleeding-edge curses implementations */
275 #if !(defined(HAVE_GETBEGX) && defined(HAVE_GETBEGY))
276 #undef getbegx
277 #undef getbegy
278 #define getbegx(win) dlg_getbegx(win)
279 #define getbegy(win) dlg_getbegy(win)
280 extern int dlg_getbegx(WINDOW * /*win*/);
281 extern int dlg_getbegy(WINDOW * /*win*/);
282 #endif
283 
284 #if !(defined(HAVE_GETCURX) && defined(HAVE_GETCURY))
285 #undef getcurx
286 #undef getcury
287 #define getcurx(win) dlg_getcurx(win)
288 #define getcury(win) dlg_getcury(win)
289 extern int dlg_getcurx(WINDOW * /*win*/);
290 extern int dlg_getcury(WINDOW * /*win*/);
291 #endif
292 
293 #if !(defined(HAVE_GETMAXX) && defined(HAVE_GETMAXY))
294 #undef getmaxx
295 #undef getmaxy
296 #define getmaxx(win) dlg_getmaxx(win)
297 #define getmaxy(win) dlg_getmaxy(win)
298 extern int dlg_getmaxx(WINDOW * /*win*/);
299 extern int dlg_getmaxy(WINDOW * /*win*/);
300 #endif
301 
302 #if !(defined(HAVE_GETPARX) && defined(HAVE_GETPARY))
303 #undef getparx
304 #undef getpary
305 #define getparx(win) dlg_getparx(win)
306 #define getpary(win) dlg_getpary(win)
307 extern int dlg_getparx(WINDOW * /*win*/);
308 extern int dlg_getpary(WINDOW * /*win*/);
309 #endif
310 
311 #if !(defined(HAVE_WGETPARENT) && defined(HAVE_WINDOW__PARENT))
312 #undef wgetparent
313 #define wgetparent(win) dlg_wgetparent(win)
314 extern WINDOW * dlg_wgetparent(WINDOW * /*win*/);
315 #endif
316 
317 /*
318  * This is a list of "old" names, which should be helpful in updating
319  * applications that use libdialog.  Starting with 2003/11/26, all exported
320  * symbols from libdialog have "dlg_" prefix, or "dialog_" prefix or "_dialog"
321  * suffix (or suffix "_dialog", e.g., init_dialog).
322  */
323 #ifdef __DIALOG_OLD_NAMES__
324 #define color_table                       dlg_color_table
325 #define attr_clear(win,h,w,a)             dlg_attr_clear(win,h,w,a)
326 #define auto_size(t,s,h,w,xl,mc)          dlg_auto_size(t,s,h,w,xl,mc)
327 #define auto_sizefile(t,f,h,w,xl,mc)      dlg_auto_sizefile(t,f,h,w,xl,mc)
328 #define beeping()                         dlg_beeping()
329 #define box_x_ordinate(w)                 dlg_box_x_ordinate(w)
330 #define box_y_ordinate(h)                 dlg_box_y_ordinate(h)
331 #define calc_listh(h,lh,in)               dlg_calc_listh(h,lh,in)
332 #define calc_listw(in,items,group)        dlg_calc_listw(in,items,group)
333 #define color_setup()                     dlg_color_setup()
334 #define create_rc(f)                      dlg_create_rc(f)
335 #define ctl_size(h,w)                     dlg_ctl_size(h,w)
336 #define del_window(win)                   dlg_del_window(win)
337 #define dialog_clear()                    dlg_clear()
338 #define draw_bottom_box(win)              dlg_draw_bottom_box(win)
339 #define draw_box(win,y,x,h,w,xc,bc)       dlg_draw_box(win,y,x,h,w,xc,bc)
340 #define draw_shadow(win,h,w,y,x)          dlg_draw_shadow(win,h,w,y,x)
341 #define draw_title(win,t)                 dlg_draw_title(win,t)
342 #define exiterr                           dlg_exiterr
343 #define killall_bg(n)                     dlg_killall_bg(n)
344 #define mouse_bigregion(y,x)              dlg_mouse_bigregion(y,x)
345 #define mouse_free_regions()              dlg_mouse_free_regions()
346 #define mouse_mkbigregion(y,x,h,w,n,ix,iy,m) dlg_mouse_mkbigregion(y,x,h,w,n,ix,iy,m)
347 #define mouse_mkregion(y,x,h,w,n)         dlg_mouse_mkregion(y,x,h,w,n)
348 #define mouse_region(y,x)                 dlg_mouse_region(y,x)
349 #define mouse_setbase(x,y)                dlg_mouse_setbase(x,y)
350 #define mouse_setcode(c)                  dlg_mouse_setcode(c)
351 #define mouse_wgetch(w,c)                 dlg_mouse_wgetch(w,c)
352 #define new_window(h,w,y,x)               dlg_new_window(h,w,y,x)
353 #define parse_rc()                        dlg_parse_rc()
354 #define print_autowrap(win,s,h,w)         dlg_print_autowrap(win,s,h,w)
355 #define print_size(h,w)                   dlg_print_size(h,w)
356 #define put_backtitle()                   dlg_put_backtitle()
357 #define strclone(cprompt)                 dlg_strclone(cprompt)
358 #define sub_window(win,h,w,y,x)           dlg_sub_window(win,h,w,y,x)
359 #define tab_correct_str(s)                dlg_tab_correct_str(s)
360 #endif
361 
362 /*
363  * Attribute names
364  */
365 #define DIALOG_ATR(n)                 dlg_color_table[n].atr
366 
367 #define screen_attr                   DIALOG_ATR(0)
368 #define shadow_attr                   DIALOG_ATR(1)
369 #define dialog_attr                   DIALOG_ATR(2)
370 #define title_attr                    DIALOG_ATR(3)
371 #define border_attr                   DIALOG_ATR(4)
372 #define button_active_attr            DIALOG_ATR(5)
373 #define button_inactive_attr          DIALOG_ATR(6)
374 #define button_key_active_attr        DIALOG_ATR(7)
375 #define button_key_inactive_attr      DIALOG_ATR(8)
376 #define button_label_active_attr      DIALOG_ATR(9)
377 #define button_label_inactive_attr    DIALOG_ATR(10)
378 #define inputbox_attr                 DIALOG_ATR(11)
379 #define inputbox_border_attr          DIALOG_ATR(12)
380 #define searchbox_attr                DIALOG_ATR(13)
381 #define searchbox_title_attr          DIALOG_ATR(14)
382 #define searchbox_border_attr         DIALOG_ATR(15)
383 #define position_indicator_attr       DIALOG_ATR(16)
384 #define menubox_attr                  DIALOG_ATR(17)
385 #define menubox_border_attr           DIALOG_ATR(18)
386 #define item_attr                     DIALOG_ATR(19)
387 #define item_selected_attr            DIALOG_ATR(20)
388 #define tag_attr                      DIALOG_ATR(21)
389 #define tag_selected_attr             DIALOG_ATR(22)
390 #define tag_key_attr                  DIALOG_ATR(23)
391 #define tag_key_selected_attr         DIALOG_ATR(24)
392 #define check_attr                    DIALOG_ATR(25)
393 #define check_selected_attr           DIALOG_ATR(26)
394 #define uarrow_attr                   DIALOG_ATR(27)
395 #define darrow_attr                   DIALOG_ATR(28)
396 #define itemhelp_attr                 DIALOG_ATR(29)
397 #define form_active_text_attr         DIALOG_ATR(30)
398 #define form_text_attr                DIALOG_ATR(31)
399 #define form_item_readonly_attr       DIALOG_ATR(32)
400 #define gauge_attr                    DIALOG_ATR(33)
401 #define border2_attr                  DIALOG_ATR(34)
402 #define inputbox_border2_attr         DIALOG_ATR(35)
403 #define searchbox_border2_attr        DIALOG_ATR(36)
404 #define menubox_border2_attr          DIALOG_ATR(37)
405 
406 #define DLGK_max (KEY_MAX + 256)
407 
408 /*
409  * Use attributes.
410  */
411 #ifdef PDCURSES
412 #define dlg_attrset(w,a)  (void) wattrset((w), (a))
413 #define dlg_attron(w,a)   (void) wattron((w), (a))
414 #define dlg_attroff(w,a)  (void) wattroff((w), (a))
415 #else
416 #define dlg_attrset(w,a)  (void) wattrset((w), (int)(a))
417 #define dlg_attron(w,a)   (void) wattron((w), (int)(a))
418 #define dlg_attroff(w,a)  (void) wattroff((w), (int)(a))
419 #endif
420 
421 /*
422  * Callbacks are used to implement the "background" tailbox.
423  */
424 struct _dlg_callback;
425 
426 typedef void (*DIALOG_FREEBACK) (struct _dlg_callback * /* p */);
427 
428 typedef struct _dlg_callback {
429     struct _dlg_callback *next;
430     FILE *input;
431     WINDOW *win;
432     bool keep_bg;	/* keep in background, on exit */
433     bool bg_task;	/* true if this is background task */
434     bool (*handle_getc)(struct _dlg_callback *p, int ch, int fkey, int *result);
435     bool keep_win;	/* true to not erase window on exit */
436     /* data for dlg_add_callback_ref */
437     struct _dlg_callback **caller;
438     DIALOG_FREEBACK freeback;
439     /* 1.1-20110107 */
440     bool (*handle_input)(struct _dlg_callback *p);
441     bool input_ready;
442 } DIALOG_CALLBACK;
443 
444 typedef struct _dlg_windows {
445     struct _dlg_windows *next;
446     WINDOW *normal;
447     WINDOW *shadow;
448     int getc_timeout;
449 } DIALOG_WINDOWS;
450 
451 /*
452  * Global variables, which are initialized as needed
453  */
454 typedef struct {
455     DIALOG_CALLBACK *getc_callbacks;
456     DIALOG_CALLBACK *getc_redirect;
457     DIALOG_WINDOWS *all_windows;
458     DIALOG_WINDOWS *all_subwindows;
459     FILE *output;		/* option "--output-fd fd" */
460     FILE *pipe_input;		/* used for gauge widget */
461     FILE *screen_output;	/* newterm(), etc. */
462     bool screen_initialized;
463     bool use_colors;		/* use colors by default? */
464     bool use_scrollbar;		/* option "--scrollbar" */
465     bool use_shadow;		/* shadow dialog boxes by default? */
466     bool visit_items;		/* option "--visit-items" */
467     char *separate_str;		/* option "--separate-widget string" */
468     int aspect_ratio;		/* option "--aspect ratio" */
469     int output_count;		/* # of widgets that may have done output */
470     int tab_len;		/* option "--tab-len n" */
471     /* 1.0-20070227 */
472     FILE *input;		/* option "--input-fd fd" */
473 #ifdef HAVE_DLG_TRACE
474     FILE *trace_output;		/* option "--trace file" */
475 #endif
476     /* 1.1-20110106 */
477     bool no_mouse;		/* option "--no-mouse" */
478     int visit_cols;		/* option "--visit-items" */
479     /* 1.2-20130922 */
480     bool finish_string;		/* caching optimization for gauge */
481     /* 1.2-20150125 */
482     bool plain_buttons;		/* true to suppress button-label highlight */
483     /* 1.3-20180610 */
484     bool text_only;		/* option "--print-text-only", etc. */
485     int text_height;
486     int text_width;
487     /* 1.3-20190211 */
488     int screen_height;
489     int screen_width;
490 #ifdef KEY_RESIZE
491     /* 1.3-20190724 */
492     bool had_resize;		/* ERR may follow KEY_RESIZE when polling */
493 #endif
494 } DIALOG_STATE;
495 
496 extern DIALOG_STATE dialog_state;
497 
498 /*
499  * Global variables, which dialog resets before each widget
500  */
501 typedef struct {
502     bool beep_after_signal;	/* option "--beep-after" */
503     bool beep_signal;		/* option "--beep" */
504     bool begin_set;		/* option "--begin y x" was used */
505     bool cant_kill;		/* option "--no-kill" */
506     bool colors;		/* option "--colors" */
507     bool cr_wrap;		/* option "--cr-wrap" */
508     bool defaultno;		/* option "--defaultno" */
509     bool dlg_clear_screen;	/* option "--clear" */
510     bool extra_button;		/* option "--extra-button" */
511     bool help_button;		/* option "--help-button" */
512     bool help_status;		/* option "--help-status" */
513     bool input_menu;		/* menu vs inputmenu widget */
514     bool insecure;		/* option "--insecure" */
515     bool item_help;		/* option "--item-help" */
516     bool keep_window;		/* option "--keep-window" */
517     bool nocancel;		/* option "--no-cancel" */
518     bool nocollapse;		/* option "--no-collapse" */
519     bool print_siz;		/* option "--print-size" */
520     bool separate_output;	/* option "--separate-output" */
521     bool single_quoted;		/* option "--single-quoted" */
522     bool size_err;		/* option "--size-err" */
523     bool tab_correct;		/* option "--tab-correct" */
524     bool trim_whitespace;	/* option "--trim" */
525     char *backtitle;		/* option "--backtitle backtitle" */
526     char *cancel_label;		/* option "--cancel-label string" */
527     char *default_item;		/* option "--default-item string" */
528     char *exit_label;		/* option "--exit-label string" */
529     char *extra_label;		/* option "--extra-label string" */
530     char *help_label;		/* option "--help-label string" */
531     char *input_result;
532     char *no_label;		/* option "--no-label string" */
533     char *ok_label;		/* option "--ok-label string" */
534     char *title;		/* option "--title title" */
535     char *yes_label;		/* option "--yes-label string" */
536     int begin_x;		/* option "--begin y x" (second value) */
537     int begin_y;		/* option "--begin y x" (first value) */
538     int max_input;		/* option "--max-input size" */
539     int scale_factor;		/* RESERVED */
540     int sleep_secs;		/* option "--sleep secs" */
541     int timeout_secs;		/* option "--timeout secs" */
542     unsigned input_length;	/* nonzero if input_result is allocated */
543     /* 1.0-20051207 */
544     unsigned formitem_type;	/* DIALOG_FORMITEM.type in dialog_form() */
545     /* 1.1-20070227 */
546     bool keep_tite;		/* option "--keep-tite" */
547     bool ascii_lines;		/* option "--ascii-lines" */
548     bool no_lines;		/* option "--no-lines" */
549     /* 1.1-20070930 */
550     bool nook;			/* option "--no-ok" */
551     /* 1.1-20080727 */
552     bool quoted;		/* option "--quoted" */
553     char *column_header;	/* RESERVED "--column-header" */
554     char *column_separator;	/* option "--column-separator" */
555     char *output_separator;	/* option "--output-separator" */
556     /* 1.1-20100118 */
557     char *date_format;		/* option "--date-format" */
558     char *time_format;		/* option "--time-format" */
559     /* 1.1-20110629 */
560     char *help_line;		/* option "--hline" */
561     char *help_file;		/* option "--hfile" */
562     bool in_helpfile;		/* flag to prevent recursion in --hfile */
563     bool no_nl_expand;		/* option "--no-nl-expand" */
564     /* 1.1-20120701 */
565     int default_button;		/* option "--default-button" (exit code) */
566     /* 1.1-20121218 */
567     bool no_tags;		/* option "--no-tags" */
568     bool no_items;		/* option "--no-items" */
569     /* 1.2-20130315 */
570     bool last_key;		/* option "--last-key" */
571     /* 1.2-20130902 */
572     bool help_tags;		/* option "--help-tags" */
573     /* 1.3-20160126 */
574     char *week_start;		/* option "--week-start" */
575     /* 1.3-20160206 */
576     bool iso_week;		/* option "--iso-week" */
577     /* 1.3-20170131 */
578     bool reorder;		/* option "--reorder" */
579     /* 1.3-20201117 */
580     int pause_secs;		/* used by pause widget */
581     /* 1.3-20201126 */
582     bool erase_on_exit;		/* option "--erase-on-exit" */
583     bool cursor_off_label;	/* option "--cursor-off-label" */
584     /* 1.3-20210117 */
585     bool no_hot_list;		/* option "--no-hot-list" */
586 } DIALOG_VARS;
587 
588 #define USE_ITEM_HELP(s)        (dialog_vars.item_help && (s) != 0)
589 
590 /*
591  * Some settings change the number of data items per row which dialog reads
592  * from a script.
593  */
594 #define DLG__NO_ITEMS		(dialog_vars.no_items ? 0 : 1)
595 #define DLG__ITEM_HELP          (dialog_vars.item_help ? 1 : 0)
596 
597 /*
598  * These are the total number of data items per row used for each widget type.
599  */
600 #define CHECKBOX_TAGS           (2 + DLG__ITEM_HELP + DLG__NO_ITEMS)
601 #define MENUBOX_TAGS            (1 + DLG__ITEM_HELP + DLG__NO_ITEMS)
602 #define FORMBOX_TAGS            (8 + DLG__ITEM_HELP)
603 #define MIXEDFORM_TAGS          (1 + FORMBOX_TAGS)
604 #define MIXEDGAUGE_TAGS         2
605 #define TREEVIEW_TAGS           (3 + DLG__ITEM_HELP + DLG__NO_ITEMS)
606 
607 extern DIALOG_VARS dialog_vars;
608 
609 #ifndef HAVE_TYPE_CHTYPE
610 #define chtype long
611 #endif
612 
613 #ifndef isblank
614 #define isblank(c)       ((c) == ' ' || (c) == TAB)
615 #endif
616 
617 #define UCH(ch)			((unsigned char)(ch))
618 
619 #define assert_ptr(ptr,msg) if ((ptr) == 0) dlg_exiterr("cannot allocate memory in " msg)
620 
621 #define dlg_malloc(t,n)    (t *) malloc((size_t)(n) * sizeof(t))
622 #define dlg_calloc(t,n)    (t *) calloc((size_t)(n), sizeof(t))
623 #define dlg_realloc(t,n,p) (t *) realloc((p), (n) * sizeof(t))
624 
625 /*
626  * Table for attribute- and color-values.
627  */
628 typedef struct {
629     chtype atr;			/* attribute corresponding to fg, bg, etc */
630 #ifdef HAVE_COLOR
631     int fg;			/* foreground color-number */
632     int bg;			/* background color-number */
633     int hilite;			/* true if bold */
634 #ifdef HAVE_RC_FILE2
635     int ul;			/* true if underline */
636     int rv;			/* true if reverse */
637 #endif /* HAVE_RC_FILE2 */
638 #endif /* HAVE_COLOR */
639 #ifdef HAVE_RC_FILE
640     const char *name;
641     const char *comment;
642 #endif
643 } DIALOG_COLORS;
644 
645 extern DIALOG_COLORS dlg_color_table[];
646 
647 /*
648  * Function prototypes
649  */
650 extern const char *dialog_version(void);
651 
652 /* widgets, each in separate files */
653 extern int dialog_buildlist(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/, int /*list_height*/, int /*item_no*/, char ** /*items*/, int /*order_mode*/);
654 extern int dialog_calendar(const char * /*title*/, const char * /*subtitle*/, int /*height*/, int /*width*/, int /*day*/, int /*month*/, int /*year*/);
655 extern int dialog_checklist(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/, int /*list_height*/, int /*item_no*/, char ** /*items*/, int /*flag*/);
656 extern int dialog_dselect(const char * /*title*/, const char * /*path*/, int /*height*/, int /*width*/);
657 extern int dialog_editbox(const char * /*title*/, const char * /*file*/, int /*height*/, int /*width*/);
658 extern int dialog_form(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/, int /*form_height*/, int /*item_no*/, char ** /*items*/);
659 extern int dialog_fselect(const char * /*title*/, const char * /*path*/, int /*height*/, int /*width*/);
660 extern int dialog_gauge(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/, int /*percent*/);
661 extern int dialog_helpfile(const char * /*title*/, const char * /*file*/, int /*height*/, int /*width*/);
662 extern int dialog_inputbox(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/, const char * /*init*/, const int /*password*/);
663 extern int dialog_menu(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/, int /*menu_height*/, int /*item_no*/, char ** /*items*/);
664 extern int dialog_mixedform(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/, int /*form_height*/, int /*item_no*/, char ** /*items*/);
665 extern int dialog_mixedgauge(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/, int /*percent*/, int /*item_no*/, char ** /*items*/);
666 extern int dialog_msgbox(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/, int /*pauseopt*/);
667 extern int dialog_pause(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/, int /*seconds*/);
668 extern int dialog_prgbox(const char * /*title*/, const char * /*cprompt*/, const char * /*command*/, int /*height*/, int /*width*/, int /*pauseopt*/);
669 extern int dialog_progressbox(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/);
670 extern int dialog_rangebox(const char * /*title*/, const char * /*file*/, int /*height*/, int /*width*/, int /*min_value*/, int /*max_value*/, int /*default_value*/);
671 extern int dialog_tailbox(const char * /*title*/, const char * /*file*/, int /*height*/, int /*width*/, int /*bg_task*/);
672 extern int dialog_textbox(const char * /*title*/, const char * /*file*/, int /*height*/, int /*width*/);
673 extern int dialog_timebox(const char * /*title*/, const char * /*subtitle*/, int /*height*/, int /*width*/, int /*hour*/, int /*minute*/, int /*second*/);
674 extern int dialog_treeview(const char * /*title*/, const char * /*subtitle*/, int /*height*/, int /*width*/, int /*list_height*/, int /*item_no*/, char ** /*items*/, int /*flag*/);
675 extern int dialog_yesno(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/);
676 
677 /* some widgets have alternate entrypoints, to allow list manipulation */
678 typedef struct {
679     char *name;
680     char *text;
681     char *help;
682     int state;
683 } DIALOG_LISTITEM;
684 
685 typedef struct {
686     unsigned type;		/* the field type (0=input, 1=password) */
687     char *name;			/* the field label */
688     int name_len;		/* ...its length */
689     int name_y;			/* ...its y-ordinate */
690     int name_x;			/* ...its x-ordinate */
691     bool name_free;		/* ...true if .name can be freed */
692     char *text;			/* the field contents */
693     int text_len;		/* ...its length on the screen */
694     int text_y;			/* ...its y-ordinate */
695     int text_x;			/* ...its x-ordinate */
696     int text_flen;		/* ...its length on screen, or 0 if no input allowed */
697     int text_ilen;		/* ...its limit on amount to be entered */
698     bool text_free;		/* ...true if .text can be freed */
699     char *help;			/* help-message, if any */
700     bool help_free;		/* ...true if .help can be freed */
701 } DIALOG_FORMITEM;
702 
703 typedef	int (DIALOG_INPUTMENU) (DIALOG_LISTITEM * /*items*/, int /*current*/, char * /*newtext*/);
704 
705 extern int dlg_checklist(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/, int /*list_height*/, int /*item_no*/, DIALOG_LISTITEM * /*items*/, const char * /*states*/, int /*flag*/, int * /*current_item*/);
706 extern int dlg_form(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/, int /*form_height*/, int /*item_no*/, DIALOG_FORMITEM * /*items*/, int * /*current_item*/);
707 extern int dlg_menu(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/, int /*menu_height*/, int /*item_no*/, DIALOG_LISTITEM * /*items*/, int * /*current_item*/, DIALOG_INPUTMENU /*rename_menu*/);
708 extern int dlg_progressbox(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/, int /*pauseopt*/, FILE * /* fp */);
709 
710 /* argv.c */
711 extern char ** dlg_string_to_argv(char * /* blob */);
712 extern int dlg_count_argv(char ** /* argv */);
713 extern int dlg_eat_argv(int * /* argcp */, char *** /* argvp */, int /* start */, int /* count */);
714 
715 /* arrows.c */
716 extern void dlg_draw_arrows(WINDOW * /*dialog*/, int /*top_arrow*/, int /*bottom_arrow*/, int /*x*/, int /*top*/, int /*bottom*/);
717 extern void dlg_draw_arrows2(WINDOW * /*dialog*/, int /*top_arrow*/, int /*bottom_arrow*/, int /*x*/, int /*top*/, int /*bottom*/, chtype /*attr*/, chtype /*borderattr*/);
718 extern void dlg_draw_helpline(WINDOW * /*dialog*/, bool /*decorations*/);
719 extern void dlg_draw_scrollbar(WINDOW * /*dialog*/, long /* first_data */, long /* this_data */, long /* next_data */, long /* total_data */, int /* left */, int /* right */, int /*top*/, int /*bottom*/, chtype /*attr*/, chtype /*borderattr*/);
720 
721 /* buildlist.c */
722 extern int dlg_buildlist(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/, int /*list_height*/, int /*item_no*/, DIALOG_LISTITEM * /*items*/, const char * /*states*/, int /*order_mode*/, int * /*current_item*/);
723 
724 /* buttons.c */
725 extern const char ** dlg_exit_label(void);
726 extern const char ** dlg_ok_label(void);
727 extern const char ** dlg_ok_labels(void);
728 extern const char ** dlg_yes_labels(void);
729 extern int dlg_button_count(const char ** /*labels*/);
730 extern int dlg_button_to_char(const char * /*label*/);
731 extern int dlg_button_x_step(const char ** /*labels*/, int /*limit*/, int * /*gap*/, int * /*margin*/, int * /*step*/);
732 extern int dlg_char_to_button(int /*ch*/, const char ** /*labels*/);
733 extern int dlg_exit_buttoncode(int /*button*/);
734 extern int dlg_match_char(int /*ch*/, const char * /*string*/);
735 extern int dlg_next_button(const char ** /*labels*/, int /*button*/);
736 extern int dlg_next_ok_buttonindex(int /*current*/, int /*extra*/);
737 extern int dlg_ok_buttoncode(int /*button*/);
738 extern int dlg_prev_button(const char ** /*labels*/, int /*button*/);
739 extern int dlg_prev_ok_buttonindex(int /*current*/, int /*extra*/);
740 extern int dlg_yes_buttoncode(int /*button*/);
741 extern void dlg_button_layout(const char ** /*labels*/, int * /*limit*/);
742 extern void dlg_button_sizes(const char ** /*labels*/, int /*vertical*/, int * /*longest*/, int * /*length*/);
743 extern void dlg_draw_buttons(WINDOW * /*win*/, int /*y*/, int /*x*/, const char ** /*labels*/, int /*selected*/, int /*vertical*/, int /*limit*/);
744 
745 /* columns.c */
746 extern void dlg_align_columns(char ** /* target */, int  /* per_row */, int /* num_rows */);
747 extern void dlg_free_columns(char ** /* target */, int  /* per_row */, int /* num_rows */);
748 
749 /* editbox.c */
750 extern int dlg_editbox(const char * /*title*/, char *** /*list*/, int * /*rows*/, int /*height*/, int /*width*/);
751 
752 /* formbox.c */
753 extern int dlg_default_formitem(DIALOG_FORMITEM * /*items*/);
754 extern int dlg_ordinate(const char * /*s*/);
755 extern void dlg_free_formitems(DIALOG_FORMITEM * /*items*/);
756 
757 /* guage.c */
758 extern void * dlg_allocate_gauge(const char * /* title */, const char * /* cprompt */, int /* height */, int /* width */, int /* percent */);
759 extern void * dlg_reallocate_gauge(void * /* objptr */, const char * /* title */, const char * /* cprompt */, int /* height */, int /* width */, int /* percent */);
760 extern void dlg_free_gauge(void * /* objptr */);
761 extern void dlg_update_gauge(void * /* objptr */, int /* percent */);
762 
763 /* inputstr.c */
764 extern bool dlg_edit_string(char * /*string*/, int * /*offset*/, int /*key*/, int /*fkey*/, bool /*force*/);
765 extern const int * dlg_index_columns(const char * /*string*/);
766 extern const int * dlg_index_wchars(const char * /*string*/);
767 extern int dlg_count_columns(const char * /*string*/);
768 extern int dlg_count_wchars(const char * /*string*/);
769 extern int dlg_edit_offset(char * /*string*/, int /*offset*/, int /*x_last*/);
770 extern int dlg_find_index(const int * /*list*/, int  /*limit*/, int /*to_find*/);
771 extern int dlg_limit_columns(const char * /*string*/, int /*limit*/, int /*offset*/);
772 extern void dlg_finish_string(const char * /* string */);
773 extern void dlg_show_string(WINDOW * /*win*/, const char * /*string*/, int /*offset*/, chtype /*attr*/, int /*y_base*/, int /*x_base*/, int /*x_last*/, bool /*hidden*/, bool /*force*/);
774 
775 /* menubox.c */
776 extern int dlg_dummy_menutext(DIALOG_LISTITEM * /*items*/, int /*current*/, char * /*newtext*/);
777 extern int dlg_renamed_menutext(DIALOG_LISTITEM * /*items*/, int /*current*/, char * /*newtext*/);
778 
779 /* prgbox.c */
780 extern FILE * dlg_popen(const char * /*command */, const char * /*type */);
781 
782 /* rc.c */
783 #ifdef HAVE_RC_FILE
784 extern int dlg_parse_rc(void);
785 extern void dlg_create_rc(const char * /*filename*/);
786 #endif
787 
788 /* treeview.c */
789 extern int dlg_treeview(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/, int /*list_height*/, int /*item_no*/, DIALOG_LISTITEM * /*items*/, const char * /*states*/, int * /*depths*/, int /*flag*/, int * /*current_item*/);
790 
791 /* ttysize.c */
792 extern int dlg_ttysize(int /* fd */, int * /* height */, int * /* width */);
793 
794 /* ui_getc.c */
795 extern int dlg_getc(WINDOW * /*win*/, int * /*fkey*/);
796 extern int dlg_getc_callbacks(int /*ch*/, int /*fkey*/, int * /*result*/);
797 extern int dlg_last_getc(void);
798 extern void dlg_add_last_key(int /*mode*/);
799 extern void dlg_add_callback(DIALOG_CALLBACK * /*p*/);
800 extern void dlg_add_callback_ref(DIALOG_CALLBACK ** /*p*/, DIALOG_FREEBACK /* cleanup */);
801 extern void dlg_flush_getc(void);
802 extern void dlg_remove_callback(DIALOG_CALLBACK * /*p*/);
803 extern void dlg_killall_bg(int *retval);
804 
805 /* util.c */
806 extern DIALOG_WINDOWS * _dlg_find_window(WINDOW * /* win */);
807 extern WINDOW * dlg_der_window(WINDOW * /*win*/, int /*height*/, int /*width*/, int /*y*/, int /*x*/);
808 extern WINDOW * dlg_new_modal_window(WINDOW * /*parent*/, int /*height*/, int /*width*/, int /*y*/, int /*x*/);
809 extern WINDOW * dlg_new_window(int /*height*/, int /*width*/, int /*y*/, int /*x*/);
810 extern WINDOW * dlg_sub_window(WINDOW * /*win*/, int /*height*/, int /*width*/, int /*y*/, int /*x*/);
811 extern bool dlg_need_separator(void);
812 extern char * dlg_getenv_str(const char * /*name*/);
813 extern char * dlg_set_result(const char * /*string*/);
814 extern char * dlg_strclone(const char * /*cprompt*/);
815 extern char * dlg_strempty(void);
816 extern chtype dlg_asciibox(chtype /*ch*/);
817 extern chtype dlg_boxchar(chtype /*ch*/);
818 extern chtype dlg_get_attrs(WINDOW * /*win*/);
819 extern const char * dlg_exitcode2s(int /*code*/);
820 extern const char * dlg_print_line(WINDOW * /*win*/, chtype * /*attr*/, const char * /*prompt*/, int /*lm*/, int /*rm*/, int * /*x*/);
821 extern int dlg_box_x_ordinate(int /*width*/);
822 extern int dlg_box_y_ordinate(int /*height*/);
823 extern int dlg_calc_list_width(int /*item_no*/, DIALOG_LISTITEM * /*items*/);
824 extern int dlg_calc_listw(int /*item_no*/, char ** /*items*/, int /*group*/);
825 extern int dlg_check_scrolled(int /* key */, int /* last */, int /* page */, bool * /* show */, int * /* offset */);
826 extern int dlg_count_real_columns(const char * /*text*/);
827 extern int dlg_default_item(char ** /*items*/, int /*llen*/);
828 extern int dlg_default_listitem(DIALOG_LISTITEM * /*items*/);
829 extern int dlg_defaultno_button(void);
830 extern int dlg_default_button(void);
831 extern int dlg_exitname2n(const char * /*name*/);
832 extern int dlg_getenv_num(const char * /*name*/, int * /* value */);
833 extern int dlg_max_input(int /*max_len*/);
834 extern int dlg_print_scrolled(WINDOW * /* win */, const char * /* prompt */, int /* offset */, int /* height */, int /* width */, int /* pauseopt */);
835 extern int dlg_set_timeout(WINDOW * /* win */, bool /* will_getc */);
836 extern void dlg_add_help_formitem(int * /* result */, char ** /* tag */, DIALOG_FORMITEM * /* item */);
837 extern void dlg_add_help_listitem(int * /* result */, char ** /* tag */, DIALOG_LISTITEM * /* item */);
838 extern void dlg_add_quoted(char * /*string*/);
839 extern void dlg_add_result(const char * /*string*/);
840 extern void dlg_add_separator(void);
841 extern void dlg_add_string(char * /*string*/);
842 extern void dlg_attr_clear(WINDOW * /*win*/, int /*height*/, int /*width*/, chtype /*attr*/);
843 extern void dlg_auto_size(const char * /*title*/, const char * /*prompt*/, int * /*height*/, int * /*width*/, int /*boxlines*/, int /*mincols*/);
844 extern void dlg_auto_sizefile(const char * /*title*/, const char * /*file*/, int * /*height*/, int * /*width*/, int /*boxlines*/, int /*mincols*/);
845 extern void dlg_beeping(void);
846 extern void dlg_calc_listh(int * /*height*/, int * /*list_height*/, int /*item_no*/);
847 extern void dlg_clear(void);
848 extern void dlg_clr_result(void);
849 extern void dlg_ctl_size(int /*height*/, int /*width*/);
850 extern void dlg_del_window(WINDOW * /*win*/);
851 extern void dlg_does_output(void);
852 extern void dlg_draw_bottom_box(WINDOW * /*win*/);
853 extern void dlg_draw_bottom_box2(WINDOW * /*win*/, chtype /*on_left*/, chtype /*on_right*/, chtype /*on_inside*/);
854 extern void dlg_draw_box(WINDOW * /*win*/, int /*y*/, int /*x*/, int /*height*/, int /*width*/, chtype /*boxchar*/, chtype /*borderchar*/);
855 extern void dlg_draw_box2(WINDOW * /*win*/, int /*y*/, int /*x*/, int /*height*/, int /*width*/, chtype /*boxchar*/, chtype /*borderchar*/, chtype /*borderchar2*/);
856 extern void dlg_draw_title(WINDOW *win, const char *title);
857 extern void dlg_exit(int /*code*/) GCC_NORETURN;
858 extern void dlg_item_help(const char * /*txt*/);
859 extern void dlg_keep_tite(FILE * /*output */);
860 extern void dlg_print_autowrap(WINDOW * /*win*/, const char * /*prompt*/, int /*height*/, int /*width*/);
861 extern void dlg_print_listitem(WINDOW * /*win*/, const char * /*text*/, int /*climit*/, bool /*first*/, int /*selected*/);
862 extern void dlg_print_size(int /*height*/, int /*width*/);
863 extern void dlg_print_text(WINDOW * /*win*/, const char * /*txt*/, int /*len*/, chtype * /*attr*/);
864 extern void dlg_put_backtitle(void);
865 extern void dlg_reset_timeout(WINDOW * /* win */);
866 extern void dlg_restore_vars(DIALOG_VARS * /* save */);
867 extern void dlg_save_vars(DIALOG_VARS * /* save */);
868 extern void dlg_set_focus(WINDOW * /*parent*/, WINDOW * /*win*/);
869 extern void dlg_tab_correct_str(char * /*prompt*/);
870 extern void dlg_trim_string(char * /*src*/);
871 extern void end_dialog(void);
872 extern void init_dialog(FILE * /*input*/, FILE * /*output*/);
873 
874 extern void dlg_exiterr(const char *, ...) GCC_NORETURN GCC_PRINTFLIKE(1,2);
875 
876 #ifdef HAVE_COLOR
877 extern chtype dlg_color_pair(int /*foreground*/, int /*background*/);
878 extern int dlg_color_count(void);
879 extern void dlg_color_setup(void);
880 extern void dlg_draw_shadow(WINDOW * /*win*/, int /*height*/, int /*width*/, int /*y*/, int /*x*/);
881 #endif
882 
883 #ifdef HAVE_STRCASECMP
884 #define dlg_strcmp(a,b) strcasecmp(a,b)
885 #else
886 extern int dlg_strcmp(const char * /*a*/, const char * /*b*/);
887 #endif
888 
889 #ifdef HAVE_DLG_TRACE
890 #define DLG_TRACE(params) dlg_trace_msg params
891 extern void dlg_trace_msg(const char *fmt, ...) GCC_PRINTFLIKE(1,2);
892 extern void dlg_trace_va_msg(const char *fmt, va_list ap);
893 #define DLG_TRACE2S(name,value) dlg_trace_2s (name,value)
894 #define DLG_TRACE2N(name,value) dlg_trace_2n (name,value)
895 extern void dlg_trace_2s(const char * /*name*/, const char * /*value*/);
896 extern void dlg_trace_2n(const char * /*name*/, int /*value*/);
897 extern void dlg_trace_win(WINDOW * /*win*/);
898 extern void dlg_trace_chr(int /*ch*/, int /*fkey*/);
899 extern void dlg_trace(const char * /*fname*/);
900 #else
901 #define DLG_TRACE(params) /* nothing */
902 #define DLG_TRACE2S(name,value) /* nothing */
903 #define DLG_TRACE2N(name,value) /* nothing */
904 #define dlg_trace_va_msg(fmt, ap) /* nothing */
905 #define dlg_trace_win(win) /* nothing */
906 #define dlg_trace_chr(ch,fkey) /* nothing */
907 #define dlg_trace(fname) /* nothing */
908 #endif
909 
910 #ifdef KEY_RESIZE
911 extern void _dlg_resize_cleanup(WINDOW * /*win*/);
912 extern void dlg_move_window(WINDOW * /*win*/, int /*height*/, int /*width*/, int /*y*/, int /*x*/);
913 extern void dlg_will_resize(WINDOW * /*win*/);
914 #endif
915 
916 /*
917  * Normally "enter" means "ok".  Use this macro to handle the explicit
918  * check for DLGK_ENTER:
919  */
920 #define dlg_enter_buttoncode(code) (dialog_vars.nook ? DLG_EXIT_OK : dlg_ok_buttoncode(code))
921 
922 /*
923  * The following stuff is needed for mouse support
924  */
925 typedef struct mseRegion {
926     int x, y, X, Y, code;
927     int mode, step_x, step_y;
928     struct mseRegion *next;
929 } mseRegion;
930 
931 #if defined(NCURSES_MOUSE_VERSION)
932 
933 #define	mouse_open() mousemask(BUTTON1_PRESSED, (mmask_t *) 0)
934 #define	mouse_close() mousemask(0, (mmask_t *) 0)
935 
936 extern mseRegion * dlg_mouse_mkregion (int /*y*/, int /*x*/, int /*height*/, int /*width*/, int /*code*/);
937 extern void dlg_mouse_free_regions (void);
938 extern void dlg_mouse_mkbigregion (int /*y*/, int /*x*/, int /*height*/, int /*width*/, int /*code*/, int /*step_x*/, int /*step_y*/, int /*mode*/);
939 extern void dlg_mouse_setbase (int /*x*/, int /*y*/);
940 extern void dlg_mouse_setcode (int /*code*/);
941 
942 #define USE_MOUSE 1
943 
944 #else
945 
946 #define	mouse_open() /*nothing*/
947 #define	mouse_close() /*nothing*/
948 #define dlg_mouse_free_regions() /* nothing */
949 #define	dlg_mouse_mkregion(y, x, height, width, code) /*nothing*/
950 #define	dlg_mouse_mkbigregion(y, x, height, width, code, step_x, step_y, mode) /*nothing*/
951 #define	dlg_mouse_setbase(x, y) /*nothing*/
952 #define	dlg_mouse_setcode(c) /*nothing*/
953 
954 #define USE_MOUSE 0
955 
956 #endif
957 
958 extern mseRegion *dlg_mouse_region (int /*y*/, int /*x*/);
959 extern mseRegion *dlg_mouse_bigregion (int /*y*/, int /*x*/);
960 extern int dlg_mouse_wgetch (WINDOW * /*win*/, int * /*fkey*/);
961 extern int dlg_mouse_wgetch_nowait (WINDOW * /*win*/, int * /*fkey*/);
962 
963 #define mouse_mkbutton(y,x,len,code) dlg_mouse_mkregion(y,x,1,len,code);
964 
965 /*
966  * This is the base for fictitious keys, which activate
967  * the buttons.
968  *
969  * Mouse-generated keys are the following:
970  *   -- the first 32 are used as numbers, in addition to '0'-'9'
971  *   -- uppercase chars are used to invoke the button (M_EVENT + 'O')
972  */
973 #define M_EVENT (DLGK_max + 1)
974 
975 /*
976  * The `flag' parameter in checklist is used to select between
977  * radiolist and checklist
978  */
979 #define FLAG_CHECK 1
980 #define FLAG_RADIO 0
981 
982 /*
983  * This is used only for debugging (FIXME: should have a separate header).
984  */
985 #ifdef NO_LEAKS
986 extern void _dlg_inputstr_leaks(void);
987 #if defined(NCURSES_VERSION)
988 #if defined(HAVE_CURSES_EXIT)
989 /* just use curses_exit() */
990 #elif defined(HAVE__NC_FREE_AND_EXIT)
991 extern void _nc_free_and_exit(int);	/* nc_alloc.h normally not installed */
992 #define curses_exit(code) _nc_free_and_exit(code)
993 #endif
994 #endif /* NCURSES_VERSION */
995 #endif /* NO_LEAKS */
996 
997 #ifdef __cplusplus
998 }
999 #endif
1000 /* *INDENT-ON* */
1001 
1002 #endif /* DIALOG_H_included */
1003