kconfig/lxdialog/dialog.h
author Arnaud Lacombe <lacombar@gmail.com>
Tue Aug 03 06:17:51 2010 +0200 (2010-08-03)
changeset 2064 f5ebe8c429dc
parent 1 eeea35fbf182
permissions -rw-r--r--
libc/uClibc: add uClibc 0.9.30.3

This version has been released a couple of month ago, but it never reached
crosstool-ng tree. This may be linked to the fact that the current 0.9.30.2,
once patched, has nothing much different from 0.9.30.3, released.

I'm not including any patch with this upgrade, on purpose.

Signed-off-by: Arnaud Lacombe <lacombar@gmail.com>
yann@1
     1
/*
yann@1
     2
 *  dialog.h -- common declarations for all dialog modules
yann@1
     3
 *
yann@1
     4
 *  AUTHOR: Savio Lam (lam836@cs.cuhk.hk)
yann@1
     5
 *
yann@1
     6
 *  This program is free software; you can redistribute it and/or
yann@1
     7
 *  modify it under the terms of the GNU General Public License
yann@1
     8
 *  as published by the Free Software Foundation; either version 2
yann@1
     9
 *  of the License, or (at your option) any later version.
yann@1
    10
 *
yann@1
    11
 *  This program is distributed in the hope that it will be useful,
yann@1
    12
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
yann@1
    13
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
yann@1
    14
 *  GNU General Public License for more details.
yann@1
    15
 *
yann@1
    16
 *  You should have received a copy of the GNU General Public License
yann@1
    17
 *  along with this program; if not, write to the Free Software
yann@1
    18
 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
yann@1
    19
 */
yann@1
    20
yann@1
    21
#include <sys/types.h>
yann@1
    22
#include <fcntl.h>
yann@1
    23
#include <unistd.h>
yann@1
    24
#include <ctype.h>
yann@1
    25
#include <stdlib.h>
yann@1
    26
#include <string.h>
yann@1
    27
#include <stdbool.h>
yann@1
    28
yann@943
    29
#ifndef KBUILD_NO_NLS
yann@943
    30
# include <libintl.h>
yann@943
    31
#else
yann@943
    32
# define gettext(Msgid) ((const char *) (Msgid))
yann@943
    33
#endif
yann@943
    34
yann@1
    35
#ifdef __sun__
yann@1
    36
#define CURS_MACROS
yann@1
    37
#endif
yann@1
    38
#include CURSES_LOC
yann@1
    39
yann@1
    40
/*
yann@1
    41
 * Colors in ncurses 1.9.9e do not work properly since foreground and
yann@1
    42
 * background colors are OR'd rather than separately masked.  This version
yann@1
    43
 * of dialog was hacked to work with ncurses 1.9.9e, making it incompatible
yann@1
    44
 * with standard curses.  The simplest fix (to make this work with standard
yann@1
    45
 * curses) uses the wbkgdset() function, not used in the original hack.
yann@1
    46
 * Turn it off if we're building with 1.9.9e, since it just confuses things.
yann@1
    47
 */
yann@1
    48
#if defined(NCURSES_VERSION) && defined(_NEED_WRAP) && !defined(GCC_PRINTFLIKE)
yann@1
    49
#define OLD_NCURSES 1
yann@1
    50
#undef  wbkgdset
yann@1
    51
#define wbkgdset(w,p)		/*nothing */
yann@1
    52
#else
yann@1
    53
#define OLD_NCURSES 0
yann@1
    54
#endif
yann@1
    55
yann@1
    56
#define TR(params) _tracef params
yann@1
    57
yann@1
    58
#define KEY_ESC 27
yann@1
    59
#define TAB 9
yann@1
    60
#define MAX_LEN 2048
yann@1
    61
#define BUF_SIZE (10*1024)
yann@1
    62
#define MIN(x,y) (x < y ? x : y)
yann@1
    63
#define MAX(x,y) (x > y ? x : y)
yann@1
    64
yann@1
    65
#ifndef ACS_ULCORNER
yann@1
    66
#define ACS_ULCORNER '+'
yann@1
    67
#endif
yann@1
    68
#ifndef ACS_LLCORNER
yann@1
    69
