]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - form/frm_def.c
ncurses 6.2 - patch 20210904
[ncurses.git] / form / frm_def.c
index fd7b56a421c5f017c6330ea549135aa8a94da785..a9f21f28a94464662904124db1e8bc8ee5fd6d2f 100644 (file)
@@ -1,5 +1,6 @@
 /****************************************************************************
 /****************************************************************************
- * Copyright (c) 1998-2010,2012 Free Software Foundation, Inc.              *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
+ * Copyright 1998-2010,2012 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            *
@@ -32,7 +33,7 @@
 
 #include "form.priv.h"
 
 
 #include "form.priv.h"
 
-MODULE_ID("$Id: frm_def.c,v 1.26 2012/03/11 00:37:16 tom Exp $")
+MODULE_ID("$Id: frm_def.c,v 1.30 2021/03/27 23:49:58 tom Exp $")
 
 /* this can't be readonly */
 static FORM default_form =
 
 /* this can't be readonly */
 static FORM default_form =
@@ -61,14 +62,14 @@ static FORM default_form =
   NULL                         /* fieldterm  */
 };
 
   NULL                         /* fieldterm  */
 };
 
-NCURSES_EXPORT_VAR(FORM *) _nc_Default_Form = &default_form;
-\f
+FORM_EXPORT_VAR(FORM *) _nc_Default_Form = &default_form;
+
 /*---------------------------------------------------------------------------
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static FIELD *Insert_Field_By_Position(
 |   Function      :  static FIELD *Insert_Field_By_Position(
-|                                     FIELD *new_field, 
+|                                     FIELD *new_field,
 |                                     FIELD *head )
 |                                     FIELD *head )
-|   
+|
 |   Description   :  Insert new_field into sorted fieldlist with head "head"
 |                    and return new head of sorted fieldlist. Sorting
 |                    criteria is (row,column). This is a circular list.
 |   Description   :  Insert new_field into sorted fieldlist with head "head"
 |                    and return new head of sorted fieldlist. Sorting
 |                    criteria is (row,column). This is a circular list.
@@ -112,9 +113,9 @@ Insert_Field_By_Position(FIELD *newfield, FIELD *head)
 }
 
 /*---------------------------------------------------------------------------
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static void Disconnect_Fields(FORM *form)
 |   Function      :  static void Disconnect_Fields(FORM *form)
-|   
+|
 |   Description   :  Break association between form and array of fields.
 |
 |   Return Values :  -
 |   Description   :  Break association between form and array of fields.
 |
 |   Return Values :  -
@@ -142,9 +143,9 @@ Disconnect_Fields(FORM *form)
 }
 
 /*---------------------------------------------------------------------------
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static int Connect_Fields(FORM *form, FIELD **fields)
 |   Function      :  static int Connect_Fields(FORM *form, FIELD **fields)
-|   
+|
 |   Description   :  Set association between form and array of fields.
 |
 |   Return Values :  E_OK            - no error
 |   Description   :  Set association between form and array of fields.
 |
 |   Return Values :  E_OK            - no error
@@ -157,7 +158,6 @@ Connect_Fields(FORM *form, FIELD **fields)
 {
   int field_cnt, j;
   int page_nr;
 {
   int field_cnt, j;
   int page_nr;
-  int maximum_row_in_field, maximum_col_in_field;
   _PAGE *pg;
 
   T((T_CALLED("Connect_Fields(%p,%p)"), (void *)form, (void *)fields));
   _PAGE *pg;
 
   T((T_CALLED("Connect_Fields(%p,%p)"), (void *)form, (void *)fields));
@@ -198,15 +198,18 @@ Connect_Fields(FORM *form, FIELD **fields)
      size of the form */
   for (j = 0; j < field_cnt; j++)
     {
      size of the form */
   for (j = 0; j < field_cnt; j++)
     {
+      int maximum_row_in_field;
+      int maximum_col_in_field;
+
       if (j == 0)
       if (j == 0)
-       pg->pmin = (short) j;
+       pg->pmin = (short)j;
       else
        {
          if (fields[j]->status & _NEWPAGE)
            {
       else
        {
          if (fields[j]->status & _NEWPAGE)
            {
-             pg->pmax = (short) (j - 1);
+             pg->pmax = (short)(j - 1);
              pg++;
              pg++;
-             pg->pmin = (short) j;
+             pg->pmin = (short)j;
            }
        }
 
            }
        }
 
@@ -214,14 +217,14 @@ Connect_Fields(FORM *form, FIELD **fields)
       maximum_col_in_field = fields[j]->fcol + fields[j]->cols;
 
       if (form->rows < maximum_row_in_field)
       maximum_col_in_field = fields[j]->fcol + fields[j]->cols;
 
       if (form->rows < maximum_row_in_field)
-       form->rows = (short) maximum_row_in_field;
+       form->rows = (short)maximum_row_in_field;
       if (form->cols < maximum_col_in_field)
       if (form->cols < maximum_col_in_field)
-       form->cols = (short) maximum_col_in_field;
+       form->cols = (short)maximum_col_in_field;
     }
 
     }
 
