| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
#ifndef FORM_H |
| 36 |
#define FORM_H |
| 37 |
|
| 38 |
#include <curses.h> |
| 39 |
#include <eti.h> |
| 40 |
#include <ncurses_cfg.h> |
| 41 |
|
| 42 |
#ifdef __cplusplus |
| 43 |
extern "C" { |
| 44 |
#endif |
| 45 |
|
| 46 |
#ifndef FORM_PRIV_H |
| 47 |
typedef void *FIELD_CELL; |
| 48 |
#endif |
| 49 |
|
| 50 |
#ifndef NCURSES_FIELD_INTERNALS |
| 51 |
#define NCURSES_FIELD_INTERNALS |
| 52 |
#endif |
| 53 |
|
| 54 |
typedef int Form_Options; |
| 55 |
typedef int Field_Options; |
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
typedef struct { |
| 62 |
short pmin; |
| 63 |
short pmax; |
| 64 |
short smin; |
| 65 |
short smax; |
| 66 |
} _PAGE; |
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
typedef struct fieldnode { |
| 73 |
unsigned short status; |
| 74 |
short rows; |
| 75 |
short cols; |
| 76 |
short frow; |
| 77 |
short fcol; |
| 78 |
int drows; |
| 79 |
int dcols; |
| 80 |
int maxgrow; |
| 81 |
int nrow; |
| 82 |
short nbuf; |
| 83 |
short just; |
| 84 |
short page; |
| 85 |
short index; |
| 86 |
int pad; |
| 87 |
chtype fore; |
| 88 |
chtype back; |
| 89 |
Field_Options opts; |
| 90 |
struct fieldnode * snext; |
| 91 |
struct fieldnode * sprev; |
| 92 |
struct fieldnode * link; |
| 93 |
struct formnode * form; |
| 94 |
struct typenode * type; |
| 95 |
void * arg; |
| 96 |
FIELD_CELL * buf; |
| 97 |
void * usrptr; |
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
NCURSES_FIELD_INTERNALS |
| 107 |
} FIELD; |
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
typedef struct formnode { |
| 114 |
unsigned short status; |
| 115 |
short rows; |
| 116 |
short cols; |
| 117 |
int currow; |
| 118 |
int curcol; |
| 119 |
int toprow; |
| 120 |
int begincol; |
| 121 |
short maxfield; |
| 122 |
short maxpage; |
| 123 |
short curpage; |
| 124 |
Form_Options opts; |
| 125 |
WINDOW * win; |
| 126 |
WINDOW * sub; |
| 127 |
WINDOW * w; |
| 128 |
FIELD ** field; |
| 129 |
FIELD * current; |
| 130 |
_PAGE * page; |
| 131 |
void * usrptr; |
| 132 |
|
| 133 |
void (*forminit)(struct formnode *); |
| 134 |
void (*formterm)(struct formnode *); |
| 135 |
void (*fieldinit)(struct formnode *); |
| 136 |
void (*fieldterm)(struct formnode *); |
| 137 |
|
| 138 |
} FORM; |
| 139 |
|
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
|
| 144 |
typedef struct typenode { |
| 145 |
unsigned short status; |
| 146 |
long ref; |
| 147 |
struct typenode * left; |
| 148 |
struct typenode * right; |
| 149 |
|
| 150 |
void* (*makearg)(va_list *); |
| 151 |
void* (*copyarg)(const void *); |
| 152 |
void (*freearg)(void *); |
| 153 |
|
| 154 |
#if NCURSES_INTEROP_FUNCS |
| 155 |
union { |
| 156 |
bool (*ofcheck)(FIELD *,const void *); |
| 157 |
bool (*gfcheck)(FORM*,FIELD *,const void*); |
| 158 |
} fieldcheck; |
| 159 |
union { |
| 160 |
bool (*occheck)(int,const void *); |
| 161 |
bool (*gccheck)(int,FORM*, |
| 162 |
FIELD*,const void*); |
| 163 |
} charcheck; |
| 164 |
union { |
| 165 |
bool (*onext)(FIELD *,const void *); |
| 166 |
bool (*gnext)(FORM*,FIELD*,const void*); |
| 167 |
} enum_next; |
| 168 |
union { |
| 169 |
bool (*oprev)(FIELD *,const void *); |
| 170 |
bool (*gprev)(FORM*,FIELD*,const void*); |
| 171 |
} enum_prev; |
| 172 |
void* (*genericarg)(void*); |
| 173 |
#else |
| 174 |
bool (*fcheck)(FIELD *,const void *); |
| 175 |
bool (*ccheck)(int,const void *); |
| 176 |
|
| 177 |
bool (*next)(FIELD *,const void *); |
| 178 |
bool (*prev)(FIELD *,const void *); |
| 179 |
#endif |
| 180 |
} FIELDTYPE; |
| 181 |
|
| 182 |
typedef void (*Form_Hook)(FORM *); |
| 183 |
|
| 184 |
|
| 185 |
|
| 186 |
|
| 187 |
|
| 188 |
|
| 189 |
#define NO_JUSTIFICATION (0) |
| 190 |
#define JUSTIFY_LEFT (1) |
| 191 |
#define JUSTIFY_CENTER (2) |
| 192 |
#define JUSTIFY_RIGHT (3) |
| 193 |
|
| 194 |
|
| 195 |
#define O_VISIBLE (0x0001U) |
| 196 |
#define O_ACTIVE (0x0002U) |
| 197 |
#define O_PUBLIC (0x0004U) |
| 198 |
#define O_EDIT (0x0008U) |
| 199 |
#define O_WRAP (0x0010U) |
| 200 |
#define O_BLANK (0x0020U) |
| 201 |
#define O_AUTOSKIP (0x0040U) |
| 202 |
#define O_NULLOK (0x0080U) |
| 203 |
#define O_PASSOK (0x0100U) |
| 204 |
#define O_STATIC (0x0200U) |
| 205 |
|
| 206 |
|
| 207 |
#define O_NL_OVERLOAD (0x0001U) |
| 208 |
#define O_BS_OVERLOAD (0x0002U) |
| 209 |
|
| 210 |
|
| 211 |
#define REQ_NEXT_PAGE (KEY_MAX + 1) |
| 212 |
#define REQ_PREV_PAGE (KEY_MAX + 2) |
| 213 |
#define REQ_FIRST_PAGE (KEY_MAX + 3) |
| 214 |
#define REQ_LAST_PAGE (KEY_MAX + 4) |
| 215 |
|
| 216 |
#define REQ_NEXT_FIELD (KEY_MAX + 5) |
| 217 |
#define REQ_PREV_FIELD (KEY_MAX + 6) |
| 218 |
#define REQ_FIRST_FIELD (KEY_MAX + 7) |
| 219 |
#define REQ_LAST_FIELD (KEY_MAX + 8) |
| 220 |
#define REQ_SNEXT_FIELD (KEY_MAX + 9) |
| 221 |
#define REQ_SPREV_FIELD (KEY_MAX + 10) |
| 222 |
#define REQ_SFIRST_FIELD (KEY_MAX + 11) |
| 223 |
#define REQ_SLAST_FIELD (KEY_MAX + 12) |
| 224 |
#define REQ_LEFT_FIELD (KEY_MAX + 13) |
| 225 |
#define REQ_RIGHT_FIELD (KEY_MAX + 14) |
| 226 |
#define REQ_UP_FIELD (KEY_MAX + 15) |
| 227 |
#define REQ_DOWN_FIELD (KEY_MAX + 16) |
| 228 |
|
| 229 |
#define REQ_NEXT_CHAR (KEY_MAX + 17) |
| 230 |
#define REQ_PREV_CHAR (KEY_MAX + 18) |
| 231 |
#define REQ_NEXT_LINE (KEY_MAX + 19) |
| 232 |
#define REQ_PREV_LINE (KEY_MAX + 20) |
| 233 |
#define REQ_NEXT_WORD (KEY_MAX + 21) |
| 234 |
#define REQ_PREV_WORD (KEY_MAX + 22) |
| 235 |
#define REQ_BEG_FIELD (KEY_MAX + 23) |
| 236 |
#define REQ_END_FIELD (KEY_MAX + 24) |
| 237 |
#define REQ_BEG_LINE (KEY_MAX + 25) |
| 238 |
#define REQ_END_LINE (KEY_MAX + 26) |
| 239 |
#define REQ_LEFT_CHAR (KEY_MAX + 27) |
| 240 |
#define REQ_RIGHT_CHAR (KEY_MAX + 28) |
| 241 |
#define REQ_UP_CHAR (KEY_MAX + 29) |
| 242 |
#define REQ_DOWN_CHAR (KEY_MAX + 30) |
| 243 |
|
| 244 |
#define REQ_NEW_LINE (KEY_MAX + 31) |
| 245 |
#define REQ_INS_CHAR (KEY_MAX + 32) |
| 246 |
#define REQ_INS_LINE (KEY_MAX + 33) |
| 247 |
#define REQ_DEL_CHAR (KEY_MAX + 34) |
| 248 |
#define REQ_DEL_PREV (KEY_MAX + 35) |
| 249 |
#define REQ_DEL_LINE (KEY_MAX + 36) |
| 250 |
#define REQ_DEL_WORD (KEY_MAX + 37) |
| 251 |
#define REQ_CLR_EOL (KEY_MAX + 38) |
| 252 |
#define REQ_CLR_EOF (KEY_MAX + 39) |
| 253 |
#define REQ_CLR_FIELD (KEY_MAX + 40) |
| 254 |
#define REQ_OVL_MODE (KEY_MAX + 41) |
| 255 |
#define REQ_INS_MODE (KEY_MAX + 42) |
| 256 |
#define REQ_SCR_FLINE (KEY_MAX + 43) |
| 257 |
#define REQ_SCR_BLINE (KEY_MAX + 44) |
| 258 |
#define REQ_SCR_FPAGE (KEY_MAX + 45) |
| 259 |
#define REQ_SCR_BPAGE (KEY_MAX + 46) |
| 260 |
#define REQ_SCR_FHPAGE (KEY_MAX + 47) |
| 261 |
#define REQ_SCR_BHPAGE (KEY_MAX + 48) |
| 262 |
#define REQ_SCR_FCHAR (KEY_MAX + 49) |
| 263 |
#define REQ_SCR_BCHAR (KEY_MAX + 50) |
| 264 |
#define REQ_SCR_HFLINE (KEY_MAX + 51) |
| 265 |
#define REQ_SCR_HBLINE (KEY_MAX + 52) |
| 266 |
#define REQ_SCR_HFHALF (KEY_MAX + 53) |
| 267 |
#define REQ_SCR_HBHALF (KEY_MAX + 54) |
| 268 |
|
| 269 |
#define REQ_VALIDATION (KEY_MAX + 55) |
| 270 |
#define REQ_NEXT_CHOICE (KEY_MAX + 56) |
| 271 |
#define REQ_PREV_CHOICE (KEY_MAX + 57) |
| 272 |
|
| 273 |
#define MIN_FORM_COMMAND (KEY_MAX + 1) |
| 274 |
#define MAX_FORM_COMMAND (KEY_MAX + 57) |
| 275 |
|
| 276 |
#if defined(MAX_COMMAND) |
| 277 |
# if (MAX_FORM_COMMAND > MAX_COMMAND) |
| 278 |
# error Something is wrong -- MAX_FORM_COMMAND is greater than MAX_COMMAND |
| 279 |
# elif (MAX_COMMAND != (KEY_MAX + 128)) |
| 280 |
# error Something is wrong -- MAX_COMMAND is already inconsistently defined. |
| 281 |
# endif |
| 282 |
#else |
| 283 |
# define MAX_COMMAND (KEY_MAX + 128) |
| 284 |
#endif |
| 285 |
|
| 286 |
|
| 287 |
|
| 288 |
|
| 289 |
extern NCURSES_EXPORT_VAR(FIELDTYPE *) TYPE_ALPHA; |
| 290 |
extern NCURSES_EXPORT_VAR(FIELDTYPE *) TYPE_ALNUM; |
| 291 |
extern NCURSES_EXPORT_VAR(FIELDTYPE *) TYPE_ENUM; |
| 292 |
extern NCURSES_EXPORT_VAR(FIELDTYPE *) TYPE_INTEGER; |
| 293 |
extern NCURSES_EXPORT_VAR(FIELDTYPE *) TYPE_NUMERIC; |
| 294 |
extern NCURSES_EXPORT_VAR(FIELDTYPE *) TYPE_REGEXP; |
| 295 |
|
| 296 |
|
| 297 |
|
| 298 |
|
| 299 |
|
| 300 |
extern NCURSES_EXPORT_VAR(FIELDTYPE *) TYPE_IPV4; |
| 301 |
|
| 302 |
|
| 303 |
|
| 304 |
|
| 305 |
extern NCURSES_EXPORT(FIELDTYPE *) new_fieldtype ( |
| 306 |
bool (* const field_check)(FIELD *,const void *), |
| 307 |
bool (* const char_check)(int,const void *)); |
| 308 |
extern NCURSES_EXPORT(FIELDTYPE *) link_fieldtype( |
| 309 |
FIELDTYPE *, FIELDTYPE *); |
| 310 |
|
| 311 |
extern NCURSES_EXPORT(int) free_fieldtype (FIELDTYPE *); |
| 312 |
extern NCURSES_EXPORT(int) set_fieldtype_arg (FIELDTYPE *, |
| 313 |
void * (* const make_arg)(va_list *), |
| 314 |
void * (* const copy_arg)(const void *), |
| 315 |
void (* const free_arg)(void *)); |
| 316 |
extern NCURSES_EXPORT(int) set_fieldtype_choice (FIELDTYPE *, |
| 317 |
bool (* const next_choice)(FIELD *,const void *), |
| 318 |
bool (* const prev_choice)(FIELD *,const void *)); |
| 319 |
|
| 320 |
|
| 321 |
|
| 322 |
|
| 323 |
extern NCURSES_EXPORT(FIELD *) new_field (int,int,int,int,int,int); |
| 324 |
extern NCURSES_EXPORT(FIELD *) dup_field (FIELD *,int,int); |
| 325 |
extern NCURSES_EXPORT(FIELD *) link_field (FIELD *,int,int); |
| 326 |
|
| 327 |
extern NCURSES_EXPORT(int) free_field (FIELD *); |
| 328 |
extern NCURSES_EXPORT(int) field_info (const FIELD *,int *,int *,int *,int *,int *,int *); |
| 329 |
extern NCURSES_EXPORT(int) dynamic_field_info (const FIELD *,int *,int *,int *); |
| 330 |
extern NCURSES_EXPORT(int) set_max_field ( FIELD *,int); |
| 331 |
extern NCURSES_EXPORT(int) move_field (FIELD *,int,int); |
| 332 |
extern NCURSES_EXPORT(int) set_field_type (FIELD *,FIELDTYPE *,...); |
| 333 |
extern NCURSES_EXPORT(int) set_new_page (FIELD *,bool); |
| 334 |
extern NCURSES_EXPORT(int) set_field_just (FIELD *,int); |
| 335 |
extern NCURSES_EXPORT(int) field_just (const FIELD *); |
| 336 |
extern NCURSES_EXPORT(int) set_field_fore (FIELD *,chtype); |
| 337 |
extern NCURSES_EXPORT(int) set_field_back (FIELD *,chtype); |
| 338 |
extern NCURSES_EXPORT(int) set_field_pad (FIELD *,int); |
| 339 |
extern NCURSES_EXPORT(int) field_pad (const FIELD *); |
| 340 |
extern NCURSES_EXPORT(int) set_field_buffer (FIELD *,int,const char *); |
| 341 |
extern NCURSES_EXPORT(int) set_field_status (FIELD *,bool); |
| 342 |
extern NCURSES_EXPORT(int) set_field_userptr (FIELD *, void *); |
| 343 |
extern NCURSES_EXPORT(int) set_field_opts (FIELD *,Field_Options); |
| 344 |
extern NCURSES_EXPORT(int) field_opts_on (FIELD *,Field_Options); |
| 345 |
extern NCURSES_EXPORT(int) field_opts_off (FIELD *,Field_Options); |
| 346 |
|
| 347 |
extern NCURSES_EXPORT(chtype) field_fore (const FIELD *); |
| 348 |
extern NCURSES_EXPORT(chtype) field_back (const FIELD *); |
| 349 |
|
| 350 |
extern NCURSES_EXPORT(bool) new_page (const FIELD *); |
| 351 |
extern NCURSES_EXPORT(bool) field_status (const FIELD *); |
| 352 |
|
| 353 |
extern NCURSES_EXPORT(void *) field_arg (const FIELD *); |
| 354 |
|
| 355 |
extern NCURSES_EXPORT(void *) field_userptr (const FIELD *); |
| 356 |
|
| 357 |
extern NCURSES_EXPORT(FIELDTYPE *) field_type (const FIELD *); |
| 358 |
|
| 359 |
extern NCURSES_EXPORT(char *) field_buffer (const FIELD *,int); |
| 360 |
|
| 361 |
extern NCURSES_EXPORT(Field_Options) field_opts (const FIELD *); |
| 362 |
|
| 363 |
|
| 364 |
|
| 365 |
|
| 366 |
|
| 367 |
extern NCURSES_EXPORT(FORM *) new_form (FIELD **); |
| 368 |
|
| 369 |
extern NCURSES_EXPORT(FIELD **) form_fields (const FORM *); |
| 370 |
extern NCURSES_EXPORT(FIELD *) current_field (const FORM *); |
| 371 |
|
| 372 |
extern NCURSES_EXPORT(WINDOW *) form_win (const FORM *); |
| 373 |
extern NCURSES_EXPORT(WINDOW *) form_sub (const FORM *); |
| 374 |
|
| 375 |
extern NCURSES_EXPORT(Form_Hook) form_init (const FORM *); |
| 376 |
extern NCURSES_EXPORT(Form_Hook) form_term (const FORM *); |
| 377 |
extern NCURSES_EXPORT(Form_Hook) field_init (const FORM *); |
| 378 |
extern NCURSES_EXPORT(Form_Hook) field_term (const FORM *); |
| 379 |
|
| 380 |
extern NCURSES_EXPORT(int) free_form (FORM *); |
| 381 |
extern NCURSES_EXPORT(int) set_form_fields (FORM *,FIELD **); |
| 382 |
extern NCURSES_EXPORT(int) field_count (const FORM *); |
| 383 |
extern NCURSES_EXPORT(int) set_form_win (FORM *,WINDOW *); |
| 384 |
extern NCURSES_EXPORT(int) set_form_sub (FORM *,WINDOW *); |
| 385 |
extern NCURSES_EXPORT(int) set_current_field (FORM *,FIELD *); |
| 386 |
extern NCURSES_EXPORT(int) field_index (const FIELD *); |
| 387 |
extern NCURSES_EXPORT(int) set_form_page (FORM *,int); |
| 388 |
extern NCURSES_EXPORT(int) form_page (const FORM *); |
| 389 |
extern NCURSES_EXPORT(int) scale_form (const FORM *,int *,int *); |
| 390 |
extern NCURSES_EXPORT(int) set_form_init (FORM *,Form_Hook); |
| 391 |
extern NCURSES_EXPORT(int) set_form_term (FORM *,Form_Hook); |
| 392 |
extern NCURSES_EXPORT(int) set_field_init (FORM *,Form_Hook); |
| 393 |
extern NCURSES_EXPORT(int) set_field_term (FORM *,Form_Hook); |
| 394 |
extern NCURSES_EXPORT(int) post_form (FORM *); |
| 395 |
extern NCURSES_EXPORT(int) unpost_form (FORM *); |
| 396 |
extern NCURSES_EXPORT(int) pos_form_cursor (FORM *); |
| 397 |
extern NCURSES_EXPORT(int) form_driver (FORM *,int); |
| 398 |
extern NCURSES_EXPORT(int) set_form_userptr (FORM *,void *); |
| 399 |
extern NCURSES_EXPORT(int) set_form_opts (FORM *,Form_Options); |
| 400 |
extern NCURSES_EXPORT(int) form_opts_on (FORM *,Form_Options); |
| 401 |
extern NCURSES_EXPORT(int) form_opts_off (FORM *,Form_Options); |
| 402 |
extern NCURSES_EXPORT(int) form_request_by_name (const char *); |
| 403 |
|
| 404 |
extern NCURSES_EXPORT(const char *) form_request_name (int); |
| 405 |
|
| 406 |
extern NCURSES_EXPORT(void *) form_userptr (const FORM *); |
| 407 |
|
| 408 |
extern NCURSES_EXPORT(Form_Options) form_opts (const FORM *); |
| 409 |
|
| 410 |
extern NCURSES_EXPORT(bool) data_ahead (const FORM *); |
| 411 |
extern NCURSES_EXPORT(bool) data_behind (const FORM *); |
| 412 |
|
| 413 |
#if NCURSES_SP_FUNCS |
| 414 |
extern NCURSES_EXPORT(FORM *) NCURSES_SP_NAME(new_form) (SCREEN*, FIELD **); |
| 415 |
#endif |
| 416 |
|
| 417 |
#ifdef __cplusplus |
| 418 |
} |
| 419 |
#endif |
| 420 |
|
| 421 |
#endif |