]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - form/form.priv.h
ncurses 6.0 - patch 20160910
[ncurses.git] / form / form.priv.h
index b43f35c2cc48eb5a71f27880a42375e2fa4cca13..625fc1073c0e9688eaa4a8d4ee10ff99820ee488 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
 /****************************************************************************
- * Copyright (c) 1998-2004,2005 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2014,2015 Free Software Foundation, Inc.              *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
  *   Author:  Juergen Pfeifer, 1995,1997                                    *
  ****************************************************************************/
 
  *   Author:  Juergen Pfeifer, 1995,1997                                    *
  ****************************************************************************/
 
-/* $Id: form.priv.h,v 0.25 2005/03/05 23:47:26 tom Exp $ */
+/* $Id: form.priv.h,v 0.39 2015/11/28 20:13:39 Leon.Winter Exp $ */
 
 #ifndef FORM_PRIV_H
 #define FORM_PRIV_H 1
 
 #ifndef FORM_PRIV_H
 #define FORM_PRIV_H 1
-
+/* *INDENT-OFF*/
 #include "curses.priv.h"
 #include "mf_common.h"
 
 #if USE_WIDEC_SUPPORT
 #include "curses.priv.h"
 #include "mf_common.h"
 
 #if USE_WIDEC_SUPPORT
-#include <wchar.h>
+#if HAVE_WCTYPE_H
 #include <wctype.h>
 #include <wctype.h>
+#endif
 
 #ifndef MB_LEN_MAX
 #define MB_LEN_MAX 8 /* should be >= MB_CUR_MAX, but that may be a function */
 
 #ifndef MB_LEN_MAX
 #define MB_LEN_MAX 8 /* should be >= MB_CUR_MAX, but that may be a function */
 
 #include "form.h"
 
 
 #include "form.h"
 
+       /***********************
+       *   Default objects    *
+       ***********************/
+extern NCURSES_EXPORT_VAR(FORM *)      _nc_Default_Form;
+extern NCURSES_EXPORT_VAR(FIELD *)     _nc_Default_Field;
+extern NCURSES_EXPORT_VAR(FIELDTYPE *) _nc_Default_FieldType;
+
 /* form  status values */
 #define _OVLMODE         (0x04U) /* Form is in overlay mode                */
 #define _WINDOW_MODIFIED (0x10U) /* Current field window has been modified */
 /* form  status values */
 #define _OVLMODE         (0x04U) /* Form is in overlay mode                */
 #define _WINDOW_MODIFIED (0x10U) /* Current field window has been modified */
@@ -77,6 +85,7 @@
 #define _HAS_ARGS        (0x02U) /* Type has arguments                     */
 #define _HAS_CHOICE      (0x04U) /* Type has choice methods                */
 #define _RESIDENT        (0x08U) /* Type is built-in                       */
 #define _HAS_ARGS        (0x02U) /* Type has arguments                     */
 #define _HAS_CHOICE      (0x04U) /* Type has choice methods                */
 #define _RESIDENT        (0x08U) /* Type is built-in                       */
+#define _GENERIC         (0x10U) /* A generic field type                   */
 
 /* This are the field options required to be a selectable field in field
    navigation requests */
 
 /* This are the field options required to be a selectable field in field
    navigation requests */
 #define Normalize_Field(field) \
   ((field) = (field != 0) ? (field) : _nc_Default_Field)
 
 #define Normalize_Field(field) \
   ((field) = (field != 0) ? (field) : _nc_Default_Field)
 
+#if NCURSES_SP_FUNCS
+#define Get_Form_Screen(form) \
+  ((form)->win ? _nc_screen_of((form->win)):CURRENT_SCREEN)
+#else
+#define Get_Form_Screen(form) CURRENT_SCREEN
+#endif
+
 /* Retrieve forms window */
 #define Get_Form_Window(form) \
 /* Retrieve forms window */
 #define Get_Form_Window(form) \
-  ((form)->sub?(form)->sub:((form)->win?(form)->win:stdscr))
+  ((form)->sub \
+   ? (form)->sub \
+   : ((form)->win \
+      ? (form)->win \
+      : StdScreen(Get_Form_Screen(form))))
 
 /* Calculate the size for a single buffer for this field */
 #define Buffer_Length(field) ((field)->drows * (field)->dcols)
 
 /* Calculate the total size of all buffers for this field */
 #define Total_Buffer_Size(field) \
 
 /* Calculate the size for a single buffer for this field */
 #define Buffer_Length(field) ((field)->drows * (field)->dcols)
 
 /* Calculate the total size of all buffers for this field */
 #define Total_Buffer_Size(field) \
