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