2 * $Id: dialog.h,v 1.245 2012/07/01 18:44:03 tom Exp $
4 * dialog.h -- common declarations for all dialog modules
6 * Copyright 2000-2011,2012 Thomas E. Dickey
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.
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.
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.
23 * An earlier version of this program lists as authors
24 * Savio Lam (lam836@cs.cuhk.hk)
27 #ifndef DIALOG_H_included
28 #define DIALOG_H_included 1
31 #include <dlg_config.h>
34 #define __HP_CURSES_COMPAT /* workaround for getattrs, etc. */
37 #include <sys/types.h>
44 #include <signal.h> /* fork() etc. */
45 #include <math.h> /* sqrt() */
47 /* header conflict with Solaris xpg4 versus <sys/regset.h> */
48 #if defined(ERR) && (ERR == 13)
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)
62 #if defined(HAVE_UNCTRL_H)
63 #include <unctrl.h> /* most curses.h headers include this, some do not */
67 /* Solaris xpg4 renames these */
70 #define KEY_MAX __KEY_MAX
76 #define KEY_MIN __KEY_MIN
80 /* possible conflicts with <term.h> which may be included in <curses.h> */
92 #define _(s) dgettext(PACKAGE, s)
98 #ifndef GCC_PRINTFLIKE
99 #define GCC_PRINTFLIKE(fmt,var) /*nothing*/
103 #define GCC_NORETURN /*nothing*/
107 #define GCC_UNUSED /*nothing*/
110 #ifndef HAVE_WGET_WCH
111 #undef USE_WIDE_CURSES
115 * FIXME: a configure check would be useful
124 * Change these if you want
126 #define USE_SHADOW TRUE
127 #define USE_COLORS TRUE
130 #define SCOLS (COLS - (dialog_state.use_shadow ? 2 : 0))
131 #define SLINES (LINES - (dialog_state.use_shadow ? 1 : 0))
137 #define DLG_EXIT_ESC 255
138 #define DLG_EXIT_UNKNOWN -2 /* never return this (internal use) */
139 #define DLG_EXIT_ERROR -1 /* the shell sees this as 255 */
140 #define DLG_EXIT_OK 0
141 #define DLG_EXIT_CANCEL 1
142 #define DLG_EXIT_HELP 2
143 #define DLG_EXIT_EXTRA 3
144 #define DLG_EXIT_ITEM_HELP 4 /* actually DLG_EXIT_HELP */
146 #define DLG_CTRL(n) ((n) & 0x1f) /* CTRL is preferred, but conflicts */
148 #define CHR_HELP DLG_CTRL('E')
149 #define CHR_BACKSPACE DLG_CTRL('H')
150 #define CHR_REPAINT DLG_CTRL('L')
151 #define CHR_KILL DLG_CTRL('U')
152 #define CHR_LITERAL DLG_CTRL('V')
153 #define CHR_DELETE 127
154 #define CHR_NEXT DLG_CTRL('N')
155 #define CHR_PREVIOUS DLG_CTRL('P')
156 #define CHR_TRACE DLG_CTRL('T')
159 #define TAB DLG_CTRL('I')
163 #define SHADOW_ROWS 1
164 #define SHADOW_COLS 2
168 #define BUF_SIZE (10L*1024)
171 #define MIN(x,y) ((x) < (y) ? (x) : (y))
174 #define MAX(x,y) ((x) > (y) ? (x) : (y))
176 #define DEFAULT_SEPARATE_STR "\t"
177 #define DEFAULT_ASPECT_RATIO 9
178 /* how many spaces is a tab long (default)? */
180 #define WTIMEOUT_VAL 10 /* minimum amount of time needed for curses */
183 #define A_CHARTEXT 0xff
186 #define CharOf(ch) ((ch) & 0xff)
189 #define ACS_ULCORNER '+'
192 #define ACS_LLCORNER '+'
195 #define ACS_URCORNER '+'
198 #define ACS_LRCORNER '+'
201 #define ACS_HLINE '-'
204 #define ACS_VLINE '|'
213 #define ACS_UARROW '^'
216 #define ACS_DARROW 'v'
219 #define ACS_BLOCK '#'
222 /* these definitions may work for antique versions of curses */
223 #ifndef HAVE_GETBEGYX
225 #define getbegyx(win,y,x) (y = (win)?(win)->_begy:ERR, x = (win)?(win)->_begx:ERR)
228 #ifndef HAVE_GETMAXYX
230 #define getmaxyx(win,y,x) (y = (win)?(win)->_maxy:ERR, x = (win)?(win)->_maxx:ERR)
233 #ifndef HAVE_GETPARYX
235 #define getparyx(win,y,x) (y = (win)?(win)->_pary:ERR, x = (win)?(win)->_parx:ERR)
238 #if !defined(HAVE_WGETPARENT) && defined(HAVE_WINDOW__PARENT)
240 #define wgetparent(win) ((win) ? (win)->_parent : 0)
247 /* these definitions may be needed for bleeding-edge curses implementations */
248 #if !(defined(HAVE_GETBEGX) && defined(HAVE_GETBEGY))
251 #define getbegx(win) dlg_getbegx(win)
252 #define getbegy(win) dlg_getbegy(win)
253 extern int dlg_getbegx(WINDOW * /*win*/);
254 extern int dlg_getbegy(WINDOW * /*win*/);
257 #if !(defined(HAVE_GETCURX) && defined(HAVE_GETCURY))
260 #define getcurx(win) dlg_getcurx(win)
261 #define getcury(win) dlg_getcury(win)
262 extern int dlg_getcurx(WINDOW * /*win*/);
263 extern int dlg_getcury(WINDOW * /*win*/);
266 #if !(defined(HAVE_GETMAXX) && defined(HAVE_GETMAXY))
269 #define getmaxx(win) dlg_getmaxx(win)
270 #define getmaxy(win) dlg_getmaxy(win)
271 extern int dlg_getmaxx(WINDOW * /*win*/);
272 extern int dlg_getmaxy(WINDOW * /*win*/);
275 #if !(defined(HAVE_GETPARX) && defined(HAVE_GETPARY))
278 #define getparx(win) dlg_getparx(win)
279 #define getpary(win) dlg_getpary(win)
280 extern int dlg_getparx(WINDOW * /*win*/);
281 extern int dlg_getpary(WINDOW * /*win*/);
284 #if !(defined(HAVE_WGETPARENT) && defined(HAVE_WINDOW__PARENT))
286 #define wgetparent(win) dlg_wgetparent(win)
287 extern WINDOW * dlg_wgetparent(WINDOW * /*win*/);
291 * This is a list of "old" names, which should be helpful in updating
292 * applications that use libdialog. Starting with 2003/11/26, all exported
293 * symbols from libdialog have "dlg_" prefix, or "dialog_" prefix or "_dialog"
294 * suffix (or suffix "_dialog", e.g., init_dialog).
296 #ifdef __DIALOG_OLD_NAMES__
297 #define color_table dlg_color_table
298 #define attr_clear(win,h,w,a) dlg_attr_clear(win,h,w,a)
299 #define auto_size(t,s,h,w,xl,mc) dlg_auto_size(t,s,h,w,xl,mc)
300 #define auto_sizefile(t,f,h,w,xl,mc) dlg_auto_sizefile(t,f,h,w,xl,mc)
301 #define beeping() dlg_beeping()
302 #define box_x_ordinate(w) dlg_box_x_ordinate(w)
303 #define box_y_ordinate(h) dlg_box_y_ordinate(h)
304 #define calc_listh(h,lh,in) dlg_calc_listh(h,lh,in)
305 #define calc_listw(in,items,group) dlg_calc_listw(in,items,group)
306 #define color_setup() dlg_color_setup()
307 #define create_rc(f) dlg_create_rc(f)
308 #define ctl_size(h,w) dlg_ctl_size(h,w)
309 #define del_window(win) dlg_del_window(win)
310 #define dialog_clear() dlg_clear()
311 #define draw_bottom_box(win) dlg_draw_bottom_box(win)
312 #define draw_box(win,y,x,h,w,xc,bc) dlg_draw_box(win,y,x,h,w,xc,bc)
313 #define draw_shadow(win,h,w,y,x) dlg_draw_shadow(win,h,w,y,x)
314 #define draw_title(win,t) dlg_draw_title(win,t)
315 #define exiterr dlg_exiterr
316 #define killall_bg(n) dlg_killall_bg(n)
317 #define mouse_bigregion(y,x) dlg_mouse_bigregion(y,x)
318 #define mouse_free_regions() dlg_mouse_free_regions()
319 #define mouse_mkbigregion(y,x,h,w,n,ix,iy,m) dlg_mouse_mkbigregion(y,x,h,w,n,ix,iy,m)
320 #define mouse_mkregion(y,x,h,w,n) dlg_mouse_mkregion(y,x,h,w,n)
321 #define mouse_region(y,x) dlg_mouse_region(y,x)
322 #define mouse_setbase(x,y) dlg_mouse_setbase(x,y)
323 #define mouse_wgetch(w,c) dlg_mouse_wgetch(w,c)
324 #define new_window(h,w,y,x) dlg_new_window(h,w,y,x)
325 #define parse_rc() dlg_parse_rc()
326 #define print_autowrap(win,s,h,w) dlg_print_autowrap(win,s,h,w)
327 #define print_size(h,w) dlg_print_size(h,w)
328 #define put_backtitle() dlg_put_backtitle()
329 #define strclone(cprompt) dlg_strclone(cprompt)
330 #define sub_window(win,h,w,y,x) dlg_sub_window(win,h,w,y,x)
331 #define tab_correct_str(s) dlg_tab_correct_str(s)
337 #define DIALOG_ATR(n) dlg_color_table[n].atr
339 #define screen_attr DIALOG_ATR(0)
340 #define shadow_attr DIALOG_ATR(1)
341 #define dialog_attr DIALOG_ATR(2)
342 #define title_attr DIALOG_ATR(3)
343 #define border_attr DIALOG_ATR(4)
344 #define button_active_attr DIALOG_ATR(5)
345 #define button_inactive_attr DIALOG_ATR(6)
346 #define button_key_active_attr DIALOG_ATR(7)
347 #define button_key_inactive_attr DIALOG_ATR(8)
348 #define button_label_active_attr DIALOG_ATR(9)
349 #define button_label_inactive_attr DIALOG_ATR(10)
350 #define inputbox_attr DIALOG_ATR(11)
351 #define inputbox_border_attr DIALOG_ATR(12)
352 #define searchbox_attr DIALOG_ATR(13)
353 #define searchbox_title_attr DIALOG_ATR(14)
354 #define searchbox_border_attr DIALOG_ATR(15)
355 #define position_indicator_attr DIALOG_ATR(16)
356 #define menubox_attr DIALOG_ATR(17)
357 #define menubox_border_attr DIALOG_ATR(18)
358 #define item_attr DIALOG_ATR(19)
359 #define item_selected_attr DIALOG_ATR(20)
360 #define tag_attr DIALOG_ATR(21)
361 #define tag_selected_attr DIALOG_ATR(22)
362 #define tag_key_attr DIALOG_ATR(23)
363 #define tag_key_selected_attr DIALOG_ATR(24)
364 #define check_attr DIALOG_ATR(25)
365 #define check_selected_attr DIALOG_ATR(26)
366 #define uarrow_attr DIALOG_ATR(27)
367 #define darrow_attr DIALOG_ATR(28)
368 #define itemhelp_attr DIALOG_ATR(29)
369 #define form_active_text_attr DIALOG_ATR(30)
370 #define form_text_attr DIALOG_ATR(31)
371 #define form_item_readonly_attr DIALOG_ATR(32)
372 #define gauge_attr DIALOG_ATR(33)
373 #define border2_attr DIALOG_ATR(34)
374 #define inputbox_border2_attr DIALOG_ATR(35)
375 #define searchbox_border2_attr DIALOG_ATR(36)
376 #define menubox_border2_attr DIALOG_ATR(37)
378 #define DLGK_max (KEY_MAX + 256)
381 * Callbacks are used to implement the "background" tailbox.
383 struct _dlg_callback;
385 typedef void (*DIALOG_FREEBACK) (struct _dlg_callback * /* p */);
387 typedef struct _dlg_callback {
388 struct _dlg_callback *next;
391 bool keep_bg; /* keep in background, on exit */
392 bool bg_task; /* true if this is background task */
393 bool (*handle_getc)(struct _dlg_callback *p, int ch, int fkey, int *result);
394 bool keep_win; /* true to not erase window on exit */
395 /* data for dlg_add_callback_ref */
396 struct _dlg_callback **caller;
397 DIALOG_FREEBACK freeback;
399 bool (*handle_input)(struct _dlg_callback *p);
403 typedef struct _dlg_windows {
404 struct _dlg_windows *next;
410 * Global variables, which are initialized as needed
413 DIALOG_CALLBACK *getc_callbacks;
414 DIALOG_CALLBACK *getc_redirect;
415 DIALOG_WINDOWS *all_windows;
416 DIALOG_WINDOWS *all_subwindows;
417 FILE *output; /* option "--output-fd fd" */
418 FILE *pipe_input; /* used for gauge widget */
419 FILE *screen_output; /* newterm(), etc. */
420 bool screen_initialized;
421 bool use_colors; /* use colors by default? */
422 bool use_scrollbar; /* option "--scrollbar" */
423 bool use_shadow; /* shadow dialog boxes by default? */
424 bool visit_items; /* option "--visit-items" */
425 char *separate_str; /* option "--separate-widget string" */
426 int aspect_ratio; /* option "--aspect ratio" */
427 int output_count; /* # of widgets that may have done output */
428 int tab_len; /* option "--tab-len n" */
430 FILE *input; /* option "--input-fd fd" */
431 #ifdef HAVE_DLG_TRACE
432 FILE *trace_output; /* option "--trace file" */
435 bool no_mouse; /* option "--no-mouse" */
438 extern DIALOG_STATE dialog_state;
441 * Global variables, which dialog resets before each widget
444 bool beep_after_signal; /* option "--beep-after" */
445 bool beep_signal; /* option "--beep" */
446 bool begin_set; /* option "--begin y x" was used */
447 bool cant_kill; /* option "--no-kill" */
448 bool colors; /* option "--colors" */
449 bool cr_wrap; /* option "--cr-wrap" */
450 bool defaultno; /* option "--defaultno" */
451 bool dlg_clear_screen; /* option "--clear" */
452 bool extra_button; /* option "--extra-button" */
453 bool help_button; /* option "--help-button" */
454 bool help_status; /* option "--help-status" */
455 bool input_menu; /* menu vs inputmenu widget */
456 bool insecure; /* option "--insecure" */
457 bool item_help; /* option "--item-help" */
458 bool keep_window; /* option "--keep-window" */
459 bool nocancel; /* option "--no-cancel" */
460 bool nocollapse; /* option "--no-collapse" */
461 bool print_siz; /* option "--print-size" */
462 bool separate_output; /* option "--separate-output" */
463 bool single_quoted; /* option "--single-quoted" */
464 bool size_err; /* option "--size-err" */
465 bool tab_correct; /* option "--tab-correct" */
466 bool trim_whitespace; /* option "--trim" */
467 char *backtitle; /* option "--backtitle backtitle" */
468 char *cancel_label; /* option "--cancel-label string" */
469 char *default_item; /* option "--default-item string" */
470 char *exit_label; /* option "--exit-label string" */
471 char *extra_label; /* option "--extra-label string" */
472 char *help_label; /* option "--help-label string" */
474 char *no_label; /* option "--no-label string" */
475 char *ok_label; /* option "--ok-label string" */
476 char *title; /* option "--title title" */
477 char *yes_label; /* option "--yes-label string" */
478 int begin_x; /* option "--begin y x" (second value) */
479 int begin_y; /* option "--begin y x" (first value) */
480 int max_input; /* option "--max-input size" */
481 int scale_factor; /* RESERVED */
482 int sleep_secs; /* option "--sleep secs" */
483 int timeout_secs; /* option "--timeout secs" */
484 unsigned input_length; /* nonzero if input_result is allocated */
486 unsigned formitem_type; /* DIALOG_FORMITEM.type in dialog_form() */
488 bool keep_tite; /* option "--keep-tite" */
489 bool ascii_lines; /* option "--ascii-lines" */
490 bool no_lines; /* option "--no-lines" */
492 bool nook; /* option "--no-ok" */
494 bool quoted; /* option "--quoted" */
495 char *column_header; /* RESERVED "--column-header" */
496 char *column_separator; /* option "--column-separator" */
497 char *output_separator; /* option "--output-separator" */
499 char *date_format; /* option "--date-format" */
500 char *time_format; /* option "--time-format" */
502 char *help_line; /* option "--hline" */
503 char *help_file; /* option "--hfile" */
504 bool in_helpfile; /* flag to prevent recursion in --hfile */
505 bool no_nl_expand; /* option "--no-nl-expand" */
507 int default_button; /* option "--default-button" (exit code) */
510 #define USE_ITEM_HELP(s) (dialog_vars.item_help && (s) != 0)
511 #define CHECKBOX_TAGS (dialog_vars.item_help ? 4 : 3)
512 #define MENUBOX_TAGS (dialog_vars.item_help ? 3 : 2)
513 #define FORMBOX_TAGS (dialog_vars.item_help ? 9 : 8)
514 #define MIXEDFORM_TAGS (FORMBOX_TAGS + 1)
515 #define MIXEDGAUGE_TAGS 2
517 extern DIALOG_VARS dialog_vars;
519 #ifndef HAVE_TYPE_CHTYPE
523 #define UCH(ch) ((unsigned char)(ch))
525 #define assert_ptr(ptr,msg) if ((ptr) == 0) dlg_exiterr("cannot allocate memory in " msg)
527 #define dlg_malloc(t,n) (t *) malloc((size_t)(n) * sizeof(t))
528 #define dlg_calloc(t,n) (t *) calloc((size_t)(n), sizeof(t))
529 #define dlg_realloc(t,n,p) (t *) realloc((p), (n) * sizeof(t))
532 * Table for attribute- and color-values.
547 extern DIALOG_COLORS dlg_color_table[];
550 * Function prototypes
552 extern const char *dialog_version(void);
554 /* widgets, each in separate files */
555 extern int dialog_calendar(const char * /*title*/, const char * /*subtitle*/, int /*height*/, int /*width*/, int /*day*/, int /*month*/, int /*year*/);
556 extern int dialog_checklist(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/, int /*list_height*/, int /*item_no*/, char ** /*items*/, int /*flag*/);
557 extern int dialog_dselect(const char * /*title*/, const char * /*path*/, int /*height*/, int /*width*/);
558 extern int dialog_editbox(const char * /*title*/, const char * /*file*/, int /*height*/, int /*width*/);
559 extern int dialog_form(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/, int /*form_height*/, int /*item_no*/, char ** /*items*/);
560 extern int dialog_fselect(const char * /*title*/, const char * /*path*/, int /*height*/, int /*width*/);
561 extern int dialog_gauge(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/, int /*percent*/);
562 extern int dialog_helpfile(const char * /*title*/, const char * /*file*/, int /*height*/, int /*width*/);
563 extern int dialog_inputbox(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/, const char * /*init*/, const int /*password*/);
564 extern int dialog_menu(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/, int /*menu_height*/, int /*item_no*/, char ** /*items*/);
565 extern int dialog_mixedform(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/, int /*form_height*/, int /*item_no*/, char ** /*items*/);
566 extern int dialog_mixedgauge(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/, int /*percent*/, int /*item_no*/, char ** /*items*/);
567 extern int dialog_msgbox(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/, int /*pauseopt*/);
568 extern int dialog_pause(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/, int /*seconds*/);
569 extern int dialog_prgbox(const char * /*title*/, const char * /*cprompt*/, const char * /*command*/, int /*height*/, int /*width*/, int /*pauseopt*/);
570 extern int dialog_progressbox(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/);
571 extern int dialog_tailbox(const char * /*title*/, const char * /*file*/, int /*height*/, int /*width*/, int /*bg_task*/);
572 extern int dialog_textbox(const char * /*title*/, const char * /*file*/, int /*height*/, int /*width*/);
573 extern int dialog_timebox(const char * /*title*/, const char * /*subtitle*/, int /*height*/, int /*width*/, int /*hour*/, int /*minute*/, int /*second*/);
574 extern int dialog_yesno(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/);
576 /* some widgets have alternate entrypoints, to allow list manipulation */
585 unsigned type; /* the field type (0=input, 1=password) */
586 char *name; /* the field label */
587 int name_len; /* ...its length */
588 int name_y; /* ...its y-ordinate */
589 int name_x; /* ...its x-ordinate */
590 bool name_free; /* ...true if .name can be freed */
591 char *text; /* the field contents */
592 int text_len; /* ...its length on the screen */
593 int text_y; /* ...its y-ordinate */
594 int text_x; /* ...its x-ordinate */
595 int text_flen; /* ...its length on screen, or 0 if no input allowed */
596 int text_ilen; /* ...its limit on amount to be entered */
597 bool text_free; /* ...true if .text can be freed */
598 char *help; /* help-message, if any */
599 bool help_free; /* ...true if .help can be freed */
602 typedef int (DIALOG_INPUTMENU) (DIALOG_LISTITEM * /*items*/, int /*current*/, char * /*newtext*/);
604 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*/);
605 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*/);
606 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*/);
607 extern int dlg_progressbox(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/, int /*pauseopt*/, FILE * /* fp */);
610 extern char ** dlg_string_to_argv(char * /* blob */);
611 extern int dlg_count_argv(char ** /* argv */);
612 extern int dlg_eat_argv(int * /* argcp */, char *** /* argvp */, int /* start */, int /* count */);
615 extern void dlg_draw_arrows(WINDOW * /*dialog*/, int /*top_arrow*/, int /*bottom_arrow*/, int /*x*/, int /*top*/, int /*bottom*/);
616 extern void dlg_draw_arrows2(WINDOW * /*dialog*/, int /*top_arrow*/, int /*bottom_arrow*/, int /*x*/, int /*top*/, int /*bottom*/, chtype /*attr*/, chtype /*borderattr*/);
617 extern void dlg_draw_helpline(WINDOW * /*dialog*/, bool /*decorations*/);
618 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*/);
621 extern const char ** dlg_exit_label(void);
622 extern const char ** dlg_ok_label(void);
623 extern const char ** dlg_ok_labels(void);
624 extern const char ** dlg_yes_labels(void);
625 extern int dlg_button_count(const char ** /*labels*/);
626 extern int dlg_button_to_char(const char * /*label*/);
627 extern int dlg_button_x_step(const char ** /*labels*/, int /*limit*/, int * /*gap*/, int * /*margin*/, int * /*step*/);
628 extern int dlg_char_to_button(int /*ch*/, const char ** /*labels*/);
629 extern int dlg_exit_buttoncode(int /*button*/);
630 extern int dlg_match_char(int /*ch*/, const char * /*string*/);
631 extern int dlg_next_button(const char ** /*labels*/, int /*button*/);
632 extern int dlg_next_ok_buttonindex(int /*current*/, int /*extra*/);
633 extern int dlg_ok_buttoncode(int /*button*/);
634 extern int dlg_prev_button(const char ** /*labels*/, int /*button*/);
635 extern int dlg_prev_ok_buttonindex(int /*current*/, int /*extra*/);
636 extern int dlg_yes_buttoncode(int /*button*/);
637 extern void dlg_button_layout(const char ** /*labels*/, int * /*limit*/);
638 extern void dlg_button_sizes(const char ** /*labels*/, int /*vertical*/, int * /*longest*/, int * /*length*/);
639 extern void dlg_draw_buttons(WINDOW * /*win*/, int /*y*/, int /*x*/, const char ** /*labels*/, int /*selected*/, int /*vertical*/, int /*limit*/);
642 extern void dlg_align_columns(char ** /* target */, int /* per_row */, int /* num_rows */);
643 extern void dlg_free_columns(char ** /* target */, int /* per_row */, int /* num_rows */);
646 extern int dlg_editbox(const char * /*title*/, char *** /*list*/, int * /*rows*/, int /*height*/, int /*width*/);
649 extern int dlg_default_formitem(DIALOG_FORMITEM * /*items*/);
650 extern int dlg_ordinate(const char * /*s*/);
651 extern void dlg_free_formitems(DIALOG_FORMITEM * /*items*/);
654 extern void * dlg_allocate_gauge(const char * /* title */, const char * /* cprompt */, int /* height */, int /* width */, int /* percent */);
655 extern void dlg_free_gauge(void * /* objptr */);
656 extern void dlg_update_gauge(void * /* objptr */, int /* percent */);
659 extern bool dlg_edit_string(char * /*string*/, int * /*offset*/, int /*key*/, int /*fkey*/, bool /*force*/);
660 extern const int * dlg_index_columns(const char * /*string*/);
661 extern const int * dlg_index_wchars(const char * /*string*/);
662 extern int dlg_count_columns(const char * /*string*/);
663 extern int dlg_count_wchars(const char * /*string*/);
664 extern int dlg_edit_offset(char * /*string*/, int /*offset*/, int /*x_last*/);
665 extern int dlg_find_index(const int * /*list*/, int /*limit*/, int /*to_find*/);
666 extern int dlg_limit_columns(const char * /*string*/, int /*limit*/, int /*offset*/);
667 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*/);
670 extern int dlg_dummy_menutext(DIALOG_LISTITEM * /*items*/, int /*current*/, char * /*newtext*/);
671 extern int dlg_renamed_menutext(DIALOG_LISTITEM * /*items*/, int /*current*/, char * /*newtext*/);
675 extern int dlg_parse_rc(void);
676 extern void dlg_create_rc(const char * /*filename*/);
680 extern int dlg_getc(WINDOW * /*win*/, int * /*fkey*/);
681 extern int dlg_getc_callbacks(int /*ch*/, int /*fkey*/, int * /*result*/);
682 extern int dlg_last_getc(void);
683 extern void dlg_add_callback(DIALOG_CALLBACK * /*p*/);
684 extern void dlg_add_callback_ref(DIALOG_CALLBACK ** /*p*/, DIALOG_FREEBACK /* cleanup */);
685 extern void dlg_flush_getc(void);
686 extern void dlg_remove_callback(DIALOG_CALLBACK * /*p*/);
687 extern void dlg_killall_bg(int *retval);
690 extern WINDOW * dlg_new_modal_window(WINDOW * /*parent*/, int /*height*/, int /*width*/, int /*y*/, int /*x*/);
691 extern WINDOW * dlg_new_window(int /*height*/, int /*width*/, int /*y*/, int /*x*/);
692 extern WINDOW * dlg_sub_window(WINDOW * /*win*/, int /*height*/, int /*width*/, int /*y*/, int /*x*/);
693 extern bool dlg_need_separator(void);
694 extern char * dlg_set_result(const char * /*string*/);
695 extern char * dlg_strclone(const char * /*cprompt*/);
696 extern char * dlg_strempty(void);
697 extern chtype dlg_asciibox(chtype /*ch*/);
698 extern chtype dlg_boxchar(chtype /*ch*/);
699 extern chtype dlg_get_attrs(WINDOW * /*win*/);
700 extern const char * dlg_print_line(WINDOW * /*win*/, chtype * /*attr*/, const char * /*prompt*/, int /*lm*/, int /*rm*/, int * /*x*/);
701 extern int dlg_box_x_ordinate(int /*width*/);
702 extern int dlg_box_y_ordinate(int /*height*/);
703 extern int dlg_calc_list_width(int /*item_no*/, DIALOG_LISTITEM * /*items*/);
704 extern int dlg_calc_listw(int /*item_no*/, char ** /*items*/, int /*group*/);
705 extern int dlg_check_scrolled(int /* key */, int /* last */, int /* page */, bool * /* show */, int * /* offset */);
706 extern int dlg_count_real_columns(const char * /*text*/);
707 extern int dlg_default_item(char ** /*items*/, int /*llen*/);
708 extern int dlg_default_listitem(DIALOG_LISTITEM * /*items*/);
709 extern int dlg_defaultno_button(void);
710 extern int dlg_default_button(void);
711 extern int dlg_max_input(int /*max_len*/);
712 extern int dlg_print_scrolled(WINDOW * /* win */, const char * /* prompt */, int /* offset */, int /* height */, int /* width */, int /* pauseopt */);
713 extern void dlg_add_quoted(char * /*string*/);
714 extern void dlg_add_result(const char * /*string*/);
715 extern void dlg_add_separator(void);
716 extern void dlg_add_string(char * /*string*/);
717 extern void dlg_attr_clear(WINDOW * /*win*/, int /*height*/, int /*width*/, chtype /*attr*/);
718 extern void dlg_auto_size(const char * /*title*/, const char * /*prompt*/, int * /*height*/, int * /*width*/, int /*boxlines*/, int /*mincols*/);
719 extern void dlg_auto_sizefile(const char * /*title*/, const char * /*file*/, int * /*height*/, int * /*width*/, int /*boxlines*/, int /*mincols*/);
720 extern void dlg_beeping(void);
721 extern void dlg_calc_listh(int * /*height*/, int * /*list_height*/, int /*item_no*/);
722 extern void dlg_clear(void);
723 extern void dlg_clr_result(void);
724 extern void dlg_ctl_size(int /*height*/, int /*width*/);
725 extern void dlg_del_window(WINDOW * /*win*/);
726 extern void dlg_does_output(void);
727 extern void dlg_draw_bottom_box(WINDOW * /*win*/);
728 extern void dlg_draw_bottom_box2(WINDOW * /*win*/, chtype /*on_left*/, chtype /*on_right*/, chtype /*on_inside*/);
729 extern void dlg_draw_box(WINDOW * /*win*/, int /*y*/, int /*x*/, int /*height*/, int /*width*/, chtype /*boxchar*/, chtype /*borderchar*/);
730 extern void dlg_draw_box2(WINDOW * /*win*/, int /*y*/, int /*x*/, int /*height*/, int /*width*/, chtype /*boxchar*/, chtype /*borderchar*/, chtype /*borderchar2*/);
731 extern void dlg_draw_title(WINDOW *win, const char *title);
732 extern void dlg_exit(int /*code*/) GCC_NORETURN;
733 extern void dlg_item_help(const char * /*txt*/);
734 extern void dlg_print_autowrap(WINDOW * /*win*/, const char * /*prompt*/, int /*height*/, int /*width*/);
735 extern void dlg_print_size(int /*height*/, int /*width*/);
736 extern void dlg_print_text(WINDOW * /*win*/, const char * /*txt*/, int /*len*/, chtype * /*attr*/);
737 extern void dlg_put_backtitle(void);
738 extern void dlg_restore_vars(DIALOG_VARS * /* save */);
739 extern void dlg_save_vars(DIALOG_VARS * /* save */);
740 extern void dlg_set_focus(WINDOW * /*parent*/, WINDOW * /*win*/);
741 extern void dlg_tab_correct_str(char * /*prompt*/);
742 extern void dlg_trim_string(char * /*src*/);
743 extern void end_dialog(void);
744 extern void init_dialog(FILE * /*input*/, FILE * /*output*/);
746 extern void dlg_exiterr(const char *, ...) GCC_NORETURN GCC_PRINTFLIKE(1,2);
749 extern chtype dlg_color_pair(int /*foreground*/, int /*background*/);
750 extern int dlg_color_count(void);
751 extern void dlg_color_setup(void);
752 extern void dlg_draw_shadow(WINDOW * /*win*/, int /*height*/, int /*width*/, int /*y*/, int /*x*/);
755 #ifdef HAVE_STRCASECMP
756 #define dlg_strcmp(a,b) strcasecmp(a,b)
758 extern int dlg_strcmp(const char * /*a*/, const char * /*b*/);
761 #ifdef HAVE_DLG_TRACE
762 #define DLG_TRACE(params) dlg_trace_msg params
763 extern void dlg_trace_msg(const char *fmt, ...) GCC_PRINTFLIKE(1,2);
764 extern void dlg_trace_win(WINDOW * /*win*/);
765 extern void dlg_trace_chr(int /*ch*/, int /*fkey*/);
766 extern void dlg_trace(const char * /*fname*/);
768 #define DLG_TRACE(params) /* nothing */
769 #define dlg_trace_win(win) /* nothing */
770 #define dlg_trace_chr(ch,fkey) /* nothing */
771 #define dlg_trace(fname) /* nothing */
775 extern void dlg_move_window(WINDOW * /*win*/, int /*height*/, int /*width*/, int /*y*/, int /*x*/);
779 * Normally "enter" means "ok". Use this macro to handle the explicit
780 * check for DLGK_ENTER:
782 #define dlg_enter_buttoncode(code) (dialog_vars.nook ? DLG_EXIT_OK : dlg_ok_buttoncode(code))
785 * The following stuff is needed for mouse support
787 typedef struct mseRegion {
788 int x, y, X, Y, code;
789 int mode, step_x, step_y;
790 struct mseRegion *next;
793 #if defined(NCURSES_MOUSE_VERSION)
795 #define mouse_open() mousemask(BUTTON1_CLICKED, (mmask_t *) 0)
796 #define mouse_close() mousemask(0, (mmask_t *) 0)
798 extern mseRegion * dlg_mouse_mkregion (int /*y*/, int /*x*/, int /*height*/, int /*width*/, int /*code*/);
799 extern void dlg_mouse_free_regions (void);
800 extern void dlg_mouse_mkbigregion (int /*y*/, int /*x*/, int /*height*/, int /*width*/, int /*code*/, int /*step_x*/, int /*step_y*/, int /*mode*/);
801 extern void dlg_mouse_setbase (int /*x*/, int /*y*/);
807 #define mouse_open() /*nothing*/
808 #define mouse_close() /*nothing*/
809 #define dlg_mouse_free_regions() /* nothing */
810 #define dlg_mouse_mkregion(y, x, height, width, code) /*nothing*/
811 #define dlg_mouse_mkbigregion(y, x, height, width, code, step_x, step_y, mode) /*nothing*/
812 #define dlg_mouse_setbase(x, y) /*nothing*/
818 extern mseRegion *dlg_mouse_region (int /*y*/, int /*x*/);
819 extern mseRegion *dlg_mouse_bigregion (int /*y*/, int /*x*/);
820 extern int dlg_mouse_wgetch (WINDOW * /*win*/, int * /*fkey*/);
821 extern int dlg_mouse_wgetch_nowait (WINDOW * /*win*/, int * /*fkey*/);
823 #define mouse_mkbutton(y,x,len,code) dlg_mouse_mkregion(y,x,1,len,code);
826 * This is the base for fictitious keys, which activate
829 * Mouse-generated keys are the following:
830 * -- the first 32 are used as numbers, in addition to '0'-'9'
831 * -- uppercase chars are used to invoke the button (M_EVENT + 'O')
833 #define M_EVENT (DLGK_max + 1)
836 * The `flag' parameter in checklist is used to select between
837 * radiolist and checklist
843 * This is used only for debugging (FIXME: should have a separate header).
846 extern void _dlg_inputstr_leaks(void);
847 #if defined(NCURSES_VERSION) && defined(HAVE__NC_FREE_AND_EXIT)
848 extern void _nc_free_and_exit(int); /* nc_alloc.h normally not installed */
857 #endif /* DIALOG_H_included */