#define ACS_LLCORNER '+'
yann@1
    70
#endif
yann@1
    71
#ifndef ACS_URCORNER
yann@1
    72
#define ACS_URCORNER '+'
yann@1
    73
#endif
yann@1
    74
#ifndef ACS_LRCORNER
yann@1
    75
#define ACS_LRCORNER '+'
yann@1
    76
#endif
yann@1
    77
#ifndef ACS_HLINE
yann@1
    78
#define ACS_HLINE '-'
yann@1
    79
#endif
yann@1
    80
#ifndef ACS_VLINE
yann@1
    81
#define ACS_VLINE '|'
yann@1
    82
#endif
yann@1
    83
#ifndef ACS_LTEE
yann@1
    84
#define ACS_LTEE '+'
yann@1
    85
#endif
yann@1
    86
#ifndef ACS_RTEE
yann@1
    87
#define ACS_RTEE '+'
yann@1
    88
#endif
yann@1
    89
#ifndef ACS_UARROW
yann@1
    90
#define ACS_UARROW '^'
yann@1
    91
#endif
yann@1
    92
#ifndef ACS_DARROW
yann@1
    93
#define ACS_DARROW 'v'
yann@1
    94
#endif
yann@1
    95
yann@1
    96
/* error return codes */
yann@1
    97
#define ERRDISPLAYTOOSMALL (KEY_MAX + 1)
yann@1
    98
yann@1
    99
/*
yann@1
   100
 *   Color definitions
yann@1
   101
 */
yann@1
   102
struct dialog_color {
yann@1
   103
	chtype atr;	/* Color attribute */
yann@1
   104
	int fg;		/* foreground */
yann@1
   105
	int bg;		/* background */
yann@1
   106
	int hl;		/* highlight this item */
yann@1
   107
};
yann@1
   108
yann@1
   109
struct dialog_info {
yann@1
   110
	const char *backtitle;
yann@1
   111
	struct dialog_color screen;
yann@1
   112
	struct dialog_color shadow;
yann@1
   113
	struct dialog_color dialog;
yann@1
   114
	struct dialog_color title;
yann@1
   115
	struct dialog_color border;
yann@1
   116
	struct dialog_color button_active;
yann@1
   117
	struct dialog_color button_inactive;
yann@1
   118
	struct dialog_color button_key_active;
yann@1
   119
	struct dialog_color button_key_inactive;
yann@1
   120
	struct dialog_color button_label_active;
yann@1
   121
	struct dialog_color button_label_inactive;
yann@1
   122
	struct dialog_color inputbox;
yann@1
   123
	struct dialog_color inputbox_border;
yann@1
   124
	struct dialog_color searchbox;
yann@1
   125
	struct dialog_color searchbox_title;
yann@1
   126
	struct dialog_color searchbox_border;
yann@1
   127
	struct dialog_color position_indicator;
yann@1
   128
	struct dialog_color menubox;
yann@1
   129
	struct dialog_color menubox_border;
yann@1
   130
	struct dialog_color item;
yann@1
   131
	struct dialog_color item_selected;
yann@1
   132
	struct dialog_color tag;
yann@1
   133
	struct dialog_color tag_selected;
yann@1
   134
	struct dialog_color tag_key;
yann@1
   135
	struct dialog_color tag_key_selected;
yann@1
   136
	struct dialog_color check;
yann@1
   137
	struct dialog_color check_selected;
yann@1
   138
	struct dialog_color uarrow;
yann@1
   139
	struct dialog_color darrow;
yann@1
   140
};
yann@1
   141
yann@1
   142
/*
yann@1
   143
 * Global variables
yann@1
   144
 */
yann@1
   145
extern struct dialog_info dlg;
yann@1
   146
extern char dialog_input_result[];
yann@1
   147
yann@1
   148
/*
yann@1
   149
 * Function prototypes
yann@1
   150
 */
yann@1
   151
yann@1
   152
/* item list as used by checklist and menubox */
yann@1
   153
void item_reset(void);
yann@1
   154
void item_make(const char *fmt, ...);
yann@1
   155
void item_add_str(const char *fmt, ...);
yann@1
   156
