dialog.h revision 217309
1/* 2 * $Id: dialog.h,v 1.214 2010/04/28 21:11:49 tom Exp $ 3 * 4 * dialog.h -- common declarations for all dialog modules 5 * 6 * Copyright 2000-2008,2010 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 30#include <dlg_config.h> 31 32#ifdef __hpux 33#define __HP_CURSES_COMPAT /* workaround for getattrs, etc. */ 34#endif 35 36#include <sys/types.h> 37#include <fcntl.h> 38#include <unistd.h> 39#include <ctype.h> 40#include <stdlib.h> 41#include <stdarg.h> 42#include <string.h> 43#include <signal.h> /* fork() etc. */ 44#include <math.h> /* sqrt() */ 45 46#if defined(HAVE_NCURSESW_NCURSES_H) 47#include <ncursesw/ncurses.h> 48#elif defined(HAVE_NCURSES_NCURSES_H) 49#include <ncurses/ncurses.h> 50#elif defined(HAVE_NCURSES_CURSES_H) 51#include <ncurses/curses.h> 52#elif defined(HAVE_NCURSES_H) 53#include <ncurses.h> 54#else 55#include <curses.h> 56#endif 57 58/* most curses.h headers include this, some do not */ 59#if defined(HAVE_UNCTRL_H) 60#include <unctrl.h> 61#endif 62 63/* possible conflicts with <term.h> which may be included in <curses.h> */ 64#ifdef color_names 65#undef color_names 66#endif 67 68#ifdef buttons 69#undef buttons 70#endif 71 72#ifdef ENABLE_NLS 73#include <libintl.h> 74#include <langinfo.h> 75#define _(s) dgettext(PACKAGE, s) 76#else 77#undef _ 78#define _(s) s 79#endif 80 81#ifndef GCC_NORETURN 82#define GCC_NORETURN /*nothing*/ 83#endif 84 85#ifndef GCC_UNUSED 86#define GCC_UNUSED /*nothing*/ 87#endif 88 89#ifndef HAVE_WGET_WCH 90#undef USE_WIDE_CURSES 91#endif 92 93/* 94 * FIXME: a configure check would be useful 95 */ 96#ifdef __hpux 97#undef ACS_UARROW 98#undef ACS_DARROW 99#undef ACS_BLOCK 100#endif 101 102/* 103 * Change these if you want 104 */ 105#define USE_SHADOW TRUE 106#define USE_COLORS TRUE 107 108#ifdef HAVE_COLOR 109#define SCOLS (COLS - (dialog_state.use_shadow ? 2 : 0)) 110#define SLINES (LINES - (dialog_state.use_shadow ? 1 : 0)) 111#else 112#define SCOLS COLS 113#define SLINES LINES 114#endif 115 116#define DLG_EXIT_ESC 255 117#define DLG_EXIT_UNKNOWN -2 /* never return this (internal use) */ 118#define DLG_EXIT_ERROR -1 /* the shell sees this as 255 */ 119#define DLG_EXIT_OK 0 120#define DLG_EXIT_CANCEL 1 121#define DLG_EXIT_HELP 2 122#define DLG_EXIT_EXTRA 3 123#define DLG_EXIT_ITEM_HELP 4 /* actually DLG_EXIT_HELP */ 124 125#define DLG_CTRL(n) ((n) & 0x1f) /* CTRL is preferred, but conflicts */ 126 127#define CHR_BACKSPACE DLG_CTRL('H') 128#define CHR_REPAINT DLG_CTRL('L') 129#define CHR_KILL DLG_CTRL('U') 130#define CHR_LITERAL DLG_CTRL('V') 131#define CHR_DELETE 127 132#define CHR_NEXT DLG_CTRL('N') 133#define CHR_PREVIOUS DLG_CTRL('P') 134#define CHR_TRACE DLG_CTRL('T') 135 136#define ESC 27 137#define TAB DLG_CTRL('I') 138 139#define MARGIN 1 140#define GUTTER 2 141#define SHADOW_ROWS 1 142#define SHADOW_COLS 2 143#define ARROWS_COL 5 144 145#define MAX_LEN 2048 146#define BUF_SIZE (10*1024) 147 148#undef MIN 149#define MIN(x,y) ((x) < (y) ? (x) : (y)) 150 151#undef MAX 152#define MAX(x,y) ((x) > (y) ? (x) : (y)) 153 154#define DEFAULT_SEPARATE_STR "\t" 155#define DEFAULT_ASPECT_RATIO 9 156/* how many spaces is a tab long (default)? */ 157#define TAB_LEN 8 158#define WTIMEOUT_VAL 10 159 160#ifndef A_CHARTEXT 161#define A_CHARTEXT 0xff 162#endif 163 164#define CharOf(ch) ((ch) & 0xff) 165 166#ifndef ACS_ULCORNER 167#define ACS_ULCORNER '+' 168#endif 169#ifndef ACS_LLCORNER 170#define ACS_LLCORNER '+' 171#endif 172#ifndef ACS_URCORNER 173#define ACS_URCORNER '+' 174#endif 175#ifndef ACS_LRCORNER 176#define ACS_LRCORNER '+' 177#endif 178#ifndef ACS_HLINE 179#define ACS_HLINE '-' 180#endif 181#ifndef ACS_VLINE 182#define ACS_VLINE '|' 183#endif 184#ifndef ACS_LTEE 185#define ACS_LTEE '+' 186#endif 187#ifndef ACS_RTEE 188#define ACS_RTEE '+' 189#endif 190#ifndef ACS_UARROW 191#define ACS_UARROW '^' 192#endif 193#ifndef ACS_DARROW 194#define ACS_DARROW 'v' 195#endif 196#ifndef ACS_BLOCK 197#define ACS_BLOCK '#' 198#endif 199 200/* these definitions may work for antique versions of curses */ 201#ifndef HAVE_GETBEGYX 202#undef getbegyx 203#define getbegyx(win,y,x) (y = (win)?(win)->_begy:ERR, x = (win)?(win)->_begx:ERR) 204#endif 205 206#ifndef HAVE_GETMAXYX 207#undef getmaxyx 208#define getmaxyx(win,y,x) (y = (win)?(win)->_maxy:ERR, x = (win)?(win)->_maxx:ERR) 209#endif 210 211#ifndef HAVE_GETPARYX 212#undef getparyx 213#define getparyx(win,y,x) (y = (win)?(win)->_pary:ERR, x = (win)?(win)->_parx:ERR) 214#endif 215 216#ifdef __cplusplus 217extern "C" { 218#endif 219 220/* these definitions may be needed for bleeding-edge curses implementations */ 221#if !(defined(HAVE_GETBEGX) && defined(HAVE_GETBEGY)) 222#undef getbegx 223#undef getbegy 224#define getbegx(win) dlg_getbegx(win) 225#define getbegy(win) dlg_getbegy(win) 226extern int dlg_getbegx(WINDOW * /*win*/); 227extern int dlg_getbegy(WINDOW * /*win*/); 228#endif 229 230#if !(defined(HAVE_GETCURX) && defined(HAVE_GETCURY)) 231#undef getcurx 232#undef getcury 233#define getcurx(win) dlg_getcurx(win) 234#define getcury(win) dlg_getcury(win) 235extern int dlg_getcurx(WINDOW * /*win*/); 236extern int dlg_getcury(WINDOW * /*win*/); 237#endif 238 239#if !(defined(HAVE_GETMAXX) && defined(HAVE_GETMAXY)) 240#undef getmaxx 241#undef getmaxy 242#define getmaxx(win) dlg_getmaxx(win) 243#define getmaxy(win) dlg_getmaxy(win) 244extern int dlg_getmaxx(WINDOW * /*win*/); 245extern int dlg_getmaxy(WINDOW * /*win*/); 246#endif 247 248#if !(defined(HAVE_GETPARX) && defined(HAVE_GETPARY)) 249#undef getparx 250#undef getpary 251#define getparx(win) dlg_getparx(win) 252#define getpary(win) dlg_getpary(win) 253extern int dlg_getparx(WINDOW * /*win*/); 254extern int dlg_getpary(WINDOW * /*win*/); 255#endif 256 257/* 258 * This is a list of "old" names, which should be helpful in updating 259 * applications that use libdialog. Starting with 2003/11/26, all exported 260 * symbols from libdialog have "dlg_" prefix, or "dialog_" prefix or "_dialog" 261 * suffix (or suffix "_dialog", e.g., init_dialog). 262 */ 263#ifdef __DIALOG_OLD_NAMES__ 264#define color_table dlg_color_table 265#define attr_clear(win,h,w,a) dlg_attr_clear(win,h,w,a) 266#define auto_size(t,s,h,w,xl,mc) dlg_auto_size(t,s,h,w,xl,mc) 267#define auto_sizefile(t,f,h,w,xl,mc) dlg_auto_sizefile(t,f,h,w,xl,mc) 268#define beeping() dlg_beeping() 269#define box_x_ordinate(w) dlg_box_x_ordinate(w) 270#define box_y_ordinate(h) dlg_box_y_ordinate(h) 271#define calc_listh(h,lh,in) dlg_calc_listh(h,lh,in) 272#define calc_listw(in,items,group) dlg_calc_listw(in,items,group) 273#define color_setup() dlg_color_setup() 274#define create_rc(f) dlg_create_rc(f) 275#define ctl_size(h,w) dlg_ctl_size(h,w) 276#define del_window(win) dlg_del_window(win) 277#define dialog_clear() dlg_clear() 278#define draw_bottom_box(win) dlg_draw_bottom_box(win) 279#define draw_box(win,y,x,h,w,xc,bc) dlg_draw_box(win,y,x,h,w,xc,bc) 280#define draw_shadow(win,h,w,y,x) dlg_draw_shadow(win,h,w,y,x) 281#define draw_title(win,t) dlg_draw_title(win,t) 282#define exiterr dlg_exiterr 283#define killall_bg(n) dlg_killall_bg(n) 284#define mouse_bigregion(y,x) dlg_mouse_bigregion(y,x) 285#define mouse_free_regions() dlg_mouse_free_regions() 286#define mouse_mkbigregion(y,x,h,w,n,ix,iy,m) dlg_mouse_mkbigregion(y,x,h,w,n,ix,iy,m) 287#define mouse_mkregion(y,x,h,w,n) dlg_mouse_mkregion(y,x,h,w,n) 288#define mouse_region(y,x) dlg_mouse_region(y,x) 289#define mouse_setbase(x,y) dlg_mouse_setbase(x,y) 290#define mouse_wgetch(w,c) dlg_mouse_wgetch(w,c) 291#define new_window(h,w,y,x) dlg_new_window(h,w,y,x) 292#define parse_rc() dlg_parse_rc() 293#define print_autowrap(win,s,h,w) dlg_print_autowrap(win,s,h,w) 294#define print_size(h,w) dlg_print_size(h,w) 295#define put_backtitle() dlg_put_backtitle() 296#define strclone(cprompt) dlg_strclone(cprompt) 297#define sub_window(win,h,w,y,x) dlg_sub_window(win,h,w,y,x) 298#define tab_correct_str(s) dlg_tab_correct_str(s) 299#endif 300 301/* 302 * Attribute names 303 */ 304#define DIALOG_ATR(n) dlg_color_table[n].atr 305 306#define screen_attr DIALOG_ATR(0) 307#define shadow_attr DIALOG_ATR(1) 308#define dialog_attr DIALOG_ATR(2) 309#define title_attr DIALOG_ATR(3) 310#define border_attr DIALOG_ATR(4) 311#define button_active_attr DIALOG_ATR(5) 312#define button_inactive_attr DIALOG_ATR(6) 313#define button_key_active_attr DIALOG_ATR(7) 314#define button_key_inactive_attr DIALOG_ATR(8) 315#define button_label_active_attr DIALOG_ATR(9) 316#define button_label_inactive_attr DIALOG_ATR(10) 317#define inputbox_attr DIALOG_ATR(11) 318#define inputbox_border_attr DIALOG_ATR(12) 319#define searchbox_attr DIALOG_ATR(13) 320#define searchbox_title_attr DIALOG_ATR(14) 321#define searchbox_border_attr DIALOG_ATR(15) 322#define position_indicator_attr DIALOG_ATR(16) 323#define menubox_attr DIALOG_ATR(17) 324#define menubox_border_attr DIALOG_ATR(18) 325#define item_attr DIALOG_ATR(19) 326#define item_selected_attr DIALOG_ATR(20) 327#define tag_attr DIALOG_ATR(21) 328#define tag_selected_attr DIALOG_ATR(22) 329#define tag_key_attr DIALOG_ATR(23) 330#define tag_key_selected_attr DIALOG_ATR(24) 331#define check_attr DIALOG_ATR(25) 332#define check_selected_attr DIALOG_ATR(26) 333#define uarrow_attr DIALOG_ATR(27) 334#define darrow_attr DIALOG_ATR(28) 335#define itemhelp_attr DIALOG_ATR(29) 336#define form_active_text_attr DIALOG_ATR(30) 337#define form_text_attr DIALOG_ATR(31) 338#define form_item_readonly_attr DIALOG_ATR(32) 339 340#define DLGK_max (KEY_MAX + 256) 341 342/* 343 * Callbacks are used to implement the "background" tailbox. 344 */ 345struct _dlg_callback; 346 347typedef void (*DIALOG_FREEBACK) (struct _dlg_callback * /* p */); 348 349typedef struct _dlg_callback { 350 struct _dlg_callback *next; 351 FILE *input; 352 WINDOW *win; 353 bool keep_bg; /* keep in background, on exit */ 354 bool bg_task; /* true if this is background task */ 355 bool (*handle_getc)(struct _dlg_callback *p, int ch, int fkey, int *result); 356 bool keep_win; /* true to not erase window on exit */ 357 /* data for dlg_add_callback_ref */ 358 struct _dlg_callback **caller; 359 DIALOG_FREEBACK freeback; 360} DIALOG_CALLBACK; 361 362typedef struct _dlg_windows { 363 struct _dlg_windows *next; 364 WINDOW *normal; 365 WINDOW *shadow; 366} DIALOG_WINDOWS; 367 368/* 369 * Global variables, which are initialized as needed 370 */ 371typedef struct { 372 DIALOG_CALLBACK *getc_callbacks; 373 DIALOG_CALLBACK *getc_redirect; 374 DIALOG_WINDOWS *all_windows; 375 FILE *output; /* option "--output-fd fd" */ 376 FILE *pipe_input; /* used for gauge widget */ 377 FILE *screen_output; /* newterm(), etc. */ 378 bool screen_initialized; 379 bool use_colors; /* use colors by default? */ 380 bool use_scrollbar; /* option "--scrollbar" */ 381 bool use_shadow; /* shadow dialog boxes by default? */ 382 bool visit_items; /* option "--visit-items" */ 383 char *separate_str; /* option "--separate-widget string" */ 384 int aspect_ratio; /* option "--aspect ratio" */ 385 int output_count; /* # of widgets that may have done output */ 386 int tab_len; /* option "--tab-len n" */ 387 /* 1.0-20070227 */ 388 FILE *input; /* option "--input-fd fd" */ 389#ifdef HAVE_DLG_TRACE 390 FILE *trace_output; /* option "--trace file" */ 391#endif 392} DIALOG_STATE; 393 394extern DIALOG_STATE dialog_state; 395 396/* 397 * Global variables, which dialog resets before each widget 398 */ 399typedef struct { 400 bool beep_after_signal; /* option "--beep-after" */ 401 bool beep_signal; /* option "--beep" */ 402 bool begin_set; /* option "--begin y x" was used */ 403 bool cant_kill; /* option "--no-kill" */ 404 bool colors; /* option "--colors" */ 405 bool cr_wrap; /* option "--cr-wrap" */ 406 bool defaultno; /* option "--defaultno" */ 407 bool dlg_clear_screen; /* option "--clear" */ 408 bool extra_button; /* option "--extra-button" */ 409 bool help_button; /* option "--help-button" */ 410 bool help_status; /* option "--help-status" */ 411 bool input_menu; /* menu vs inputmenu widget */ 412 bool insecure; /* option "--insecure" */ 413 bool item_help; /* option "--item-help" */ 414 bool keep_window; /* option "--keep-window" */ 415 bool nocancel; /* option "--no-cancel" */ 416 bool nocollapse; /* option "--no-collapse" */ 417 bool print_siz; /* option "--print-size" */ 418 bool separate_output; /* option "--separate-output" */ 419 bool single_quoted; /* option "--single-quoted" */ 420 bool size_err; /* option "--size-err" */ 421 bool tab_correct; /* option "--tab-correct" */ 422 bool trim_whitespace; /* option "--trim" */ 423 char *backtitle; /* option "--backtitle backtitle" */ 424 char *cancel_label; /* option "--cancel-label string" */ 425 char *default_item; /* option "--default-item string" */ 426 char *exit_label; /* option "--exit-label string" */ 427 char *extra_label; /* option "--extra-label string" */ 428 char *help_label; /* option "--help-label string" */ 429 char *input_result; 430 char *no_label; /* option "--no-label string" */ 431 char *ok_label; /* option "--ok-label string" */ 432 char *title; /* option "--title title" */ 433 char *yes_label; /* option "--yes-label string" */ 434 int begin_x; /* option "--begin y x" (second value) */ 435 int begin_y; /* option "--begin y x" (first value) */ 436 int max_input; /* option "--max-input size" */ 437 int scale_factor; /* RESERVED */ 438 int sleep_secs; /* option "--sleep secs" */ 439 int timeout_secs; /* option "--timeout secs" */ 440 unsigned input_length; /* nonzero if input_result is allocated */ 441 /* 1.0-20051207 */ 442 unsigned formitem_type; /* DIALOG_FORMITEM.type in dialog_form() */ 443 /* 1.1-20070227 */ 444 bool keep_tite; /* option "--keep-tite" */ 445 bool ascii_lines; /* option "--ascii-lines" */ 446 bool no_lines; /* option "--no-lines" */ 447 /* 1.1-20070930 */ 448 bool nook; /* option "--no-ok" */ 449 /* 1.1-20080727 */ 450 bool quoted; /* option "--quoted" */ 451 char *column_header; /* RESERVED "--column-header" */ 452 char *column_separator; /* option "--column-separator" */ 453 char *output_separator; /* option "--output-separator" */ 454 /* 1.1-20100118 */ 455 char *date_format; /* option "--date-format" */ 456 char *time_format; /* option "--time-format" */ 457} DIALOG_VARS; 458 459#define USE_ITEM_HELP(s) (dialog_vars.item_help && (s) != 0) 460#define CHECKBOX_TAGS (dialog_vars.item_help ? 4 : 3) 461#define MENUBOX_TAGS (dialog_vars.item_help ? 3 : 2) 462#define FORMBOX_TAGS (dialog_vars.item_help ? 9 : 8) 463#define MIXEDFORM_TAGS (FORMBOX_TAGS + 1) 464#define MIXEDGAUGE_TAGS 2 465 466extern DIALOG_VARS dialog_vars; 467 468#ifndef HAVE_TYPE_CHTYPE 469#define chtype long 470#endif 471 472#define UCH(ch) ((unsigned char)(ch)) 473 474#define assert_ptr(ptr,msg) if ((ptr) == 0) dlg_exiterr("cannot allocate memory in " msg) 475 476#define dlg_malloc(t,n) (t *) malloc((n) * sizeof(t)) 477#define dlg_calloc(t,n) (t *) calloc((n), sizeof(t)) 478#define dlg_realloc(t,n,p) (t *) realloc((p), (n) * sizeof(t)) 479 480/* 481 * Table for attribute- and color-values. 482 */ 483typedef struct { 484 chtype atr; 485#ifdef HAVE_COLOR 486 int fg; 487 int bg; 488 int hilite; 489#endif 490#ifdef HAVE_RC_FILE 491 const char *name; 492 const char *comment; 493#endif 494} DIALOG_COLORS; 495 496extern DIALOG_COLORS dlg_color_table[]; 497 498/* 499 * Function prototypes 500 */ 501extern const char *dialog_version(void); 502 503/* widgets, each in separate files */ 504extern int dialog_calendar(const char * /*title*/, const char * /*subtitle*/, int /*height*/, int /*width*/, int /*day*/, int /*month*/, int /*year*/); 505extern int dialog_checklist(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/, int /*list_height*/, int /*item_no*/, char ** /*items*/, int /*flag*/); 506extern int dialog_dselect(const char * /*title*/, const char * /*path*/, int /*height*/, int /*width*/); 507extern int dialog_editbox(const char * /*title*/, const char * /*file*/, int /*height*/, int /*width*/); 508extern int dialog_form(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/, int /*form_height*/, int /*item_no*/, char ** /*items*/); 509extern int dialog_fselect(const char * /*title*/, const char * /*path*/, int /*height*/, int /*width*/); 510extern int dialog_gauge(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/, int /*percent*/); 511extern int dialog_inputbox(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/, const char * /*init*/, const int /*password*/); 512extern int dialog_menu(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/, int /*menu_height*/, int /*item_no*/, char ** /*items*/); 513extern int dialog_mixedform(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/, int /*form_height*/, int /*item_no*/, char ** /*items*/); 514extern int dialog_mixedgauge(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/, int /*percent*/, int /*item_no*/, char ** /*items*/); 515extern int dialog_msgbox(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/, int /*pauseopt*/); 516extern int dialog_pause(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/, int /*seconds*/); 517extern int dialog_progressbox(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/); 518extern int dialog_tailbox(const char * /*title*/, const char * /*file*/, int /*height*/, int /*width*/, int /*bg_task*/); 519extern int dialog_textbox(const char * /*title*/, const char * /*file*/, int /*height*/, int /*width*/); 520extern int dialog_timebox(const char * /*title*/, const char * /*subtitle*/, int /*height*/, int /*width*/, int /*hour*/, int /*minute*/, int /*second*/); 521extern int dialog_yesno(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/); 522 523/* some widgets have alternate entrypoints, to allow list manipulation */ 524typedef struct { 525 char *name; 526 char *text; 527 char *help; 528 int state; 529} DIALOG_LISTITEM; 530 531typedef struct { 532 unsigned type; /* the field type (0=input, 1=password) */ 533 char *name; /* the field label */ 534 int name_len; /* ...its length */ 535 int name_y; /* ...its y-ordinate */ 536 int name_x; /* ...its x-ordinate */ 537 bool name_free; /* ...true if .name can be freed */ 538 char *text; /* the field contents */ 539 int text_len; /* ...its length on the screen */ 540 int text_y; /* ...its y-ordinate */ 541 int text_x; /* ...its x-ordinate */ 542 int text_flen; /* ...its length on screen, or 0 if no input allowed */ 543 int text_ilen; /* ...its limit on amount to be entered */ 544 bool text_free; /* ...true if .text can be freed */ 545 char *help; /* help-message, if any */ 546 bool help_free; /* ...true if .help can be freed */ 547} DIALOG_FORMITEM; 548 549typedef int (DIALOG_INPUTMENU) (DIALOG_LISTITEM * /*items*/, int /*current*/, char * /*newtext*/); 550 551extern 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*/); 552extern 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*/); 553extern 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*/); 554 555/* arrows.c */ 556extern void dlg_draw_arrows(WINDOW * /*dialog*/, int /*top_arrow*/, int /*bottom_arrow*/, int /*x*/, int /*top*/, int /*bottom*/); 557extern void dlg_draw_arrows2(WINDOW * /*dialog*/, int /*top_arrow*/, int /*bottom_arrow*/, int /*x*/, int /*top*/, int /*bottom*/, chtype /*attr*/, chtype /*borderattr*/); 558extern 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*/); 559 560/* buttons.c */ 561extern const char ** dlg_exit_label(void); 562extern const char ** dlg_ok_label(void); 563extern const char ** dlg_ok_labels(void); 564extern const char ** dlg_yes_labels(void); 565extern int dlg_button_count(const char ** /*labels*/); 566extern int dlg_button_to_char(const char * /*label*/); 567extern int dlg_button_x_step(const char ** /*labels*/, int /*limit*/, int * /*gap*/, int * /*margin*/, int * /*step*/); 568extern int dlg_char_to_button(int /*ch*/, const char ** /*labels*/); 569extern int dlg_exit_buttoncode(int /*button*/); 570extern int dlg_match_char(int /*ch*/, const char * /*string*/); 571extern int dlg_next_button(const char ** /*labels*/, int /*button*/); 572extern int dlg_next_ok_buttonindex(int /*current*/, int /*extra*/); 573extern int dlg_ok_buttoncode(int /*button*/); 574extern int dlg_prev_button(const char ** /*labels*/, int /*button*/); 575extern int dlg_prev_ok_buttonindex(int /*current*/, int /*extra*/); 576extern int dlg_yes_buttoncode(int /*button*/); 577extern void dlg_button_layout(const char ** /*labels*/, int * /*limit*/); 578extern void dlg_button_sizes(const char ** /*labels*/, int /*vertical*/, int * /*longest*/, int * /*length*/); 579extern void dlg_draw_buttons(WINDOW * /*win*/, int /*y*/, int /*x*/, const char ** /*labels*/, int /*selected*/, int /*vertical*/, int /*limit*/); 580 581/* columns.c */ 582extern void dlg_align_columns(char ** /* target */, int /* per_row */, int /* num_rows */); 583extern void dlg_free_columns(char ** /* target */, int /* per_row */, int /* num_rows */); 584 585/* editbox.c */ 586extern int dlg_editbox(const char */*title*/, char ***/*list*/, int */*rows*/, int /*height*/, int /*width*/); 587 588/* formbox.c */ 589extern int dlg_default_formitem(DIALOG_FORMITEM * /*items*/); 590extern int dlg_ordinate(const char * /*s*/); 591extern void dlg_free_formitems(DIALOG_FORMITEM * /*items*/); 592 593/* inputstr.c */ 594extern bool dlg_edit_string(char * /*string*/, int * /*offset*/, int /*key*/, int /*fkey*/, bool /*force*/); 595extern const int * dlg_index_columns(const char * /*string*/); 596extern const int * dlg_index_wchars(const char * /*string*/); 597extern int dlg_count_columns(const char * /*string*/); 598extern int dlg_count_wchars(const char * /*string*/); 599extern int dlg_edit_offset(char * /*string*/, int /*offset*/, int /*x_last*/); 600extern int dlg_find_index(const int * /*list*/, int /*limit*/, int /*to_find*/); 601extern int dlg_limit_columns(const char * /*string*/, int /*limit*/, int /*offset*/); 602extern 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*/); 603 604/* rc.c */ 605#ifdef HAVE_RC_FILE 606extern int dlg_parse_rc(void); 607extern void dlg_create_rc(const char * /*filename*/); 608#endif 609 610/* ui_getc.c */ 611extern int dlg_getc(WINDOW * /*win*/, int * /*fkey*/); 612extern int dlg_getc_callbacks(int /*ch*/, int /*fkey*/, int * /*result*/); 613extern int dlg_last_getc(void); 614extern void dlg_add_callback(DIALOG_CALLBACK * /*p*/); 615extern void dlg_add_callback_ref(DIALOG_CALLBACK ** /*p*/, DIALOG_FREEBACK /* cleanup */); 616extern void dlg_flush_getc(void); 617extern void dlg_remove_callback(DIALOG_CALLBACK * /*p*/); 618extern void dlg_killall_bg(int *retval); 619 620/* util.c */ 621extern WINDOW * dlg_new_modal_window(WINDOW * /*parent*/, int /*height*/, int /*width*/, int /*y*/, int /*x*/); 622extern WINDOW * dlg_new_window(int /*height*/, int /*width*/, int /*y*/, int /*x*/); 623extern WINDOW * dlg_sub_window(WINDOW * /*win*/, int /*height*/, int /*width*/, int /*y*/, int /*x*/); 624extern bool dlg_need_separator(void); 625extern char * dlg_set_result(const char * /*string*/); 626extern char * dlg_strclone(const char * /*cprompt*/); 627extern char * dlg_strempty(void); 628extern chtype dlg_asciibox(chtype /*ch*/); 629extern chtype dlg_boxchar(chtype /*ch*/); 630extern const char * dlg_print_line(WINDOW */*win*/, chtype */*attr*/, const char */*prompt*/, int /*lm*/, int /*rm*/, int */*x*/); 631extern int dlg_box_x_ordinate(int /*width*/); 632extern int dlg_box_y_ordinate(int /*height*/); 633extern int dlg_calc_list_width(int /*item_no*/, DIALOG_LISTITEM * /*items*/); 634extern int dlg_calc_listw(int /*item_no*/, char ** /*items*/, int /*group*/); 635extern int dlg_check_scrolled(int /* key */, int /* last */, int /* page */, bool */* show */, int */* offset */); 636extern int dlg_default_item(char ** /*items*/, int /*llen*/); 637extern int dlg_default_listitem(DIALOG_LISTITEM * /*items*/); 638extern int dlg_defaultno_button(void); 639extern int dlg_max_input(int /*max_len*/); 640extern int dlg_print_scrolled(WINDOW * /* win */, const char * /* prompt */, int /* offset */, int /* height */, int /* width */, int /* pauseopt */); 641extern void dlg_add_quoted(char * /*string*/); 642extern void dlg_add_result(const char * /*string*/); 643extern void dlg_add_separator(void); 644extern void dlg_add_string(char * /*string*/); 645extern void dlg_attr_clear(WINDOW * /*win*/, int /*height*/, int /*width*/, chtype /*attr*/); 646extern void dlg_auto_size(const char * /*title*/, const char * /*prompt*/, int * /*height*/, int * /*width*/, int /*boxlines*/, int /*mincols*/); 647extern void dlg_auto_sizefile(const char * /*title*/, const char * /*file*/, int * /*height*/, int * /*width*/, int /*boxlines*/, int /*mincols*/); 648extern void dlg_beeping(void); 649extern void dlg_calc_listh(int * /*height*/, int * /*list_height*/, int /*item_no*/); 650extern void dlg_clear(void); 651extern void dlg_clr_result(void); 652extern void dlg_ctl_size(int /*height*/, int /*width*/); 653extern void dlg_del_window(WINDOW * /*win*/); 654extern void dlg_does_output(void); 655extern void dlg_draw_bottom_box(WINDOW * /*win*/); 656extern void dlg_draw_box(WINDOW * /*win*/, int /*y*/, int /*x*/, int /*height*/, int /*width*/, chtype /*boxchar*/, chtype /*borderchar*/); 657extern void dlg_draw_title(WINDOW *win, const char *title); 658extern void dlg_exit(int /*code*/) GCC_NORETURN; 659extern void dlg_item_help(const char * /*txt*/); 660extern void dlg_print_autowrap(WINDOW * /*win*/, const char * /*prompt*/, int /*height*/, int /*width*/); 661extern void dlg_print_size(int /*height*/, int /*width*/); 662extern void dlg_print_text(WINDOW * /*win*/, const char * /*txt*/, int /*len*/, chtype * /*attr*/); 663extern void dlg_put_backtitle(void); 664extern void dlg_restore_vars(DIALOG_VARS * /* save */); 665extern void dlg_save_vars(DIALOG_VARS * /* save */); 666extern void dlg_set_focus(WINDOW * /*parent*/, WINDOW * /*win*/); 667extern void dlg_tab_correct_str(char * /*prompt*/); 668extern void dlg_trim_string(char * /*src*/); 669extern void end_dialog(void); 670extern void init_dialog(FILE * /*input*/, FILE * /*output*/); 671 672extern void dlg_exiterr(const char *, ...) GCC_NORETURN 673#if defined(__GNUC__) && !defined(printf) 674__attribute__((format(printf,1,2))) 675#endif 676; 677 678#ifdef HAVE_COLOR 679extern chtype dlg_color_pair(int /*foreground*/, int /*background*/); 680extern int dlg_color_count(void); 681extern void dlg_color_setup(void); 682extern void dlg_draw_shadow(WINDOW * /*win*/, int /*height*/, int /*width*/, int /*y*/, int /*x*/); 683#endif 684 685#ifdef HAVE_STRCASECMP 686#define dlg_strcmp(a,b) strcasecmp(a,b) 687#else 688extern int dlg_strcmp(const char * /*a*/, const char * /*b*/); 689#endif 690 691#ifdef HAVE_DLG_TRACE 692#define DLG_TRACE(params) dlg_trace_msg params 693extern void dlg_trace_msg(const char *fmt, ...) 694#ifdef GCC_PRINTF 695 __attribute__((format(printf,1,2))) 696#endif 697; 698extern void dlg_trace_win(WINDOW * /*win*/); 699extern void dlg_trace_chr(int /*ch*/, int /*fkey*/); 700extern void dlg_trace(const char * /*fname*/); 701#else 702#define DLG_TRACE(params) /* nothing */ 703#define dlg_trace_win(win) /* nothing */ 704#define dlg_trace_chr(ch,fkey) /* nothing */ 705#define dlg_trace(fname) /* nothing */ 706#endif 707 708#ifdef KEY_RESIZE 709extern void dlg_move_window(WINDOW * /*win*/, int /*height*/, int /*width*/, int /*y*/, int /*x*/); 710#endif 711 712/* 713 * The following stuff is needed for mouse support 714 */ 715typedef struct mseRegion { 716 int x, y, X, Y, code; 717 int mode, step_x, step_y; 718 struct mseRegion *next; 719} mseRegion; 720 721#if defined(NCURSES_MOUSE_VERSION) 722 723#define mouse_open() mousemask(BUTTON1_CLICKED, (mmask_t *) 0) 724#define mouse_close() mousemask(0, (mmask_t *) 0) 725 726extern mseRegion * dlg_mouse_mkregion (int /*y*/, int /*x*/, int /*height*/, int /*width*/, int /*code*/); 727extern void dlg_mouse_free_regions (void); 728extern void dlg_mouse_mkbigregion (int /*y*/, int /*x*/, int /*height*/, int /*width*/, int /*code*/, int /*step_x*/, int /*step_y*/, int /*mode*/); 729extern void dlg_mouse_setbase (int /*x*/, int /*y*/); 730 731#define USE_MOUSE 1 732 733#else 734 735#define mouse_open() /*nothing*/ 736#define mouse_close() /*nothing*/ 737#define dlg_mouse_free_regions() /* nothing */ 738#define dlg_mouse_mkregion(y, x, height, width, code) /*nothing*/ 739#define dlg_mouse_mkbigregion(y, x, height, width, code, step_x, step_y, mode) /*nothing*/ 740#define dlg_mouse_setbase(x, y) /*nothing*/ 741 742#define USE_MOUSE 0 743 744#endif 745 746extern mseRegion *dlg_mouse_region (int /*y*/, int /*x*/); 747extern mseRegion *dlg_mouse_bigregion (int /*y*/, int /*x*/); 748extern int dlg_mouse_wgetch (WINDOW * /*win*/, int * /*fkey*/); 749extern int dlg_mouse_wgetch_nowait (WINDOW * /*win*/, int * /*fkey*/); 750 751#define mouse_mkbutton(y,x,len,code) dlg_mouse_mkregion(y,x,1,len,code); 752 753/* 754 * This is the base for fictitious keys, which activate 755 * the buttons. 756 * 757 * Mouse-generated keys are the following: 758 * -- the first 32 are used as numbers, in addition to '0'-'9' 759 * -- uppercase chars are used to invoke the button (M_EVENT + 'O') 760 */ 761#define M_EVENT (DLGK_max + 1) 762 763/* 764 * The `flag' parameter in checklist is used to select between 765 * radiolist and checklist 766 */ 767#define FLAG_CHECK 1 768#define FLAG_RADIO 0 769 770/* 771 * This is used only for debugging (FIXME: should have a separate header). 772 */ 773#ifdef NO_LEAKS 774extern void _dlg_inputstr_leaks(void); 775#if defined(NCURSES_VERSION) && defined(HAVE__NC_FREE_AND_EXIT) 776extern void _nc_free_and_exit(int); /* nc_alloc.h normally not installed */ 777#endif 778#endif 779 780#ifdef __cplusplus 781} 782#endif 783 784#endif /* DIALOG_H_included */ 785