libdialog: Increase MAX_LEN to 4096 (bug 2480)
[dragonfly.git] / gnu / lib / libdialog / dialog.h
... / ...
CommitLineData
1#ifndef _DIALOG_H_INCLUDE
2#define _DIALOG_H_INCLUDE
3
4/*
5 * dialog.h -- common declarations for all dialog modules
6 *
7 * AUTHOR: Savio Lam (lam836@cs.cuhk.hk)
8 *
9 * Substantial rennovation: 12/18/95, Jordan K. Hubbard
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 *
25 * $FreeBSD: src/gnu/lib/libdialog/dialog.h,v 1.21.6.1 2000/12/15 05:54:36 jkh Exp $
26 * $DragonFly: src/gnu/lib/libdialog/dialog.h,v 1.2 2003/06/17 04:25:43 dillon Exp $
27 *
28 */
29
30#define HAVE_NCURSES
31
32#ifdef HAVE_NCURSES
33#include <ncurses.h>
34
35#else
36
37#ifdef ultrix
38#include <cursesX.h>
39#else
40#include <curses.h>
41#endif
42
43#endif
44
45/* special return codes for `fire' actions */
46#define DITEM_STATUS(flag) ((flag) & 0x0000FFFF)
47#define DITEM_SUCCESS 0
48#define DITEM_FAILURE 1
49
50/* Flags - returned in upper 16 bits of return status */
51#define DITEM_LEAVE_MENU (1 << 16)
52#define DITEM_REDRAW (1 << 17)
53#define DITEM_RECREATE (1 << 18)
54#define DITEM_RESTORE (1 << 19)
55#define DITEM_CONTINUE (1 << 20)
56
57/* Attributes as used by entry fields right now */
58#define DITEM_NO_ECHO 0x0001
59
60
61/* negative offsets for buttons in item lists, if specified */
62#define OK_BUTTON -2
63#define CANCEL_BUTTON -1
64
65/* for use in describing more exotic behaviors */
66typedef struct _dmenu_item {
67 char *prompt;
68 char *title;
69 int (*checked)(struct _dmenu_item *self);
70 int (*fire)(struct _dmenu_item *self);
71 void (*selected)(struct _dmenu_item *self, int is_selected);
72 void *data;
73 char lbra, mark, rbra;
74 long aux;
75} dialogMenuItem;
76
77#define VERSION "0.4"
78#define MAX_LEN 4096
79
80#ifndef TRUE
81#define TRUE (1)
82#endif
83#ifndef FALSE
84#define FALSE (0)
85#endif
86
87extern int DialogX, DialogY, DialogInputAttrs;
88
89/*
90 * Attribute names
91 */
92#define screen_attr attributes[0]
93#define shadow_attr attributes[1]
94#define dialog_attr attributes[2]
95#define title_attr attributes[3]
96#define border_attr attributes[4]
97#define button_active_attr attributes[5]
98#define button_inactive_attr attributes[6]
99#define button_key_active_attr attributes[7]
100#define button_key_inactive_attr attributes[8]
101#define button_label_active_attr attributes[9]
102#define button_label_inactive_attr attributes[10]
103#define inputbox_attr attributes[11]
104#define inputbox_border_attr attributes[12]
105#define searchbox_attr attributes[13]
106#define searchbox_title_attr attributes[14]
107#define searchbox_border_attr attributes[15]
108#define position_indicator_attr attributes[16]
109#define menubox_attr attributes[17]
110#define menubox_border_attr attributes[18]
111#define item_attr attributes[19]
112#define item_selected_attr attributes[20]
113#define tag_attr attributes[21]
114#define tag_selected_attr attributes[22]
115#define tag_key_attr attributes[23]
116#define tag_key_selected_attr attributes[24]
117#define check_attr attributes[25]
118#define check_selected_attr attributes[26]
119#define uarrow_attr attributes[27]
120#define darrow_attr attributes[28]
121
122/* number of attributes */
123#define ATTRIBUTE_COUNT 29
124
125extern chtype attributes[];
126
127#ifdef HAVE_NCURSES
128extern bool use_shadow;
129void draw_shadow(WINDOW *win, int y, int x, int height, int width);
130#endif
131void draw_box(WINDOW *win, int y, int x, int height, int width, chtype box, chtype border);
132int line_edit(WINDOW *dialog, int box_y, int box_x, int flen, int box_width, chtype attrs, int first, unsigned char *result, int attr_mask);
133int strheight(const char *p);
134int strwidth(const char *p);
135
136void dialog_create_rc(unsigned char *filename);
137int dialog_yesno(unsigned char *title, unsigned char *prompt, int height, int width);
138int dialog_noyes(unsigned char *title, unsigned char *prompt, int height, int width);
139int dialog_prgbox(unsigned char *title, const unsigned char *line, int height, int width, int pause, int use_shell);
140int dialog_msgbox(unsigned char *title, unsigned char *prompt, int height, int width, int pause);
141int dialog_textbox(unsigned char *title, unsigned char *file, int height, int width);
142int dialog_menu(unsigned char *title, unsigned char *prompt, int height, int width, int menu_height,
143 int item_no, void *itptr, unsigned char *result, int *ch, int *sc);
144int dialog_checklist(unsigned char *title, unsigned char *prompt, int height, int width, int list_height,
145 int item_no, void *itptr, unsigned char *result);
146int dialog_radiolist(unsigned char *title, unsigned char *prompt, int height, int width, int list_height,
147 int item_no, void *itptr, unsigned char *result);
148int dialog_inputbox(unsigned char *title, unsigned char *prompt, int height, int width, unsigned char *result);
149void dialog_clear_norefresh(void);
150void dialog_clear(void);
151void dialog_update(void);
152void init_dialog(void);
153void end_dialog(void);
154
155/* Additions to libdialog */
156char *dialog_fselect(char *dir, char *fmask);
157int dialog_dselect(char *dir, char *fmask);
158void dialog_notify(char *msg);
159int dialog_mesgbox(unsigned char *title, unsigned char *prompt, int height, int width);
160void use_helpfile(char *helpfile);
161void use_helpline(char *helpline);
162char *get_helpline(void);
163void restore_helpline(char *helpline);
164void dialog_gauge(char *title, char *prompt, int y, int x, int height, int width, int perc);
165
166/*
167 * Display a tree menu from file
168 *
169 * filename - file with like find(1) output
170 * FS - fields separator
171 * title - title of dialog box
172 * prompt - prompt text into dialog box
173 * height - height of dialog box
174 * width - width of dialog box
175 * menu_height - height of menu box
176 * result - pointer to char array
177 *
178 * return values:
179 * -1 - ESC pressed
180 * 0 - Ok, result set (must be freed later)
181 * 1 - Cancel
182 */
183int dialog_ftree(unsigned char *filename, unsigned char FS,
184 unsigned char *title, unsigned char *prompt,
185 int height, int width, int menu_height,
186 unsigned char **result);
187
188/*
189 * Display a tree menu from array
190 *
191 * names - array with like find(1) output
192 * size - size of array
193 * FS - fields separator
194 * title - title of dialog box
195 * prompt - prompt text into dialog box
196 * height - height of dialog box
197 * width - width of dialog box
198 * menu_height - height of menu box
199 * result - pointer to char array
200 *
201 * return values:
202 * -1 - ESC pressed
203 * 0 - Ok, result set
204 * 1 - Cancel
205 */
206
207int dialog_tree(unsigned char **names, int size, unsigned char FS,
208 unsigned char *title, unsigned char *prompt,
209 int height, int width, int menu_height,
210 unsigned char **result);
211
212#endif /* _DIALOG_H_INCLUDE */