void item_set_tag(char tag);
yann@1
   157
void item_set_data(void *p);
yann@1
   158
void item_set_selected(int val);
yann@1
   159
int item_activate_selected(void);
yann@1
   160
void *item_data(void);
yann@1
   161
char item_tag(void);
yann@1
   162
yann@1
   163
/* item list manipulation for lxdialog use */
yann@1
   164
#define MAXITEMSTR 200
yann@1
   165
struct dialog_item {
yann@1
   166
	char str[MAXITEMSTR];	/* promtp displayed */
yann@1
   167
	char tag;
yann@1
   168
	void *data;	/* pointer to menu item - used by menubox+checklist */
yann@1
   169
	int selected;	/* Set to 1 by dialog_*() function if selected. */
yann@1
   170
};
yann@1
   171
yann@1
   172
/* list of lialog_items */
yann@1
   173
struct dialog_list {
yann@1
   174
	struct dialog_item node;
yann@1
   175
	struct dialog_list *next;
yann@1
   176
};
yann@1
   177
yann@1
   178
extern struct dialog_list *item_cur;
yann@1
   179
extern struct dialog_list item_nil;
yann@1
   180
extern struct dialog_list *item_head;
yann@1
   181
yann@1
   182
int item_count(void);
yann@1
   183
void item_set(int n);
yann@1
   184
int item_n(void);
yann@1
   185
const char *item_str(void);
yann@1
   186
int item_is_selected(void);
yann@1
   187
int item_is_tag(char tag);
yann@1
   188
#define item_foreach() \
yann@1
   189
	for (item_cur = item_head ? item_head: item_cur; \
yann@1
   190
	     item_cur && (item_cur != &item_nil); item_cur = item_cur->next)
yann@1
   191
yann@1
   192
/* generic key handlers */
yann@1
   193
int on_key_esc(WINDOW *win);
yann@1
   194
int on_key_resize(void);
yann@1
   195
yann@943
   196
int init_dialog(const char *backtitle);
yann@943
   197
void set_dialog_backtitle(const char *backtitle);
yann@943
   198
void end_dialog(int x, int y);
yann@1
   199
void attr_clear(WINDOW * win, int height, int width, chtype attr);
yann@1
   200
void dialog_clear(void);
yann@1
   201
void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x);
yann@1
   202
void print_button(WINDOW * win, const char *label, int y, int x, int selected);
yann@1
   203
void print_title(WINDOW *dialog, const char *title, int width);
yann@1
   204
void draw_box(WINDOW * win, int y, int x, int height, int width, chtype box,
yann@1
   205
	      chtype border);
yann@1
   206
void draw_shadow(WINDOW * win, int y, int x, int height, int width);
yann@1
   207
yann@1
   208
int first_alpha(const char *string, const char *exempt);
yann@1
   209
int dialog_yesno(const char *title, const char *prompt, int height, int width);
yann@1
   210
int dialog_msgbox(const char *title, const char *prompt, int height,
yann@1
   211
		  int width, int pause);
yann@1
   212
int dialog_textbox(const char *title, const char *file, int height, int width);
yann@1
   213
int dialog_menu(const char *title, const char *prompt,
yann@1
   214
		const void *selected, int *s_scroll);
yann@1
   215
int dialog_checklist(const char *title, const char *prompt, int height,
yann@1
   216
		     int width, int list_height);
yann@1
   217
extern char dialog_input_result[];
yann@1
   218
int dialog_inputbox(const char *title, const char *prompt, int height,
yann@1
   219
		    int width, const char *init);
yann@1
   220
yann@1
   221
/*
yann@1
   222
 * This is the base for fictitious keys, which activate
yann@1
   223
 * the buttons.
yann@1
   224
 *
yann@1
   225
 * Mouse-generated keys are the following:
yann@1
   226
 *   -- the first 32 are used as numbers, in addition to '0'-'9'
yann@1
   227
 *   -- the lowercase are used to signal mouse-enter events (M_EVENT + 'o')
yann@1
   228
 *   -- uppercase chars are used to invoke the button (M_EVENT + 'O')
yann@1
   229
 */
yann@1
   230
#define M_EVENT (KEY_MAX+1)