]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - form/fld_current.c
ncurses 5.6 - patch 20081004
[ncurses.git] / form / fld_current.c
index f4b308adcb9b01ddb19847f3c9b08f533da0d4d5..7c3a90af511d97a1c0fddacbf6236ad493183ca2 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2003,2004 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            *
 
 #include "form.priv.h"
 
-MODULE_ID("$Id: fld_current.c,v 1.7 2003/10/25 15:17:08 tom Exp $")
+MODULE_ID("$Id: fld_current.c,v 1.11 2004/12/25 22:40:13 tom Exp $")
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  int set_current_field(FORM  * form,FIELD * field)
-|   
+|
 |   Description   :  Set the current field of the form to the specified one.
 |
 |   Return Values :  E_OK              - success
@@ -48,46 +48,53 @@ MODULE_ID("$Id: fld_current.c,v 1.7 2003/10/25 15:17:08 tom Exp $")
 |                    E_SYSTEM_ERROR    - system error
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(int)
-set_current_field (FORM  * form, FIELD * field)
+set_current_field(FORM *form, FIELD *field)
 {
   int err = E_OK;
 
-  if ( !form || !field )
-    RETURN(E_BAD_ARGUMENT);
-
-  if ( (form != field->form) || Field_Is_Not_Selectable(field) )
-    RETURN(E_REQUEST_DENIED);
-
-  if (!(form->status & _POSTED))
+  T((T_CALLED("set_current_field(%p,%p)"), form, field));
+  if (form == 0 || field == 0)
+    {
+      RETURN(E_BAD_ARGUMENT);
+    }
+  else if ((form != field->form) || Field_Is_Not_Selectable(field))
+    {
+      RETURN(E_REQUEST_DENIED);
+    }
+  else if ((form->status & _POSTED) == 0)
     {
       form->current = field;
       form->curpage = field->page;
-  }
+    }
   else
     {
-      if (form->status & _IN_DRIVER) 
-       err = E_BAD_STATE;
+      if ((form->status & _IN_DRIVER) != 0)
+       {
+         err = E_BAD_STATE;
+       }
       else
        {
          if (form->current != field)
            {
-             if (!_nc_Internal_Validation(form)) 
-              err = E_INVALID_FIELD;
+             if (!_nc_Internal_Validation(form))
+               {
+                 err = E_INVALID_FIELD;
+               }
              else
                {
-                 Call_Hook(form,fieldterm);
+                 Call_Hook(form, fieldterm);
                  if (field->page != form->curpage)
                    {
-                     Call_Hook(form,formterm);
-                     err = _nc_Set_Form_Page(form,field->page,field);
-                     Call_Hook(form,forminit);
-                   } 
-                 else 
+                     Call_Hook(form, formterm);
+                     err = _nc_Set_Form_Page(form, (int)field->page, field);
+                     Call_Hook(form, forminit);
+                   }
+                 else
                    {
-                     err = _nc_Set_Current_Field(form,field);
+                     err = _nc_Set_Current_Field(form, field);
                    }
-                 Call_Hook(form,fieldinit);
-                 _nc_Refresh_Current_Field(form);
+                 Call_Hook(form, fieldinit);
+                 (void)_nc_Refresh_Current_Field(form);
                }
            }
        }
@@ -96,23 +103,24 @@ set_current_field (FORM  * form, FIELD * field)
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  FIELD *current_field(const FORM * form)
-|   
+|
 |   Description   :  Return the current field.
 |
 |   Return Values :  Pointer to the current field.
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(FIELD *)
-current_field (const FORM * form)
+current_field(const FORM *form)
 {
-  return Normalize_Form(form)->current;
+  T((T_CALLED("current_field(%p)"), form));
+  returnField(Normalize_Form(form)->current);
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  int field_index(const FIELD * field)
-|   
+|
 |   Description   :  Return the index of the field in the field-array of
 |                    the form.
 |
@@ -120,9 +128,10 @@ current_field (const FORM * form)
 |                    -1     : fieldpointer invalid or field not connected
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(int)
-field_index (const FIELD * field)
+field_index(const FIELD *field)
 {
-  return ( (field && field->form) ? field->index : -1 );
+  T((T_CALLED("field_index(%p)"), field));
+  returnCode((field != 0 && field->form != 0) ? (int)field->index : -1);
 }
 
 /* fld_current.c ends here */