-   ( (Buffer_Length(field) + 1) * (1+(field)->nbuf) * sizeof(FIELD_CELL) )
+   ( (size_t)(Buffer_Length(field) + 1) * (size_t)(1+(field)->nbuf) * sizeof(FIELD_CELL) )
 
 /* Logic to determine whether or not a field is single lined */
 #define Single_Line_Field(field) \
    (((field)->rows + (field)->nrow) == 1)
 
 
 /* Logic to determine whether or not a field is single lined */
 #define Single_Line_Field(field) \
    (((field)->rows + (field)->nrow) == 1)
 
+#define Field_Has_Option(f,o)      ((((unsigned)(f)->opts) & o) != 0)
+
 /* Logic to determine whether or not a field is selectable */
 #define Field_Is_Selectable(f)     (((unsigned)((f)->opts) & O_SELECTABLE)==O_SELECTABLE)
 #define Field_Is_Not_Selectable(f) (((unsigned)((f)->opts) & O_SELECTABLE)!=O_SELECTABLE)
 /* Logic to determine whether or not a field is selectable */
 #define Field_Is_Selectable(f)     (((unsigned)((f)->opts) & O_SELECTABLE)==O_SELECTABLE)
 #define Field_Is_Not_Selectable(f) (((unsigned)((f)->opts) & O_SELECTABLE)!=O_SELECTABLE)
@@ -126,7 +148,7 @@ TypeArgument;
                        O_NL_OVERLOAD  |\
                        O_BS_OVERLOAD   )
 
                        O_NL_OVERLOAD  |\
                        O_BS_OVERLOAD   )
 
-#define ALL_FIELD_OPTS (Field_Options)( \
+#define STD_FIELD_OPTS (Field_Options)( \
                        O_VISIBLE |\
                        O_ACTIVE  |\
                        O_PUBLIC  |\
                        O_VISIBLE |\
                        O_ACTIVE  |\
                        O_PUBLIC  |\
@@ -136,15 +158,18 @@ TypeArgument;
                        O_AUTOSKIP|\
                        O_NULLOK  |\
                        O_PASSOK  |\
                        O_AUTOSKIP|\
                        O_NULLOK  |\
                        O_PASSOK  |\
-                       O_STATIC   )
+                       O_STATIC)
+
+#define ALL_FIELD_OPTS (Field_Options)( \
+                       STD_FIELD_OPTS |\
+                       O_DYNAMIC_JUSTIFY |\
+                       O_NO_LEFT_STRIP)
 
 #define C_BLANK ' '
 #define is_blank(c) ((c)==C_BLANK)
 
 #define C_ZEROS '\0'
 
 
 #define C_BLANK ' '
 #define is_blank(c) ((c)==C_BLANK)
 
 #define C_ZEROS '\0'
 
-extern NCURSES_EXPORT_VAR(const FIELDTYPE *) _nc_Default_FieldType;
-
 extern NCURSES_EXPORT(TypeArgument *) _nc_Make_Argument (const FIELDTYPE*, va_list*, int*);
 extern NCURSES_EXPORT(TypeArgument *) _nc_Copy_Argument (const FIELDTYPE*, const TypeArgument*, int*);
 extern NCURSES_EXPORT(void) _nc_Free_Argument (const FIELDTYPE*, TypeArgument*);
 extern NCURSES_EXPORT(TypeArgument *) _nc_Make_Argument (const FIELDTYPE*, va_list*, int*);
 extern NCURSES_EXPORT(TypeArgument *) _nc_Copy_Argument (const FIELDTYPE*, const TypeArgument*, int*);
 extern NCURSES_EXPORT(void) _nc_Free_Argument (const FIELDTYPE*, TypeArgument*);
@@ -160,23 +185,53 @@ extern NCURSES_EXPORT(bool) _nc_Internal_Validation (FORM*);
 extern NCURSES_EXPORT(int) _nc_Set_Current_Field (FORM*, FIELD*);
 extern NCURSES_EXPORT(int) _nc_Position_Form_Cursor (FORM*);
 
 extern NCURSES_EXPORT(int) _nc_Set_Current_Field (FORM*, FIELD*);
 extern NCURSES_EXPORT(int) _nc_Position_Form_Cursor (FORM*);
 