-  pg->pmax = (short) (field_cnt - 1);
-  form->maxfield = (short) field_cnt;
-  form->maxpage = (short) page_nr;
+  pg->pmax = (short)(field_cnt - 1);
+  form->maxfield = (short)field_cnt;
+  form->maxpage = (short)page_nr;
 
   /* Sort fields on form pages */
   for (page_nr = 0; page_nr < form->maxpage; page_nr++)
 
   /* Sort fields on form pages */
   for (page_nr = 0; page_nr < form->maxpage; page_nr++)
@@ -230,8 +233,8 @@ Connect_Fields(FORM *form, FIELD **fields)
 
       for (j = form->page[page_nr].pmin; j <= form->page[page_nr].pmax; j++)
        {
 
       for (j = form->page[page_nr].pmin; j <= form->page[page_nr].pmax; j++)
        {
-         fields[j]->index = (short) j;
-         fields[j]->page = (short) page_nr;
+         fields[j]->index = (short)j;
+         fields[j]->page = (short)page_nr;
          fld = Insert_Field_By_Position(fields[j], fld);
        }
       if (fld)
          fld = Insert_Field_By_Position(fields[j], fld);
        }
       if (fld)
@@ -249,10 +252,10 @@ Connect_Fields(FORM *form, FIELD **fields)
 }
 
 /*---------------------------------------------------------------------------
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static int Associate_Fields(FORM *form, FIELD **fields)
 |   Function      :  static int Associate_Fields(FORM *form, FIELD **fields)
-|   
-|   Description   :  Set association between form and array of fields. 
+|
+|   Description   :  Set association between form and array of fields.
 |                    If there are fields, position to first active field.
 |
 |   Return Values :  E_OK            - success
 |                    If there are fields, position to first active field.
 |
 |   Return Values :  E_OK            - success
@@ -282,9 +285,9 @@ Associate_Fields(FORM *form, FIELD **fields)
 }
 
 /*---------------------------------------------------------------------------
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  FORM *new_form_sp(SCREEN* sp, FIELD** fields )
 |   Function      :  FORM *new_form_sp(SCREEN* sp, FIELD** fields )
-|   
+|
 |   Description   :  Create new form with given array of fields.
 |
 |   Return Values :  Pointer to form. NULL if error occurred.
 |   Description   :  Create new form with given array of fields.
 |
 |   Return Values :  Pointer to form. NULL if error occurred.
@@ -294,7 +297,7 @@ Associate_Fields(FORM *form, FIELD **fields)
 |                    E_CONNECTED     - a field is already connected
 |                    E_SYSTEM_ERROR  - not enough memory
 +--------------------------------------------------------------------------*/
 |                    E_CONNECTED     - a field is already connected
 |                    E_SYSTEM_ERROR  - not enough memory
 +--------------------------------------------------------------------------*/
