15382d832SPeter Avalos /* 2*a8e38dc0SAntonio Huete Jimenez * $Id: dialog.h,v 1.308 2022/04/03 22:38:16 tom Exp $ 35382d832SPeter Avalos * 45382d832SPeter Avalos * dialog.h -- common declarations for all dialog modules 55382d832SPeter Avalos * 6*a8e38dc0SAntonio Huete Jimenez * Copyright 2000-2021,2022 Thomas E. Dickey 75382d832SPeter Avalos * 85382d832SPeter Avalos * This program is free software; you can redistribute it and/or modify 95382d832SPeter Avalos * it under the terms of the GNU Lesser General Public License, version 2.1 105382d832SPeter Avalos * as published by the Free Software Foundation. 115382d832SPeter Avalos * 125382d832SPeter Avalos * This program is distributed in the hope that it will be useful, but 135382d832SPeter Avalos * WITHOUT ANY WARRANTY; without even the implied warranty of 145382d832SPeter Avalos * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 155382d832SPeter Avalos * Lesser General Public License for more details. 165382d832SPeter Avalos * 175382d832SPeter Avalos * You should have received a copy of the GNU Lesser General Public 185382d832SPeter Avalos * License along with this program; if not, write to 195382d832SPeter Avalos * Free Software Foundation, Inc. 205382d832SPeter Avalos * 51 Franklin St., Fifth Floor 215382d832SPeter Avalos * Boston, MA 02110, USA. 225382d832SPeter Avalos * 235382d832SPeter Avalos * An earlier version of this program lists as authors 245382d832SPeter Avalos * Savio Lam (lam836@cs.cuhk.hk) 255382d832SPeter Avalos */ 265382d832SPeter Avalos 275382d832SPeter Avalos #ifndef DIALOG_H_included 285382d832SPeter Avalos #define DIALOG_H_included 1 295382d832SPeter Avalos /* *INDENT-OFF* */ 305382d832SPeter Avalos 315382d832SPeter Avalos #include <dlg_config.h> 325382d832SPeter Avalos 335382d832SPeter Avalos #ifdef __hpux 345382d832SPeter Avalos #define __HP_CURSES_COMPAT /* workaround for getattrs, etc. */ 355382d832SPeter Avalos #endif 365382d832SPeter Avalos 375382d832SPeter Avalos #include <sys/types.h> 385382d832SPeter Avalos #include <fcntl.h> 395382d832SPeter Avalos #include <unistd.h> 405382d832SPeter Avalos #include <ctype.h> 415382d832SPeter Avalos #include <stdlib.h> 425382d832SPeter Avalos #include <stdarg.h> 435382d832SPeter Avalos #include <string.h> 445382d832SPeter Avalos #include <signal.h> /* fork() etc. */ 455382d832SPeter Avalos #include <math.h> /* sqrt() */ 465382d832SPeter Avalos 475382d832SPeter Avalos /* header conflict with Solaris xpg4 versus <sys/regset.h> */ 485382d832SPeter Avalos #if defined(ERR) && (ERR == 13) 495382d832SPeter Avalos #undef ERR 505382d832SPeter Avalos #endif 515382d832SPeter Avalos 525382d832SPeter Avalos #if defined(HAVE_NCURSESW_NCURSES_H) 535382d832SPeter Avalos #include <ncursesw/ncurses.h> 545382d832SPeter Avalos #elif defined(HAVE_NCURSES_NCURSES_H) 555382d832SPeter Avalos #include <ncurses/ncurses.h> 565382d832SPeter Avalos #elif defined(HAVE_NCURSES_CURSES_H) 575382d832SPeter Avalos #include <ncurses/curses.h> 585382d832SPeter Avalos #elif defined(HAVE_NCURSES_H) 595382d832SPeter Avalos #include <ncurses.h> 605382d832SPeter Avalos #else 615382d832SPeter Avalos #include <curses.h> 625382d832SPeter Avalos #if defined(HAVE_UNCTRL_H) 635382d832SPeter Avalos #include <unctrl.h> /* most curses.h headers include this, some do not */ 645382d832SPeter Avalos #endif 655382d832SPeter Avalos #endif 665382d832SPeter Avalos 675382d832SPeter Avalos /* Solaris xpg4 renames these */ 685382d832SPeter Avalos #ifndef KEY_MAX 695382d832SPeter Avalos #ifdef __KEY_MAX 705382d832SPeter Avalos #define KEY_MAX __KEY_MAX 715382d832SPeter Avalos #endif 725382d832SPeter Avalos #endif 735382d832SPeter Avalos 745382d832SPeter Avalos #ifndef KEY_MIN 755382d832SPeter Avalos #ifdef __KEY_MIN 765382d832SPeter Avalos #define KEY_MIN __KEY_MIN 775382d832SPeter Avalos #endif 785382d832SPeter Avalos #endif 795382d832SPeter Avalos 805382d832SPeter Avalos #ifndef GCC_PRINTFLIKE 815382d832SPeter Avalos #define GCC_PRINTFLIKE(fmt,var) /*nothing*/ 825382d832SPeter Avalos #endif 835382d832SPeter Avalos 845382d832SPeter Avalos #ifndef GCC_NORETURN 855382d832SPeter Avalos #define GCC_NORETURN /*nothing*/ 865382d832SPeter Avalos #endif 875382d832SPeter Avalos 885382d832SPeter Avalos #ifndef GCC_UNUSED 895382d832SPeter Avalos #define GCC_UNUSED /*nothing*/ 905382d832SPeter Avalos #endif 915382d832SPeter Avalos 925382d832SPeter Avalos /* 935382d832SPeter Avalos * FIXME: a configure check would be useful 945382d832SPeter Avalos */ 955382d832SPeter Avalos #ifdef __hpux 965382d832SPeter Avalos #undef ACS_UARROW 975382d832SPeter Avalos #undef ACS_DARROW 985382d832SPeter Avalos #undef ACS_BLOCK 995382d832SPeter Avalos #endif 1005382d832SPeter Avalos 1015382d832SPeter Avalos /* 1025382d832SPeter Avalos * Change these if you want 1035382d832SPeter Avalos */ 1045382d832SPeter Avalos #define USE_SHADOW TRUE 1055382d832SPeter Avalos #define USE_COLORS TRUE 1065382d832SPeter Avalos 1075940c9abSDaniel Fojt /* 1085940c9abSDaniel Fojt * These allow using the print-formatting code before curses is initialized. 1095940c9abSDaniel Fojt */ 1105940c9abSDaniel Fojt #define DLG_COLS (COLS ? COLS : dialog_state.screen_width) 1115940c9abSDaniel Fojt #define DLG_LINES (LINES ? LINES : dialog_state.screen_height) 1125940c9abSDaniel Fojt 1135940c9abSDaniel Fojt /* 1145940c9abSDaniel Fojt * Define the usable size of a window, discounting the area needed for shadow. 1155940c9abSDaniel Fojt */ 1165382d832SPeter Avalos #ifdef HAVE_COLOR 1175940c9abSDaniel Fojt #define SCOLS (DLG_COLS - (dialog_state.use_shadow ? SHADOW_COLS : 0)) 1185940c9abSDaniel Fojt #define SLINES (DLG_LINES - (dialog_state.use_shadow ? SHADOW_ROWS : 0)) 1195382d832SPeter Avalos #else 1205382d832SPeter Avalos #define SCOLS COLS 1215382d832SPeter Avalos #define SLINES LINES 1225382d832SPeter Avalos #endif 1235382d832SPeter Avalos 1245940c9abSDaniel Fojt /* 1255940c9abSDaniel Fojt * These are the default values for exit-codes, which can be overridden by 1265940c9abSDaniel Fojt * environment variables, e.g., $DIALOG_CANCEL for DLG_EXIT_CANCEL. 1275940c9abSDaniel Fojt */ 1285382d832SPeter Avalos #define DLG_EXIT_ESC 255 1295382d832SPeter Avalos #define DLG_EXIT_UNKNOWN -2 /* never return this (internal use) */ 1305382d832SPeter Avalos #define DLG_EXIT_ERROR -1 /* the shell sees this as 255 */ 1315382d832SPeter Avalos #define DLG_EXIT_OK 0 1325382d832SPeter Avalos #define DLG_EXIT_CANCEL 1 1335382d832SPeter Avalos #define DLG_EXIT_HELP 2 1345382d832SPeter Avalos #define DLG_EXIT_EXTRA 3 1355382d832SPeter Avalos #define DLG_EXIT_ITEM_HELP 4 /* actually DLG_EXIT_HELP */ 136*a8e38dc0SAntonio Huete Jimenez #define DLG_EXIT_TIMEOUT 5 1375382d832SPeter Avalos 1385940c9abSDaniel Fojt #define MARGIN 1 /* width of the line drawn around each box */ 1395940c9abSDaniel Fojt #define GUTTER 2 /* minimum columns between name/description in menu */ 1405940c9abSDaniel Fojt #define SHADOW_ROWS 1 /* rows to reserve for window's shadow */ 1415940c9abSDaniel Fojt #define SHADOW_COLS 2 /* columns to reserve for window's shadow */ 1425940c9abSDaniel Fojt #define ARROWS_COL 5 /* distance from left margin to up/down arrows */ 1435382d832SPeter Avalos 1445382d832SPeter Avalos #define DEFAULT_SEPARATE_STR "\t" 1455382d832SPeter Avalos #define DEFAULT_ASPECT_RATIO 9 1465382d832SPeter Avalos /* how many spaces is a tab long (default)? */ 1475382d832SPeter Avalos #define TAB_LEN 8 1485382d832SPeter Avalos #define WTIMEOUT_VAL 10 /* minimum amount of time needed for curses */ 1495940c9abSDaniel Fojt #define WTIMEOUT_OFF -1 /* value to disable timeout */ 1505382d832SPeter Avalos 1515382d832SPeter Avalos #ifndef A_CHARTEXT 1525382d832SPeter Avalos #define A_CHARTEXT 0xff 1535382d832SPeter Avalos #endif 1545382d832SPeter Avalos 1555382d832SPeter Avalos #ifndef ACS_ULCORNER 1565382d832SPeter Avalos #define ACS_ULCORNER '+' 1575382d832SPeter Avalos #endif 1585382d832SPeter Avalos #ifndef ACS_LLCORNER 1595382d832SPeter Avalos #define ACS_LLCORNER '+' 1605382d832SPeter Avalos #endif 1615382d832SPeter Avalos #ifndef ACS_URCORNER 1625382d832SPeter Avalos #define ACS_URCORNER '+' 1635382d832SPeter Avalos #endif 1645382d832SPeter Avalos #ifndef ACS_LRCORNER 1655382d832SPeter Avalos #define ACS_LRCORNER '+' 1665382d832SPeter Avalos #endif 1675382d832SPeter Avalos #ifndef ACS_HLINE 1685382d832SPeter Avalos #define ACS_HLINE '-' 1695382d832SPeter Avalos #endif 1705382d832SPeter Avalos #ifndef ACS_VLINE 1715382d832SPeter Avalos #define ACS_VLINE '|' 1725382d832SPeter Avalos #endif 1735382d832SPeter Avalos #ifndef ACS_LTEE 1745382d832SPeter Avalos #define ACS_LTEE '+' 1755382d832SPeter Avalos #endif 1765382d832SPeter Avalos #ifndef ACS_RTEE 1775382d832SPeter Avalos #define ACS_RTEE '+' 1785382d832SPeter Avalos #endif 1795382d832SPeter Avalos #ifndef ACS_UARROW 1805382d832SPeter Avalos #define ACS_UARROW '^' 1815382d832SPeter Avalos #endif 1825382d832SPeter Avalos #ifndef ACS_DARROW 1835382d832SPeter Avalos #define ACS_DARROW 'v' 1845382d832SPeter Avalos #endif 1855382d832SPeter Avalos #ifndef ACS_BLOCK 1865382d832SPeter Avalos #define ACS_BLOCK '#' 1875382d832SPeter Avalos #endif 1885382d832SPeter Avalos 1895382d832SPeter Avalos #ifdef __cplusplus 1905382d832SPeter Avalos extern "C" { 1915382d832SPeter Avalos #endif 1925382d832SPeter Avalos 1935382d832SPeter Avalos /* 1945382d832SPeter Avalos * This is a list of "old" names, which should be helpful in updating 1955382d832SPeter Avalos * applications that use libdialog. Starting with 2003/11/26, all exported 1965382d832SPeter Avalos * symbols from libdialog have "dlg_" prefix, or "dialog_" prefix or "_dialog" 1975382d832SPeter Avalos * suffix (or suffix "_dialog", e.g., init_dialog). 1985382d832SPeter Avalos */ 1995382d832SPeter Avalos #ifdef __DIALOG_OLD_NAMES__ 2005382d832SPeter Avalos #define color_table dlg_color_table 2015382d832SPeter Avalos #define attr_clear(win,h,w,a) dlg_attr_clear(win,h,w,a) 2025382d832SPeter Avalos #define auto_size(t,s,h,w,xl,mc) dlg_auto_size(t,s,h,w,xl,mc) 2035382d832SPeter Avalos #define auto_sizefile(t,f,h,w,xl,mc) dlg_auto_sizefile(t,f,h,w,xl,mc) 2045382d832SPeter Avalos #define beeping() dlg_beeping() 2055382d832SPeter Avalos #define box_x_ordinate(w) dlg_box_x_ordinate(w) 2065382d832SPeter Avalos #define box_y_ordinate(h) dlg_box_y_ordinate(h) 2075382d832SPeter Avalos #define calc_listh(h,lh,in) dlg_calc_listh(h,lh,in) 2085382d832SPeter Avalos #define calc_listw(in,items,group) dlg_calc_listw(in,items,group) 2095382d832SPeter Avalos #define color_setup() dlg_color_setup() 2105382d832SPeter Avalos #define create_rc(f) dlg_create_rc(f) 2115382d832SPeter Avalos #define ctl_size(h,w) dlg_ctl_size(h,w) 2125382d832SPeter Avalos #define del_window(win) dlg_del_window(win) 2135382d832SPeter Avalos #define dialog_clear() dlg_clear() 2145382d832SPeter Avalos #define draw_bottom_box(win) dlg_draw_bottom_box(win) 2155382d832SPeter Avalos #define draw_box(win,y,x,h,w,xc,bc) dlg_draw_box(win,y,x,h,w,xc,bc) 2165382d832SPeter Avalos #define draw_shadow(win,h,w,y,x) dlg_draw_shadow(win,h,w,y,x) 2175382d832SPeter Avalos #define draw_title(win,t) dlg_draw_title(win,t) 2185382d832SPeter Avalos #define exiterr dlg_exiterr 2195382d832SPeter Avalos #define killall_bg(n) dlg_killall_bg(n) 2205382d832SPeter Avalos #define mouse_bigregion(y,x) dlg_mouse_bigregion(y,x) 2215382d832SPeter Avalos #define mouse_free_regions() dlg_mouse_free_regions() 2225382d832SPeter Avalos #define mouse_mkbigregion(y,x,h,w,n,ix,iy,m) dlg_mouse_mkbigregion(y,x,h,w,n,ix,iy,m) 2235382d832SPeter Avalos #define mouse_mkregion(y,x,h,w,n) dlg_mouse_mkregion(y,x,h,w,n) 2245382d832SPeter Avalos #define mouse_region(y,x) dlg_mouse_region(y,x) 2255382d832SPeter Avalos #define mouse_setbase(x,y) dlg_mouse_setbase(x,y) 2265382d832SPeter Avalos #define mouse_setcode(c) dlg_mouse_setcode(c) 2275382d832SPeter Avalos #define mouse_wgetch(w,c) dlg_mouse_wgetch(w,c) 2285382d832SPeter Avalos #define new_window(h,w,y,x) dlg_new_window(h,w,y,x) 2295382d832SPeter Avalos #define parse_rc() dlg_parse_rc() 2305382d832SPeter Avalos #define print_autowrap(win,s,h,w) dlg_print_autowrap(win,s,h,w) 2315382d832SPeter Avalos #define print_size(h,w) dlg_print_size(h,w) 2325382d832SPeter Avalos #define put_backtitle() dlg_put_backtitle() 2335382d832SPeter Avalos #define strclone(cprompt) dlg_strclone(cprompt) 2345382d832SPeter Avalos #define sub_window(win,h,w,y,x) dlg_sub_window(win,h,w,y,x) 2355382d832SPeter Avalos #define tab_correct_str(s) dlg_tab_correct_str(s) 2365382d832SPeter Avalos #endif 2375382d832SPeter Avalos 2385382d832SPeter Avalos /* 2395382d832SPeter Avalos * Attribute names 2405382d832SPeter Avalos */ 2415382d832SPeter Avalos #define DIALOG_ATR(n) dlg_color_table[n].atr 2425382d832SPeter Avalos 2435382d832SPeter Avalos #define screen_attr DIALOG_ATR(0) 2445382d832SPeter Avalos #define shadow_attr DIALOG_ATR(1) 2455382d832SPeter Avalos #define dialog_attr DIALOG_ATR(2) 2465382d832SPeter Avalos #define title_attr DIALOG_ATR(3) 2475382d832SPeter Avalos #define border_attr DIALOG_ATR(4) 2485382d832SPeter Avalos #define button_active_attr DIALOG_ATR(5) 2495382d832SPeter Avalos #define button_inactive_attr DIALOG_ATR(6) 2505382d832SPeter Avalos #define button_key_active_attr DIALOG_ATR(7) 2515382d832SPeter Avalos #define button_key_inactive_attr DIALOG_ATR(8) 2525382d832SPeter Avalos #define button_label_active_attr DIALOG_ATR(9) 2535382d832SPeter Avalos #define button_label_inactive_attr DIALOG_ATR(10) 2545382d832SPeter Avalos #define inputbox_attr DIALOG_ATR(11) 2555382d832SPeter Avalos #define inputbox_border_attr DIALOG_ATR(12) 2565382d832SPeter Avalos #define searchbox_attr DIALOG_ATR(13) 2575382d832SPeter Avalos #define searchbox_title_attr DIALOG_ATR(14) 2585382d832SPeter Avalos #define searchbox_border_attr DIALOG_ATR(15) 2595382d832SPeter Avalos #define position_indicator_attr DIALOG_ATR(16) 2605382d832SPeter Avalos #define menubox_attr DIALOG_ATR(17) 2615382d832SPeter Avalos #define menubox_border_attr DIALOG_ATR(18) 2625382d832SPeter Avalos #define item_attr DIALOG_ATR(19) 2635382d832SPeter Avalos #define item_selected_attr DIALOG_ATR(20) 2645382d832SPeter Avalos #define tag_attr DIALOG_ATR(21) 2655382d832SPeter Avalos #define tag_selected_attr DIALOG_ATR(22) 2665382d832SPeter Avalos #define tag_key_attr DIALOG_ATR(23) 2675382d832SPeter Avalos #define tag_key_selected_attr DIALOG_ATR(24) 2685382d832SPeter Avalos #define check_attr DIALOG_ATR(25) 2695382d832SPeter Avalos #define check_selected_attr DIALOG_ATR(26) 2705382d832SPeter Avalos #define uarrow_attr DIALOG_ATR(27) 2715382d832SPeter Avalos #define darrow_attr DIALOG_ATR(28) 2725382d832SPeter Avalos #define itemhelp_attr DIALOG_ATR(29) 2735382d832SPeter Avalos #define form_active_text_attr DIALOG_ATR(30) 2745382d832SPeter Avalos #define form_text_attr DIALOG_ATR(31) 2755382d832SPeter Avalos #define form_item_readonly_attr DIALOG_ATR(32) 2765382d832SPeter Avalos #define gauge_attr DIALOG_ATR(33) 2775382d832SPeter Avalos #define border2_attr DIALOG_ATR(34) 2785382d832SPeter Avalos #define inputbox_border2_attr DIALOG_ATR(35) 2795382d832SPeter Avalos #define searchbox_border2_attr DIALOG_ATR(36) 2805382d832SPeter Avalos #define menubox_border2_attr DIALOG_ATR(37) 2815382d832SPeter Avalos 2825382d832SPeter Avalos #define DLGK_max (KEY_MAX + 256) 2835382d832SPeter Avalos 2845382d832SPeter Avalos /* 2855382d832SPeter Avalos * Callbacks are used to implement the "background" tailbox. 2865382d832SPeter Avalos */ 2875382d832SPeter Avalos struct _dlg_callback; 2885382d832SPeter Avalos 2895382d832SPeter Avalos typedef void (*DIALOG_FREEBACK) (struct _dlg_callback * /* p */); 2905382d832SPeter Avalos 2915382d832SPeter Avalos typedef struct _dlg_callback { 2925382d832SPeter Avalos struct _dlg_callback *next; 2935382d832SPeter Avalos FILE *input; 2945382d832SPeter Avalos WINDOW *win; 2955382d832SPeter Avalos bool keep_bg; /* keep in background, on exit */ 2965382d832SPeter Avalos bool bg_task; /* true if this is background task */ 2975382d832SPeter Avalos bool (*handle_getc)(struct _dlg_callback *p, int ch, int fkey, int *result); 2985382d832SPeter Avalos bool keep_win; /* true to not erase window on exit */ 2995382d832SPeter Avalos /* data for dlg_add_callback_ref */ 3005382d832SPeter Avalos struct _dlg_callback **caller; 3015382d832SPeter Avalos DIALOG_FREEBACK freeback; 3025382d832SPeter Avalos /* 1.1-20110107 */ 3035382d832SPeter Avalos bool (*handle_input)(struct _dlg_callback *p); 3045382d832SPeter Avalos bool input_ready; 3055382d832SPeter Avalos } DIALOG_CALLBACK; 3065382d832SPeter Avalos 3075382d832SPeter Avalos typedef struct _dlg_windows { 3085382d832SPeter Avalos struct _dlg_windows *next; 3095382d832SPeter Avalos WINDOW *normal; 3105382d832SPeter Avalos WINDOW *shadow; 3115940c9abSDaniel Fojt int getc_timeout; 3125382d832SPeter Avalos } DIALOG_WINDOWS; 3135382d832SPeter Avalos 3145382d832SPeter Avalos /* 3155382d832SPeter Avalos * Global variables, which are initialized as needed 3165382d832SPeter Avalos */ 3175382d832SPeter Avalos typedef struct { 3185382d832SPeter Avalos DIALOG_CALLBACK *getc_callbacks; 3195382d832SPeter Avalos DIALOG_CALLBACK *getc_redirect; 3205382d832SPeter Avalos DIALOG_WINDOWS *all_windows; 3215382d832SPeter Avalos DIALOG_WINDOWS *all_subwindows; 3225382d832SPeter Avalos FILE *output; /* option "--output-fd fd" */ 3235382d832SPeter Avalos FILE *pipe_input; /* used for gauge widget */ 3245382d832SPeter Avalos FILE *screen_output; /* newterm(), etc. */ 3255382d832SPeter Avalos bool screen_initialized; 3265382d832SPeter Avalos bool use_colors; /* use colors by default? */ 3275382d832SPeter Avalos bool use_scrollbar; /* option "--scrollbar" */ 3285382d832SPeter Avalos bool use_shadow; /* shadow dialog boxes by default? */ 3295382d832SPeter Avalos bool visit_items; /* option "--visit-items" */ 3305382d832SPeter Avalos char *separate_str; /* option "--separate-widget string" */ 3315382d832SPeter Avalos int aspect_ratio; /* option "--aspect ratio" */ 3325382d832SPeter Avalos int output_count; /* # of widgets that may have done output */ 3335382d832SPeter Avalos int tab_len; /* option "--tab-len n" */ 3345382d832SPeter Avalos /* 1.0-20070227 */ 3355382d832SPeter Avalos FILE *input; /* option "--input-fd fd" */ 3365382d832SPeter Avalos #ifdef HAVE_DLG_TRACE 3375382d832SPeter Avalos FILE *trace_output; /* option "--trace file" */ 3385382d832SPeter Avalos #endif 3395382d832SPeter Avalos /* 1.1-20110106 */ 3405382d832SPeter Avalos bool no_mouse; /* option "--no-mouse" */ 3415382d832SPeter Avalos int visit_cols; /* option "--visit-items" */ 3421ef6786aSJohn Marino /* 1.2-20130922 */ 3431ef6786aSJohn Marino bool finish_string; /* caching optimization for gauge */ 3441ef6786aSJohn Marino /* 1.2-20150125 */ 3451ef6786aSJohn Marino bool plain_buttons; /* true to suppress button-label highlight */ 3465940c9abSDaniel Fojt /* 1.3-20180610 */ 3475940c9abSDaniel Fojt bool text_only; /* option "--print-text-only", etc. */ 3485940c9abSDaniel Fojt int text_height; 3495940c9abSDaniel Fojt int text_width; 3505940c9abSDaniel Fojt /* 1.3-20190211 */ 3515940c9abSDaniel Fojt int screen_height; 3525940c9abSDaniel Fojt int screen_width; 3535940c9abSDaniel Fojt #ifdef KEY_RESIZE 3545940c9abSDaniel Fojt /* 1.3-20190724 */ 3555940c9abSDaniel Fojt bool had_resize; /* ERR may follow KEY_RESIZE when polling */ 3565940c9abSDaniel Fojt #endif 3575382d832SPeter Avalos } DIALOG_STATE; 3585382d832SPeter Avalos 3595382d832SPeter Avalos extern DIALOG_STATE dialog_state; 3605382d832SPeter Avalos 3615382d832SPeter Avalos /* 3625382d832SPeter Avalos * Global variables, which dialog resets before each widget 3635382d832SPeter Avalos */ 3645382d832SPeter Avalos typedef struct { 3655382d832SPeter Avalos bool beep_after_signal; /* option "--beep-after" */ 3665382d832SPeter Avalos bool beep_signal; /* option "--beep" */ 3675382d832SPeter Avalos bool begin_set; /* option "--begin y x" was used */ 3685382d832SPeter Avalos bool cant_kill; /* option "--no-kill" */ 3695382d832SPeter Avalos bool colors; /* option "--colors" */ 3705382d832SPeter Avalos bool cr_wrap; /* option "--cr-wrap" */ 3715382d832SPeter Avalos bool defaultno; /* option "--defaultno" */ 3725382d832SPeter Avalos bool dlg_clear_screen; /* option "--clear" */ 3735382d832SPeter Avalos bool extra_button; /* option "--extra-button" */ 3745382d832SPeter Avalos bool help_button; /* option "--help-button" */ 3755382d832SPeter Avalos bool help_status; /* option "--help-status" */ 3765382d832SPeter Avalos bool input_menu; /* menu vs inputmenu widget */ 3775382d832SPeter Avalos bool insecure; /* option "--insecure" */ 3785382d832SPeter Avalos bool item_help; /* option "--item-help" */ 3795382d832SPeter Avalos bool keep_window; /* option "--keep-window" */ 3805382d832SPeter Avalos bool nocancel; /* option "--no-cancel" */ 3815382d832SPeter Avalos bool nocollapse; /* option "--no-collapse" */ 3825382d832SPeter Avalos bool print_siz; /* option "--print-size" */ 3835382d832SPeter Avalos bool separate_output; /* option "--separate-output" */ 3845382d832SPeter Avalos bool single_quoted; /* option "--single-quoted" */ 3855382d832SPeter Avalos bool size_err; /* option "--size-err" */ 3865382d832SPeter Avalos bool tab_correct; /* option "--tab-correct" */ 3875382d832SPeter Avalos bool trim_whitespace; /* option "--trim" */ 3885382d832SPeter Avalos char *backtitle; /* option "--backtitle backtitle" */ 3895382d832SPeter Avalos char *cancel_label; /* option "--cancel-label string" */ 3905382d832SPeter Avalos char *default_item; /* option "--default-item string" */ 3915382d832SPeter Avalos char *exit_label; /* option "--exit-label string" */ 3925382d832SPeter Avalos char *extra_label; /* option "--extra-label string" */ 3935382d832SPeter Avalos char *help_label; /* option "--help-label string" */ 3945382d832SPeter Avalos char *input_result; 3955382d832SPeter Avalos char *no_label; /* option "--no-label string" */ 3965382d832SPeter Avalos char *ok_label; /* option "--ok-label string" */ 3975382d832SPeter Avalos char *title; /* option "--title title" */ 3985382d832SPeter Avalos char *yes_label; /* option "--yes-label string" */ 3995382d832SPeter Avalos int begin_x; /* option "--begin y x" (second value) */ 4005382d832SPeter Avalos int begin_y; /* option "--begin y x" (first value) */ 4015382d832SPeter Avalos int max_input; /* option "--max-input size" */ 4025382d832SPeter Avalos int scale_factor; /* RESERVED */ 4035382d832SPeter Avalos int sleep_secs; /* option "--sleep secs" */ 4045382d832SPeter Avalos int timeout_secs; /* option "--timeout secs" */ 4055382d832SPeter Avalos unsigned input_length; /* nonzero if input_result is allocated */ 4065382d832SPeter Avalos /* 1.0-20051207 */ 4075382d832SPeter Avalos unsigned formitem_type; /* DIALOG_FORMITEM.type in dialog_form() */ 4085382d832SPeter Avalos /* 1.1-20070227 */ 4095382d832SPeter Avalos bool keep_tite; /* option "--keep-tite" */ 4105382d832SPeter Avalos bool ascii_lines; /* option "--ascii-lines" */ 4115382d832SPeter Avalos bool no_lines; /* option "--no-lines" */ 4125382d832SPeter Avalos /* 1.1-20070930 */ 4135382d832SPeter Avalos bool nook; /* option "--no-ok" */ 4145382d832SPeter Avalos /* 1.1-20080727 */ 4155382d832SPeter Avalos bool quoted; /* option "--quoted" */ 4165382d832SPeter Avalos char *column_header; /* RESERVED "--column-header" */ 4175382d832SPeter Avalos char *column_separator; /* option "--column-separator" */ 4185382d832SPeter Avalos char *output_separator; /* option "--output-separator" */ 4195382d832SPeter Avalos /* 1.1-20100118 */ 4205382d832SPeter Avalos char *date_format; /* option "--date-format" */ 4215382d832SPeter Avalos char *time_format; /* option "--time-format" */ 4225382d832SPeter Avalos /* 1.1-20110629 */ 4235382d832SPeter Avalos char *help_line; /* option "--hline" */ 4245382d832SPeter Avalos char *help_file; /* option "--hfile" */ 4255382d832SPeter Avalos bool in_helpfile; /* flag to prevent recursion in --hfile */ 4265382d832SPeter Avalos bool no_nl_expand; /* option "--no-nl-expand" */ 4275382d832SPeter Avalos /* 1.1-20120701 */ 4285382d832SPeter Avalos int default_button; /* option "--default-button" (exit code) */ 4295382d832SPeter Avalos /* 1.1-20121218 */ 4305382d832SPeter Avalos bool no_tags; /* option "--no-tags" */ 4315382d832SPeter Avalos bool no_items; /* option "--no-items" */ 4321ef6786aSJohn Marino /* 1.2-20130315 */ 4331ef6786aSJohn Marino bool last_key; /* option "--last-key" */ 4341ef6786aSJohn Marino /* 1.2-20130902 */ 4351ef6786aSJohn Marino bool help_tags; /* option "--help-tags" */ 4365940c9abSDaniel Fojt /* 1.3-20160126 */ 4375940c9abSDaniel Fojt char *week_start; /* option "--week-start" */ 4385940c9abSDaniel Fojt /* 1.3-20160206 */ 4395940c9abSDaniel Fojt bool iso_week; /* option "--iso-week" */ 4405940c9abSDaniel Fojt /* 1.3-20170131 */ 4415940c9abSDaniel Fojt bool reorder; /* option "--reorder" */ 442*a8e38dc0SAntonio Huete Jimenez /* 1.3-20201117 */ 443*a8e38dc0SAntonio Huete Jimenez int pause_secs; /* used by pause widget */ 444*a8e38dc0SAntonio Huete Jimenez /* 1.3-20201126 */ 445*a8e38dc0SAntonio Huete Jimenez bool erase_on_exit; /* option "--erase-on-exit" */ 446*a8e38dc0SAntonio Huete Jimenez bool cursor_off_label; /* option "--cursor-off-label" */ 447*a8e38dc0SAntonio Huete Jimenez /* 1.3-20210117 */ 448*a8e38dc0SAntonio Huete Jimenez bool no_hot_list; /* option "--no-hot-list" */ 4495382d832SPeter Avalos } DIALOG_VARS; 4505382d832SPeter Avalos 4515382d832SPeter Avalos #define USE_ITEM_HELP(s) (dialog_vars.item_help && (s) != 0) 4525382d832SPeter Avalos 4535382d832SPeter Avalos /* 4545382d832SPeter Avalos * Some settings change the number of data items per row which dialog reads 4555382d832SPeter Avalos * from a script. 4565382d832SPeter Avalos */ 4575382d832SPeter Avalos #define DLG__NO_ITEMS (dialog_vars.no_items ? 0 : 1) 4585382d832SPeter Avalos #define DLG__ITEM_HELP (dialog_vars.item_help ? 1 : 0) 4595382d832SPeter Avalos 4605382d832SPeter Avalos /* 4615382d832SPeter Avalos * These are the total number of data items per row used for each widget type. 4625382d832SPeter Avalos */ 4635382d832SPeter Avalos #define CHECKBOX_TAGS (2 + DLG__ITEM_HELP + DLG__NO_ITEMS) 4645382d832SPeter Avalos #define MENUBOX_TAGS (1 + DLG__ITEM_HELP + DLG__NO_ITEMS) 4655382d832SPeter Avalos #define FORMBOX_TAGS (8 + DLG__ITEM_HELP) 4665382d832SPeter Avalos #define MIXEDFORM_TAGS (1 + FORMBOX_TAGS) 4675382d832SPeter Avalos #define MIXEDGAUGE_TAGS 2 4685382d832SPeter Avalos #define TREEVIEW_TAGS (3 + DLG__ITEM_HELP + DLG__NO_ITEMS) 4695382d832SPeter Avalos 4705382d832SPeter Avalos extern DIALOG_VARS dialog_vars; 4715382d832SPeter Avalos 4725382d832SPeter Avalos #ifndef HAVE_TYPE_CHTYPE 4735382d832SPeter Avalos #define chtype long 4745382d832SPeter Avalos #endif 4755382d832SPeter Avalos 4765382d832SPeter Avalos /* 4775382d832SPeter Avalos * Table for attribute- and color-values. 4785382d832SPeter Avalos */ 4795382d832SPeter Avalos typedef struct { 4805940c9abSDaniel Fojt chtype atr; /* attribute corresponding to fg, bg, etc */ 4815382d832SPeter Avalos #ifdef HAVE_COLOR 4825940c9abSDaniel Fojt int fg; /* foreground color-number */ 4835940c9abSDaniel Fojt int bg; /* background color-number */ 4845940c9abSDaniel Fojt int hilite; /* true if bold */ 4855940c9abSDaniel Fojt #ifdef HAVE_RC_FILE2 4865940c9abSDaniel Fojt int ul; /* true if underline */ 4875940c9abSDaniel Fojt int rv; /* true if reverse */ 4885940c9abSDaniel Fojt #endif /* HAVE_RC_FILE2 */ 4895940c9abSDaniel Fojt #endif /* HAVE_COLOR */ 4905382d832SPeter Avalos #ifdef HAVE_RC_FILE 4915382d832SPeter Avalos const char *name; 4925382d832SPeter Avalos const char *comment; 4935382d832SPeter Avalos #endif 4945382d832SPeter Avalos } DIALOG_COLORS; 4955382d832SPeter Avalos 4965382d832SPeter Avalos extern DIALOG_COLORS dlg_color_table[]; 4975382d832SPeter Avalos 4985382d832SPeter Avalos /* 4995382d832SPeter Avalos * Function prototypes 5005382d832SPeter Avalos */ 5015382d832SPeter Avalos extern const char *dialog_version(void); 5025382d832SPeter Avalos 5035382d832SPeter Avalos /* widgets, each in separate files */ 5045382d832SPeter Avalos 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*/); 5055382d832SPeter Avalos extern int dialog_calendar(const char * /*title*/, const char * /*subtitle*/, int /*height*/, int /*width*/, int /*day*/, int /*month*/, int /*year*/); 5065382d832SPeter Avalos extern int dialog_checklist(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/, int /*list_height*/, int /*item_no*/, char ** /*items*/, int /*flag*/); 5075382d832SPeter Avalos extern int dialog_dselect(const char * /*title*/, const char * /*path*/, int /*height*/, int /*width*/); 5085382d832SPeter Avalos extern int dialog_editbox(const char * /*title*/, const char * /*file*/, int /*height*/, int /*width*/); 5095382d832SPeter Avalos extern int dialog_form(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/, int /*form_height*/, int /*item_no*/, char ** /*items*/); 5105382d832SPeter Avalos extern int dialog_fselect(const char * /*title*/, const char * /*path*/, int /*height*/, int /*width*/); 5115382d832SPeter Avalos extern int dialog_gauge(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/, int /*percent*/); 5125382d832SPeter Avalos extern int dialog_helpfile(const char * /*title*/, const char * /*file*/, int /*height*/, int /*width*/); 5135382d832SPeter Avalos extern int dialog_inputbox(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/, const char * /*init*/, const int /*password*/); 5145382d832SPeter Avalos extern int dialog_menu(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/, int /*menu_height*/, int /*item_no*/, char ** /*items*/); 5155382d832SPeter Avalos extern int dialog_mixedform(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/, int /*form_height*/, int /*item_no*/, char ** /*items*/); 5165382d832SPeter Avalos extern int dialog_mixedgauge(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/, int /*percent*/, int /*item_no*/, char ** /*items*/); 5175382d832SPeter Avalos extern int dialog_msgbox(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/, int /*pauseopt*/); 5185382d832SPeter Avalos extern int dialog_pause(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/, int /*seconds*/); 5195382d832SPeter Avalos extern int dialog_prgbox(const char * /*title*/, const char * /*cprompt*/, const char * /*command*/, int /*height*/, int /*width*/, int /*pauseopt*/); 5205382d832SPeter Avalos extern int dialog_progressbox(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/); 5215382d832SPeter Avalos extern int dialog_rangebox(const char * /*title*/, const char * /*file*/, int /*height*/, int /*width*/, int /*min_value*/, int /*max_value*/, int /*default_value*/); 5225382d832SPeter Avalos extern int dialog_tailbox(const char * /*title*/, const char * /*file*/, int /*height*/, int /*width*/, int /*bg_task*/); 5235382d832SPeter Avalos extern int dialog_textbox(const char * /*title*/, const char * /*file*/, int /*height*/, int /*width*/); 5245382d832SPeter Avalos extern int dialog_timebox(const char * /*title*/, const char * /*subtitle*/, int /*height*/, int /*width*/, int /*hour*/, int /*minute*/, int /*second*/); 5255382d832SPeter Avalos extern int dialog_treeview(const char * /*title*/, const char * /*subtitle*/, int /*height*/, int /*width*/, int /*list_height*/, int /*item_no*/, char ** /*items*/, int /*flag*/); 5265382d832SPeter Avalos extern int dialog_yesno(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/); 5275382d832SPeter Avalos 5285382d832SPeter Avalos /* some widgets have alternate entrypoints, to allow list manipulation */ 5295382d832SPeter Avalos typedef struct { 5305382d832SPeter Avalos char *name; 5315382d832SPeter Avalos char *text; 5325382d832SPeter Avalos char *help; 5335382d832SPeter Avalos int state; 5345382d832SPeter Avalos } DIALOG_LISTITEM; 5355382d832SPeter Avalos 5365382d832SPeter Avalos typedef struct { 5375382d832SPeter Avalos unsigned type; /* the field type (0=input, 1=password) */ 5385382d832SPeter Avalos char *name; /* the field label */ 5395382d832SPeter Avalos int name_len; /* ...its length */ 5405382d832SPeter Avalos int name_y; /* ...its y-ordinate */ 5415382d832SPeter Avalos int name_x; /* ...its x-ordinate */ 5425382d832SPeter Avalos bool name_free; /* ...true if .name can be freed */ 5435382d832SPeter Avalos char *text; /* the field contents */ 5445382d832SPeter Avalos int text_len; /* ...its length on the screen */ 5455382d832SPeter Avalos int text_y; /* ...its y-ordinate */ 5465382d832SPeter Avalos int text_x; /* ...its x-ordinate */ 5475382d832SPeter Avalos int text_flen; /* ...its length on screen, or 0 if no input allowed */ 5485382d832SPeter Avalos int text_ilen; /* ...its limit on amount to be entered */ 5495382d832SPeter Avalos bool text_free; /* ...true if .text can be freed */ 5505382d832SPeter Avalos char *help; /* help-message, if any */ 5515382d832SPeter Avalos bool help_free; /* ...true if .help can be freed */ 5525382d832SPeter Avalos } DIALOG_FORMITEM; 5535382d832SPeter Avalos 5545382d832SPeter Avalos typedef int (DIALOG_INPUTMENU) (DIALOG_LISTITEM * /*items*/, int /*current*/, char * /*newtext*/); 5555382d832SPeter Avalos 5565382d832SPeter Avalos 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*/); 5575382d832SPeter Avalos 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*/); 5585382d832SPeter Avalos 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*/); 5595382d832SPeter Avalos extern int dlg_progressbox(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/, int /*pauseopt*/, FILE * /* fp */); 5605382d832SPeter Avalos 5615382d832SPeter Avalos /* argv.c */ 5625382d832SPeter Avalos extern char ** dlg_string_to_argv(char * /* blob */); 5635382d832SPeter Avalos extern int dlg_count_argv(char ** /* argv */); 5645382d832SPeter Avalos extern int dlg_eat_argv(int * /* argcp */, char *** /* argvp */, int /* start */, int /* count */); 5655382d832SPeter Avalos 5665382d832SPeter Avalos /* arrows.c */ 5675382d832SPeter Avalos extern void dlg_draw_arrows(WINDOW * /*dialog*/, int /*top_arrow*/, int /*bottom_arrow*/, int /*x*/, int /*top*/, int /*bottom*/); 5685382d832SPeter Avalos extern void dlg_draw_arrows2(WINDOW * /*dialog*/, int /*top_arrow*/, int /*bottom_arrow*/, int /*x*/, int /*top*/, int /*bottom*/, chtype /*attr*/, chtype /*borderattr*/); 5695382d832SPeter Avalos extern void dlg_draw_helpline(WINDOW * /*dialog*/, bool /*decorations*/); 5705382d832SPeter Avalos 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*/); 5715382d832SPeter Avalos 5725382d832SPeter Avalos /* buildlist.c */ 5735382d832SPeter Avalos 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*/); 5745382d832SPeter Avalos 5755382d832SPeter Avalos /* buttons.c */ 5765382d832SPeter Avalos extern const char ** dlg_exit_label(void); 5775382d832SPeter Avalos extern const char ** dlg_ok_label(void); 5785382d832SPeter Avalos extern const char ** dlg_ok_labels(void); 5795382d832SPeter Avalos extern const char ** dlg_yes_labels(void); 5805382d832SPeter Avalos extern int dlg_button_count(const char ** /*labels*/); 5815382d832SPeter Avalos extern int dlg_button_to_char(const char * /*label*/); 5825382d832SPeter Avalos extern int dlg_button_x_step(const char ** /*labels*/, int /*limit*/, int * /*gap*/, int * /*margin*/, int * /*step*/); 5835382d832SPeter Avalos extern int dlg_char_to_button(int /*ch*/, const char ** /*labels*/); 5845382d832SPeter Avalos extern int dlg_exit_buttoncode(int /*button*/); 5855382d832SPeter Avalos extern int dlg_match_char(int /*ch*/, const char * /*string*/); 5865382d832SPeter Avalos extern int dlg_next_button(const char ** /*labels*/, int /*button*/); 5875382d832SPeter Avalos extern int dlg_next_ok_buttonindex(int /*current*/, int /*extra*/); 5885382d832SPeter Avalos extern int dlg_ok_buttoncode(int /*button*/); 5895382d832SPeter Avalos extern int dlg_prev_button(const char ** /*labels*/, int /*button*/); 5905382d832SPeter Avalos extern int dlg_prev_ok_buttonindex(int /*current*/, int /*extra*/); 5915382d832SPeter Avalos extern int dlg_yes_buttoncode(int /*button*/); 5925382d832SPeter Avalos extern void dlg_button_layout(const char ** /*labels*/, int * /*limit*/); 5935382d832SPeter Avalos extern void dlg_button_sizes(const char ** /*labels*/, int /*vertical*/, int * /*longest*/, int * /*length*/); 5945382d832SPeter Avalos extern void dlg_draw_buttons(WINDOW * /*win*/, int /*y*/, int /*x*/, const char ** /*labels*/, int /*selected*/, int /*vertical*/, int /*limit*/); 5955382d832SPeter Avalos 5965382d832SPeter Avalos /* columns.c */ 5975382d832SPeter Avalos extern void dlg_align_columns(char ** /* target */, int /* per_row */, int /* num_rows */); 5985382d832SPeter Avalos extern void dlg_free_columns(char ** /* target */, int /* per_row */, int /* num_rows */); 5995382d832SPeter Avalos 6005382d832SPeter Avalos /* editbox.c */ 6015382d832SPeter Avalos extern int dlg_editbox(const char * /*title*/, char *** /*list*/, int * /*rows*/, int /*height*/, int /*width*/); 6025382d832SPeter Avalos 6035382d832SPeter Avalos /* formbox.c */ 6045382d832SPeter Avalos extern int dlg_default_formitem(DIALOG_FORMITEM * /*items*/); 6055382d832SPeter Avalos extern int dlg_ordinate(const char * /*s*/); 6065382d832SPeter Avalos extern void dlg_free_formitems(DIALOG_FORMITEM * /*items*/); 6075382d832SPeter Avalos 6085382d832SPeter Avalos /* guage.c */ 6095382d832SPeter Avalos extern void * dlg_allocate_gauge(const char * /* title */, const char * /* cprompt */, int /* height */, int /* width */, int /* percent */); 6101ef6786aSJohn Marino extern void * dlg_reallocate_gauge(void * /* objptr */, const char * /* title */, const char * /* cprompt */, int /* height */, int /* width */, int /* percent */); 6115382d832SPeter Avalos extern void dlg_free_gauge(void * /* objptr */); 6125382d832SPeter Avalos extern void dlg_update_gauge(void * /* objptr */, int /* percent */); 6135382d832SPeter Avalos 6145382d832SPeter Avalos /* inputstr.c */ 6155382d832SPeter Avalos extern bool dlg_edit_string(char * /*string*/, int * /*offset*/, int /*key*/, int /*fkey*/, bool /*force*/); 6165382d832SPeter Avalos extern const int * dlg_index_columns(const char * /*string*/); 6175382d832SPeter Avalos extern const int * dlg_index_wchars(const char * /*string*/); 6185382d832SPeter Avalos extern int dlg_count_columns(const char * /*string*/); 6195382d832SPeter Avalos extern int dlg_count_wchars(const char * /*string*/); 6205382d832SPeter Avalos extern int dlg_edit_offset(char * /*string*/, int /*offset*/, int /*x_last*/); 6215382d832SPeter Avalos extern int dlg_find_index(const int * /*list*/, int /*limit*/, int /*to_find*/); 6225382d832SPeter Avalos extern int dlg_limit_columns(const char * /*string*/, int /*limit*/, int /*offset*/); 6231ef6786aSJohn Marino extern void dlg_finish_string(const char * /* string */); 6245382d832SPeter Avalos 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*/); 6255382d832SPeter Avalos 6265382d832SPeter Avalos /* menubox.c */ 6275382d832SPeter Avalos extern int dlg_dummy_menutext(DIALOG_LISTITEM * /*items*/, int /*current*/, char * /*newtext*/); 6285382d832SPeter Avalos extern int dlg_renamed_menutext(DIALOG_LISTITEM * /*items*/, int /*current*/, char * /*newtext*/); 6295382d832SPeter Avalos 6305940c9abSDaniel Fojt /* prgbox.c */ 6315940c9abSDaniel Fojt extern FILE * dlg_popen(const char * /*command */, const char * /*type */); 6325940c9abSDaniel Fojt 6335382d832SPeter Avalos /* rc.c */ 6345382d832SPeter Avalos #ifdef HAVE_RC_FILE 6355382d832SPeter Avalos extern int dlg_parse_rc(void); 6365382d832SPeter Avalos extern void dlg_create_rc(const char * /*filename*/); 6375382d832SPeter Avalos #endif 6385382d832SPeter Avalos 6395382d832SPeter Avalos /* treeview.c */ 6405382d832SPeter Avalos 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*/); 6415382d832SPeter Avalos 6425940c9abSDaniel Fojt /* ttysize.c */ 6435940c9abSDaniel Fojt extern int dlg_ttysize(int /* fd */, int * /* height */, int * /* width */); 6445940c9abSDaniel Fojt 6455382d832SPeter Avalos /* ui_getc.c */ 6465382d832SPeter Avalos extern int dlg_getc(WINDOW * /*win*/, int * /*fkey*/); 6475382d832SPeter Avalos extern int dlg_getc_callbacks(int /*ch*/, int /*fkey*/, int * /*result*/); 6485382d832SPeter Avalos extern int dlg_last_getc(void); 6491ef6786aSJohn Marino extern void dlg_add_last_key(int /*mode*/); 6505382d832SPeter Avalos extern void dlg_add_callback(DIALOG_CALLBACK * /*p*/); 6515382d832SPeter Avalos extern void dlg_add_callback_ref(DIALOG_CALLBACK ** /*p*/, DIALOG_FREEBACK /* cleanup */); 6525382d832SPeter Avalos extern void dlg_flush_getc(void); 6535382d832SPeter Avalos extern void dlg_remove_callback(DIALOG_CALLBACK * /*p*/); 6545382d832SPeter Avalos extern void dlg_killall_bg(int *retval); 6555382d832SPeter Avalos 6565382d832SPeter Avalos /* util.c */ 657*a8e38dc0SAntonio Huete Jimenez extern DIALOG_WINDOWS * _dlg_find_window(WINDOW * /* win */); 658*a8e38dc0SAntonio Huete Jimenez extern WINDOW * dlg_der_window(WINDOW * /*win*/, int /*height*/, int /*width*/, int /*y*/, int /*x*/); 6595382d832SPeter Avalos extern WINDOW * dlg_new_modal_window(WINDOW * /*parent*/, int /*height*/, int /*width*/, int /*y*/, int /*x*/); 6605382d832SPeter Avalos extern WINDOW * dlg_new_window(int /*height*/, int /*width*/, int /*y*/, int /*x*/); 6615382d832SPeter Avalos extern WINDOW * dlg_sub_window(WINDOW * /*win*/, int /*height*/, int /*width*/, int /*y*/, int /*x*/); 6625382d832SPeter Avalos extern bool dlg_need_separator(void); 663*a8e38dc0SAntonio Huete Jimenez extern char * dlg_getenv_str(const char * /*name*/); 6645382d832SPeter Avalos extern char * dlg_set_result(const char * /*string*/); 6655382d832SPeter Avalos extern char * dlg_strclone(const char * /*cprompt*/); 6665382d832SPeter Avalos extern char * dlg_strempty(void); 6675382d832SPeter Avalos extern chtype dlg_asciibox(chtype /*ch*/); 6685382d832SPeter Avalos extern chtype dlg_boxchar(chtype /*ch*/); 6695382d832SPeter Avalos extern chtype dlg_get_attrs(WINDOW * /*win*/); 6705940c9abSDaniel Fojt extern const char * dlg_exitcode2s(int /*code*/); 6715382d832SPeter Avalos extern const char * dlg_print_line(WINDOW * /*win*/, chtype * /*attr*/, const char * /*prompt*/, int /*lm*/, int /*rm*/, int * /*x*/); 6725382d832SPeter Avalos extern int dlg_box_x_ordinate(int /*width*/); 6735382d832SPeter Avalos extern int dlg_box_y_ordinate(int /*height*/); 6745382d832SPeter Avalos extern int dlg_calc_list_width(int /*item_no*/, DIALOG_LISTITEM * /*items*/); 6755382d832SPeter Avalos extern int dlg_calc_listw(int /*item_no*/, char ** /*items*/, int /*group*/); 6765382d832SPeter Avalos extern int dlg_check_scrolled(int /* key */, int /* last */, int /* page */, bool * /* show */, int * /* offset */); 6775382d832SPeter Avalos extern int dlg_count_real_columns(const char * /*text*/); 6785382d832SPeter Avalos extern int dlg_default_item(char ** /*items*/, int /*llen*/); 6795382d832SPeter Avalos extern int dlg_default_listitem(DIALOG_LISTITEM * /*items*/); 6805382d832SPeter Avalos extern int dlg_defaultno_button(void); 6815382d832SPeter Avalos extern int dlg_default_button(void); 6825940c9abSDaniel Fojt extern int dlg_exitname2n(const char * /*name*/); 683*a8e38dc0SAntonio Huete Jimenez extern int dlg_getenv_num(const char * /*name*/, int * /* value */); 6845382d832SPeter Avalos extern int dlg_max_input(int /*max_len*/); 6855382d832SPeter Avalos extern int dlg_print_scrolled(WINDOW * /* win */, const char * /* prompt */, int /* offset */, int /* height */, int /* width */, int /* pauseopt */); 6865940c9abSDaniel Fojt extern int dlg_set_timeout(WINDOW * /* win */, bool /* will_getc */); 6871ef6786aSJohn Marino extern void dlg_add_help_formitem(int * /* result */, char ** /* tag */, DIALOG_FORMITEM * /* item */); 6881ef6786aSJohn Marino extern void dlg_add_help_listitem(int * /* result */, char ** /* tag */, DIALOG_LISTITEM * /* item */); 6895382d832SPeter Avalos extern void dlg_add_quoted(char * /*string*/); 6905382d832SPeter Avalos extern void dlg_add_result(const char * /*string*/); 6915382d832SPeter Avalos extern void dlg_add_separator(void); 6925382d832SPeter Avalos extern void dlg_add_string(char * /*string*/); 6935382d832SPeter Avalos extern void dlg_attr_clear(WINDOW * /*win*/, int /*height*/, int /*width*/, chtype /*attr*/); 6945382d832SPeter Avalos extern void dlg_auto_size(const char * /*title*/, const char * /*prompt*/, int * /*height*/, int * /*width*/, int /*boxlines*/, int /*mincols*/); 6955382d832SPeter Avalos extern void dlg_auto_sizefile(const char * /*title*/, const char * /*file*/, int * /*height*/, int * /*width*/, int /*boxlines*/, int /*mincols*/); 6965382d832SPeter Avalos extern void dlg_beeping(void); 6975382d832SPeter Avalos extern void dlg_calc_listh(int * /*height*/, int * /*list_height*/, int /*item_no*/); 6985382d832SPeter Avalos extern void dlg_clear(void); 6995382d832SPeter Avalos extern void dlg_clr_result(void); 7005382d832SPeter Avalos extern void dlg_ctl_size(int /*height*/, int /*width*/); 7015382d832SPeter Avalos extern void dlg_del_window(WINDOW * /*win*/); 7025382d832SPeter Avalos extern void dlg_does_output(void); 7035382d832SPeter Avalos extern void dlg_draw_bottom_box(WINDOW * /*win*/); 7045382d832SPeter Avalos extern void dlg_draw_bottom_box2(WINDOW * /*win*/, chtype /*on_left*/, chtype /*on_right*/, chtype /*on_inside*/); 7055382d832SPeter Avalos extern void dlg_draw_box(WINDOW * /*win*/, int /*y*/, int /*x*/, int /*height*/, int /*width*/, chtype /*boxchar*/, chtype /*borderchar*/); 7065382d832SPeter Avalos extern void dlg_draw_box2(WINDOW * /*win*/, int /*y*/, int /*x*/, int /*height*/, int /*width*/, chtype /*boxchar*/, chtype /*borderchar*/, chtype /*borderchar2*/); 7075382d832SPeter Avalos extern void dlg_draw_title(WINDOW *win, const char *title); 708*a8e38dc0SAntonio Huete Jimenez extern GCC_NORETURN void dlg_exit(int /*code*/); 7095382d832SPeter Avalos extern void dlg_item_help(const char * /*txt*/); 710*a8e38dc0SAntonio Huete Jimenez extern void dlg_keep_tite(FILE * /*output */); 7115382d832SPeter Avalos extern void dlg_print_autowrap(WINDOW * /*win*/, const char * /*prompt*/, int /*height*/, int /*width*/); 7125382d832SPeter Avalos extern void dlg_print_listitem(WINDOW * /*win*/, const char * /*text*/, int /*climit*/, bool /*first*/, int /*selected*/); 7135382d832SPeter Avalos extern void dlg_print_size(int /*height*/, int /*width*/); 7145382d832SPeter Avalos extern void dlg_print_text(WINDOW * /*win*/, const char * /*txt*/, int /*len*/, chtype * /*attr*/); 7155382d832SPeter Avalos extern void dlg_put_backtitle(void); 7165940c9abSDaniel Fojt extern void dlg_reset_timeout(WINDOW * /* win */); 7175382d832SPeter Avalos extern void dlg_restore_vars(DIALOG_VARS * /* save */); 7185382d832SPeter Avalos extern void dlg_save_vars(DIALOG_VARS * /* save */); 7195382d832SPeter Avalos extern void dlg_set_focus(WINDOW * /*parent*/, WINDOW * /*win*/); 7205382d832SPeter Avalos extern void dlg_tab_correct_str(char * /*prompt*/); 7215382d832SPeter Avalos extern void dlg_trim_string(char * /*src*/); 7225382d832SPeter Avalos extern void end_dialog(void); 7235382d832SPeter Avalos extern void init_dialog(FILE * /*input*/, FILE * /*output*/); 7245382d832SPeter Avalos 725*a8e38dc0SAntonio Huete Jimenez extern GCC_NORETURN void dlg_exiterr(const char *, ...) GCC_PRINTFLIKE(1,2); 7265382d832SPeter Avalos 7275382d832SPeter Avalos #ifdef HAVE_COLOR 7285382d832SPeter Avalos extern chtype dlg_color_pair(int /*foreground*/, int /*background*/); 7295382d832SPeter Avalos extern int dlg_color_count(void); 7305382d832SPeter Avalos extern void dlg_color_setup(void); 7315382d832SPeter Avalos extern void dlg_draw_shadow(WINDOW * /*win*/, int /*height*/, int /*width*/, int /*y*/, int /*x*/); 7325382d832SPeter Avalos #endif 7335382d832SPeter Avalos 7345382d832SPeter Avalos #ifdef HAVE_STRCASECMP 7355382d832SPeter Avalos #define dlg_strcmp(a,b) strcasecmp(a,b) 7365382d832SPeter Avalos #else 7375382d832SPeter Avalos extern int dlg_strcmp(const char * /*a*/, const char * /*b*/); 7385382d832SPeter Avalos #endif 7395382d832SPeter Avalos 7405382d832SPeter Avalos #ifdef HAVE_DLG_TRACE 7415382d832SPeter Avalos #define DLG_TRACE(params) dlg_trace_msg params 7425382d832SPeter Avalos extern void dlg_trace_msg(const char *fmt, ...) GCC_PRINTFLIKE(1,2); 7435940c9abSDaniel Fojt extern void dlg_trace_va_msg(const char *fmt, va_list ap); 7445940c9abSDaniel Fojt #define DLG_TRACE2S(name,value) dlg_trace_2s (name,value) 7455940c9abSDaniel Fojt #define DLG_TRACE2N(name,value) dlg_trace_2n (name,value) 7465940c9abSDaniel Fojt extern void dlg_trace_2s(const char * /*name*/, const char * /*value*/); 7475940c9abSDaniel Fojt extern void dlg_trace_2n(const char * /*name*/, int /*value*/); 7485382d832SPeter Avalos extern void dlg_trace_win(WINDOW * /*win*/); 7495382d832SPeter Avalos extern void dlg_trace_chr(int /*ch*/, int /*fkey*/); 7505382d832SPeter Avalos extern void dlg_trace(const char * /*fname*/); 7515382d832SPeter Avalos #else 7525382d832SPeter Avalos #define DLG_TRACE(params) /* nothing */ 7535940c9abSDaniel Fojt #define DLG_TRACE2S(name,value) /* nothing */ 7545940c9abSDaniel Fojt #define DLG_TRACE2N(name,value) /* nothing */ 7555940c9abSDaniel Fojt #define dlg_trace_va_msg(fmt, ap) /* nothing */ 7565382d832SPeter Avalos #define dlg_trace_win(win) /* nothing */ 7575382d832SPeter Avalos #define dlg_trace_chr(ch,fkey) /* nothing */ 7585382d832SPeter Avalos #define dlg_trace(fname) /* nothing */ 7595382d832SPeter Avalos #endif 7605382d832SPeter Avalos 7615382d832SPeter Avalos #ifdef KEY_RESIZE 7625940c9abSDaniel Fojt extern void _dlg_resize_cleanup(WINDOW * /*win*/); 7635382d832SPeter Avalos extern void dlg_move_window(WINDOW * /*win*/, int /*height*/, int /*width*/, int /*y*/, int /*x*/); 7645940c9abSDaniel Fojt extern void dlg_will_resize(WINDOW * /*win*/); 7655382d832SPeter Avalos #endif 7665382d832SPeter Avalos 7675382d832SPeter Avalos /* 7685382d832SPeter Avalos * Normally "enter" means "ok". Use this macro to handle the explicit 7695382d832SPeter Avalos * check for DLGK_ENTER: 7705382d832SPeter Avalos */ 7715382d832SPeter Avalos #define dlg_enter_buttoncode(code) (dialog_vars.nook ? DLG_EXIT_OK : dlg_ok_buttoncode(code)) 7725382d832SPeter Avalos 7735382d832SPeter Avalos /* 7745382d832SPeter Avalos * The following stuff is needed for mouse support 7755382d832SPeter Avalos */ 7765382d832SPeter Avalos typedef struct mseRegion { 7775382d832SPeter Avalos int x, y, X, Y, code; 7785382d832SPeter Avalos int mode, step_x, step_y; 7795382d832SPeter Avalos struct mseRegion *next; 7805382d832SPeter Avalos } mseRegion; 7815382d832SPeter Avalos 7825382d832SPeter Avalos #if defined(NCURSES_MOUSE_VERSION) 7835382d832SPeter Avalos 7845940c9abSDaniel Fojt #define mouse_open() mousemask(BUTTON1_PRESSED, (mmask_t *) 0) 7855382d832SPeter Avalos #define mouse_close() mousemask(0, (mmask_t *) 0) 7865382d832SPeter Avalos 7875382d832SPeter Avalos extern mseRegion * dlg_mouse_mkregion (int /*y*/, int /*x*/, int /*height*/, int /*width*/, int /*code*/); 7885382d832SPeter Avalos extern void dlg_mouse_free_regions (void); 7895382d832SPeter Avalos extern void dlg_mouse_mkbigregion (int /*y*/, int /*x*/, int /*height*/, int /*width*/, int /*code*/, int /*step_x*/, int /*step_y*/, int /*mode*/); 7905382d832SPeter Avalos extern void dlg_mouse_setbase (int /*x*/, int /*y*/); 7915382d832SPeter Avalos extern void dlg_mouse_setcode (int /*code*/); 7925382d832SPeter Avalos 7935382d832SPeter Avalos #define USE_MOUSE 1 7945382d832SPeter Avalos 7955382d832SPeter Avalos #else 7965382d832SPeter Avalos 7975382d832SPeter Avalos #define mouse_open() /*nothing*/ 7985382d832SPeter Avalos #define mouse_close() /*nothing*/ 7995382d832SPeter Avalos #define dlg_mouse_free_regions() /* nothing */ 8005382d832SPeter Avalos #define dlg_mouse_mkregion(y, x, height, width, code) /*nothing*/ 8015382d832SPeter Avalos #define dlg_mouse_mkbigregion(y, x, height, width, code, step_x, step_y, mode) /*nothing*/ 8025382d832SPeter Avalos #define dlg_mouse_setbase(x, y) /*nothing*/ 8035382d832SPeter Avalos #define dlg_mouse_setcode(c) /*nothing*/ 8045382d832SPeter Avalos 8055382d832SPeter Avalos #define USE_MOUSE 0 8065382d832SPeter Avalos 8075382d832SPeter Avalos #endif 8085382d832SPeter Avalos 8095382d832SPeter Avalos extern mseRegion *dlg_mouse_region (int /*y*/, int /*x*/); 8105382d832SPeter Avalos extern mseRegion *dlg_mouse_bigregion (int /*y*/, int /*x*/); 8115382d832SPeter Avalos extern int dlg_mouse_wgetch (WINDOW * /*win*/, int * /*fkey*/); 8125382d832SPeter Avalos extern int dlg_mouse_wgetch_nowait (WINDOW * /*win*/, int * /*fkey*/); 8135382d832SPeter Avalos 8145382d832SPeter Avalos #define mouse_mkbutton(y,x,len,code) dlg_mouse_mkregion(y,x,1,len,code); 8155382d832SPeter Avalos 8165382d832SPeter Avalos /* 8175382d832SPeter Avalos * This is the base for fictitious keys, which activate 8185382d832SPeter Avalos * the buttons. 8195382d832SPeter Avalos * 8205382d832SPeter Avalos * Mouse-generated keys are the following: 8215382d832SPeter Avalos * -- the first 32 are used as numbers, in addition to '0'-'9' 8225382d832SPeter Avalos * -- uppercase chars are used to invoke the button (M_EVENT + 'O') 8235382d832SPeter Avalos */ 8245382d832SPeter Avalos #define M_EVENT (DLGK_max + 1) 8255382d832SPeter Avalos 8265382d832SPeter Avalos /* 8275382d832SPeter Avalos * The `flag' parameter in checklist is used to select between 8285382d832SPeter Avalos * radiolist and checklist 8295382d832SPeter Avalos */ 8305382d832SPeter Avalos #define FLAG_CHECK 1 8315382d832SPeter Avalos #define FLAG_RADIO 0 8325382d832SPeter Avalos 8335382d832SPeter Avalos #ifdef __cplusplus 8345382d832SPeter Avalos } 8355382d832SPeter Avalos #endif 8365382d832SPeter Avalos /* *INDENT-ON* */ 8375382d832SPeter Avalos 8385382d832SPeter Avalos #endif /* DIALOG_H_included */ 839