2 * $Id: dialog.h,v 1.231 2011/06/29 09:51:00 tom Exp $
4 * dialog.h -- common declarations for all dialog modules
6 * Copyright 2000-2010,2011 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)
64 /* most curses.h headers include this, some do not */
65 #if defined(HAVE_UNCTRL_H)
69 /* Solaris xpg4 renames these */
72 #define KEY_MAX __KEY_MAX
78 #define KEY_MIN __KEY_MIN
82 /* possible conflicts with <term.h> which may be included in <curses.h> */
94 #define _(s) dgettext(PACKAGE, s)
101 #define GCC_NORETURN /*nothing*/
105 #define GCC_UNUSED /*nothing*/
108 #ifndef HAVE_WGET_WCH
109 #undef USE_WIDE_CURSES
113 * FIXME: a configure check would be useful
122 * Change these if you want
124 #define USE_SHADOW TRUE
125 #define USE_COLORS TRUE
128 #define SCOLS (COLS - (dialog_state.use_shadow ? 2 : 0))
129 #define SLINES (LINES - (dialog_state.use_shadow ? 1 : 0))
135 #define DLG_EXIT_ESC 255
136 #define DLG_EXIT_UNKNOWN -2 /* never return this (internal use) */
137 #define DLG_EXIT_ERROR -1 /* the shell sees this as 255 */
138 #define DLG_EXIT_OK 0
139 #define DLG_EXIT_CANCEL 1
140 #define DLG_EXIT_HELP 2
141 #define DLG_EXIT_EXTRA 3
142 #define DLG_EXIT_ITEM_HELP 4 /* actually DLG_EXIT_HELP */
144 #define DLG_CTRL(n) ((n) & 0x1f) /* CTRL is preferred, but conflicts */
146 #define CHR_HELP DLG_CTRL('E')
147 #define CHR_BACKSPACE DLG_CTRL('H')
148 #define CHR_REPAINT DLG_CTRL('L')
149 #define CHR_KILL DLG_CTRL('U')
150 #define CHR_LITERAL DLG_CTRL('V')
151 #define CHR_DELETE 127
152 #define CHR_NEXT DLG_CTRL('N')
153 #define CHR_PREVIOUS DLG_CTRL('P')
154 #define CHR_TRACE DLG_CTRL('T')
157 #define TAB DLG_CTRL('I')
161 #define SHADOW_ROWS 1
162 #define SHADOW_COLS 2
166 #define BUF_SIZE (10L*1024)
169 #define MIN(x,y) ((x) < (y) ? (x) : (y))
172 #define MAX(x,y) ((x) > (y) ? (x) : (y))
174 #define DEFAULT_SEPARATE_STR "\t"
175 #define DEFAULT_ASPECT_RATIO 9
176 /* how many spaces is a tab long (default)? */
178 #define WTIMEOUT_VAL 10 /* minimum amount of time needed for curses */
181 #define A_CHARTEXT 0xff
184 #define CharOf(ch) ((ch) & 0xff)
187 #define ACS_ULCORNER '+'
190 #define ACS_LLCORNER '+'
193 #define ACS_URCORNER '+'
196 #define ACS_LRCORNER '+'
199 #define ACS_HLINE '-'
202 #define ACS_VLINE '|'
211 #define ACS_UARROW '^'
214 #define ACS_DARROW 'v'
217 #define ACS_BLOCK '#'
220 /* these definitions may work for antique versions of curses */
221 #ifndef HAVE_GETBEGYX
223 #define getbegyx(win,y,x) (y = (win)?(win)->_begy:ERR, x = (win)?(win)->_begx:ERR)
226 #ifndef HAVE_GETMAXYX
228 #define getmaxyx(win,y,x) (y = (win)?(win)->_maxy:ERR, x = (win)?(win)->_maxx:ERR)
231 #ifndef HAVE_GETPARYX
233 #define getparyx(win,y,x) (y = (win)?(win)->_pary:ERR, x = (win)?(win)->_parx:ERR)
240 /* these definitions may be needed for bleeding-edge curses implementations */
241 #if !(defined(HAVE_GETBEGX) && defined(HAVE_GETBEGY))
244 #define getbegx(win) dlg_getbegx(win)
245 #define getbegy(win) dlg_getbegy(win)
246 extern int dlg_getbegx(WINDOW * /*win*/);
247 extern int dlg_getbegy(WINDOW * /*win*/);
250 #if !(defined(HAVE_GETCURX) && defined(HAVE_GETCURY))
253 #define getcurx(win) dlg_getcurx(win)
254 #define getcury(win) dlg_getcury(win)
255 extern int dlg_getcurx(WINDOW * /*win*/);
256 extern int dlg_getcury(WINDOW * /*win*/);
259 #if !(defined(HAVE_GETMAXX) && defined(HAVE_GETMAXY))
262 #define getmaxx(win) dlg_getmaxx(win)
263 #define getmaxy(win) dlg_getmaxy(win)
264 extern int dlg_getmaxx(WINDOW * /*win*/);
265 extern int dlg_getmaxy(WINDOW * /*win*/);
268 #if !(defined(HAVE_GETPARX) && defined(HAVE_GETPARY))
271 #define getparx(win) dlg_getparx(win)
272 #define getpary(win) dlg_getpary(win)
273 extern int dlg_getparx(WINDOW * /*win*/);
274 extern int dlg_getpary(WINDOW * /*win*/);
278 * This is a list of "old" names, which should be helpful in updating
279 * applications that use libdialog. Starting with 2003/11/26, all exported
280 * symbols from libdialog have "dlg_" prefix, or "dialog_" prefix or "_dialog"
281 * suffix (or suffix "_dialog", e.g., init_dialog).
283 #ifdef __DIALOG_OLD_NAMES__
284 #define color_table dlg_color_table
285 #define attr_clear(win,h,w,a) dlg_attr_clear(win,h,w,a)
286 #define auto_size(t,s,h,w,xl,mc) dlg_auto_size(t,s,h,w,xl,mc)
287 #define auto_sizefile(t,f,h,w,xl,mc) dlg_auto_sizefile(t,f,h,w,xl,mc)
288 #define beeping() dlg_beeping()
289 #define box_x_ordinate(w) dlg_box_x_ordinate(w)
290 #define box_y_ordinate(h) dlg_box_y_ordinate(h)
291 #define calc_listh(h,lh,in) dlg_calc_listh(h,lh,in)
292 #define calc_listw(in,items,group) dlg_calc_listw(in,items,group)
293 #define color_setup() dlg_color_setup()
294 #define create_rc(f) dlg_create_rc(f)
295 #define ctl_size(h,w) dlg_ctl_size(h,w)
296 #define del_window(win) dlg_del_window(win)
297 #define dialog_clear() dlg_clear()
298 #define draw_bottom_box(win) dlg_draw_bottom_box(win)
299 #define draw_box(win,y,x,h,w,xc,bc) dlg_draw_box(win,y,x,h,w,xc,bc)
300 #define draw_shadow(win,h,w,y,x) dlg_draw_shadow(win,h,w,y,x)
301 #define draw_title(win,t) dlg_draw_title(win,t)
302 #define exiterr dlg_exiterr
303 #define killall_bg(n) dlg_killall_bg(n)
304 #define mouse_bigregion(y,x) dlg_mouse_bigregion(y,x)
305 #define mouse_free_regions() dlg_mouse_free_regions()
306 #define mouse_mkbigregion(y,x,h,w,n,ix,iy,m) dlg_mouse_mkbigregion(y,x,h,w,n,ix,iy,m)
307 #define mouse_mkregion(y,x,h,w,n) dlg_mouse_mkregion(y,x,h,w,n)
308 #define mouse_region(y,x) dlg_mouse_region(y,x)
309 #define mouse_setbase(x,y) dlg_mouse_setbase(x,y)
310 #define mouse_wgetch(w,c) dlg_mouse_wgetch(w,c)
311 #define new_window(h,w,y,x) dlg_new_window(h,w,y,x)
312 #define parse_rc() dlg_parse_rc()
313 #define print_autowrap(win,s,h,w) dlg_print_autowrap(win,s,h,w)
314 #define print_size(h,w) dlg_print_size(h,w)
315 #define put_backtitle() dlg_put_backtitle()
316 #define strclone(cprompt) dlg_strclone(cprompt)
317 #define sub_window(win,h,w,y,x) dlg_sub_window(win,h,w,y,x)
318 #define tab_correct_str(s) dlg_tab_correct_str(s)
324 #define DIALOG_ATR(n) dlg_color_table[n].atr
326 #define screen_attr DIALOG_ATR(0)
327 #define shadow_attr DIALOG_ATR(1)
328 #define dialog_attr DIALOG_ATR(2)
329 #define title_attr DIALOG_ATR(3)
330 #define border_attr DIALOG_ATR(4)
331 #define button_active_attr DIALOG_ATR(5)
332 #define button_inactive_attr DIALOG_ATR(6)
333 #define button_key_active_attr DIALOG_ATR(7)
334 #define button_key_inactive_attr DIALOG_ATR(8)
335 #define button_label_active_attr DIALOG_ATR(9)
336 #define button_label_inactive_attr DIALOG_ATR(10)
337 #define inputbox_attr DIALOG_ATR(11)
338 #define inputbox_border_attr DIALOG_ATR(12)
339 #define searchbox_attr DIALOG_ATR(13)
340 #define searchbox_title_attr DIALOG_ATR(14)
341 #define searchbox_border_attr DIALOG_ATR(15)
342 #define position_indicator_attr DIALOG_ATR(16)
343 #define menubox_attr DIALOG_ATR(17)
344 #define menubox_border_attr DIALOG_ATR(18)
345 #define item_attr DIALOG_ATR(19)
346 #define item_selected_attr DIALOG_ATR(20)
347 #define tag_attr DIALOG_ATR(21)
348 #define tag_selected_attr DIALOG_ATR(22)
349 #define tag_key_attr DIALOG_ATR(23)
350 #define tag_key_selected_attr DIALOG_ATR(24)
351 #define check_attr DIALOG_ATR(25)
352 #define check_selected_attr DIALOG_ATR(26)
353 #define uarrow_attr DIALOG_ATR(27)
354 #define darrow_attr DIALOG_ATR(28)
355 #define itemhelp_attr DIALOG_ATR(29)
356 #define form_active_text_attr DIALOG_ATR(30)
357 #define form_text_attr DIALOG_ATR(31)
358 #define form_item_readonly_attr DIALOG_ATR(32)
359 #define gauge_attr DIALOG_ATR(33)
361 #define DLGK_max (KEY_MAX + 256)
364 * Callbacks are used to implement the "background" tailbox.
366 struct _dlg_callback;
368 typedef void (*DIALOG_FREEBACK) (struct _dlg_callback * /* p */);
370 typedef struct _dlg_callback {
371 struct _dlg_callback *next;
374 bool keep_bg; /* keep in background, on exit */
375 bool bg_task; /* true if this is background task */
376 bool (*handle_getc)(struct _dlg_callback *p, int ch, int fkey, int *result);
377 bool keep_win; /* true to not erase window on exit */
378 /* data for dlg_add_callback_ref */
379 struct _dlg_callback **caller;
380 DIALOG_FREEBACK freeback;
382 bool (*handle_input)(struct _dlg_callback *p);
386 typedef struct _dlg_windows {
387 struct _dlg_windows *next;
393 * Global variables, which are initialized as needed
396 DIALOG_CALLBACK *getc_callbacks;
397 DIALOG_CALLBACK *getc_redirect;
398 DIALOG_WINDOWS *all_windows;
399 FILE *output; /* option "--output-fd fd" */
400 FILE *pipe_input; /* used for gauge widget */
401 FILE *screen_output; /* newterm(), etc. */
402 bool screen_initialized;
403 bool use_colors; /* use colors by default? */
404 bool use_scrollbar; /* option "--scrollbar" */
405 bool use_shadow; /* shadow dialog boxes by default? */
406 bool visit_items; /* option "--visit-items" */
407 char *separate_str; /* option "--separate-widget string" */
408 int aspect_ratio; /* option "--aspect ratio" */
409 int output_count; /* # of widgets that may have done output */
410 int tab_len; /* option "--tab-len n" */
412 FILE *input; /* option "--input-fd fd" */
413 #ifdef HAVE_DLG_TRACE
414 FILE *trace_output; /* option "--trace file" */
417 bool no_mouse; /* option "--no-mouse" */
420 extern DIALOG_STATE dialog_state;
423 * Global variables, which dialog resets before each widget
426 bool beep_after_signal; /* option "--beep-after" */
427 bool beep_signal; /* option "--beep" */
428 bool begin_set; /* option "--begin y x" was used */
429 bool cant_kill; /* option "--no-kill" */
430 bool colors; /* option "--colors" */
431 bool cr_wrap; /* option "--cr-wrap" */
432 bool defaultno; /* option "--defaultno" */
433 bool dlg_clear_screen; /* option "--clear" */
434 bool extra_button; /* option "--extra-button" */
435 bool help_button; /* option "--help-button" */
436 bool help_status; /* option "--help-status" */
437 bool input_menu; /* menu vs inputmenu widget */
438 bool insecure; /* option "--insecure" */
439 bool item_help; /* option "--item-help" */
440 bool keep_window; /* option "--keep-window" */
441 bool nocancel; /* option "--no-cancel" */
442 bool nocollapse; /* option "--no-collapse" */
443 bool print_siz; /* option "--print-size" */
444 bool separate_output; /* option "--separate-output" */
445 bool single_quoted; /* option "--single-quoted" */
446 bool size_err; /* option "--size-err" */
447 bool tab_correct; /* option "--tab-correct" */
448 bool trim_whitespace; /* option "--trim" */
449 char *backtitle; /* option "--backtitle backtitle" */
450 char *cancel_label; /* option "--cancel-label string" */
451 char *default_item; /* option "--default-item string" */
452 char *exit_label; /* option "--exit-label string" */
453 char *extra_label; /* option "--extra-label string" */
454 char *help_label; /* option "--help-label string" */
456 char *no_label; /* option "--no-label string" */
457 char *ok_label; /* option "--ok-label string" */
458 char *title; /* option "--title title" */
459 char *yes_label; /* option "--yes-label string" */
460 int begin_x; /* option "--begin y x" (second value) */
461 int begin_y; /* option "--begin y x" (first value) */
462 int max_input; /* option "--max-input size" */
463 int scale_factor; /* RESERVED */
464 int sleep_secs; /* option "--sleep secs" */
465 int timeout_secs; /* option "--timeout secs" */
466 unsigned input_length; /* nonzero if input_result is allocated */
468 unsigned formitem_type; /* DIALOG_FORMITEM.type in dialog_form() */
470 bool keep_tite; /* option "--keep-tite" */
471 bool ascii_lines; /* option "--ascii-lines" */
472 bool no_lines; /* option "--no-lines" */
474 bool nook; /* option "--no-ok" */
476 bool quoted; /* option "--quoted" */
477 char *column_header; /* RESERVED "--column-header" */
478 char *column_separator; /* option "--column-separator" */
479 char *output_separator; /* option "--output-separator" */
481 char *date_format; /* option "--date-format" */
482 char *time_format; /* option "--time-format" */
484 char *help_line; /* option "--hline" */
485 char *help_file; /* option "--hfile" */
486 bool in_helpfile; /* flag to prevent recursion in --hfile */
487 bool no_nl_expand; /* option "--no-nl-expand" */
490 #define USE_ITEM_HELP(s) (dialog_vars.item_help && (s) != 0)
491 #define CHECKBOX_TAGS (dialog_vars.item_help ? 4 : 3)
492 #define MENUBOX_TAGS (dialog_vars.item_help ? 3 : 2)
493 #define FORMBOX_TAGS (dialog_vars.item_help ? 9 : 8)
494 #define MIXEDFORM_TAGS (FORMBOX_TAGS + 1)
495 #define MIXEDGAUGE_TAGS 2
497 extern DIALOG_VARS dialog_vars;
499 #ifndef HAVE_TYPE_CHTYPE
503 #define UCH(ch) ((unsigned char)(ch))
505 #define assert_ptr(ptr,msg) if ((ptr) == 0) dlg_exiterr("cannot allocate memory in " msg)
507 #define dlg_malloc(t,n) (t *) malloc((size_t)(n) * sizeof(t))
508 #define dlg_calloc(t,n) (t *) calloc((size_t)(n), sizeof(t))
509 #define dlg_realloc(t,n,p) (t *) realloc((p), (n) * sizeof(t))
512 * Table for attribute- and color-values.
527 extern DIALOG_COLORS dlg_color_table[];
530 * Function prototypes
532 extern const char *dialog_version(void);
534 /* widgets, each in separate files */
535 extern int dialog_calendar(const char * /*title*/, const char * /*subtitle*/, int /*height*/, int /*width*/, int /*day*/, int /*month*/, int /*year*/);
536 extern int dialog_checklist(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/, int /*list_height*/, int /*item_no*/, char ** /*items*/, int /*flag*/);
537 extern int dialog_dselect(const char * /*title*/, const char * /*path*/, int /*height*/, int /*width*/);
538 extern int dialog_editbox(const char * /*title*/, const char * /*file*/, int /*height*/, int /*width*/);
539 extern int dialog_form(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/, int /*form_height*/, int /*item_no*/, char ** /*items*/);
540 extern int dialog_fselect(const char * /*title*/, const char * /*path*/, int /*height*/, int /*width*/);
541 extern int dialog_gauge(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/, int /*percent*/);
542 extern int dialog_helpfile(const char * /*title*/, const char * /*file*/, int /*height*/, int /*width*/);
543 extern int dialog_inputbox(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/, const char * /*init*/, const int /*password*/);
544 extern int dialog_menu(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/, int /*menu_height*/, int /*item_no*/, char ** /*items*/);
545 extern int dialog_mixedform(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/, int /*form_height*/, int /*item_no*/, char ** /*items*/);
546 extern int dialog_mixedgauge(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/, int /*percent*/, int /*item_no*/, char ** /*items*/);
547 extern int dialog_msgbox(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/, int /*pauseopt*/);
548 extern int dialog_pause(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/, int /*seconds*/);
549 extern int dialog_prgbox(const char * /*title*/, const char * /*cprompt*/, const char * /*command*/, int /*height*/, int /*width*/, int /*pauseopt*/);
550 extern int dialog_progressbox(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/);
551 extern int dialog_tailbox(const char * /*title*/, const char * /*file*/, int /*height*/, int /*width*/, int /*bg_task*/);
552 extern int dialog_textbox(const char * /*title*/, const char * /*file*/, int /*height*/, int /*width*/);
553 extern int dialog_timebox(const char * /*title*/, const char * /*subtitle*/, int /*height*/, int /*width*/, int /*hour*/, int /*minute*/, int /*second*/);
554 extern int dialog_yesno(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/);
556 /* some widgets have alternate entrypoints, to allow list manipulation */
565 unsigned type; /* the field type (0=input, 1=password) */
566 char *name; /* the field label */
567 int name_len; /* ...its length */
568 int name_y; /* ...its y-ordinate */
569 int name_x; /* ...its x-ordinate */
570 bool name_free; /* ...true if .name can be freed */
571 char *text; /* the field contents */
572 int text_len; /* ...its length on the screen */
573 int text_y; /* ...its y-ordinate */
574 int text_x; /* ...its x-ordinate */
575 int text_flen; /* ...its length on screen, or 0 if no input allowed */
576 int text_ilen; /* ...its limit on amount to be entered */
577 bool text_free; /* ...true if .text can be freed */
578 char *help; /* help-message, if any */
579 bool help_free; /* ...true if .help can be freed */
582 typedef int (DIALOG_INPUTMENU) (DIALOG_LISTITEM * /*items*/, int /*current*/, char * /*newtext*/);
584 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*/);
585 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*/);
586 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*/);
587 extern int dlg_progressbox(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/, int /*pauseopt*/, FILE * /* fp */);
590 extern char ** dlg_string_to_argv(char * /* blob */);
591 extern int dlg_count_argv(char ** /* argv */);
592 extern int dlg_eat_argv(int * /* argcp */, char *** /* argvp */, int /* start */, int /* count */);
595 extern void dlg_draw_arrows(WINDOW * /*dialog*/, int /*top_arrow*/, int /*bottom_arrow*/, int /*x*/, int /*top*/, int /*bottom*/);
596 extern void dlg_draw_arrows2(WINDOW * /*dialog*/, int /*top_arrow*/, int /*bottom_arrow*/, int /*x*/, int /*top*/, int /*bottom*/, chtype /*attr*/, chtype /*borderattr*/);
597 extern void dlg_draw_helpline(WINDOW * /*dialog*/, bool /*decorations*/);
598 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*/);
601 extern const char ** dlg_exit_label(void);
602 extern const char ** dlg_ok_label(void);
603 extern const char ** dlg_ok_labels(void);
604 extern const char ** dlg_yes_labels(void);
605 extern int dlg_button_count(const char ** /*labels*/);
606 extern int dlg_button_to_char(const char * /*label*/);
607 extern int dlg_button_x_step(const char ** /*labels*/, int /*limit*/, int * /*gap*/, int * /*margin*/, int * /*step*/);
608 extern int dlg_char_to_button(int /*ch*/, const char ** /*labels*/);
609 extern int dlg_exit_buttoncode(int /*button*/);
610 extern int dlg_match_char(int /*ch*/, const char * /*string*/);
611 extern int dlg_next_button(const char ** /*labels*/, int /*button*/);
612 extern int dlg_next_ok_buttonindex(int /*current*/, int /*extra*/);
613 extern int dlg_ok_buttoncode(int /*button*/);
614 extern int dlg_prev_button(const char ** /*labels*/, int /*button*/);
615 extern int dlg_prev_ok_buttonindex(int /*current*/, int /*extra*/);
616 extern int dlg_yes_buttoncode(int /*button*/);
617 extern void dlg_button_layout(const char ** /*labels*/, int * /*limit*/);
618 extern void dlg_button_sizes(const char ** /*labels*/, int /*vertical*/, int * /*longest*/, int * /*length*/);
619 extern void dlg_draw_buttons(WINDOW * /*win*/, int /*y*/, int /*x*/, const char ** /*labels*/, int /*selected*/, int /*vertical*/, int /*limit*/);
622 extern void dlg_align_columns(char ** /* target */, int /* per_row */, int /* num_rows */);
623 extern void dlg_free_columns(char ** /* target */, int /* per_row */, int /* num_rows */);
626 extern int dlg_editbox(const char */*title*/, char ***/*list*/, int */*rows*/, int /*height*/, int /*width*/);
629 extern int dlg_default_formitem(DIALOG_FORMITEM * /*items*/);
630 extern int dlg_ordinate(const char * /*s*/);
631 extern void dlg_free_formitems(DIALOG_FORMITEM * /*items*/);
634 extern void * dlg_allocate_gauge(const char * /* title */, const char * /* cprompt */, int /* height */, int /* width */, int /* percent */);
635 extern void dlg_free_gauge(void * /* objptr */);
636 extern void dlg_update_gauge(void * /* objptr */, int /* percent */);
639 extern bool dlg_edit_string(char * /*string*/, int * /*offset*/, int /*key*/, int /*fkey*/, bool /*force*/);
640 extern const int * dlg_index_columns(const char * /*string*/);
641 extern const int * dlg_index_wchars(const char * /*string*/);
642 extern int dlg_count_columns(const char * /*string*/);
643 extern int dlg_count_wchars(const char * /*string*/);
644 extern int dlg_edit_offset(char * /*string*/, int /*offset*/, int /*x_last*/);
645 extern int dlg_find_index(const int * /*list*/, int /*limit*/, int /*to_find*/);
646 extern int dlg_limit_columns(const char * /*string*/, int /*limit*/, int /*offset*/);
647 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*/);
651 extern int dlg_parse_rc(void);
652 extern void dlg_create_rc(const char * /*filename*/);
656 extern int dlg_getc(WINDOW * /*win*/, int * /*fkey*/);
657 extern int dlg_getc_callbacks(int /*ch*/, int /*fkey*/, int * /*result*/);
658 extern int dlg_last_getc(void);
659 extern void dlg_add_callback(DIALOG_CALLBACK * /*p*/);
660 extern void dlg_add_callback_ref(DIALOG_CALLBACK ** /*p*/, DIALOG_FREEBACK /* cleanup */);
661 extern void dlg_flush_getc(void);
662 extern void dlg_remove_callback(DIALOG_CALLBACK * /*p*/);
663 extern void dlg_killall_bg(int *retval);
666 extern WINDOW * dlg_new_modal_window(WINDOW * /*parent*/, int /*height*/, int /*width*/, int /*y*/, int /*x*/);
667 extern WINDOW * dlg_new_window(int /*height*/, int /*width*/, int /*y*/, int /*x*/);
668 extern WINDOW * dlg_sub_window(WINDOW * /*win*/, int /*height*/, int /*width*/, int /*y*/, int /*x*/);
669 extern bool dlg_need_separator(void);
670 extern char * dlg_set_result(const char * /*string*/);
671 extern char * dlg_strclone(const char * /*cprompt*/);
672 extern char * dlg_strempty(void);
673 extern chtype dlg_asciibox(chtype /*ch*/);
674 extern chtype dlg_boxchar(chtype /*ch*/);
675 extern chtype dlg_get_attrs(WINDOW * /*win*/);
676 extern const char * dlg_print_line(WINDOW */*win*/, chtype */*attr*/, const char */*prompt*/, int /*lm*/, int /*rm*/, int */*x*/);
677 extern int dlg_box_x_ordinate(int /*width*/);
678 extern int dlg_box_y_ordinate(int /*height*/);
679 extern int dlg_calc_list_width(int /*item_no*/, DIALOG_LISTITEM * /*items*/);
680 extern int dlg_calc_listw(int /*item_no*/, char ** /*items*/, int /*group*/);
681 extern int dlg_check_scrolled(int /* key */, int /* last */, int /* page */, bool */* show */, int */* offset */);
682 extern int dlg_default_item(char ** /*items*/, int /*llen*/);
683 extern int dlg_default_listitem(DIALOG_LISTITEM * /*items*/);
684 extern int dlg_defaultno_button(void);
685 extern int dlg_max_input(int /*max_len*/);
686 extern int dlg_print_scrolled(WINDOW * /* win */, const char * /* prompt */, int /* offset */, int /* height */, int /* width */, int /* pauseopt */);
687 extern void dlg_add_quoted(char * /*string*/);
688 extern void dlg_add_result(const char * /*string*/);
689 extern void dlg_add_separator(void);
690 extern void dlg_add_string(char * /*string*/);
691 extern void dlg_attr_clear(WINDOW * /*win*/, int /*height*/, int /*width*/, chtype /*attr*/);
692 extern void dlg_auto_size(const char * /*title*/, const char * /*prompt*/, int * /*height*/, int * /*width*/, int /*boxlines*/, int /*mincols*/);
693 extern void dlg_auto_sizefile(const char * /*title*/, const char * /*file*/, int * /*height*/, int * /*width*/, int /*boxlines*/, int /*mincols*/);
694 extern void dlg_beeping(void);
695 extern void dlg_calc_listh(int * /*height*/, int * /*list_height*/, int /*item_no*/);
696 extern void dlg_clear(void);
697 extern void dlg_clr_result(void);
698 extern void dlg_ctl_size(int /*height*/, int /*width*/);
699 extern void dlg_del_window(WINDOW * /*win*/);
700 extern void dlg_does_output(void);
701 extern void dlg_draw_bottom_box(WINDOW * /*win*/);
702 extern void dlg_draw_box(WINDOW * /*win*/, int /*y*/, int /*x*/, int /*height*/, int /*width*/, chtype /*boxchar*/, chtype /*borderchar*/);
703 extern void dlg_draw_title(WINDOW *win, const char *title);
704 extern void dlg_exit(int /*code*/) GCC_NORETURN;
705 extern void dlg_item_help(const char * /*txt*/);
706 extern void dlg_print_autowrap(WINDOW * /*win*/, const char * /*prompt*/, int /*height*/, int /*width*/);
707 extern void dlg_print_size(int /*height*/, int /*width*/);
708 extern void dlg_print_text(WINDOW * /*win*/, const char * /*txt*/, int /*len*/, chtype * /*attr*/);
709 extern void dlg_put_backtitle(void);
710 extern void dlg_restore_vars(DIALOG_VARS * /* save */);
711 extern void dlg_save_vars(DIALOG_VARS * /* save */);
712 extern void dlg_set_focus(WINDOW * /*parent*/, WINDOW * /*win*/);
713 extern void dlg_tab_correct_str(char * /*prompt*/);
714 extern void dlg_trim_string(char * /*src*/);
715 extern void end_dialog(void);
716 extern void init_dialog(FILE * /*input*/, FILE * /*output*/);
718 extern void dlg_exiterr(const char *, ...) GCC_NORETURN
719 #if defined(__GNUC__) && !defined(printf)
720 __attribute__((format(printf,1,2)))
725 extern chtype dlg_color_pair(int /*foreground*/, int /*background*/);
726 extern int dlg_color_count(void);
727 extern void dlg_color_setup(void);
728 extern void dlg_draw_shadow(WINDOW * /*win*/, int /*height*/, int /*width*/, int /*y*/, int /*x*/);
731 #ifdef HAVE_STRCASECMP
732 #define dlg_strcmp(a,b) strcasecmp(a,b)
734 extern int dlg_strcmp(const char * /*a*/, const char * /*b*/);
737 #ifdef HAVE_DLG_TRACE
738 #define DLG_TRACE(params) dlg_trace_msg params
739 extern void dlg_trace_msg(const char *fmt, ...)
741 __attribute__((format(printf,1,2)))
744 extern void dlg_trace_win(WINDOW * /*win*/);
745 extern void dlg_trace_chr(int /*ch*/, int /*fkey*/);
746 extern void dlg_trace(const char * /*fname*/);
748 #define DLG_TRACE(params) /* nothing */
749 #define dlg_trace_win(win) /* nothing */
750 #define dlg_trace_chr(ch,fkey) /* nothing */
751 #define dlg_trace(fname) /* nothing */
755 extern void dlg_move_window(WINDOW * /*win*/, int /*height*/, int /*width*/, int /*y*/, int /*x*/);
759 * Normally "enter" means "ok". Use this macro to handle the explicit
760 * check for DLGK_ENTER:
762 #define dlg_enter_buttoncode(code) (dialog_vars.nook ? DLG_EXIT_OK : dlg_ok_buttoncode(code))
765 * The following stuff is needed for mouse support
767 typedef struct mseRegion {
768 int x, y, X, Y, code;
769 int mode, step_x, step_y;
770 struct mseRegion *next;
773 #if defined(NCURSES_MOUSE_VERSION)
775 #define mouse_open() mousemask(BUTTON1_CLICKED, (mmask_t *) 0)
776 #define mouse_close() mousemask(0, (mmask_t *) 0)
778 extern mseRegion * dlg_mouse_mkregion (int /*y*/, int /*x*/, int /*height*/, int /*width*/, int /*code*/);
779 extern void dlg_mouse_free_regions (void);
780 extern void dlg_mouse_mkbigregion (int /*y*/, int /*x*/, int /*height*/, int /*width*/, int /*code*/, int /*step_x*/, int /*step_y*/, int /*mode*/);
781 extern void dlg_mouse_setbase (int /*x*/, int /*y*/);
787 #define mouse_open() /*nothing*/
788 #define mouse_close() /*nothing*/
789 #define dlg_mouse_free_regions() /* nothing */
790 #define dlg_mouse_mkregion(y, x, height, width, code) /*nothing*/
791 #define dlg_mouse_mkbigregion(y, x, height, width, code, step_x, step_y, mode) /*nothing*/
792 #define dlg_mouse_setbase(x, y) /*nothing*/
798 extern mseRegion *dlg_mouse_region (int /*y*/, int /*x*/);
799 extern mseRegion *dlg_mouse_bigregion (int /*y*/, int /*x*/);
800 extern int dlg_mouse_wgetch (WINDOW * /*win*/, int * /*fkey*/);
801 extern int dlg_mouse_wgetch_nowait (WINDOW * /*win*/, int * /*fkey*/);
803 #define mouse_mkbutton(y,x,len,code) dlg_mouse_mkregion(y,x,1,len,code);
806 * This is the base for fictitious keys, which activate
809 * Mouse-generated keys are the following:
810 * -- the first 32 are used as numbers, in addition to '0'-'9'
811 * -- uppercase chars are used to invoke the button (M_EVENT + 'O')
813 #define M_EVENT (DLGK_max + 1)
816 * The `flag' parameter in checklist is used to select between
817 * radiolist and checklist
823 * This is used only for debugging (FIXME: should have a separate header).
826 extern void _dlg_inputstr_leaks(void);
827 #if defined(NCURSES_VERSION) && defined(HAVE__NC_FREE_AND_EXIT)
828 extern void _nc_free_and_exit(int); /* nc_alloc.h normally not installed */
837 #endif /* DIALOG_H_included */