home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / usr / include / dialog.h < prev    next >
Encoding:
C/C++ Source or Header  |  2006-06-16  |  25.7 KB  |  687 lines

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