mirror of the now-defunct rocklinux.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

184 lines
5.9 KiB

  1. /*
  2. * dialog.h -- common declarations for all dialog modules
  3. *
  4. * AUTHOR: Savio Lam (lam836@cs.cuhk.hk)
  5. * MODIFIED FOR ROCK LINUX CONFIG BY: Clifford Wolf (clifford@clifford.at)
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License
  9. * as published by the Free Software Foundation; either version 2
  10. * of the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20. */
  21. #include <sys/types.h>
  22. #include <fcntl.h>
  23. #include <unistd.h>
  24. #include <ctype.h>
  25. #include <stdlib.h>
  26. #include <string.h>
  27. #include <ncurses.h>
  28. /*
  29. * Colors in ncurses 1.9.9e do not work properly since foreground and
  30. * background colors are OR'd rather than separately masked. This version
  31. * of dialog was hacked to work with ncurses 1.9.9e, making it incompatible
  32. * with standard curses. The simplest fix (to make this work with standard
  33. * curses) uses the wbkgdset() function, not used in the original hack.
  34. * Turn it off if we're building with 1.9.9e, since it just confuses things.
  35. */
  36. #if defined(NCURSES_VERSION) && defined(_NEED_WRAP) && !defined(GCC_PRINTFLIKE)
  37. #define OLD_NCURSES 1
  38. #undef wbkgdset
  39. #define wbkgdset(w,p) /*nothing*/
  40. #else
  41. #define OLD_NCURSES 0
  42. #endif
  43. #define TR(params) _tracef params
  44. #define ESC 27
  45. #define TAB 9
  46. #define MAX_LEN 2048
  47. #define BUF_SIZE (10*1024)
  48. #define MIN(x,y) (x < y ? x : y)
  49. #define MAX(x,y) (x > y ? x : y)
  50. #ifndef ACS_ULCORNER
  51. #define ACS_ULCORNER '+'
  52. #endif
  53. #ifndef ACS_LLCORNER
  54. #define ACS_LLCORNER '+'
  55. #endif
  56. #ifndef ACS_URCORNER
  57. #define ACS_URCORNER '+'
  58. #endif
  59. #ifndef ACS_LRCORNER
  60. #define ACS_LRCORNER '+'
  61. #endif
  62. #ifndef ACS_HLINE
  63. #define ACS_HLINE '-'
  64. #endif
  65. #ifndef ACS_VLINE
  66. #define ACS_VLINE '|'
  67. #endif
  68. #ifndef ACS_LTEE
  69. #define ACS_LTEE '+'
  70. #endif
  71. #ifndef ACS_RTEE
  72. #define ACS_RTEE '+'
  73. #endif
  74. #ifndef ACS_UARROW
  75. #define ACS_UARROW '^'
  76. #endif
  77. #ifndef ACS_DARROW
  78. #define ACS_DARROW 'v'
  79. #endif
  80. /*
  81. * Attribute names
  82. */
  83. #define screen_attr attributes[0]
  84. #define shadow_attr attributes[1]
  85. #define dialog_attr attributes[2]
  86. #define title_attr attributes[3]
  87. #define border_attr attributes[4]
  88. #define button_active_attr attributes[5]
  89. #define button_inactive_attr attributes[6]
  90. #define button_key_active_attr attributes[7]
  91. #define button_key_inactive_attr attributes[8]
  92. #define button_label_active_attr attributes[9]
  93. #define button_label_inactive_attr attributes[10]
  94. #define inputbox_attr attributes[11]
  95. #define inputbox_border_attr attributes[12]
  96. #define searchbox_attr attributes[13]
  97. #define searchbox_title_attr attributes[14]
  98. #define searchbox_border_attr attributes[15]
  99. #define position_indicator_attr attributes[16]
  100. #define menubox_attr attributes[17]
  101. #define menubox_border_attr attributes[18]
  102. #define item_attr attributes[19]
  103. #define item_selected_attr attributes[20]
  104. #define tag_attr attributes[21]
  105. #define tag_selected_attr attributes[22]
  106. #define tag_key_attr attributes[23]
  107. #define tag_key_selected_attr attributes[24]
  108. #define check_attr attributes[25]
  109. #define check_selected_attr attributes[26]
  110. #define uarrow_attr attributes[27]
  111. #define darrow_attr attributes[28]
  112. /* number of attributes */
  113. #define ATTRIBUTE_COUNT 29
  114. /*
  115. * Global variables
  116. */
  117. extern bool use_colors;
  118. extern bool use_shadow;
  119. extern chtype attributes[];
  120. extern const char *backtitle;
  121. /*
  122. * Function prototypes
  123. */
  124. extern void create_rc (const char *filename);
  125. extern int parse_rc (void);
  126. void init_dialog (void);
  127. void end_dialog (void);
  128. void attr_clear (WINDOW * win, int height, int width, chtype attr);
  129. void dialog_clear (void);
  130. void color_setup (void);
  131. void print_autowrap (WINDOW * win, const char *prompt, int width, int y, int x);
  132. void print_button (WINDOW * win, const char *label, int y, int x, int selected);
  133. void draw_box (WINDOW * win, int y, int x, int height, int width, chtype box,
  134. chtype border);
  135. void draw_shadow (WINDOW * win, int y, int x, int height, int width);
  136. int first_alpha (const char *string, const char *exempt);
  137. int dialog_yesno (const char *title, const char *prompt, int height, int width);
  138. int dialog_msgbox (const char *title, const char *prompt, int height,
  139. int width, int pause);
  140. int dialog_textbox (const char *title, const char *file, int height, int width);
  141. int dialog_menu (const char *title, const char *prompt, int height, int width,
  142. int menu_height, const char *choice, int item_no,
  143. const char * const * items);
  144. int dialog_checklist (const char *title, const char *prompt, int height,
  145. int width, int list_height, int item_no,
  146. const char * const * items, int flag);
  147. extern unsigned char dialog_input_result[];
  148. int dialog_inputbox (const char *title, const char *prompt, int height,
  149. int width, const char *init);
  150. /*
  151. * This is the base for fictitious keys, which activate
  152. * the buttons.
  153. *
  154. * Mouse-generated keys are the following:
  155. * -- the first 32 are used as numbers, in addition to '0'-'9'
  156. * -- the lowercase are used to signal mouse-enter events (M_EVENT + 'o')
  157. * -- uppercase chars are used to invoke the button (M_EVENT + 'O')
  158. */
  159. #define M_EVENT (KEY_MAX+1)
  160. /*
  161. * The `flag' parameter in checklist is used to select between
  162. * radiolist and checklist
  163. */
  164. #define FLAG_CHECK 1
  165. #define FLAG_RADIO 0