xref: /freebsd-src/contrib/dialog/dialog.h (revision a96ef4501919d7ac08e94e98dc34b0bdd744802b)
14c8945a0SNathan Whitehorn /*
2*a96ef450SBaptiste Daroussin  *  $Id: dialog.h,v 1.304 2021/01/17 16:58:22 tom Exp $
34c8945a0SNathan Whitehorn  *
44c8945a0SNathan Whitehorn  *  dialog.h -- common declarations for all dialog modules
54c8945a0SNathan Whitehorn  *
6*a96ef450SBaptiste Daroussin  *  Copyright 2000-2020,2021	Thomas E. Dickey
74c8945a0SNathan Whitehorn  *
84c8945a0SNathan Whitehorn  *  This program is free software; you can redistribute it and/or modify
94c8945a0SNathan Whitehorn  *  it under the terms of the GNU Lesser General Public License, version 2.1
104c8945a0SNathan Whitehorn  *  as published by the Free Software Foundation.
114c8945a0SNathan Whitehorn  *
124c8945a0SNathan Whitehorn  *  This program is distributed in the hope that it will be useful, but
134c8945a0SNathan Whitehorn  *  WITHOUT ANY WARRANTY; without even the implied warranty of
144c8945a0SNathan Whitehorn  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
154c8945a0SNathan Whitehorn  *  Lesser General Public License for more details.
164c8945a0SNathan Whitehorn  *
174c8945a0SNathan Whitehorn  *  You should have received a copy of the GNU Lesser General Public
184c8945a0SNathan Whitehorn  *  License along with this program; if not, write to
194c8945a0SNathan Whitehorn  *	Free Software Foundation, Inc.
204c8945a0SNathan Whitehorn  *	51 Franklin St., Fifth Floor
214c8945a0SNathan Whitehorn  *	Boston, MA 02110, USA.
224c8945a0SNathan Whitehorn  *
234c8945a0SNathan Whitehorn  *  An earlier version of this program lists as authors
244c8945a0SNathan Whitehorn  *	Savio Lam (lam836@cs.cuhk.hk)
254c8945a0SNathan Whitehorn  */
264c8945a0SNathan Whitehorn 
274c8945a0SNathan Whitehorn #ifndef DIALOG_H_included
284c8945a0SNathan Whitehorn #define DIALOG_H_included 1
297a1c0d96SNathan Whitehorn /* *INDENT-OFF* */
304c8945a0SNathan Whitehorn 
314c8945a0SNathan Whitehorn #include <dlg_config.h>
324c8945a0SNathan Whitehorn 
334c8945a0SNathan Whitehorn #ifdef __hpux
344c8945a0SNathan Whitehorn #define __HP_CURSES_COMPAT	/* workaround for getattrs, etc. */
354c8945a0SNathan Whitehorn #endif
364c8945a0SNathan Whitehorn 
374c8945a0SNathan Whitehorn #include <sys/types.h>
384c8945a0SNathan Whitehorn #include <fcntl.h>
394c8945a0SNathan Whitehorn #include <unistd.h>
404c8945a0SNathan Whitehorn #include <ctype.h>
414c8945a0SNathan Whitehorn #include <stdlib.h>
424c8945a0SNathan Whitehorn #include <stdarg.h>
434c8945a0SNathan Whitehorn #include <string.h>
444c8945a0SNathan Whitehorn #include <signal.h>	/* fork() etc. */
454c8945a0SNathan Whitehorn #include <math.h>	/* sqrt() */
464c8945a0SNathan Whitehorn 
4743764a7fSJaakko Heinonen /* header conflict with Solaris xpg4 versus <sys/regset.h> */
4843764a7fSJaakko Heinonen #if defined(ERR) && (ERR == 13)
4943764a7fSJaakko Heinonen #undef ERR
5043764a7fSJaakko Heinonen #endif
517a1c0d96SNathan Whitehorn 
524c8945a0SNathan Whitehorn #if defined(HAVE_NCURSESW_NCURSES_H)
534c8945a0SNathan Whitehorn #include <ncursesw/ncurses.h>
544c8945a0SNathan Whitehorn #elif defined(HAVE_NCURSES_NCURSES_H)
554c8945a0SNathan Whitehorn #include <ncurses/ncurses.h>
564c8945a0SNathan Whitehorn #elif defined(HAVE_NCURSES_CURSES_H)
574c8945a0SNathan Whitehorn #include <ncurses/curses.h>
584c8945a0SNathan Whitehorn #elif defined(HAVE_NCURSES_H)
594c8945a0SNathan Whitehorn #include <ncurses.h>
604c8945a0SNathan Whitehorn #else
614c8945a0SNathan Whitehorn #include <curses.h>
6219718649SNathan Whitehorn #if defined(HAVE_UNCTRL_H)
632a3e3873SBaptiste Daroussin #include <unctrl.h> /* most curses.h headers include this, some do not */
642a3e3873SBaptiste Daroussin #endif
654c8945a0SNathan Whitehorn #endif
664c8945a0SNathan Whitehorn 
677a1c0d96SNathan Whitehorn /* Solaris xpg4 renames these */
687a1c0d96SNathan Whitehorn #ifndef KEY_MAX
697a1c0d96SNathan Whitehorn #ifdef __KEY_MAX
707a1c0d96SNathan Whitehorn #define KEY_MAX __KEY_MAX
717a1c0d96SNathan Whitehorn #endif
727a1c0d96SNathan Whitehorn #endif
737a1c0d96SNathan Whitehorn 
747a1c0d96SNathan Whitehorn #ifndef KEY_MIN
757a1c0d96SNathan Whitehorn #ifdef __KEY_MIN
767a1c0d96SNathan Whitehorn #define KEY_MIN __KEY_MIN
777a1c0d96SNathan Whitehorn #endif
787a1c0d96SNathan Whitehorn #endif
797a1c0d96SNathan Whitehorn 
804c8945a0SNathan Whitehorn /* possible conflicts with <term.h> which may be included in <curses.h> */
814c8945a0SNathan Whitehorn #ifdef color_names
824c8945a0SNathan Whitehorn #undef color_names
834c8945a0SNathan Whitehorn #endif
844c8945a0SNathan Whitehorn 
854c8945a0SNathan Whitehorn #ifdef buttons
864c8945a0SNathan Whitehorn #undef buttons
874c8945a0SNathan Whitehorn #endif
884c8945a0SNathan Whitehorn 
894c8945a0SNathan Whitehorn #ifdef ENABLE_NLS
904c8945a0SNathan Whitehorn #include <libintl.h>
914c8945a0SNathan Whitehorn #include <langinfo.h>
924c8945a0SNathan Whitehorn #define _(s) dgettext(PACKAGE, s)
934c8945a0SNathan Whitehorn #else
944c8945a0SNathan Whitehorn #undef _
954c8945a0SNathan Whitehorn #define _(s) s
964c8945a0SNathan Whitehorn #endif
974c8945a0SNathan Whitehorn 
982a3e3873SBaptiste Daroussin #ifndef GCC_PRINTFLIKE
992a3e3873SBaptiste Daroussin #define GCC_PRINTFLIKE(fmt,var) /*nothing*/
1002a3e3873SBaptiste Daroussin #endif
1012a3e3873SBaptiste Daroussin 
1024c8945a0SNathan Whitehorn #ifndef GCC_NORETURN
1034c8945a0SNathan Whitehorn #define GCC_NORETURN /*nothing*/
1044c8945a0SNathan Whitehorn #endif
1054c8945a0SNathan Whitehorn 
1064c8945a0SNathan Whitehorn #ifndef GCC_UNUSED
1074c8945a0SNathan Whitehorn #define GCC_UNUSED /*nothing*/
1084c8945a0SNathan Whitehorn #endif
1094c8945a0SNathan Whitehorn 
1104c8945a0SNathan Whitehorn #ifndef HAVE_WGET_WCH
1114c8945a0SNathan Whitehorn #undef USE_WIDE_CURSES
1124c8945a0SNathan Whitehorn #endif
1134c8945a0SNathan Whitehorn 
1144c8945a0SNathan Whitehorn /*
1154c8945a0SNathan Whitehorn  * FIXME: a configure check would be useful
1164c8945a0SNathan Whitehorn  */
1174c8945a0SNathan Whitehorn #ifdef __hpux
1184c8945a0SNathan Whitehorn #undef ACS_UARROW
1194c8945a0SNathan Whitehorn #undef ACS_DARROW
1204c8945a0SNathan Whitehorn #undef ACS_BLOCK
1214c8945a0SNathan Whitehorn #endif
1224c8945a0SNathan Whitehorn 
1234c8945a0SNathan Whitehorn /*
1244c8945a0SNathan Whitehorn  * Change these if you want
1254c8945a0SNathan Whitehorn  */
1264c8945a0SNathan Whitehorn #define USE_SHADOW TRUE
1274c8945a0SNathan Whitehorn #define USE_COLORS TRUE
1284c8945a0SNathan Whitehorn 
129*a96ef450SBaptiste Daroussin /*
130*a96ef450SBaptiste Daroussin  * These allow using the print-formatting code before curses is initialized.
131*a96ef450SBaptiste Daroussin  */
132*a96ef450SBaptiste Daroussin #define DLG_COLS  (COLS  ? COLS  : dialog_state.screen_width)
133*a96ef450SBaptiste Daroussin #define DLG_LINES (LINES ? LINES : dialog_state.screen_height)
134*a96ef450SBaptiste Daroussin 
135*a96ef450SBaptiste Daroussin /*
136*a96ef450SBaptiste Daroussin  * Define the usable size of a window, discounting the area needed for shadow.
137*a96ef450SBaptiste Daroussin  */
1384c8945a0SNathan Whitehorn #ifdef HAVE_COLOR
139*a96ef450SBaptiste Daroussin #define SCOLS	(DLG_COLS  - (dialog_state.use_shadow ? SHADOW_COLS : 0))
140*a96ef450SBaptiste Daroussin #define SLINES	(DLG_LINES - (dialog_state.use_shadow ? SHADOW_ROWS : 0))
1414c8945a0SNathan Whitehorn #else
1424c8945a0SNathan Whitehorn #define SCOLS	COLS
1434c8945a0SNathan Whitehorn #define SLINES	LINES
1444c8945a0SNathan Whitehorn #endif
1454c8945a0SNathan Whitehorn 
146*a96ef450SBaptiste Daroussin /*
147*a96ef450SBaptiste Daroussin  * These are the default values for exit-codes, which can be overridden by
148*a96ef450SBaptiste Daroussin  * environment variables, e.g., $DIALOG_CANCEL for DLG_EXIT_CANCEL.
149*a96ef450SBaptiste Daroussin  */
1504c8945a0SNathan Whitehorn #define DLG_EXIT_ESC		255
1514c8945a0SNathan Whitehorn #define DLG_EXIT_UNKNOWN	-2	/* never return this (internal use) */
1524c8945a0SNathan Whitehorn #define DLG_EXIT_ERROR		-1	/* the shell sees this as 255 */
1534c8945a0SNathan Whitehorn #define DLG_EXIT_OK		0
1544c8945a0SNathan Whitehorn #define DLG_EXIT_CANCEL		1
1554c8945a0SNathan Whitehorn #define DLG_EXIT_HELP		2
1564c8945a0SNathan Whitehorn #define DLG_EXIT_EXTRA		3
1574c8945a0SNathan Whitehorn #define DLG_EXIT_ITEM_HELP	4	/* actually DLG_EXIT_HELP */
158*a96ef450SBaptiste Daroussin #define DLG_EXIT_TIMEOUT	5
1594c8945a0SNathan Whitehorn 
1604c8945a0SNathan Whitehorn #define DLG_CTRL(n)	((n) & 0x1f)	/* CTRL is preferred, but conflicts */
1614c8945a0SNathan Whitehorn 
162*a96ef450SBaptiste Daroussin #define CHR_LEAVE	DLG_CTRL('D')
163682c9e0fSNathan Whitehorn #define CHR_HELP	DLG_CTRL('E')
1644c8945a0SNathan Whitehorn #define CHR_BACKSPACE	DLG_CTRL('H')
1654c8945a0SNathan Whitehorn #define CHR_REPAINT	DLG_CTRL('L')
1664c8945a0SNathan Whitehorn #define CHR_NEXT	DLG_CTRL('N')
1674c8945a0SNathan Whitehorn #define CHR_PREVIOUS	DLG_CTRL('P')
168*a96ef450SBaptiste Daroussin #define CHR_KILL	DLG_CTRL('U')
1694c8945a0SNathan Whitehorn #define CHR_TRACE	DLG_CTRL('T')
170*a96ef450SBaptiste Daroussin #define CHR_LITERAL	DLG_CTRL('V')
171f4f33ea0SBaptiste Daroussin #define CHR_SPACE 	' '
172*a96ef450SBaptiste Daroussin #define CHR_DELETE	127
1734c8945a0SNathan Whitehorn 
1744c8945a0SNathan Whitehorn #define ESC		27
1754c8945a0SNathan Whitehorn #define TAB		DLG_CTRL('I')
1764c8945a0SNathan Whitehorn 
177f4f33ea0SBaptiste Daroussin #define MARGIN 1	/* width of the line drawn around each box */
178f4f33ea0SBaptiste Daroussin #define GUTTER 2	/* minimum columns between name/description in menu */
179f4f33ea0SBaptiste Daroussin #define SHADOW_ROWS 1	/* rows to reserve for window's shadow */
180f4f33ea0SBaptiste Daroussin #define SHADOW_COLS 2	/* columns to reserve for window's shadow */
181f4f33ea0SBaptiste Daroussin #define ARROWS_COL  5	/* distance from left margin to up/down arrows */
1824c8945a0SNathan Whitehorn 
1834c8945a0SNathan Whitehorn #define MAX_LEN 2048
1847a1c0d96SNathan Whitehorn #define BUF_SIZE (10L*1024)
1854c8945a0SNathan Whitehorn 
1864c8945a0SNathan Whitehorn #undef  MIN
1874c8945a0SNathan Whitehorn #define MIN(x,y) ((x) < (y) ? (x) : (y))
1884c8945a0SNathan Whitehorn 
1894c8945a0SNathan Whitehorn #undef  MAX
1904c8945a0SNathan Whitehorn #define MAX(x,y) ((x) > (y) ? (x) : (y))
1914c8945a0SNathan Whitehorn 
1924c8945a0SNathan Whitehorn #define DEFAULT_SEPARATE_STR "\t"
1934c8945a0SNathan Whitehorn #define DEFAULT_ASPECT_RATIO 9
1944c8945a0SNathan Whitehorn /* how many spaces is a tab long (default)? */
1954c8945a0SNathan Whitehorn #define TAB_LEN 8
1967a1c0d96SNathan Whitehorn #define WTIMEOUT_VAL        10	/* minimum amount of time needed for curses */
197*a96ef450SBaptiste Daroussin #define WTIMEOUT_OFF        -1	/* value to disable timeout */
1984c8945a0SNathan Whitehorn 
1994c8945a0SNathan Whitehorn #ifndef A_CHARTEXT
2004c8945a0SNathan Whitehorn #define A_CHARTEXT 0xff
2014c8945a0SNathan Whitehorn #endif
2024c8945a0SNathan Whitehorn 
2034c8945a0SNathan Whitehorn #define CharOf(ch)  ((ch) & 0xff)
2044c8945a0SNathan Whitehorn 
2054c8945a0SNathan Whitehorn #ifndef ACS_ULCORNER
2064c8945a0SNathan Whitehorn #define ACS_ULCORNER '+'
2074c8945a0SNathan Whitehorn #endif
2084c8945a0SNathan Whitehorn #ifndef ACS_LLCORNER
2094c8945a0SNathan Whitehorn #define ACS_LLCORNER '+'
2104c8945a0SNathan Whitehorn #endif
2114c8945a0SNathan Whitehorn #ifndef ACS_URCORNER
2124c8945a0SNathan Whitehorn #define ACS_URCORNER '+'
2134c8945a0SNathan Whitehorn #endif
2144c8945a0SNathan Whitehorn #ifndef ACS_LRCORNER
2154c8945a0SNathan Whitehorn #define ACS_LRCORNER '+'
2164c8945a0SNathan Whitehorn #endif
2174c8945a0SNathan Whitehorn #ifndef ACS_HLINE
2184c8945a0SNathan Whitehorn #define ACS_HLINE '-'
2194c8945a0SNathan Whitehorn #endif
2204c8945a0SNathan Whitehorn #ifndef ACS_VLINE
2214c8945a0SNathan Whitehorn #define ACS_VLINE '|'
2224c8945a0SNathan Whitehorn #endif
2234c8945a0SNathan Whitehorn #ifndef ACS_LTEE
2244c8945a0SNathan Whitehorn #define ACS_LTEE '+'
2254c8945a0SNathan Whitehorn #endif
2264c8945a0SNathan Whitehorn #ifndef ACS_RTEE
2274c8945a0SNathan Whitehorn #define ACS_RTEE '+'
2284c8945a0SNathan Whitehorn #endif
2294c8945a0SNathan Whitehorn #ifndef ACS_UARROW
2304c8945a0SNathan Whitehorn #define ACS_UARROW '^'
2314c8945a0SNathan Whitehorn #endif
2324c8945a0SNathan Whitehorn #ifndef ACS_DARROW
2334c8945a0SNathan Whitehorn #define ACS_DARROW 'v'
2344c8945a0SNathan Whitehorn #endif
2354c8945a0SNathan Whitehorn #ifndef ACS_BLOCK
2364c8945a0SNathan Whitehorn #define ACS_BLOCK '#'
2374c8945a0SNathan Whitehorn #endif
2384c8945a0SNathan Whitehorn 
2394c8945a0SNathan Whitehorn /* these definitions may work for antique versions of curses */
2404c8945a0SNathan Whitehorn #ifndef HAVE_GETBEGYX
2414c8945a0SNathan Whitehorn #undef  getbegyx
2424c8945a0SNathan Whitehorn #define getbegyx(win,y,x)	(y = (win)?(win)->_begy:ERR, x = (win)?(win)->_begx:ERR)
2434c8945a0SNathan Whitehorn #endif
2444c8945a0SNathan Whitehorn 
2454c8945a0SNathan Whitehorn #ifndef HAVE_GETMAXYX
2464c8945a0SNathan Whitehorn #undef  getmaxyx
2474c8945a0SNathan Whitehorn #define getmaxyx(win,y,x)	(y = (win)?(win)->_maxy:ERR, x = (win)?(win)->_maxx:ERR)
2484c8945a0SNathan Whitehorn #endif
2494c8945a0SNathan Whitehorn 
2504c8945a0SNathan Whitehorn #ifndef HAVE_GETPARYX
2514c8945a0SNathan Whitehorn #undef  getparyx
2524c8945a0SNathan Whitehorn #define getparyx(win,y,x)	(y = (win)?(win)->_pary:ERR, x = (win)?(win)->_parx:ERR)
2534c8945a0SNathan Whitehorn #endif
2544c8945a0SNathan Whitehorn 
2552a3e3873SBaptiste Daroussin #if !defined(HAVE_WGETPARENT) && defined(HAVE_WINDOW__PARENT)
2562a3e3873SBaptiste Daroussin #undef  wgetparent
2572a3e3873SBaptiste Daroussin #define wgetparent(win)		((win) ? (win)->_parent : 0)
2582a3e3873SBaptiste Daroussin #endif
2592a3e3873SBaptiste Daroussin 
2602a3e3873SBaptiste Daroussin #if !defined(HAVE_WSYNCUP)
2612a3e3873SBaptiste Daroussin #undef wsyncup
2622a3e3873SBaptiste Daroussin #define wsyncup(win) /* nothing */
2632a3e3873SBaptiste Daroussin #endif
2642a3e3873SBaptiste Daroussin 
2652a3e3873SBaptiste Daroussin #if !defined(HAVE_WCURSYNCUP)
2662a3e3873SBaptiste Daroussin #undef wcursyncup
2672a3e3873SBaptiste Daroussin #define wcursyncup(win) /* nothing */
2682a3e3873SBaptiste Daroussin #endif
2692a3e3873SBaptiste Daroussin 
2704c8945a0SNathan Whitehorn #ifdef __cplusplus
2714c8945a0SNathan Whitehorn extern "C" {
2724c8945a0SNathan Whitehorn #endif
2734c8945a0SNathan Whitehorn 
2744c8945a0SNathan Whitehorn /* these definitions may be needed for bleeding-edge curses implementations */
2754c8945a0SNathan Whitehorn #if !(defined(HAVE_GETBEGX) && defined(HAVE_GETBEGY))
2764c8945a0SNathan Whitehorn #undef getbegx
2774c8945a0SNathan Whitehorn #undef getbegy
2784c8945a0SNathan Whitehorn #define getbegx(win) dlg_getbegx(win)
2794c8945a0SNathan Whitehorn #define getbegy(win) dlg_getbegy(win)
2804c8945a0SNathan Whitehorn extern int dlg_getbegx(WINDOW * /*win*/);
2814c8945a0SNathan Whitehorn extern int dlg_getbegy(WINDOW * /*win*/);
2824c8945a0SNathan Whitehorn #endif
2834c8945a0SNathan Whitehorn 
2844c8945a0SNathan Whitehorn #if !(defined(HAVE_GETCURX) && defined(HAVE_GETCURY))
2854c8945a0SNathan Whitehorn #undef getcurx
2864c8945a0SNathan Whitehorn #undef getcury
2874c8945a0SNathan Whitehorn #define getcurx(win) dlg_getcurx(win)
2884c8945a0SNathan Whitehorn #define getcury(win) dlg_getcury(win)
2894c8945a0SNathan Whitehorn extern int dlg_getcurx(WINDOW * /*win*/);
2904c8945a0SNathan Whitehorn extern int dlg_getcury(WINDOW * /*win*/);
2914c8945a0SNathan Whitehorn #endif
2924c8945a0SNathan Whitehorn 
2934c8945a0SNathan Whitehorn #if !(defined(HAVE_GETMAXX) && defined(HAVE_GETMAXY))
2944c8945a0SNathan Whitehorn #undef getmaxx
2954c8945a0SNathan Whitehorn #undef getmaxy
2964c8945a0SNathan Whitehorn #define getmaxx(win) dlg_getmaxx(win)
2974c8945a0SNathan Whitehorn #define getmaxy(win) dlg_getmaxy(win)
2984c8945a0SNathan Whitehorn extern int dlg_getmaxx(WINDOW * /*win*/);
2994c8945a0SNathan Whitehorn extern int dlg_getmaxy(WINDOW * /*win*/);
3004c8945a0SNathan Whitehorn #endif
3014c8945a0SNathan Whitehorn 
3024c8945a0SNathan Whitehorn #if !(defined(HAVE_GETPARX) && defined(HAVE_GETPARY))
3034c8945a0SNathan Whitehorn #undef getparx
3044c8945a0SNathan Whitehorn #undef getpary
3054c8945a0SNathan Whitehorn #define getparx(win) dlg_getparx(win)
3064c8945a0SNathan Whitehorn #define getpary(win) dlg_getpary(win)
3074c8945a0SNathan Whitehorn extern int dlg_getparx(WINDOW * /*win*/);
3084c8945a0SNathan Whitehorn extern int dlg_getpary(WINDOW * /*win*/);
3094c8945a0SNathan Whitehorn #endif
3104c8945a0SNathan Whitehorn 
3112a3e3873SBaptiste Daroussin #if !(defined(HAVE_WGETPARENT) && defined(HAVE_WINDOW__PARENT))
3122a3e3873SBaptiste Daroussin #undef wgetparent
3132a3e3873SBaptiste Daroussin #define wgetparent(win) dlg_wgetparent(win)
3142a3e3873SBaptiste Daroussin extern WINDOW * dlg_wgetparent(WINDOW * /*win*/);
3152a3e3873SBaptiste Daroussin #endif
3162a3e3873SBaptiste Daroussin 
3174c8945a0SNathan Whitehorn /*
3184c8945a0SNathan Whitehorn  * This is a list of "old" names, which should be helpful in updating
3194c8945a0SNathan Whitehorn  * applications that use libdialog.  Starting with 2003/11/26, all exported
3204c8945a0SNathan Whitehorn  * symbols from libdialog have "dlg_" prefix, or "dialog_" prefix or "_dialog"
3214c8945a0SNathan Whitehorn  * suffix (or suffix "_dialog", e.g., init_dialog).
3224c8945a0SNathan Whitehorn  */
3234c8945a0SNathan Whitehorn #ifdef __DIALOG_OLD_NAMES__
3244c8945a0SNathan Whitehorn #define color_table                       dlg_color_table
3254c8945a0SNathan Whitehorn #define attr_clear(win,h,w,a)             dlg_attr_clear(win,h,w,a)
3264c8945a0SNathan Whitehorn #define auto_size(t,s,h,w,xl,mc)          dlg_auto_size(t,s,h,w,xl,mc)
3274c8945a0SNathan Whitehorn #define auto_sizefile(t,f,h,w,xl,mc)      dlg_auto_sizefile(t,f,h,w,xl,mc)
3284c8945a0SNathan Whitehorn #define beeping()                         dlg_beeping()
3294c8945a0SNathan Whitehorn #define box_x_ordinate(w)                 dlg_box_x_ordinate(w)
3304c8945a0SNathan Whitehorn #define box_y_ordinate(h)                 dlg_box_y_ordinate(h)
3314c8945a0SNathan Whitehorn #define calc_listh(h,lh,in)               dlg_calc_listh(h,lh,in)
3324c8945a0SNathan Whitehorn #define calc_listw(in,items,group)        dlg_calc_listw(in,items,group)
3334c8945a0SNathan Whitehorn #define color_setup()                     dlg_color_setup()
3344c8945a0SNathan Whitehorn #define create_rc(f)                      dlg_create_rc(f)
3354c8945a0SNathan Whitehorn #define ctl_size(h,w)                     dlg_ctl_size(h,w)
3364c8945a0SNathan Whitehorn #define del_window(win)                   dlg_del_window(win)
3374c8945a0SNathan Whitehorn #define dialog_clear()                    dlg_clear()
3384c8945a0SNathan Whitehorn #define draw_bottom_box(win)              dlg_draw_bottom_box(win)
3394c8945a0SNathan Whitehorn #define draw_box(win,y,x,h,w,xc,bc)       dlg_draw_box(win,y,x,h,w,xc,bc)
3404c8945a0SNathan Whitehorn #define draw_shadow(win,h,w,y,x)          dlg_draw_shadow(win,h,w,y,x)
3414c8945a0SNathan Whitehorn #define draw_title(win,t)                 dlg_draw_title(win,t)
3424c8945a0SNathan Whitehorn #define exiterr                           dlg_exiterr
3434c8945a0SNathan Whitehorn #define killall_bg(n)                     dlg_killall_bg(n)
3444c8945a0SNathan Whitehorn #define mouse_bigregion(y,x)              dlg_mouse_bigregion(y,x)
3454c8945a0SNathan Whitehorn #define mouse_free_regions()              dlg_mouse_free_regions()
3464c8945a0SNathan Whitehorn #define mouse_mkbigregion(y,x,h,w,n,ix,iy,m) dlg_mouse_mkbigregion(y,x,h,w,n,ix,iy,m)
3474c8945a0SNathan Whitehorn #define mouse_mkregion(y,x,h,w,n)         dlg_mouse_mkregion(y,x,h,w,n)
3484c8945a0SNathan Whitehorn #define mouse_region(y,x)                 dlg_mouse_region(y,x)
3494c8945a0SNathan Whitehorn #define mouse_setbase(x,y)                dlg_mouse_setbase(x,y)
3502a3e3873SBaptiste Daroussin #define mouse_setcode(c)                  dlg_mouse_setcode(c)
3514c8945a0SNathan Whitehorn #define mouse_wgetch(w,c)                 dlg_mouse_wgetch(w,c)
3524c8945a0SNathan Whitehorn #define new_window(h,w,y,x)               dlg_new_window(h,w,y,x)
3534c8945a0SNathan Whitehorn #define parse_rc()                        dlg_parse_rc()
3544c8945a0SNathan Whitehorn #define print_autowrap(win,s,h,w)         dlg_print_autowrap(win,s,h,w)
3554c8945a0SNathan Whitehorn #define print_size(h,w)                   dlg_print_size(h,w)
3564c8945a0SNathan Whitehorn #define put_backtitle()                   dlg_put_backtitle()
3574c8945a0SNathan Whitehorn #define strclone(cprompt)                 dlg_strclone(cprompt)
3584c8945a0SNathan Whitehorn #define sub_window(win,h,w,y,x)           dlg_sub_window(win,h,w,y,x)
3594c8945a0SNathan Whitehorn #define tab_correct_str(s)                dlg_tab_correct_str(s)
3604c8945a0SNathan Whitehorn #endif
3614c8945a0SNathan Whitehorn 
3624c8945a0SNathan Whitehorn /*
3634c8945a0SNathan Whitehorn  * Attribute names
3644c8945a0SNathan Whitehorn  */
3654c8945a0SNathan Whitehorn #define DIALOG_ATR(n)                 dlg_color_table[n].atr
3664c8945a0SNathan Whitehorn 
3674c8945a0SNathan Whitehorn #define screen_attr                   DIALOG_ATR(0)
3684c8945a0SNathan Whitehorn #define shadow_attr                   DIALOG_ATR(1)
3694c8945a0SNathan Whitehorn #define dialog_attr                   DIALOG_ATR(2)
3704c8945a0SNathan Whitehorn #define title_attr                    DIALOG_ATR(3)
3714c8945a0SNathan Whitehorn #define border_attr                   DIALOG_ATR(4)
3724c8945a0SNathan Whitehorn #define button_active_attr            DIALOG_ATR(5)
3734c8945a0SNathan Whitehorn #define button_inactive_attr          DIALOG_ATR(6)
3744c8945a0SNathan Whitehorn #define button_key_active_attr        DIALOG_ATR(7)
3754c8945a0SNathan Whitehorn #define button_key_inactive_attr      DIALOG_ATR(8)
3764c8945a0SNathan Whitehorn #define button_label_active_attr      DIALOG_ATR(9)
3774c8945a0SNathan Whitehorn #define button_label_inactive_attr    DIALOG_ATR(10)
3784c8945a0SNathan Whitehorn #define inputbox_attr                 DIALOG_ATR(11)
3794c8945a0SNathan Whitehorn #define inputbox_border_attr          DIALOG_ATR(12)
3804c8945a0SNathan Whitehorn #define searchbox_attr                DIALOG_ATR(13)
3814c8945a0SNathan Whitehorn #define searchbox_title_attr          DIALOG_ATR(14)
3824c8945a0SNathan Whitehorn #define searchbox_border_attr         DIALOG_ATR(15)
3834c8945a0SNathan Whitehorn #define position_indicator_attr       DIALOG_ATR(16)
3844c8945a0SNathan Whitehorn #define menubox_attr                  DIALOG_ATR(17)
3854c8945a0SNathan Whitehorn #define menubox_border_attr           DIALOG_ATR(18)
3864c8945a0SNathan Whitehorn #define item_attr                     DIALOG_ATR(19)
3874c8945a0SNathan Whitehorn #define item_selected_attr            DIALOG_ATR(20)
3884c8945a0SNathan Whitehorn #define tag_attr                      DIALOG_ATR(21)
3894c8945a0SNathan Whitehorn #define tag_selected_attr             DIALOG_ATR(22)
3904c8945a0SNathan Whitehorn #define tag_key_attr                  DIALOG_ATR(23)
3914c8945a0SNathan Whitehorn #define tag_key_selected_attr         DIALOG_ATR(24)
3924c8945a0SNathan Whitehorn #define check_attr                    DIALOG_ATR(25)
3934c8945a0SNathan Whitehorn #define check_selected_attr           DIALOG_ATR(26)
3944c8945a0SNathan Whitehorn #define uarrow_attr                   DIALOG_ATR(27)
3954c8945a0SNathan Whitehorn #define darrow_attr                   DIALOG_ATR(28)
3964c8945a0SNathan Whitehorn #define itemhelp_attr                 DIALOG_ATR(29)
3974c8945a0SNathan Whitehorn #define form_active_text_attr         DIALOG_ATR(30)
3984c8945a0SNathan Whitehorn #define form_text_attr                DIALOG_ATR(31)
3994c8945a0SNathan Whitehorn #define form_item_readonly_attr       DIALOG_ATR(32)
4007a1c0d96SNathan Whitehorn #define gauge_attr                    DIALOG_ATR(33)
4012a3e3873SBaptiste Daroussin #define border2_attr                  DIALOG_ATR(34)
4022a3e3873SBaptiste Daroussin #define inputbox_border2_attr         DIALOG_ATR(35)
4032a3e3873SBaptiste Daroussin #define searchbox_border2_attr        DIALOG_ATR(36)
4042a3e3873SBaptiste Daroussin #define menubox_border2_attr          DIALOG_ATR(37)
4054c8945a0SNathan Whitehorn 
4064c8945a0SNathan Whitehorn #define DLGK_max (KEY_MAX + 256)
4074c8945a0SNathan Whitehorn 
4084c8945a0SNathan Whitehorn /*
409f4f33ea0SBaptiste Daroussin  * Use attributes.
410f4f33ea0SBaptiste Daroussin  */
411f4f33ea0SBaptiste Daroussin #ifdef PDCURSES
412f4f33ea0SBaptiste Daroussin #define dlg_attrset(w,a)  (void) wattrset((w), (a))
413f4f33ea0SBaptiste Daroussin #define dlg_attron(w,a)   (void) wattron((w), (a))
414f4f33ea0SBaptiste Daroussin #define dlg_attroff(w,a)  (void) wattroff((w), (a))
415f4f33ea0SBaptiste Daroussin #else
416f4f33ea0SBaptiste Daroussin #define dlg_attrset(w,a)  (void) wattrset((w), (int)(a))
417f4f33ea0SBaptiste Daroussin #define dlg_attron(w,a)   (void) wattron((w), (int)(a))
418f4f33ea0SBaptiste Daroussin #define dlg_attroff(w,a)  (void) wattroff((w), (int)(a))
419f4f33ea0SBaptiste Daroussin #endif
420f4f33ea0SBaptiste Daroussin 
421f4f33ea0SBaptiste Daroussin /*
4224c8945a0SNathan Whitehorn  * Callbacks are used to implement the "background" tailbox.
4234c8945a0SNathan Whitehorn  */
4244c8945a0SNathan Whitehorn struct _dlg_callback;
4254c8945a0SNathan Whitehorn 
4264c8945a0SNathan Whitehorn typedef void (*DIALOG_FREEBACK) (struct _dlg_callback * /* p */);
4274c8945a0SNathan Whitehorn 
4284c8945a0SNathan Whitehorn typedef struct _dlg_callback {
4294c8945a0SNathan Whitehorn     struct _dlg_callback *next;
4304c8945a0SNathan Whitehorn     FILE *input;
4314c8945a0SNathan Whitehorn     WINDOW *win;
4324c8945a0SNathan Whitehorn     bool keep_bg;	/* keep in background, on exit */
4334c8945a0SNathan Whitehorn     bool bg_task;	/* true if this is background task */
4344c8945a0SNathan Whitehorn     bool (*handle_getc)(struct _dlg_callback *p, int ch, int fkey, int *result);
4354c8945a0SNathan Whitehorn     bool keep_win;	/* true to not erase window on exit */
4364c8945a0SNathan Whitehorn     /* data for dlg_add_callback_ref */
4374c8945a0SNathan Whitehorn     struct _dlg_callback **caller;
4384c8945a0SNathan Whitehorn     DIALOG_FREEBACK freeback;
4397a1c0d96SNathan Whitehorn     /* 1.1-20110107 */
4407a1c0d96SNathan Whitehorn     bool (*handle_input)(struct _dlg_callback *p);
4417a1c0d96SNathan Whitehorn     bool input_ready;
4424c8945a0SNathan Whitehorn } DIALOG_CALLBACK;
4434c8945a0SNathan Whitehorn 
4444c8945a0SNathan Whitehorn typedef struct _dlg_windows {
4454c8945a0SNathan Whitehorn     struct _dlg_windows *next;
4464c8945a0SNathan Whitehorn     WINDOW *normal;
4474c8945a0SNathan Whitehorn     WINDOW *shadow;
448*a96ef450SBaptiste Daroussin     int getc_timeout;
4494c8945a0SNathan Whitehorn } DIALOG_WINDOWS;
4504c8945a0SNathan Whitehorn 
4514c8945a0SNathan Whitehorn /*
4524c8945a0SNathan Whitehorn  * Global variables, which are initialized as needed
4534c8945a0SNathan Whitehorn  */
4544c8945a0SNathan Whitehorn typedef struct {
4554c8945a0SNathan Whitehorn     DIALOG_CALLBACK *getc_callbacks;
4564c8945a0SNathan Whitehorn     DIALOG_CALLBACK *getc_redirect;
4574c8945a0SNathan Whitehorn     DIALOG_WINDOWS *all_windows;
4582a3e3873SBaptiste Daroussin     DIALOG_WINDOWS *all_subwindows;
4594c8945a0SNathan Whitehorn     FILE *output;		/* option "--output-fd fd" */
4604c8945a0SNathan Whitehorn     FILE *pipe_input;		/* used for gauge widget */
4614c8945a0SNathan Whitehorn     FILE *screen_output;	/* newterm(), etc. */
4624c8945a0SNathan Whitehorn     bool screen_initialized;
4634c8945a0SNathan Whitehorn     bool use_colors;		/* use colors by default? */
4644c8945a0SNathan Whitehorn     bool use_scrollbar;		/* option "--scrollbar" */
4654c8945a0SNathan Whitehorn     bool use_shadow;		/* shadow dialog boxes by default? */
4664c8945a0SNathan Whitehorn     bool visit_items;		/* option "--visit-items" */
4674c8945a0SNathan Whitehorn     char *separate_str;		/* option "--separate-widget string" */
4684c8945a0SNathan Whitehorn     int aspect_ratio;		/* option "--aspect ratio" */
4694c8945a0SNathan Whitehorn     int output_count;		/* # of widgets that may have done output */
4704c8945a0SNathan Whitehorn     int tab_len;		/* option "--tab-len n" */
4714c8945a0SNathan Whitehorn     /* 1.0-20070227 */
4724c8945a0SNathan Whitehorn     FILE *input;		/* option "--input-fd fd" */
4734c8945a0SNathan Whitehorn #ifdef HAVE_DLG_TRACE
4744c8945a0SNathan Whitehorn     FILE *trace_output;		/* option "--trace file" */
4754c8945a0SNathan Whitehorn #endif
4767a1c0d96SNathan Whitehorn     /* 1.1-20110106 */
4777a1c0d96SNathan Whitehorn     bool no_mouse;		/* option "--no-mouse" */
4782a3e3873SBaptiste Daroussin     int visit_cols;		/* option "--visit-items" */
479febdb468SDevin Teske     /* 1.2-20130922 */
480febdb468SDevin Teske     bool finish_string;		/* caching optimization for gauge */
481f4f33ea0SBaptiste Daroussin     /* 1.2-20150125 */
482f4f33ea0SBaptiste Daroussin     bool plain_buttons;		/* true to suppress button-label highlight */
483f4f33ea0SBaptiste Daroussin     /* 1.3-20180610 */
484f4f33ea0SBaptiste Daroussin     bool text_only;		/* option "--print-text-only", etc. */
485f4f33ea0SBaptiste Daroussin     int text_height;
486f4f33ea0SBaptiste Daroussin     int text_width;
487*a96ef450SBaptiste Daroussin     /* 1.3-20190211 */
488*a96ef450SBaptiste Daroussin     int screen_height;
489*a96ef450SBaptiste Daroussin     int screen_width;
490*a96ef450SBaptiste Daroussin #ifdef KEY_RESIZE
491*a96ef450SBaptiste Daroussin     /* 1.3-20190724 */
492*a96ef450SBaptiste Daroussin     bool had_resize;		/* ERR may follow KEY_RESIZE when polling */
493*a96ef450SBaptiste Daroussin #endif
4944c8945a0SNathan Whitehorn } DIALOG_STATE;
4954c8945a0SNathan Whitehorn 
4964c8945a0SNathan Whitehorn extern DIALOG_STATE dialog_state;
4974c8945a0SNathan Whitehorn 
4984c8945a0SNathan Whitehorn /*
4994c8945a0SNathan Whitehorn  * Global variables, which dialog resets before each widget
5004c8945a0SNathan Whitehorn  */
5014c8945a0SNathan Whitehorn typedef struct {
5024c8945a0SNathan Whitehorn     bool beep_after_signal;	/* option "--beep-after" */
5034c8945a0SNathan Whitehorn     bool beep_signal;		/* option "--beep" */
5044c8945a0SNathan Whitehorn     bool begin_set;		/* option "--begin y x" was used */
5054c8945a0SNathan Whitehorn     bool cant_kill;		/* option "--no-kill" */
5064c8945a0SNathan Whitehorn     bool colors;		/* option "--colors" */
5074c8945a0SNathan Whitehorn     bool cr_wrap;		/* option "--cr-wrap" */
5084c8945a0SNathan Whitehorn     bool defaultno;		/* option "--defaultno" */
5094c8945a0SNathan Whitehorn     bool dlg_clear_screen;	/* option "--clear" */
5104c8945a0SNathan Whitehorn     bool extra_button;		/* option "--extra-button" */
5114c8945a0SNathan Whitehorn     bool help_button;		/* option "--help-button" */
5124c8945a0SNathan Whitehorn     bool help_status;		/* option "--help-status" */
5134c8945a0SNathan Whitehorn     bool input_menu;		/* menu vs inputmenu widget */
5144c8945a0SNathan Whitehorn     bool insecure;		/* option "--insecure" */
5154c8945a0SNathan Whitehorn     bool item_help;		/* option "--item-help" */
5164c8945a0SNathan Whitehorn     bool keep_window;		/* option "--keep-window" */
5174c8945a0SNathan Whitehorn     bool nocancel;		/* option "--no-cancel" */
5184c8945a0SNathan Whitehorn     bool nocollapse;		/* option "--no-collapse" */
5194c8945a0SNathan Whitehorn     bool print_siz;		/* option "--print-size" */
5204c8945a0SNathan Whitehorn     bool separate_output;	/* option "--separate-output" */
5214c8945a0SNathan Whitehorn     bool single_quoted;		/* option "--single-quoted" */
5224c8945a0SNathan Whitehorn     bool size_err;		/* option "--size-err" */
5234c8945a0SNathan Whitehorn     bool tab_correct;		/* option "--tab-correct" */
5244c8945a0SNathan Whitehorn     bool trim_whitespace;	/* option "--trim" */
5254c8945a0SNathan Whitehorn     char *backtitle;		/* option "--backtitle backtitle" */
5264c8945a0SNathan Whitehorn     char *cancel_label;		/* option "--cancel-label string" */
5274c8945a0SNathan Whitehorn     char *default_item;		/* option "--default-item string" */
5284c8945a0SNathan Whitehorn     char *exit_label;		/* option "--exit-label string" */
5294c8945a0SNathan Whitehorn     char *extra_label;		/* option "--extra-label string" */
5304c8945a0SNathan Whitehorn     char *help_label;		/* option "--help-label string" */
5314c8945a0SNathan Whitehorn     char *input_result;
5324c8945a0SNathan Whitehorn     char *no_label;		/* option "--no-label string" */
5334c8945a0SNathan Whitehorn     char *ok_label;		/* option "--ok-label string" */
5344c8945a0SNathan Whitehorn     char *title;		/* option "--title title" */
5354c8945a0SNathan Whitehorn     char *yes_label;		/* option "--yes-label string" */
5364c8945a0SNathan Whitehorn     int begin_x;		/* option "--begin y x" (second value) */
5374c8945a0SNathan Whitehorn     int begin_y;		/* option "--begin y x" (first value) */
5384c8945a0SNathan Whitehorn     int max_input;		/* option "--max-input size" */
5394c8945a0SNathan Whitehorn     int scale_factor;		/* RESERVED */
5404c8945a0SNathan Whitehorn     int sleep_secs;		/* option "--sleep secs" */
5414c8945a0SNathan Whitehorn     int timeout_secs;		/* option "--timeout secs" */
5424c8945a0SNathan Whitehorn     unsigned input_length;	/* nonzero if input_result is allocated */
5434c8945a0SNathan Whitehorn     /* 1.0-20051207 */
5444c8945a0SNathan Whitehorn     unsigned formitem_type;	/* DIALOG_FORMITEM.type in dialog_form() */
5454c8945a0SNathan Whitehorn     /* 1.1-20070227 */
5464c8945a0SNathan Whitehorn     bool keep_tite;		/* option "--keep-tite" */
5474c8945a0SNathan Whitehorn     bool ascii_lines;		/* option "--ascii-lines" */
5484c8945a0SNathan Whitehorn     bool no_lines;		/* option "--no-lines" */
5494c8945a0SNathan Whitehorn     /* 1.1-20070930 */
5504c8945a0SNathan Whitehorn     bool nook;			/* option "--no-ok" */
5514c8945a0SNathan Whitehorn     /* 1.1-20080727 */
5524c8945a0SNathan Whitehorn     bool quoted;		/* option "--quoted" */
5534c8945a0SNathan Whitehorn     char *column_header;	/* RESERVED "--column-header" */
5544c8945a0SNathan Whitehorn     char *column_separator;	/* option "--column-separator" */
5554c8945a0SNathan Whitehorn     char *output_separator;	/* option "--output-separator" */
5564c8945a0SNathan Whitehorn     /* 1.1-20100118 */
5574c8945a0SNathan Whitehorn     char *date_format;		/* option "--date-format" */
5584c8945a0SNathan Whitehorn     char *time_format;		/* option "--time-format" */
559682c9e0fSNathan Whitehorn     /* 1.1-20110629 */
560682c9e0fSNathan Whitehorn     char *help_line;		/* option "--hline" */
561682c9e0fSNathan Whitehorn     char *help_file;		/* option "--hfile" */
562682c9e0fSNathan Whitehorn     bool in_helpfile;		/* flag to prevent recursion in --hfile */
563682c9e0fSNathan Whitehorn     bool no_nl_expand;		/* option "--no-nl-expand" */
5642a3e3873SBaptiste Daroussin     /* 1.1-20120701 */
5652a3e3873SBaptiste Daroussin     int default_button;		/* option "--default-button" (exit code) */
5662a3e3873SBaptiste Daroussin     /* 1.1-20121218 */
5672a3e3873SBaptiste Daroussin     bool no_tags;		/* option "--no-tags" */
5682a3e3873SBaptiste Daroussin     bool no_items;		/* option "--no-items" */
5692a3e3873SBaptiste Daroussin     /* 1.2-20130315 */
5702a3e3873SBaptiste Daroussin     bool last_key;		/* option "--last-key" */
571febdb468SDevin Teske     /* 1.2-20130902 */
572febdb468SDevin Teske     bool help_tags;		/* option "--help-tags" */
573f4f33ea0SBaptiste Daroussin     /* 1.3-20160126 */
574f4f33ea0SBaptiste Daroussin     char *week_start;		/* option "--week-start" */
575f4f33ea0SBaptiste Daroussin     /* 1.3-20160206 */
576f4f33ea0SBaptiste Daroussin     bool iso_week;		/* option "--iso-week" */
577f4f33ea0SBaptiste Daroussin     /* 1.3-20170131 */
578f4f33ea0SBaptiste Daroussin     bool reorder;		/* option "--reorder" */
579*a96ef450SBaptiste Daroussin     /* 1.3-20201117 */
580*a96ef450SBaptiste Daroussin     int pause_secs;		/* used by pause widget */
581*a96ef450SBaptiste Daroussin     /* 1.3-20201126 */
582*a96ef450SBaptiste Daroussin     bool erase_on_exit;		/* option "--erase-on-exit" */
583*a96ef450SBaptiste Daroussin     bool cursor_off_label;	/* option "--cursor-off-label" */
584*a96ef450SBaptiste Daroussin     /* 1.3-20210117 */
585*a96ef450SBaptiste Daroussin     bool no_hot_list;		/* option "--no-hot-list" */
5864c8945a0SNathan Whitehorn } DIALOG_VARS;
5874c8945a0SNathan Whitehorn 
5884c8945a0SNathan Whitehorn #define USE_ITEM_HELP(s)        (dialog_vars.item_help && (s) != 0)
5892a3e3873SBaptiste Daroussin 
5902a3e3873SBaptiste Daroussin /*
5912a3e3873SBaptiste Daroussin  * Some settings change the number of data items per row which dialog reads
5922a3e3873SBaptiste Daroussin  * from a script.
5932a3e3873SBaptiste Daroussin  */
5942a3e3873SBaptiste Daroussin #define DLG__NO_ITEMS		(dialog_vars.no_items ? 0 : 1)
5952a3e3873SBaptiste Daroussin #define DLG__ITEM_HELP          (dialog_vars.item_help ? 1 : 0)
5962a3e3873SBaptiste Daroussin 
5972a3e3873SBaptiste Daroussin /*
5982a3e3873SBaptiste Daroussin  * These are the total number of data items per row used for each widget type.
5992a3e3873SBaptiste Daroussin  */
6002a3e3873SBaptiste Daroussin #define CHECKBOX_TAGS           (2 + DLG__ITEM_HELP + DLG__NO_ITEMS)
6012a3e3873SBaptiste Daroussin #define MENUBOX_TAGS            (1 + DLG__ITEM_HELP + DLG__NO_ITEMS)
6022a3e3873SBaptiste Daroussin #define FORMBOX_TAGS            (8 + DLG__ITEM_HELP)
6032a3e3873SBaptiste Daroussin #define MIXEDFORM_TAGS          (1 + FORMBOX_TAGS)
6044c8945a0SNathan Whitehorn #define MIXEDGAUGE_TAGS         2
6052a3e3873SBaptiste Daroussin #define TREEVIEW_TAGS           (3 + DLG__ITEM_HELP + DLG__NO_ITEMS)
6064c8945a0SNathan Whitehorn 
6074c8945a0SNathan Whitehorn extern DIALOG_VARS dialog_vars;
6084c8945a0SNathan Whitehorn 
6094c8945a0SNathan Whitehorn #ifndef HAVE_TYPE_CHTYPE
6104c8945a0SNathan Whitehorn #define chtype long
6114c8945a0SNathan Whitehorn #endif
6124c8945a0SNathan Whitehorn 
613f4f33ea0SBaptiste Daroussin #ifndef isblank
614f4f33ea0SBaptiste Daroussin #define isblank(c)       ((c) == ' ' || (c) == TAB)
615f4f33ea0SBaptiste Daroussin #endif
616f4f33ea0SBaptiste Daroussin 
6174c8945a0SNathan Whitehorn #define UCH(ch)			((unsigned char)(ch))
6184c8945a0SNathan Whitehorn 
6194c8945a0SNathan Whitehorn #define assert_ptr(ptr,msg) if ((ptr) == 0) dlg_exiterr("cannot allocate memory in " msg)
6204c8945a0SNathan Whitehorn 
6217a1c0d96SNathan Whitehorn #define dlg_malloc(t,n)    (t *) malloc((size_t)(n) * sizeof(t))
6227a1c0d96SNathan Whitehorn #define dlg_calloc(t,n)    (t *) calloc((size_t)(n), sizeof(t))
6234c8945a0SNathan Whitehorn #define dlg_realloc(t,n,p) (t *) realloc((p), (n) * sizeof(t))
6244c8945a0SNathan Whitehorn 
6254c8945a0SNathan Whitehorn /*
6264c8945a0SNathan Whitehorn  * Table for attribute- and color-values.
6274c8945a0SNathan Whitehorn  */
6284c8945a0SNathan Whitehorn typedef struct {
629*a96ef450SBaptiste Daroussin     chtype atr;			/* attribute corresponding to fg, bg, etc */
6304c8945a0SNathan Whitehorn #ifdef HAVE_COLOR
631*a96ef450SBaptiste Daroussin     int fg;			/* foreground color-number */
632*a96ef450SBaptiste Daroussin     int bg;			/* background color-number */
633*a96ef450SBaptiste Daroussin     int hilite;			/* true if bold */
634*a96ef450SBaptiste Daroussin #ifdef HAVE_RC_FILE2
635*a96ef450SBaptiste Daroussin     int ul;			/* true if underline */
636*a96ef450SBaptiste Daroussin     int rv;			/* true if reverse */
637*a96ef450SBaptiste Daroussin #endif /* HAVE_RC_FILE2 */
638*a96ef450SBaptiste Daroussin #endif /* HAVE_COLOR */
6394c8945a0SNathan Whitehorn #ifdef HAVE_RC_FILE
6404c8945a0SNathan Whitehorn     const char *name;
6414c8945a0SNathan Whitehorn     const char *comment;
6424c8945a0SNathan Whitehorn #endif
6434c8945a0SNathan Whitehorn } DIALOG_COLORS;
6444c8945a0SNathan Whitehorn 
6454c8945a0SNathan Whitehorn extern DIALOG_COLORS dlg_color_table[];
6464c8945a0SNathan Whitehorn 
6474c8945a0SNathan Whitehorn /*
6484c8945a0SNathan Whitehorn  * Function prototypes
6494c8945a0SNathan Whitehorn  */
6504c8945a0SNathan Whitehorn extern const char *dialog_version(void);
6514c8945a0SNathan Whitehorn 
6524c8945a0SNathan Whitehorn /* widgets, each in separate files */
6532a3e3873SBaptiste Daroussin 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*/);
6544c8945a0SNathan Whitehorn extern int dialog_calendar(const char * /*title*/, const char * /*subtitle*/, int /*height*/, int /*width*/, int /*day*/, int /*month*/, int /*year*/);
6554c8945a0SNathan Whitehorn extern int dialog_checklist(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/, int /*list_height*/, int /*item_no*/, char ** /*items*/, int /*flag*/);
6564c8945a0SNathan Whitehorn extern int dialog_dselect(const char * /*title*/, const char * /*path*/, int /*height*/, int /*width*/);
6574c8945a0SNathan Whitehorn extern int dialog_editbox(const char * /*title*/, const char * /*file*/, int /*height*/, int /*width*/);
6584c8945a0SNathan Whitehorn extern int dialog_form(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/, int /*form_height*/, int /*item_no*/, char ** /*items*/);
6594c8945a0SNathan Whitehorn extern int dialog_fselect(const char * /*title*/, const char * /*path*/, int /*height*/, int /*width*/);
6604c8945a0SNathan Whitehorn extern int dialog_gauge(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/, int /*percent*/);
661682c9e0fSNathan Whitehorn extern int dialog_helpfile(const char * /*title*/, const char * /*file*/, int /*height*/, int /*width*/);
6624c8945a0SNathan Whitehorn extern int dialog_inputbox(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/, const char * /*init*/, const int /*password*/);
6634c8945a0SNathan Whitehorn extern int dialog_menu(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/, int /*menu_height*/, int /*item_no*/, char ** /*items*/);
6644c8945a0SNathan Whitehorn extern int dialog_mixedform(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/, int /*form_height*/, int /*item_no*/, char ** /*items*/);
6654c8945a0SNathan Whitehorn extern int dialog_mixedgauge(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/, int /*percent*/, int /*item_no*/, char ** /*items*/);
6664c8945a0SNathan Whitehorn extern int dialog_msgbox(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/, int /*pauseopt*/);
6674c8945a0SNathan Whitehorn extern int dialog_pause(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/, int /*seconds*/);
6687a1c0d96SNathan Whitehorn extern int dialog_prgbox(const char * /*title*/, const char * /*cprompt*/, const char * /*command*/, int /*height*/, int /*width*/, int /*pauseopt*/);
6694c8945a0SNathan Whitehorn extern int dialog_progressbox(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/);
6702a3e3873SBaptiste Daroussin extern int dialog_rangebox(const char * /*title*/, const char * /*file*/, int /*height*/, int /*width*/, int /*min_value*/, int /*max_value*/, int /*default_value*/);
6714c8945a0SNathan Whitehorn extern int dialog_tailbox(const char * /*title*/, const char * /*file*/, int /*height*/, int /*width*/, int /*bg_task*/);
6724c8945a0SNathan Whitehorn extern int dialog_textbox(const char * /*title*/, const char * /*file*/, int /*height*/, int /*width*/);
6734c8945a0SNathan Whitehorn extern int dialog_timebox(const char * /*title*/, const char * /*subtitle*/, int /*height*/, int /*width*/, int /*hour*/, int /*minute*/, int /*second*/);
6742a3e3873SBaptiste Daroussin extern int dialog_treeview(const char * /*title*/, const char * /*subtitle*/, int /*height*/, int /*width*/, int /*list_height*/, int /*item_no*/, char ** /*items*/, int /*flag*/);
6754c8945a0SNathan Whitehorn extern int dialog_yesno(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/);
6764c8945a0SNathan Whitehorn 
6774c8945a0SNathan Whitehorn /* some widgets have alternate entrypoints, to allow list manipulation */
6784c8945a0SNathan Whitehorn typedef struct {
6794c8945a0SNathan Whitehorn     char *name;
6804c8945a0SNathan Whitehorn     char *text;
6814c8945a0SNathan Whitehorn     char *help;
6824c8945a0SNathan Whitehorn     int state;
6834c8945a0SNathan Whitehorn } DIALOG_LISTITEM;
6844c8945a0SNathan Whitehorn 
6854c8945a0SNathan Whitehorn typedef struct {
6864c8945a0SNathan Whitehorn     unsigned type;		/* the field type (0=input, 1=password) */
6874c8945a0SNathan Whitehorn     char *name;			/* the field label */
6884c8945a0SNathan Whitehorn     int name_len;		/* ...its length */
6894c8945a0SNathan Whitehorn     int name_y;			/* ...its y-ordinate */
6904c8945a0SNathan Whitehorn     int name_x;			/* ...its x-ordinate */
6914c8945a0SNathan Whitehorn     bool name_free;		/* ...true if .name can be freed */
6924c8945a0SNathan Whitehorn     char *text;			/* the field contents */
6934c8945a0SNathan Whitehorn     int text_len;		/* ...its length on the screen */
6944c8945a0SNathan Whitehorn     int text_y;			/* ...its y-ordinate */
6954c8945a0SNathan Whitehorn     int text_x;			/* ...its x-ordinate */
6964c8945a0SNathan Whitehorn     int text_flen;		/* ...its length on screen, or 0 if no input allowed */
6974c8945a0SNathan Whitehorn     int text_ilen;		/* ...its limit on amount to be entered */
6984c8945a0SNathan Whitehorn     bool text_free;		/* ...true if .text can be freed */
6994c8945a0SNathan Whitehorn     char *help;			/* help-message, if any */
7004c8945a0SNathan Whitehorn     bool help_free;		/* ...true if .help can be freed */
7014c8945a0SNathan Whitehorn } DIALOG_FORMITEM;
7024c8945a0SNathan Whitehorn 
7034c8945a0SNathan Whitehorn typedef	int (DIALOG_INPUTMENU) (DIALOG_LISTITEM * /*items*/, int /*current*/, char * /*newtext*/);
7044c8945a0SNathan Whitehorn 
7054c8945a0SNathan Whitehorn 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*/);
7064c8945a0SNathan Whitehorn 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*/);
7074c8945a0SNathan Whitehorn 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*/);
7087a1c0d96SNathan Whitehorn extern int dlg_progressbox(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/, int /*pauseopt*/, FILE * /* fp */);
7097a1c0d96SNathan Whitehorn 
7107a1c0d96SNathan Whitehorn /* argv.c */
7117a1c0d96SNathan Whitehorn extern char ** dlg_string_to_argv(char * /* blob */);
7127a1c0d96SNathan Whitehorn extern int dlg_count_argv(char ** /* argv */);
7137a1c0d96SNathan Whitehorn extern int dlg_eat_argv(int * /* argcp */, char *** /* argvp */, int /* start */, int /* count */);
7144c8945a0SNathan Whitehorn 
7154c8945a0SNathan Whitehorn /* arrows.c */
7164c8945a0SNathan Whitehorn extern void dlg_draw_arrows(WINDOW * /*dialog*/, int /*top_arrow*/, int /*bottom_arrow*/, int /*x*/, int /*top*/, int /*bottom*/);
7174c8945a0SNathan Whitehorn extern void dlg_draw_arrows2(WINDOW * /*dialog*/, int /*top_arrow*/, int /*bottom_arrow*/, int /*x*/, int /*top*/, int /*bottom*/, chtype /*attr*/, chtype /*borderattr*/);
718682c9e0fSNathan Whitehorn extern void dlg_draw_helpline(WINDOW * /*dialog*/, bool /*decorations*/);
7194c8945a0SNathan Whitehorn 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*/);
7204c8945a0SNathan Whitehorn 
7212a3e3873SBaptiste Daroussin /* buildlist.c */
7222a3e3873SBaptiste Daroussin 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*/);
7232a3e3873SBaptiste Daroussin 
7244c8945a0SNathan Whitehorn /* buttons.c */
7254c8945a0SNathan Whitehorn extern const char ** dlg_exit_label(void);
7264c8945a0SNathan Whitehorn extern const char ** dlg_ok_label(void);
7274c8945a0SNathan Whitehorn extern const char ** dlg_ok_labels(void);
7284c8945a0SNathan Whitehorn extern const char ** dlg_yes_labels(void);
7294c8945a0SNathan Whitehorn extern int dlg_button_count(const char ** /*labels*/);
7304c8945a0SNathan Whitehorn extern int dlg_button_to_char(const char * /*label*/);
7314c8945a0SNathan Whitehorn extern int dlg_button_x_step(const char ** /*labels*/, int /*limit*/, int * /*gap*/, int * /*margin*/, int * /*step*/);
7324c8945a0SNathan Whitehorn extern int dlg_char_to_button(int /*ch*/, const char ** /*labels*/);
7334c8945a0SNathan Whitehorn extern int dlg_exit_buttoncode(int /*button*/);
7344c8945a0SNathan Whitehorn extern int dlg_match_char(int /*ch*/, const char * /*string*/);
7354c8945a0SNathan Whitehorn extern int dlg_next_button(const char ** /*labels*/, int /*button*/);
7364c8945a0SNathan Whitehorn extern int dlg_next_ok_buttonindex(int /*current*/, int /*extra*/);
7374c8945a0SNathan Whitehorn extern int dlg_ok_buttoncode(int /*button*/);
7384c8945a0SNathan Whitehorn extern int dlg_prev_button(const char ** /*labels*/, int /*button*/);
7394c8945a0SNathan Whitehorn extern int dlg_prev_ok_buttonindex(int /*current*/, int /*extra*/);
7404c8945a0SNathan Whitehorn extern int dlg_yes_buttoncode(int /*button*/);
7414c8945a0SNathan Whitehorn extern void dlg_button_layout(const char ** /*labels*/, int * /*limit*/);
7424c8945a0SNathan Whitehorn extern void dlg_button_sizes(const char ** /*labels*/, int /*vertical*/, int * /*longest*/, int * /*length*/);
7434c8945a0SNathan Whitehorn extern void dlg_draw_buttons(WINDOW * /*win*/, int /*y*/, int /*x*/, const char ** /*labels*/, int /*selected*/, int /*vertical*/, int /*limit*/);
7444c8945a0SNathan Whitehorn 
7454c8945a0SNathan Whitehorn /* columns.c */
7464c8945a0SNathan Whitehorn extern void dlg_align_columns(char ** /* target */, int  /* per_row */, int /* num_rows */);
7474c8945a0SNathan Whitehorn extern void dlg_free_columns(char ** /* target */, int  /* per_row */, int /* num_rows */);
7484c8945a0SNathan Whitehorn 
7494c8945a0SNathan Whitehorn /* editbox.c */
7504c8945a0SNathan Whitehorn extern int dlg_editbox(const char * /*title*/, char *** /*list*/, int * /*rows*/, int /*height*/, int /*width*/);
7514c8945a0SNathan Whitehorn 
7524c8945a0SNathan Whitehorn /* formbox.c */
7534c8945a0SNathan Whitehorn extern int dlg_default_formitem(DIALOG_FORMITEM * /*items*/);
7544c8945a0SNathan Whitehorn extern int dlg_ordinate(const char * /*s*/);
7554c8945a0SNathan Whitehorn extern void dlg_free_formitems(DIALOG_FORMITEM * /*items*/);
7564c8945a0SNathan Whitehorn 
757682c9e0fSNathan Whitehorn /* guage.c */
758682c9e0fSNathan Whitehorn extern void * dlg_allocate_gauge(const char * /* title */, const char * /* cprompt */, int /* height */, int /* width */, int /* percent */);
759febdb468SDevin Teske extern void * dlg_reallocate_gauge(void * /* objptr */, const char * /* title */, const char * /* cprompt */, int /* height */, int /* width */, int /* percent */);
760682c9e0fSNathan Whitehorn extern void dlg_free_gauge(void * /* objptr */);
761682c9e0fSNathan Whitehorn extern void dlg_update_gauge(void * /* objptr */, int /* percent */);
762682c9e0fSNathan Whitehorn 
7634c8945a0SNathan Whitehorn /* inputstr.c */
7644c8945a0SNathan Whitehorn extern bool dlg_edit_string(char * /*string*/, int * /*offset*/, int /*key*/, int /*fkey*/, bool /*force*/);
7654c8945a0SNathan Whitehorn extern const int * dlg_index_columns(const char * /*string*/);
7664c8945a0SNathan Whitehorn extern const int * dlg_index_wchars(const char * /*string*/);
7674c8945a0SNathan Whitehorn extern int dlg_count_columns(const char * /*string*/);
7684c8945a0SNathan Whitehorn extern int dlg_count_wchars(const char * /*string*/);
7694c8945a0SNathan Whitehorn extern int dlg_edit_offset(char * /*string*/, int /*offset*/, int /*x_last*/);
7704c8945a0SNathan Whitehorn extern int dlg_find_index(const int * /*list*/, int  /*limit*/, int /*to_find*/);
7714c8945a0SNathan Whitehorn extern int dlg_limit_columns(const char * /*string*/, int /*limit*/, int /*offset*/);
772febdb468SDevin Teske extern void dlg_finish_string(const char * /* string */);
7734c8945a0SNathan Whitehorn 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*/);
7744c8945a0SNathan Whitehorn 
7752a3e3873SBaptiste Daroussin /* menubox.c */
7762a3e3873SBaptiste Daroussin extern int dlg_dummy_menutext(DIALOG_LISTITEM * /*items*/, int /*current*/, char * /*newtext*/);
7772a3e3873SBaptiste Daroussin extern int dlg_renamed_menutext(DIALOG_LISTITEM * /*items*/, int /*current*/, char * /*newtext*/);
7782a3e3873SBaptiste Daroussin 
779f4f33ea0SBaptiste Daroussin /* prgbox.c */
780f4f33ea0SBaptiste Daroussin extern FILE * dlg_popen(const char * /*command */, const char * /*type */);
781f4f33ea0SBaptiste Daroussin 
7824c8945a0SNathan Whitehorn /* rc.c */
7834c8945a0SNathan Whitehorn #ifdef HAVE_RC_FILE
7844c8945a0SNathan Whitehorn extern int dlg_parse_rc(void);
7854c8945a0SNathan Whitehorn extern void dlg_create_rc(const char * /*filename*/);
7864c8945a0SNathan Whitehorn #endif
7874c8945a0SNathan Whitehorn 
7882a3e3873SBaptiste Daroussin /* treeview.c */
7892a3e3873SBaptiste Daroussin 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*/);
7902a3e3873SBaptiste Daroussin 
791f4f33ea0SBaptiste Daroussin /* ttysize.c */
792f4f33ea0SBaptiste Daroussin extern int dlg_ttysize(int /* fd */, int * /* height */, int * /* width */);
793f4f33ea0SBaptiste Daroussin 
7944c8945a0SNathan Whitehorn /* ui_getc.c */
7954c8945a0SNathan Whitehorn extern int dlg_getc(WINDOW * /*win*/, int * /*fkey*/);
7964c8945a0SNathan Whitehorn extern int dlg_getc_callbacks(int /*ch*/, int /*fkey*/, int * /*result*/);
7974c8945a0SNathan Whitehorn extern int dlg_last_getc(void);
7982a3e3873SBaptiste Daroussin extern void dlg_add_last_key(int /*mode*/);
7994c8945a0SNathan Whitehorn extern void dlg_add_callback(DIALOG_CALLBACK * /*p*/);
8004c8945a0SNathan Whitehorn extern void dlg_add_callback_ref(DIALOG_CALLBACK ** /*p*/, DIALOG_FREEBACK /* cleanup */);
8014c8945a0SNathan Whitehorn extern void dlg_flush_getc(void);
8024c8945a0SNathan Whitehorn extern void dlg_remove_callback(DIALOG_CALLBACK * /*p*/);
8034c8945a0SNathan Whitehorn extern void dlg_killall_bg(int *retval);
8044c8945a0SNathan Whitehorn 
8054c8945a0SNathan Whitehorn /* util.c */
806*a96ef450SBaptiste Daroussin extern DIALOG_WINDOWS * _dlg_find_window(WINDOW * /* win */);
807*a96ef450SBaptiste Daroussin extern WINDOW * dlg_der_window(WINDOW * /*win*/, int /*height*/, int /*width*/, int /*y*/, int /*x*/);
8084c8945a0SNathan Whitehorn extern WINDOW * dlg_new_modal_window(WINDOW * /*parent*/, int /*height*/, int /*width*/, int /*y*/, int /*x*/);
8094c8945a0SNathan Whitehorn extern WINDOW * dlg_new_window(int /*height*/, int /*width*/, int /*y*/, int /*x*/);
8104c8945a0SNathan Whitehorn extern WINDOW * dlg_sub_window(WINDOW * /*win*/, int /*height*/, int /*width*/, int /*y*/, int /*x*/);
8114c8945a0SNathan Whitehorn extern bool dlg_need_separator(void);
812*a96ef450SBaptiste Daroussin extern char * dlg_getenv_str(const char * /*name*/);
8134c8945a0SNathan Whitehorn extern char * dlg_set_result(const char * /*string*/);
8144c8945a0SNathan Whitehorn extern char * dlg_strclone(const char * /*cprompt*/);
8154c8945a0SNathan Whitehorn extern char * dlg_strempty(void);
8164c8945a0SNathan Whitehorn extern chtype dlg_asciibox(chtype /*ch*/);
8174c8945a0SNathan Whitehorn extern chtype dlg_boxchar(chtype /*ch*/);
8187a1c0d96SNathan Whitehorn extern chtype dlg_get_attrs(WINDOW * /*win*/);
819*a96ef450SBaptiste Daroussin extern const char * dlg_exitcode2s(int /*code*/);
8204c8945a0SNathan Whitehorn extern const char * dlg_print_line(WINDOW * /*win*/, chtype * /*attr*/, const char * /*prompt*/, int /*lm*/, int /*rm*/, int * /*x*/);
8214c8945a0SNathan Whitehorn extern int dlg_box_x_ordinate(int /*width*/);
8224c8945a0SNathan Whitehorn extern int dlg_box_y_ordinate(int /*height*/);
8234c8945a0SNathan Whitehorn extern int dlg_calc_list_width(int /*item_no*/, DIALOG_LISTITEM * /*items*/);
8244c8945a0SNathan Whitehorn extern int dlg_calc_listw(int /*item_no*/, char ** /*items*/, int /*group*/);
8254c8945a0SNathan Whitehorn extern int dlg_check_scrolled(int /* key */, int /* last */, int /* page */, bool * /* show */, int * /* offset */);
8262a3e3873SBaptiste Daroussin extern int dlg_count_real_columns(const char * /*text*/);
8274c8945a0SNathan Whitehorn extern int dlg_default_item(char ** /*items*/, int /*llen*/);
8284c8945a0SNathan Whitehorn extern int dlg_default_listitem(DIALOG_LISTITEM * /*items*/);
8294c8945a0SNathan Whitehorn extern int dlg_defaultno_button(void);
8302a3e3873SBaptiste Daroussin extern int dlg_default_button(void);
831*a96ef450SBaptiste Daroussin extern int dlg_exitname2n(const char * /*name*/);
832*a96ef450SBaptiste Daroussin extern int dlg_getenv_num(const char * /*name*/, int * /* value */);
8334c8945a0SNathan Whitehorn extern int dlg_max_input(int /*max_len*/);
8344c8945a0SNathan Whitehorn extern int dlg_print_scrolled(WINDOW * /* win */, const char * /* prompt */, int /* offset */, int /* height */, int /* width */, int /* pauseopt */);
835*a96ef450SBaptiste Daroussin extern int dlg_set_timeout(WINDOW * /* win */, bool /* will_getc */);
836febdb468SDevin Teske extern void dlg_add_help_formitem(int * /* result */, char ** /* tag */, DIALOG_FORMITEM * /* item */);
837febdb468SDevin Teske extern void dlg_add_help_listitem(int * /* result */, char ** /* tag */, DIALOG_LISTITEM * /* item */);
8384c8945a0SNathan Whitehorn extern void dlg_add_quoted(char * /*string*/);
8394c8945a0SNathan Whitehorn extern void dlg_add_result(const char * /*string*/);
8404c8945a0SNathan Whitehorn extern void dlg_add_separator(void);
8414c8945a0SNathan Whitehorn extern void dlg_add_string(char * /*string*/);
8424c8945a0SNathan Whitehorn extern void dlg_attr_clear(WINDOW * /*win*/, int /*height*/, int /*width*/, chtype /*attr*/);
8434c8945a0SNathan Whitehorn extern void dlg_auto_size(const char * /*title*/, const char * /*prompt*/, int * /*height*/, int * /*width*/, int /*boxlines*/, int /*mincols*/);
8444c8945a0SNathan Whitehorn extern void dlg_auto_sizefile(const char * /*title*/, const char * /*file*/, int * /*height*/, int * /*width*/, int /*boxlines*/, int /*mincols*/);
8454c8945a0SNathan Whitehorn extern void dlg_beeping(void);
8464c8945a0SNathan Whitehorn extern void dlg_calc_listh(int * /*height*/, int * /*list_height*/, int /*item_no*/);
8474c8945a0SNathan Whitehorn extern void dlg_clear(void);
8484c8945a0SNathan Whitehorn extern void dlg_clr_result(void);
8494c8945a0SNathan Whitehorn extern void dlg_ctl_size(int /*height*/, int /*width*/);
8504c8945a0SNathan Whitehorn extern void dlg_del_window(WINDOW * /*win*/);
8514c8945a0SNathan Whitehorn extern void dlg_does_output(void);
8524c8945a0SNathan Whitehorn extern void dlg_draw_bottom_box(WINDOW * /*win*/);
8532a3e3873SBaptiste Daroussin extern void dlg_draw_bottom_box2(WINDOW * /*win*/, chtype /*on_left*/, chtype /*on_right*/, chtype /*on_inside*/);
8544c8945a0SNathan Whitehorn extern void dlg_draw_box(WINDOW * /*win*/, int /*y*/, int /*x*/, int /*height*/, int /*width*/, chtype /*boxchar*/, chtype /*borderchar*/);
8552a3e3873SBaptiste Daroussin extern void dlg_draw_box2(WINDOW * /*win*/, int /*y*/, int /*x*/, int /*height*/, int /*width*/, chtype /*boxchar*/, chtype /*borderchar*/, chtype /*borderchar2*/);
8564c8945a0SNathan Whitehorn extern void dlg_draw_title(WINDOW *win, const char *title);
8574c8945a0SNathan Whitehorn extern void dlg_exit(int /*code*/) GCC_NORETURN;
8584c8945a0SNathan Whitehorn extern void dlg_item_help(const char * /*txt*/);
859*a96ef450SBaptiste Daroussin extern void dlg_keep_tite(FILE * /*output */);
8604c8945a0SNathan Whitehorn extern void dlg_print_autowrap(WINDOW * /*win*/, const char * /*prompt*/, int /*height*/, int /*width*/);
8612a3e3873SBaptiste Daroussin extern void dlg_print_listitem(WINDOW * /*win*/, const char * /*text*/, int /*climit*/, bool /*first*/, int /*selected*/);
8624c8945a0SNathan Whitehorn extern void dlg_print_size(int /*height*/, int /*width*/);
8634c8945a0SNathan Whitehorn extern void dlg_print_text(WINDOW * /*win*/, const char * /*txt*/, int /*len*/, chtype * /*attr*/);
8644c8945a0SNathan Whitehorn extern void dlg_put_backtitle(void);
865*a96ef450SBaptiste Daroussin extern void dlg_reset_timeout(WINDOW * /* win */);
8664c8945a0SNathan Whitehorn extern void dlg_restore_vars(DIALOG_VARS * /* save */);
8674c8945a0SNathan Whitehorn extern void dlg_save_vars(DIALOG_VARS * /* save */);
8684c8945a0SNathan Whitehorn extern void dlg_set_focus(WINDOW * /*parent*/, WINDOW * /*win*/);
8694c8945a0SNathan Whitehorn extern void dlg_tab_correct_str(char * /*prompt*/);
8704c8945a0SNathan Whitehorn extern void dlg_trim_string(char * /*src*/);
8714c8945a0SNathan Whitehorn extern void end_dialog(void);
8724c8945a0SNathan Whitehorn extern void init_dialog(FILE * /*input*/, FILE * /*output*/);
8734c8945a0SNathan Whitehorn 
8742a3e3873SBaptiste Daroussin extern void dlg_exiterr(const char *, ...) GCC_NORETURN GCC_PRINTFLIKE(1,2);
8754c8945a0SNathan Whitehorn 
8764c8945a0SNathan Whitehorn #ifdef HAVE_COLOR
8774c8945a0SNathan Whitehorn extern chtype dlg_color_pair(int /*foreground*/, int /*background*/);
8784c8945a0SNathan Whitehorn extern int dlg_color_count(void);
8794c8945a0SNathan Whitehorn extern void dlg_color_setup(void);
8804c8945a0SNathan Whitehorn extern void dlg_draw_shadow(WINDOW * /*win*/, int /*height*/, int /*width*/, int /*y*/, int /*x*/);
8814c8945a0SNathan Whitehorn #endif
8824c8945a0SNathan Whitehorn 
8834c8945a0SNathan Whitehorn #ifdef HAVE_STRCASECMP
8844c8945a0SNathan Whitehorn #define dlg_strcmp(a,b) strcasecmp(a,b)
8854c8945a0SNathan Whitehorn #else
8864c8945a0SNathan Whitehorn extern int dlg_strcmp(const char * /*a*/, const char * /*b*/);
8874c8945a0SNathan Whitehorn #endif
8884c8945a0SNathan Whitehorn 
8894c8945a0SNathan Whitehorn #ifdef HAVE_DLG_TRACE
8904c8945a0SNathan Whitehorn #define DLG_TRACE(params) dlg_trace_msg params
8912a3e3873SBaptiste Daroussin extern void dlg_trace_msg(const char *fmt, ...) GCC_PRINTFLIKE(1,2);
892*a96ef450SBaptiste Daroussin extern void dlg_trace_va_msg(const char *fmt, va_list ap);
893f4f33ea0SBaptiste Daroussin #define DLG_TRACE2S(name,value) dlg_trace_2s (name,value)
894f4f33ea0SBaptiste Daroussin #define DLG_TRACE2N(name,value) dlg_trace_2n (name,value)
895f4f33ea0SBaptiste Daroussin extern void dlg_trace_2s(const char * /*name*/, const char * /*value*/);
896f4f33ea0SBaptiste Daroussin extern void dlg_trace_2n(const char * /*name*/, int /*value*/);
8974c8945a0SNathan Whitehorn extern void dlg_trace_win(WINDOW * /*win*/);
8984c8945a0SNathan Whitehorn extern void dlg_trace_chr(int /*ch*/, int /*fkey*/);
8994c8945a0SNathan Whitehorn extern void dlg_trace(const char * /*fname*/);
9004c8945a0SNathan Whitehorn #else
9014c8945a0SNathan Whitehorn #define DLG_TRACE(params) /* nothing */
902f4f33ea0SBaptiste Daroussin #define DLG_TRACE2S(name,value) /* nothing */
903f4f33ea0SBaptiste Daroussin #define DLG_TRACE2N(name,value) /* nothing */
904*a96ef450SBaptiste Daroussin #define dlg_trace_va_msg(fmt, ap) /* nothing */
9054c8945a0SNathan Whitehorn #define dlg_trace_win(win) /* nothing */
9064c8945a0SNathan Whitehorn #define dlg_trace_chr(ch,fkey) /* nothing */
9074c8945a0SNathan Whitehorn #define dlg_trace(fname) /* nothing */
9084c8945a0SNathan Whitehorn #endif
9094c8945a0SNathan Whitehorn 
9104c8945a0SNathan Whitehorn #ifdef KEY_RESIZE
911*a96ef450SBaptiste Daroussin extern void _dlg_resize_cleanup(WINDOW * /*win*/);
9124c8945a0SNathan Whitehorn extern void dlg_move_window(WINDOW * /*win*/, int /*height*/, int /*width*/, int /*y*/, int /*x*/);
913f4f33ea0SBaptiste Daroussin extern void dlg_will_resize(WINDOW * /*win*/);
9144c8945a0SNathan Whitehorn #endif
9154c8945a0SNathan Whitehorn 
9164c8945a0SNathan Whitehorn /*
917682c9e0fSNathan Whitehorn  * Normally "enter" means "ok".  Use this macro to handle the explicit
918682c9e0fSNathan Whitehorn  * check for DLGK_ENTER:
919682c9e0fSNathan Whitehorn  */
920682c9e0fSNathan Whitehorn #define dlg_enter_buttoncode(code) (dialog_vars.nook ? DLG_EXIT_OK : dlg_ok_buttoncode(code))
921682c9e0fSNathan Whitehorn 
922682c9e0fSNathan Whitehorn /*
9234c8945a0SNathan Whitehorn  * The following stuff is needed for mouse support
9244c8945a0SNathan Whitehorn  */
9254c8945a0SNathan Whitehorn typedef struct mseRegion {
9264c8945a0SNathan Whitehorn     int x, y, X, Y, code;
9274c8945a0SNathan Whitehorn     int mode, step_x, step_y;
9284c8945a0SNathan Whitehorn     struct mseRegion *next;
9294c8945a0SNathan Whitehorn } mseRegion;
9304c8945a0SNathan Whitehorn 
9314c8945a0SNathan Whitehorn #if defined(NCURSES_MOUSE_VERSION)
9324c8945a0SNathan Whitehorn 
933f4f33ea0SBaptiste Daroussin #define	mouse_open() mousemask(BUTTON1_PRESSED, (mmask_t *) 0)
9344c8945a0SNathan Whitehorn #define	mouse_close() mousemask(0, (mmask_t *) 0)
9354c8945a0SNathan Whitehorn 
9364c8945a0SNathan Whitehorn extern mseRegion * dlg_mouse_mkregion (int /*y*/, int /*x*/, int /*height*/, int /*width*/, int /*code*/);
9374c8945a0SNathan Whitehorn extern void dlg_mouse_free_regions (void);
9384c8945a0SNathan Whitehorn extern void dlg_mouse_mkbigregion (int /*y*/, int /*x*/, int /*height*/, int /*width*/, int /*code*/, int /*step_x*/, int /*step_y*/, int /*mode*/);
9394c8945a0SNathan Whitehorn extern void dlg_mouse_setbase (int /*x*/, int /*y*/);
9402a3e3873SBaptiste Daroussin extern void dlg_mouse_setcode (int /*code*/);
9414c8945a0SNathan Whitehorn 
9424c8945a0SNathan Whitehorn #define USE_MOUSE 1
9434c8945a0SNathan Whitehorn 
9444c8945a0SNathan Whitehorn #else
9454c8945a0SNathan Whitehorn 
9464c8945a0SNathan Whitehorn #define	mouse_open() /*nothing*/
9474c8945a0SNathan Whitehorn #define	mouse_close() /*nothing*/
9484c8945a0SNathan Whitehorn #define dlg_mouse_free_regions() /* nothing */
9494c8945a0SNathan Whitehorn #define	dlg_mouse_mkregion(y, x, height, width, code) /*nothing*/
9504c8945a0SNathan Whitehorn #define	dlg_mouse_mkbigregion(y, x, height, width, code, step_x, step_y, mode) /*nothing*/
9514c8945a0SNathan Whitehorn #define	dlg_mouse_setbase(x, y) /*nothing*/
9522a3e3873SBaptiste Daroussin #define	dlg_mouse_setcode(c) /*nothing*/
9534c8945a0SNathan Whitehorn 
9544c8945a0SNathan Whitehorn #define USE_MOUSE 0
9554c8945a0SNathan Whitehorn 
9564c8945a0SNathan Whitehorn #endif
9574c8945a0SNathan Whitehorn 
9584c8945a0SNathan Whitehorn extern mseRegion *dlg_mouse_region (int /*y*/, int /*x*/);
9594c8945a0SNathan Whitehorn extern mseRegion *dlg_mouse_bigregion (int /*y*/, int /*x*/);
9604c8945a0SNathan Whitehorn extern int dlg_mouse_wgetch (WINDOW * /*win*/, int * /*fkey*/);
9614c8945a0SNathan Whitehorn extern int dlg_mouse_wgetch_nowait (WINDOW * /*win*/, int * /*fkey*/);
9624c8945a0SNathan Whitehorn 
9634c8945a0SNathan Whitehorn #define mouse_mkbutton(y,x,len,code) dlg_mouse_mkregion(y,x,1,len,code);
9644c8945a0SNathan Whitehorn 
9654c8945a0SNathan Whitehorn /*
9664c8945a0SNathan Whitehorn  * This is the base for fictitious keys, which activate
9674c8945a0SNathan Whitehorn  * the buttons.
9684c8945a0SNathan Whitehorn  *
9694c8945a0SNathan Whitehorn  * Mouse-generated keys are the following:
9704c8945a0SNathan Whitehorn  *   -- the first 32 are used as numbers, in addition to '0'-'9'
9714c8945a0SNathan Whitehorn  *   -- uppercase chars are used to invoke the button (M_EVENT + 'O')
9724c8945a0SNathan Whitehorn  */
9734c8945a0SNathan Whitehorn #define M_EVENT (DLGK_max + 1)
9744c8945a0SNathan Whitehorn 
9754c8945a0SNathan Whitehorn /*
9764c8945a0SNathan Whitehorn  * The `flag' parameter in checklist is used to select between
9774c8945a0SNathan Whitehorn  * radiolist and checklist
9784c8945a0SNathan Whitehorn  */
9794c8945a0SNathan Whitehorn #define FLAG_CHECK 1
9804c8945a0SNathan Whitehorn #define FLAG_RADIO 0
9814c8945a0SNathan Whitehorn 
9824c8945a0SNathan Whitehorn /*
9834c8945a0SNathan Whitehorn  * This is used only for debugging (FIXME: should have a separate header).
9844c8945a0SNathan Whitehorn  */
9854c8945a0SNathan Whitehorn #ifdef NO_LEAKS
9864c8945a0SNathan Whitehorn extern void _dlg_inputstr_leaks(void);
987*a96ef450SBaptiste Daroussin #if defined(NCURSES_VERSION)
988*a96ef450SBaptiste Daroussin #if defined(HAVE_CURSES_EXIT)
989*a96ef450SBaptiste Daroussin /* just use curses_exit() */
990*a96ef450SBaptiste Daroussin #elif defined(HAVE__NC_FREE_AND_EXIT)
9914c8945a0SNathan Whitehorn extern void _nc_free_and_exit(int);	/* nc_alloc.h normally not installed */
992*a96ef450SBaptiste Daroussin #define curses_exit(code) _nc_free_and_exit(code)
9934c8945a0SNathan Whitehorn #endif
994*a96ef450SBaptiste Daroussin #endif /* NCURSES_VERSION */
995*a96ef450SBaptiste Daroussin #endif /* NO_LEAKS */
9964c8945a0SNathan Whitehorn 
9974c8945a0SNathan Whitehorn #ifdef __cplusplus
9984c8945a0SNathan Whitehorn }
9994c8945a0SNathan Whitehorn #endif
10007a1c0d96SNathan Whitehorn /* *INDENT-ON* */
10014c8945a0SNathan Whitehorn 
10024c8945a0SNathan Whitehorn #endif /* DIALOG_H_included */
1003