-NCURSES_EXPORT(FORM *)
+FORM_EXPORT(FORM *)
 NCURSES_SP_NAME(new_form) (NCURSES_SP_DCLx FIELD **fields)
 {
   int err = E_SYSTEM_ERROR;
 NCURSES_SP_NAME(new_form) (NCURSES_SP_DCLx FIELD **fields)
 {
   int err = E_SYSTEM_ERROR;
@@ -330,9 +333,9 @@ NCURSES_SP_NAME(new_form) (NCURSES_SP_DCLx FIELD **fields)
 }
 
 /*---------------------------------------------------------------------------
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  FORM* new_form(FIELD** fields )
 |   Function      :  FORM* new_form(FIELD** fields )
-|   
+|
 |   Description   :  Create new form with given array of fields.
 |
 |   Return Values :  Pointer to form. NULL if error occurred.
 |   Description   :  Create new form with given array of fields.
 |
 |   Return Values :  Pointer to form. NULL if error occurred.
@@ -343,7 +346,7 @@ NCURSES_SP_NAME(new_form) (NCURSES_SP_DCLx FIELD **fields)
 |                    E_SYSTEM_ERROR  - not enough memory
 +--------------------------------------------------------------------------*/
 #if NCURSES_SP_FUNCS
 |                    E_SYSTEM_ERROR  - not enough memory
 +--------------------------------------------------------------------------*/
 #if NCURSES_SP_FUNCS
-NCURSES_EXPORT(FORM *)
+FORM_EXPORT(FORM *)
 new_form(FIELD **fields)
 {
   return NCURSES_SP_NAME(new_form) (CURRENT_SCREEN, fields);
 new_form(FIELD **fields)
 {
   return NCURSES_SP_NAME(new_form) (CURRENT_SCREEN, fields);
@@ -351,16 +354,16 @@ new_form(FIELD **fields)
 #endif
 
 /*---------------------------------------------------------------------------
 #endif
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  int free_form( FORM *form )
 |   Function      :  int free_form( FORM *form )
-|   
+|
 |   Description   :  Release internal memory associated with form.
 |
 |   Return Values :  E_OK           - no error
 |                    E_BAD_ARGUMENT - invalid form pointer
 |                    E_POSTED       - form is posted
 +--------------------------------------------------------------------------*/
 |   Description   :  Release internal memory associated with form.
 |
 |   Return Values :  E_OK           - no error
 |                    E_BAD_ARGUMENT - invalid form pointer
 |                    E_POSTED       - form is posted
 +--------------------------------------------------------------------------*/
-NCURSES_EXPORT(int)
+FORM_EXPORT(int)
 free_form(FORM *form)
 {
   T((T_CALLED("free_form(%p)"), (void *)form));
 free_form(FORM *form)
 {
   T((T_CALLED("free_form(%p)"), (void *)form));
@@ -380,9 +383,9 @@ free_form(FORM *form)
 }
 
 /*---------------------------------------------------------------------------
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  int set_form_fields( FORM *form, FIELD **fields )
 |   Function      :  int set_form_fields( FORM *form, FIELD **fields )
-|   
+|
 |   Description   :  Set a new association of an array of fields to a form
 |
 |   Return Values :  E_OK            - no error
 |   Description   :  Set a new association of an array of fields to a form
 |
 |   Return Values :  E_OK            - no error
@@ -391,7 +394,7 @@ free_form(FORM *form)
 |                    E_POSTED        - form is posted
 |                    E_SYSTEM_ERROR  - not enough memory
 +--------------------------------------------------------------------------*/
 |                    E_POSTED        - form is posted
 |                    E_SYSTEM_ERROR  - not enough memory
 +--------------------------------------------------------------------------*/
-NCURSES_EXPORT(int)
+FORM_EXPORT(int)
 set_form_fields(FORM *form, FIELD **fields)
 {
   FIELD **old;
 set_form_fields(FORM *form, FIELD **fields)
 {
   FIELD **old;
@@ -415,14 +418,14 @@ set_form_fields(FORM *form, FIELD **fields)
 }
 
 /*---------------------------------------------------------------------------
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  FIELD **form_fields( const FORM *form )
 |   Function      :  FIELD **form_fields( const FORM *form )
-|   
+|
 |   Description   :  Retrieve array of fields
 |
 |   Return Values :  Pointer to field array
 +--------------------------------------------------------------------------*/
 |   Description   :  Retrieve array of fields
 |
 |   Return Values :  Pointer to field array
 +--------------------------------------------------------------------------*/
-NCURSES_EXPORT(FIELD **)
+FORM_EXPORT(FIELD **)
 form_fields(const FORM *form)
 {
   T((T_CALLED("form_field(%p)"), (const void *)form));
 form_fields(const FORM *form)
 {
   T((T_CALLED("form_field(%p)"), (const void *)form));
@@ -430,14 +433,14 @@ form_fields(const FORM *form)
 }
 
 /*---------------------------------------------------------------------------
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  int field_count( const FORM *form )
 |   Function      :  int field_count( const FORM *form )
-|   
+|
 |   Description   :  Retrieve number of fields
 |
 |   Return Values :  Number of fields, -1 if none are defined
 +--------------------------------------------------------------------------*/
 |   Description   :  Retrieve number of fields
 |
 |   Return Values :  Number of fields, -1 if none are defined
 +--------------------------------------------------------------------------*/
-NCURSES_EXPORT(int)
+FORM_EXPORT(int)
 field_count(const FORM *form)
 {
   T((T_CALLED("field_count(%p)"), (const void *)form));
 field_count(const FORM *form)
 {
   T((T_CALLED("field_count(%p)"), (const void *)form));