+#if NCURSES_INTEROP_FUNCS
+extern NCURSES_EXPORT(FIELDTYPE *) _nc_TYPE_INTEGER(void);
+extern NCURSES_EXPORT(FIELDTYPE *) _nc_TYPE_ALNUM(void);
+extern NCURSES_EXPORT(FIELDTYPE *) _nc_TYPE_ALPHA(void);
+extern NCURSES_EXPORT(FIELDTYPE *) _nc_TYPE_ENUM(void);
+extern NCURSES_EXPORT(FIELDTYPE *) _nc_TYPE_NUMERIC(void);
+extern NCURSES_EXPORT(FIELDTYPE *) _nc_TYPE_REGEXP(void);
+extern NCURSES_EXPORT(FIELDTYPE *) _nc_TYPE_IPV4(void);
+
+extern NCURSES_EXPORT(FIELDTYPE *)
+_nc_generic_fieldtype(bool (*const field_check) (FORM*, 
+                                                FIELD *, 
+                                                const void *),
+                     bool (*const char_check)  (int, 
+                                                FORM*, 
+                                                FIELD*, 
+                                                const void *),
+                     bool (*const next)(FORM*,FIELD*,const void*),
+                     bool (*const prev)(FORM*,FIELD*,const void*),
+                     void (*freecallback)(void*));
+extern NCURSES_EXPORT(int) _nc_set_generic_fieldtype(FIELD*, FIELDTYPE*, int (*)(void**));
+extern NCURSES_EXPORT(WINDOW*) _nc_form_cursor(const FORM* , int* , int* );
+
+#define INIT_FT_FUNC(func) {func}
+#else
+#define INIT_FT_FUNC(func) func
+#endif
+
+extern NCURSES_EXPORT(void) _nc_get_fieldbuffer(FORM*, FIELD*, FIELD_CELL*);
+
 #if USE_WIDEC_SUPPORT
 extern NCURSES_EXPORT(wchar_t *) _nc_Widen_String(char *, int *);
 #endif
 
 #ifdef TRACE
 
 #if USE_WIDEC_SUPPORT
 extern NCURSES_EXPORT(wchar_t *) _nc_Widen_String(char *, int *);
 #endif
 
 #ifdef TRACE
 
-#define returnField(code)      TRACE_RETURN(code,field)
-#define returnFieldPtr(code)   TRACE_RETURN(code,field_ptr)
-#define returnForm(code)       TRACE_RETURN(code,form)
-#define returnFieldType(code)  TRACE_RETURN(code,field_type)
-#define returnFormHook(code)   TRACE_RETURN(code,form_hook)
+#define returnField(code)      TRACE_RETURN1(code,field)
+#define returnFieldPtr(code)   TRACE_RETURN1(code,field_ptr)
+#define returnForm(code)       TRACE_RETURN1(code,form)
+#define returnFieldType(code)  TRACE_RETURN1(code,field_type)
+#define returnFormHook(code)   TRACE_RETURN1(code,form_hook)
 
 extern NCURSES_EXPORT(FIELD **)            _nc_retrace_field_ptr (FIELD **);
 extern NCURSES_EXPORT(FIELD *)     _nc_retrace_field (FIELD *);
 extern NCURSES_EXPORT(FIELDTYPE *)  _nc_retrace_field_type (FIELDTYPE *);
 
 extern NCURSES_EXPORT(FIELD **)            _nc_retrace_field_ptr (FIELD **);
 extern NCURSES_EXPORT(FIELD *)     _nc_retrace_field (FIELD *);
 extern NCURSES_EXPORT(FIELDTYPE *)  _nc_retrace_field_type (FIELDTYPE *);
-extern NCURSES_EXPORT(FORM *)  _nc_retrace_form (FORM *);
-extern NCURSES_EXPORT(Form_Hook)  _nc_retrace_form_hook (Form_Hook);
+extern NCURSES_EXPORT(FORM *)       _nc_retrace_form (FORM *);
+extern NCURSES_EXPORT(Form_Hook)    _nc_retrace_form_hook (Form_Hook);
 
 #else /* !TRACE */
 
 
 #else /* !TRACE */
 
@@ -245,5 +300,6 @@ extern NCURSES_EXPORT(Form_Hook)  _nc_retrace_form_hook (Form_Hook);
       result = ((*buffer || (l < width)) ? FALSE : TRUE); \
     }
 #endif
       result = ((*buffer || (l < width)) ? FALSE : TRUE); \
     }
 #endif
+/* *INDENT-ON*/
 
 #endif /* FORM_PRIV_H */
 
 #endif /* FORM_PRIV_H */