X-Git-Url: http://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=form%2Ffrm_def.c;h=89ae4ec39c54ef5f70857098c3c412aa895a0fa7;hp=fd7b56a421c5f017c6330ea549135aa8a94da785;hb=HEAD;hpb=ba39fbc2e0cee4681395df4079d9e61c27262132 diff --git a/form/frm_def.c b/form/frm_def.c index fd7b56a4..a9f21f28 100644 --- a/form/frm_def.c +++ b/form/frm_def.c @@ -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 * @@ -32,7 +33,7 @@ #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 = @@ -61,14 +62,14 @@ static FORM default_form = NULL /* fieldterm */ }; -NCURSES_EXPORT_VAR(FORM *) _nc_Default_Form = &default_form; - +FORM_EXPORT_VAR(FORM *) _nc_Default_Form = &default_form; + /*--------------------------------------------------------------------------- -| Facility : libnform +| Facility : libnform | Function : static FIELD *Insert_Field_By_Position( -| FIELD *new_field, +| FIELD *new_field, | 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. @@ -112,9 +113,9 @@ Insert_Field_By_Position(FIELD *newfield, FIELD *head) } /*--------------------------------------------------------------------------- -| Facility : libnform +| Facility : libnform | Function : static void Disconnect_Fields(FORM *form) -| +| | 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) -| +| | 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 maximum_row_in_field, maximum_col_in_field; _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++) { + int maximum_row_in_field; + int maximum_col_in_field; + if (j == 0) - pg->pmin = (short) j; + pg->pmin = (short)j; else { if (fields[j]->status & _NEWPAGE) { - pg->pmax = (short) (j - 1); + pg->pmax = (short)(j - 1); 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) - form->rows = (short) maximum_row_in_field; + form->rows = (short)maximum_row_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++) @@ -230,8 +233,8 @@ Connect_Fields(FORM *form, FIELD **fields) 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) @@ -249,10 +252,10 @@ Connect_Fields(FORM *form, FIELD **fields) } /*--------------------------------------------------------------------------- -| Facility : libnform +| Facility : libnform | 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 @@ -282,9 +285,9 @@ Associate_Fields(FORM *form, FIELD **fields) } /*--------------------------------------------------------------------------- -| Facility : libnform +| Facility : libnform | 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. @@ -294,7 +297,7 @@ Associate_Fields(FORM *form, FIELD **fields) | 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; @@ -330,9 +333,9 @@ NCURSES_SP_NAME(new_form) (NCURSES_SP_DCLx FIELD **fields) } /*--------------------------------------------------------------------------- -| Facility : libnform +| Facility : libnform | Function : FORM* new_form(FIELD** fields ) -| +| | 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 -NCURSES_EXPORT(FORM *) +FORM_EXPORT(FORM *) new_form(FIELD **fields) { return NCURSES_SP_NAME(new_form) (CURRENT_SCREEN, fields); @@ -351,16 +354,16 @@ new_form(FIELD **fields) #endif /*--------------------------------------------------------------------------- -| Facility : libnform +| Facility : libnform | 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 +--------------------------------------------------------------------------*/ -NCURSES_EXPORT(int) +FORM_EXPORT(int) 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 ) -| +| | 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 +--------------------------------------------------------------------------*/ -NCURSES_EXPORT(int) +FORM_EXPORT(int) 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 ) -| +| | 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)); @@ -430,14 +433,14 @@ form_fields(const FORM *form) } /*--------------------------------------------------------------------------- -| Facility : libnform +| Facility : libnform | Function : int field_count( const FORM *form ) -| +| | 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));