home *** CD-ROM | disk | FTP | other *** search
/ PC-Online 1996 May / PCOnline_05_1996.bin / linux / source / a / hdsetup / dialog-0.4-1 / dialog-0 / dialog-0.4-slackware / src / dialog.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-06-05  |  7.0 KB  |  240 lines

  1. /*
  2.  *  dialog.h -- common declarations for all dialog modules
  3.  *
  4.  *  AUTHOR: Savio Lam (lam836@cs.cuhk.hk)
  5.  *
  6.  *  This program is free software; you can redistribute it and/or
  7.  *  modify it under the terms of the GNU General Public License
  8.  *  as published by the Free Software Foundation; either version 2
  9.  *  of the License, or (at your option) any later version.
  10.  *
  11.  *  This program is distributed in the hope that it will be useful,
  12.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.  *  GNU General Public License for more details.
  15.  *
  16.  *  You should have received a copy of the GNU General Public License
  17.  *  along with this program; if not, write to the Free Software
  18.  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19.  */
  20.  
  21.  
  22. #include <sys/types.h>
  23. #include <fcntl.h>
  24. #include <unistd.h>
  25. #include <ctype.h>
  26. #include <stdlib.h>
  27. #include <string.h>
  28.  
  29. #ifdef HAVE_NCURSES
  30. #include <ncurses.h>
  31.  
  32. #else
  33.  
  34. #ifdef ultrix
  35. #include <cursesX.h>
  36. #else
  37. #include <curses.h>
  38. #endif
  39.  
  40. #endif
  41.  
  42. #if defined(LOCALE)
  43. #include <locale.h>
  44. #endif
  45.  
  46. /*
  47.  * Change these if you want
  48.  */
  49. #define USE_SHADOW TRUE
  50. #define USE_COLORS TRUE
  51.  
  52. #if defined(LOCALE)
  53. #include <locale.h>
  54. #endif
  55.  
  56.  
  57. #define VERSION "0.4"
  58. #define ESC 27
  59. #define TAB 9
  60. #define MAX_LEN 2048
  61. #define BUF_SIZE (10*1024)
  62. #define MIN(x,y) (x < y ? x : y)
  63. #define MAX(x,y) (x > y ? x : y)
  64.  
  65. #ifndef HAVE_NCURSES
  66. #ifndef ACS_ULCORNER
  67. #define ACS_ULCORNER '+'
  68. #endif
  69. #ifndef ACS_LLCORNER
  70. #define ACS_LLCORNER '+'
  71. #endif
  72. #ifndef ACS_URCORNER
  73. #define ACS_URCORNER '+'
  74. #endif
  75. #ifndef ACS_LRCORNER
  76. #define ACS_LRCORNER '+'
  77. #endif
  78. #ifndef ACS_HLINE
  79. #define ACS_HLINE '-'
  80. #endif
  81. #ifndef ACS_VLINE
  82. #define ACS_VLINE '|'
  83. #endif
  84. #ifndef ACS_LTEE
  85. #define ACS_LTEE '+'
  86. #endif
  87. #ifndef ACS_RTEE
  88. #define ACS_RTEE '+'
  89. #endif
  90. #endif    /* HAVE_NCURSES */
  91.  
  92. /* Normally these are surrounded by #ifndefs like the variables above and
  93.    we use the real up/down arrow characters.  However, the proper functioning
  94.    of these characters has been unreliable under Linux 1.1.x kernels -- it
  95.    works for some of them, but prints garbage or nothing at all under others.
  96.    It's probably easier to use these normal ASCII characters until these
  97.    problems are worked out.  -- Pat */
  98.  
  99. /* #define ACS_UARROW '^'
  100. #define ACS_DARROW 'v' */
  101.  
  102. /* 
  103.  * Attribute names
  104.  */
  105. #define screen_attr                   attributes[0]
  106. #define shadow_attr                   attributes[1]
  107. #define dialog_attr                   attributes[2]
  108. #define title_attr                    attributes[3]
  109. #define border_attr                   attributes[4]
  110. #define button_active_attr            attributes[5]
  111. #define button_inactive_attr          attributes[6]
  112. #define button_key_active_attr        attributes[7]
  113. #define button_key_inactive_attr      attributes[8]
  114. #define button_label_active_attr      attributes[9]
  115. #define button_label_inactive_attr    attributes[10]
  116. #define inputbox_attr                 attributes[11]
  117. #define inputbox_border_attr          attributes[12]
  118. #define searchbox_attr                attributes[13]
  119. #define searchbox_title_attr          attributes[14]
  120. #define searchbox_border_attr         attributes[15]
  121. #define position_indicator_attr       attributes[16]
  122. #define menubox_attr                  attributes[17]
  123. #define menubox_border_attr           attributes[18]
  124. #define item_attr                     attributes[19]
  125. #define item_selected_attr            attributes[20]
  126. #define tag_attr                      attributes[21]
  127. #define tag_selected_attr             attributes[22]
  128. #define tag_key_attr                  attributes[23]
  129. #define tag_key_selected_attr         attributes[24]
  130. #define check_attr                    attributes[25]
  131. #define check_selected_attr           attributes[26]
  132. #define uarrow_attr                   attributes[27]
  133. #define darrow_attr                   attributes[28]
  134.  
  135. /* number of attributes */
  136. #define ATTRIBUTE_COUNT               29
  137.  
  138.  
  139. /*
  140.  * Global variables
  141.  */
  142. #ifdef __DIALOG_MAIN__
  143.  
  144. #ifdef HAVE_NCURSES
  145.  
  146. /* use colors by default? */
  147. bool use_colors = USE_COLORS;
  148.  
  149. /* shadow dialog boxes by default?
  150.    Note that 'use_shadow' implies 'use_colors' */
  151. bool use_shadow = USE_SHADOW;
  152.  
  153. #endif
  154.  
  155.  
  156. /* 
  157.  * Attribute values, default is for mono display
  158.  */
  159. chtype attributes[] = {
  160.   A_NORMAL,       /* screen_attr */
  161.   A_NORMAL,       /* shadow_attr */
  162.   A_REVERSE,      /* dialog_attr */
  163.   A_REVERSE,      /* title_attr */
  164.   A_REVERSE,      /* border_attr */
  165.   A_BOLD,         /* button_active_attr */
  166.   A_DIM,          /* button_inactive_attr */
  167.   A_UNDERLINE,    /* button_key_active_attr */
  168.   A_UNDERLINE,    /* button_key_inactive_attr */
  169.   A_NORMAL,       /* button_label_active_attr */
  170.   A_NORMAL,       /* button_label_inactive_attr */
  171.   A_REVERSE,      /* inputbox_attr */
  172.   A_REVERSE,      /* inputbox_border_attr */
  173.   A_REVERSE,      /* searchbox_attr */
  174.   A_REVERSE,      /* searchbox_title_attr */
  175.   A_REVERSE,      /* searchbox_border_attr */
  176.   A_REVERSE,      /* position_indicator_attr */
  177.   A_REVERSE,      /* menubox_attr */
  178.   A_REVERSE,      /* menubox_border_attr */
  179.   A_REVERSE,      /* item_attr */
  180.   A_NORMAL,       /* item_selected_attr */
  181.   A_REVERSE,      /* tag_attr */
  182.   A_REVERSE,      /* tag_selected_attr */
  183.   A_NORMAL,       /* tag_key_attr */
  184.   A_BOLD,         /* tag_key_selected_attr */
  185.   A_REVERSE,      /* check_attr */
  186.   A_REVERSE,      /* check_selected_attr */
  187.   A_REVERSE,      /* uarrow_attr */
  188.   A_REVERSE       /* darrow_attr */
  189. };
  190.  
  191. #else
  192.  
  193. #ifdef HAVE_NCURSES
  194. extern bool use_colors;
  195. extern bool use_shadow;
  196. #endif
  197.  
  198. extern chtype attributes[];
  199.  
  200. #endif    /* __DIALOG_MAIN__ */
  201.  
  202.  
  203.  
  204. #ifdef HAVE_NCURSES
  205.  
  206. /*
  207.  * Function prototypes
  208.  */
  209. #ifdef __DIALOG_MAIN__
  210.  
  211. extern void create_rc(unsigned char *filename);
  212. extern int parse_rc(void);
  213.  
  214. #endif    /* __DIALOG_MAIN__ */
  215.  
  216. #endif
  217.  
  218.  
  219. void Usage(unsigned char *name);
  220. void init_dialog(void);
  221. #ifdef HAVE_NCURSES
  222. void color_setup(void);
  223. #endif
  224. void attr_clear(WINDOW *win, int height, int width, chtype attr);
  225. void print_autowrap(WINDOW *win, unsigned char *prompt, int width, int y, int x);
  226. void print_button(WINDOW *win, unsigned char *label, int y, int x, int selected);
  227. void draw_box(WINDOW *win, int y, int x, int height, int width, chtype box, chtype border);
  228. #ifdef HAVE_NCURSES
  229. void draw_shadow(WINDOW *win, int y, int x, int height, int width);
  230. #endif
  231.  
  232. int dialog_yesno(unsigned char *title, unsigned char *prompt, int height, int width);
  233. int dialog_msgbox(unsigned char *title, unsigned char *prompt, int height, int width, int pause);
  234. int dialog_textbox(unsigned char *title, unsigned char *file, int height, int width);
  235. int dialog_menu(unsigned char *title, unsigned char *prompt, int height, int width, int menu_height, int item_no, unsigned char **items);
  236. int dialog_checklist(unsigned char *title, unsigned char *prompt, int height, int width, int list_height, int item_no, unsigned char **items);
  237. /* int dialog_radiolist(char *title, char *prompt, int height, int width, int list_height, int item_no, char **items); */
  238. int dialog_inputbox(unsigned char *title, unsigned char *prompt, int height, int width);
  239.  
  240.