00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #ifndef FORM_PRIV_H
00036 #define FORM_PRIV_H 1
00037
00038 #include "curses.priv.h"
00039 #include "mf_common.h"
00040
00041 #if USE_WIDEC_SUPPORT
00042 #include <wchar.h>
00043 #include <wctype.h>
00044
00045 #ifndef MB_LEN_MAX
00046 #define MB_LEN_MAX 8
00047 #endif
00048
00049 #define FIELD_CELL NCURSES_CH_T
00050
00051 #define NCURSES_FIELD_INTERNALS char** expanded; WINDOW *working;
00052 #define NCURSES_FIELD_EXTENSION , (char **)0, (WINDOW *)0
00053
00054 #else
00055
00056 #define FIELD_CELL char
00057
00058 #define NCURSES_FIELD_EXTENSION
00059
00060 #endif
00061
00062 #include "form.h"
00063
00064
00065 #define _OVLMODE (0x04U)
00066 #define _WINDOW_MODIFIED (0x10U)
00067 #define _FCHECK_REQUIRED (0x20U)
00068
00069
00070 #define _CHANGED (0x01U)
00071 #define _NEWTOP (0x02U)
00072 #define _NEWPAGE (0x04U)
00073 #define _MAY_GROW (0x08U)
00074
00075
00076 #define _LINKED_TYPE (0x01U)
00077 #define _HAS_ARGS (0x02U)
00078 #define _HAS_CHOICE (0x04U)
00079 #define _RESIDENT (0x08U)
00080
00081
00082
00083 #define O_SELECTABLE (O_ACTIVE | O_VISIBLE)
00084
00085
00086 #define Normalize_Form(form) \
00087 ((form) = (form != 0) ? (form) : _nc_Default_Form)
00088
00089
00090 #define Normalize_Field(field) \
00091 ((field) = (field != 0) ? (field) : _nc_Default_Field)
00092
00093
00094 #define Get_Form_Window(form) \
00095 ((form)->sub?(form)->sub:((form)->win?(form)->win:stdscr))
00096
00097
00098 #define Buffer_Length(field) ((field)->drows * (field)->dcols)
00099
00100
00101 #define Total_Buffer_Size(field) \
00102 ( (Buffer_Length(field) + 1) * (1+(field)->nbuf) * sizeof(FIELD_CELL) )
00103
00104
00105 #define Single_Line_Field(field) \
00106 (((field)->rows + (field)->nrow) == 1)
00107
00108
00109 #define Field_Is_Selectable(f) (((unsigned)((f)->opts) & O_SELECTABLE)==O_SELECTABLE)
00110 #define Field_Is_Not_Selectable(f) (((unsigned)((f)->opts) & O_SELECTABLE)!=O_SELECTABLE)
00111
00112 typedef struct typearg
00113 {
00114 struct typearg *left;
00115 struct typearg *right;
00116 }
00117 TypeArgument;
00118
00119
00120
00121
00122
00123 #define FIRST_ACTIVE_MAGIC (-291056)
00124
00125 #define ALL_FORM_OPTS ( \
00126 O_NL_OVERLOAD |\
00127 O_BS_OVERLOAD )
00128
00129 #define ALL_FIELD_OPTS (Field_Options)( \
00130 O_VISIBLE |\
00131 O_ACTIVE |\
00132 O_PUBLIC |\
00133 O_EDIT |\
00134 O_WRAP |\
00135 O_BLANK |\
00136 O_AUTOSKIP|\
00137 O_NULLOK |\
00138 O_PASSOK |\
00139 O_STATIC )
00140
00141 #define C_BLANK ' '
00142 #define is_blank(c) ((c)==C_BLANK)
00143
00144 #define C_ZEROS '\0'
00145
00146 extern NCURSES_EXPORT_VAR(const FIELDTYPE *) _nc_Default_FieldType;
00147
00148 extern NCURSES_EXPORT(TypeArgument *) _nc_Make_Argument (const FIELDTYPE*, va_list*, int*);
00149 extern NCURSES_EXPORT(TypeArgument *) _nc_Copy_Argument (const FIELDTYPE*, const TypeArgument*, int*);
00150 extern NCURSES_EXPORT(void) _nc_Free_Argument (const FIELDTYPE*, TypeArgument*);
00151 extern NCURSES_EXPORT(bool) _nc_Copy_Type (FIELD*, FIELD const *);
00152 extern NCURSES_EXPORT(void) _nc_Free_Type (FIELD *);
00153
00154 extern NCURSES_EXPORT(int) _nc_Synchronize_Attributes (FIELD*);
00155 extern NCURSES_EXPORT(int) _nc_Synchronize_Options (FIELD*, Field_Options);
00156 extern NCURSES_EXPORT(int) _nc_Set_Form_Page (FORM*, int, FIELD*);
00157 extern NCURSES_EXPORT(int) _nc_Refresh_Current_Field (FORM*);
00158 extern NCURSES_EXPORT(FIELD *) _nc_First_Active_Field (FORM*);
00159 extern NCURSES_EXPORT(bool) _nc_Internal_Validation (FORM*);
00160 extern NCURSES_EXPORT(int) _nc_Set_Current_Field (FORM*, FIELD*);
00161 extern NCURSES_EXPORT(int) _nc_Position_Form_Cursor (FORM*);
00162
00163 #if USE_WIDEC_SUPPORT
00164 extern NCURSES_EXPORT(wchar_t *) _nc_Widen_String(char *, int *);
00165 #endif
00166
00167 #ifdef TRACE
00168
00169 #define returnField(code) TRACE_RETURN(code,field)
00170 #define returnFieldPtr(code) TRACE_RETURN(code,field_ptr)
00171 #define returnForm(code) TRACE_RETURN(code,form)
00172 #define returnFieldType(code) TRACE_RETURN(code,field_type)
00173 #define returnFormHook(code) TRACE_RETURN(code,form_hook)
00174
00175 extern NCURSES_EXPORT(FIELD **) _nc_retrace_field_ptr (FIELD **);
00176 extern NCURSES_EXPORT(FIELD *) _nc_retrace_field (FIELD *);
00177 extern NCURSES_EXPORT(FIELDTYPE *) _nc_retrace_field_type (FIELDTYPE *);
00178 extern NCURSES_EXPORT(FORM *) _nc_retrace_form (FORM *);
00179 extern NCURSES_EXPORT(Form_Hook) _nc_retrace_form_hook (Form_Hook);
00180
00181 #else
00182
00183 #define returnFieldPtr(code) return code
00184 #define returnFieldType(code) return code
00185 #define returnField(code) return code
00186 #define returnForm(code) return code
00187 #define returnFormHook(code) return code
00188
00189 #endif
00190
00191
00192
00193
00194
00195 #if USE_WIDEC_SUPPORT
00196 #define Check_CTYPE_Field(result, buffer, width, ccheck) \
00197 while (*buffer && *buffer == ' ') \
00198 buffer++; \
00199 if (*buffer) \
00200 { \
00201 bool blank = FALSE; \
00202 int len; \
00203 int n; \
00204 wchar_t *list = _nc_Widen_String((char *)buffer, &len); \
00205 if (list != 0) \
00206 { \
00207 result = TRUE; \
00208 for (n = 0; n < len; ++n) \
00209 { \
00210 if (blank) \
00211 { \
00212 if (list[n] != ' ') \
00213 { \
00214 result = FALSE; \
00215 break; \
00216 } \
00217 } \
00218 else if (list[n] == ' ') \
00219 { \
00220 blank = TRUE; \
00221 result = (n + 1 >= width); \
00222 } \
00223 else if (!ccheck(list[n], NULL)) \
00224 { \
00225 result = FALSE; \
00226 break; \
00227 } \
00228 } \
00229 free(list); \
00230 } \
00231 }
00232 #else
00233 #define Check_CTYPE_Field(result, buffer, width, ccheck) \
00234 while (*buffer && *buffer == ' ') \
00235 buffer++; \
00236 if (*buffer) \
00237 { \
00238 unsigned char *s = buffer; \
00239 int l = -1; \
00240 while (*buffer && ccheck(*buffer, NULL)) \
00241 buffer++; \
00242 l = (int)(buffer - s); \
00243 while (*buffer && *buffer == ' ') \
00244 buffer++; \
00245 result = ((*buffer || (l < width)) ? FALSE : TRUE); \
00246 }
00247 #endif
00248
00249 #endif