| 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_PRIV_H |
| 36 |
#define FORM_PRIV_H 1 |
| 37 |
|
| 38 |
#include "curspriv.h" |
| 39 |
#include "mf_common.h" |
| 40 |
|
| 41 |
#define UChar(c) ((unsigned char)(c)) |
| 42 |
|
| 43 |
#if USE_WIDEC_SUPPORT |
| 44 |
#if HAVE_WCTYPE_H |
| 45 |
#include <wctype.h> |
| 46 |
#endif |
| 47 |
|
| 48 |
#ifndef MB_LEN_MAX |
| 49 |
#define MB_LEN_MAX 8 |
| 50 |
#endif |
| 51 |
|
| 52 |
#define FIELD_CELL NCURSES_CH_T |
| 53 |
|
| 54 |
#define NCURSES_FIELD_INTERNALS char** expanded; WINDOW *working; |
| 55 |
#define NCURSES_FIELD_EXTENSION , (char **)0, (WINDOW *)0 |
| 56 |
|
| 57 |
#else |
| 58 |
|
| 59 |
#define FIELD_CELL char |
| 60 |
|
| 61 |
#define NCURSES_FIELD_EXTENSION |
| 62 |
|
| 63 |
#endif |
| 64 |
|
| 65 |
#include "form.h" |
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
extern NCURSES_EXPORT_VAR(FORM *) _nc_Default_Form; |
| 71 |
extern NCURSES_EXPORT_VAR(FIELD *) _nc_Default_Field; |
| 72 |
extern NCURSES_EXPORT_VAR(FIELDTYPE *) _nc_Default_FieldType; |
| 73 |
|
| 74 |
|
| 75 |
#define _OVLMODE (0x04U) |
| 76 |
#define _WINDOW_MODIFIED (0x10U) |
| 77 |
#define _FCHECK_REQUIRED (0x20U) |
| 78 |
|
| 79 |
|
| 80 |
#define _CHANGED (0x01U) |
| 81 |
#define _NEWTOP (0x02U) |
| 82 |
#define _NEWPAGE (0x04U) |
| 83 |
#define _MAY_GROW (0x08U) |
| 84 |
|
| 85 |
|
| 86 |
#define _LINKED_TYPE (0x01U) |
| 87 |
#define _HAS_ARGS (0x02U) |
| 88 |
#define _HAS_CHOICE (0x04U) |
| 89 |
#define _RESIDENT (0x08U) |
| 90 |
#define _GENERIC (0x10U) |
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
#define O_SELECTABLE (O_ACTIVE | O_VISIBLE) |
| 95 |
|
| 96 |
|
| 97 |
#define Normalize_Form(form) \ |
| 98 |
((form) = (form != 0) ? (form) : _nc_Default_Form) |
| 99 |
|
| 100 |
|
| 101 |
#define Normalize_Field(field) \ |
| 102 |
((field) = (field != 0) ? (field) : _nc_Default_Field) |
| 103 |
|
| 104 |
#if NCURSES_SP_FUNCS |
| 105 |
#define Get_Form_Screen(form) \ |
| 106 |
((form)->win ? _nc_screen_of((form->win)):CURRENT_SCREEN) |
| 107 |
#else |
| 108 |
#define Get_Form_Screen(form) CURRENT_SCREEN |
| 109 |
#endif |
| 110 |
|
| 111 |
|
| 112 |
#define Get_Form_Window(form) \ |
| 113 |
((form)->sub != NULL \ |
| 114 |
? (form)->sub \ |
| 115 |
: ((form)->win != NULL \ |
| 116 |
? (form)->win \ |
| 117 |
: StdScreen(Get_Form_Screen(form)))) |
| 118 |
|
| 119 |
|
| 120 |
#define Buffer_Length(field) ((field)->drows * (field)->dcols) |
| 121 |
|
| 122 |
|
| 123 |
#define Total_Buffer_Size(field) \ |
| 124 |
( (Buffer_Length(field) + 1) * (1+(field)->nbuf) * sizeof(FIELD_CELL) ) |
| 125 |
|
| 126 |
|
| 127 |
#define Single_Line_Field(field) \ |
| 128 |
(((field)->rows + (field)->nrow) == 1) |
| 129 |
|
| 130 |
|
| 131 |
#define Field_Is_Selectable(f) (((unsigned)((f)->opts) & O_SELECTABLE)==O_SELECTABLE) |
| 132 |
#define Field_Is_Not_Selectable(f) (((unsigned)((f)->opts) & O_SELECTABLE)!=O_SELECTABLE) |
| 133 |
|
| 134 |
typedef struct typearg |
| 135 |
{ |
| 136 |
struct typearg *left; |
| 137 |
struct typearg *right; |
| 138 |
} |
| 139 |
TypeArgument; |
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
|
| 144 |
|
| 145 |
#define FIRST_ACTIVE_MAGIC (-291056) |
| 146 |
|
| 147 |
#define ALL_FORM_OPTS ( \ |
| 148 |
O_NL_OVERLOAD |\ |
| 149 |
O_BS_OVERLOAD ) |
| 150 |
|
| 151 |
#define ALL_FIELD_OPTS (Field_Options)( \ |
| 152 |
O_VISIBLE |\ |
| 153 |
O_ACTIVE |\ |
| 154 |
O_PUBLIC |\ |
| 155 |
O_EDIT |\ |
| 156 |
O_WRAP |\ |
| 157 |
O_BLANK |\ |
| 158 |
O_AUTOSKIP|\ |
| 159 |
O_NULLOK |\ |
| 160 |
O_PASSOK |\ |
| 161 |
O_STATIC ) |
| 162 |
|
| 163 |
#define C_BLANK ' ' |
| 164 |
#define is_blank(c) ((c)==C_BLANK) |
| 165 |
|
| 166 |
#define C_ZEROS '\0' |
| 167 |
|
| 168 |
extern NCURSES_EXPORT(TypeArgument *) _nc_Make_Argument (const FIELDTYPE*, va_list*, int*); |
| 169 |
extern NCURSES_EXPORT(TypeArgument *) _nc_Copy_Argument (const FIELDTYPE*, const TypeArgument*, int*); |
| 170 |
extern NCURSES_EXPORT(void) _nc_Free_Argument (const FIELDTYPE*, TypeArgument*); |
| 171 |
extern NCURSES_EXPORT(bool) _nc_Copy_Type (FIELD*, FIELD const *); |
| 172 |
extern NCURSES_EXPORT(void) _nc_Free_Type (FIELD *); |
| 173 |
|
| 174 |
extern NCURSES_EXPORT(int) _nc_Synchronize_Attributes (FIELD*); |
| 175 |
extern NCURSES_EXPORT(int) _nc_Synchronize_Options (FIELD*, Field_Options); |
| 176 |
extern NCURSES_EXPORT(int) _nc_Set_Form_Page (FORM*, int, FIELD*); |
| 177 |
extern NCURSES_EXPORT(int) _nc_Refresh_Current_Field (FORM*); |
| 178 |
extern NCURSES_EXPORT(FIELD *) _nc_First_Active_Field (FORM*); |
| 179 |
extern NCURSES_EXPORT(bool) _nc_Internal_Validation (FORM*); |
| 180 |
extern NCURSES_EXPORT(int) _nc_Set_Current_Field (FORM*, FIELD*); |
| 181 |
extern NCURSES_EXPORT(int) _nc_Position_Form_Cursor (FORM*); |
| 182 |
|
| 183 |
#if NCURSES_INTEROP_FUNCS |
| 184 |
extern NCURSES_EXPORT(FIELDTYPE *) _nc_TYPE_INTEGER(void); |
| 185 |
extern NCURSES_EXPORT(FIELDTYPE *) _nc_TYPE_ALNUM(void); |
| 186 |
extern NCURSES_EXPORT(FIELDTYPE *) _nc_TYPE_ALPHA(void); |
| 187 |
extern NCURSES_EXPORT(FIELDTYPE *) _nc_TYPE_ENUM(void); |
| 188 |
extern NCURSES_EXPORT(FIELDTYPE *) _nc_TYPE_NUMERIC(void); |
| 189 |
extern NCURSES_EXPORT(FIELDTYPE *) _nc_TYPE_REGEXP(void); |
| 190 |
extern NCURSES_EXPORT(FIELDTYPE *) _nc_TYPE_IPV4(void); |
| 191 |
|
| 192 |
extern NCURSES_EXPORT(FIELDTYPE *) |
| 193 |
_nc_generic_fieldtype(bool (*const field_check) (FORM*, |
| 194 |
FIELD *, |
| 195 |
const void *), |
| 196 |
bool (*const char_check) (int, |
| 197 |
FORM*, |
| 198 |
FIELD*, |
| 199 |
const void *), |
| 200 |
bool (*const next)(FORM*,FIELD*,const void*), |
| 201 |
bool (*const prev)(FORM*,FIELD*,const void*), |
| 202 |
void (*freecallback)(void*)); |
| 203 |
extern NCURSES_EXPORT(int) _nc_set_generic_fieldtype(FIELD*, FIELDTYPE*, int (*)(void**)); |
| 204 |
extern NCURSES_EXPORT(WINDOW*) _nc_form_cursor(const FORM* , int* , int* ); |
| 205 |
|
| 206 |
#define INIT_FT_FUNC(func) {func} |
| 207 |
#else |
| 208 |
#define INIT_FT_FUNC(func) func |
| 209 |
#endif |
| 210 |
|
| 211 |
extern NCURSES_EXPORT(void) _nc_get_fieldbuffer(FORM*, FIELD*, FIELD_CELL*); |
| 212 |
|
| 213 |
#if USE_WIDEC_SUPPORT |
| 214 |
extern NCURSES_EXPORT(wchar_t *) _nc_Widen_String(char *, int *); |
| 215 |
#endif |
| 216 |
|
| 217 |
#ifdef TRACE |
| 218 |
|
| 219 |
#define returnField(code) TRACE_RETURN(code,field) |
| 220 |
#define returnFieldPtr(code) TRACE_RETURN(code,field_ptr) |
| 221 |
#define returnForm(code) TRACE_RETURN(code,form) |
| 222 |
#define returnFieldType(code) TRACE_RETURN(code,field_type) |
| 223 |
#define returnFormHook(code) TRACE_RETURN(code,form_hook) |
| 224 |
|
| 225 |
extern NCURSES_EXPORT(FIELD **) _nc_retrace_field_ptr (FIELD **); |
| 226 |
extern NCURSES_EXPORT(FIELD *) _nc_retrace_field (FIELD *); |
| 227 |
extern NCURSES_EXPORT(FIELDTYPE *) _nc_retrace_field_type (FIELDTYPE *); |
| 228 |
extern NCURSES_EXPORT(FORM *) _nc_retrace_form (FORM *); |
| 229 |
extern NCURSES_EXPORT(Form_Hook) _nc_retrace_form_hook (Form_Hook); |
| 230 |
|
| 231 |
#else |
| 232 |
|
| 233 |
#define returnFieldPtr(code) return code |
| 234 |
#define returnFieldType(code) return code |
| 235 |
#define returnField(code) return code |
| 236 |
#define returnForm(code) return code |
| 237 |
#define returnFormHook(code) return code |
| 238 |
|
| 239 |
#endif |
| 240 |
|
| 241 |
|
| 242 |
|
| 243 |
|
| 244 |
|
| 245 |
#if USE_WIDEC_SUPPORT |
| 246 |
#define Check_CTYPE_Field(result, buffer, width, ccheck) \ |
| 247 |
while (*buffer && *buffer == ' ') \ |
| 248 |
buffer++; \ |
| 249 |
if (*buffer) \ |
| 250 |
{ \ |
| 251 |
bool blank = FALSE; \ |
| 252 |
int len; \ |
| 253 |
int n; \ |
| 254 |
wchar_t *list = _nc_Widen_String((char *)buffer, &len); \ |
| 255 |
if (list != 0) \ |
| 256 |
{ \ |
| 257 |
result = TRUE; \ |
| 258 |
for (n = 0; n < len; ++n) \ |
| 259 |
{ \ |
| 260 |
if (blank) \ |
| 261 |
{ \ |
| 262 |
if (list[n] != ' ') \ |
| 263 |
{ \ |
| 264 |
result = FALSE; \ |
| 265 |
break; \ |
| 266 |
} \ |
| 267 |
} \ |
| 268 |
else if (list[n] == ' ') \ |
| 269 |
{ \ |
| 270 |
blank = TRUE; \ |
| 271 |
result = (n + 1 >= width); \ |
| 272 |
} \ |
| 273 |
else if (!ccheck(list[n], NULL)) \ |
| 274 |
{ \ |
| 275 |
result = FALSE; \ |
| 276 |
break; \ |
| 277 |
} \ |
| 278 |
} \ |
| 279 |
free(list); \ |
| 280 |
} \ |
| 281 |
} |
| 282 |
#else |
| 283 |
#define Check_CTYPE_Field(result, buffer, width, ccheck) \ |
| 284 |
while (*buffer && *buffer == ' ') \ |
| 285 |
buffer++; \ |
| 286 |
if (*buffer) \ |
| 287 |
{ \ |
| 288 |
unsigned char *s = buffer; \ |
| 289 |
int l = -1; \ |
| 290 |
while (*buffer && ccheck(*buffer, NULL)) \ |
| 291 |
buffer++; \ |
| 292 |
l = (int)(buffer - s); \ |
| 293 |
while (*buffer && *buffer == ' ') \ |
| 294 |
buffer++; \ |
| 295 |
result = ((*buffer || (l < width)) ? FALSE : TRUE); \ |
| 296 |
} |
| 297 |
#endif |
| 298 |
|
| 299 |
#endif |