]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - form/frm_driver.c
ncurses 5.3
[ncurses.git] / form / frm_driver.c
index e609e191de2adfd4b09ba1df36b79e4fe3c3eee7..c9275f7e51625e0fea28eb7b0799aed67c9b5a13 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998 Free Software Foundation, Inc.                        *
+ * Copyright (c) 1998,2000 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            *
  ****************************************************************************/
 
 /****************************************************************************
- *   Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997            *
+ *   Author:  Juergen Pfeifer, 1995,1997                                    *
+ *   Contact: http://www.familiepfeifer.de/Contact.aspx?Lang=en             *
  ****************************************************************************/
 #include "form.priv.h"
 
-MODULE_ID("$Id: frm_driver.c,v 1.35 1999/05/16 17:20:52 juergen Exp $")
+MODULE_ID("$Id: frm_driver.c,v 1.39 2002/07/06 15:33:27 juergen Exp $")
 
 /*----------------------------------------------------------------------------
   This is the core module of the form library. It contains the majority
@@ -516,7 +517,8 @@ static bool Field_Grown(FIELD * field, int amount)
                  return FALSE;
                }
              assert(form!=(FORM *)0);
-             delwin(form->w);
+             if (form->w)
+               delwin(form->w);
              form->w = new_window;
              Set_Field_Window_Attributes(field,form->w);
              werase(form->w);
@@ -558,8 +560,8 @@ static bool Field_Grown(FIELD * field, int amount)
 |                    E_SYSTEM_ERROR    - form has no current field or
 |                                        field-window
 +--------------------------------------------------------------------------*/
-int
-_nc_Position_Form_Cursor(FORM * form)
+NCURSES_EXPORT(int)
+_nc_Position_Form_Cursor (FORM * form)
 {
   FIELD  *field;
   WINDOW *formwin;
@@ -599,8 +601,8 @@ _nc_Position_Form_Cursor(FORM * form)
 |                    E_BAD_ARGUMENT    - invalid form pointer
 |                    E_SYSTEM_ERROR    - general error
 +--------------------------------------------------------------------------*/
-int
-_nc_Refresh_Current_Field(FORM * form)
+NCURSES_EXPORT(int)
+_nc_Refresh_Current_Field (FORM * form)
 {
   WINDOW *formwin;
   FIELD  *field;
@@ -957,7 +959,8 @@ static int Synchronize_Linked_Fields(FIELD * field)
 |                    E_BAD_ARGUMENT   - invalid field pointer
 |                    E_SYSTEM_ERROR   - some severe basic error
 +--------------------------------------------------------------------------*/
-int _nc_Synchronize_Attributes(FIELD * field)
+NCURSES_EXPORT(int)
+_nc_Synchronize_Attributes (FIELD * field)
 {
   FORM *form;
   int res = E_OK;
@@ -1015,8 +1018,9 @@ int _nc_Synchronize_Attributes(FIELD * field)
 |                    E_BAD_ARGUMENT      - invalid field pointer 
 |                    E_SYSTEM_ERROR      - some severe basic error
 +--------------------------------------------------------------------------*/
-int
-_nc_Synchronize_Options(FIELD *field, Field_Options newopts)
+NCURSES_EXPORT(int)
+_nc_Synchronize_Options
+(FIELD *field, Field_Options newopts)
 {
   Field_Options oldopts;
   Field_Options changed_opts;
@@ -1113,8 +1117,9 @@ _nc_Synchronize_Options(FIELD *field, Field_Options newopts)
 |                    E_BAD_ARGUMENT      - invalid form or field pointer 
 |                    E_SYSTEM_ERROR      - some severe basic error
 +--------------------------------------------------------------------------*/
-int
-_nc_Set_Current_Field(FORM  *form, FIELD *newfield)
+NCURSES_EXPORT(int)
+_nc_Set_Current_Field
+(FORM  *form, FIELD *newfield)
 {
   FIELD  *field;
   WINDOW *new_window;
@@ -1159,6 +1164,7 @@ _nc_Set_Current_Field(FORM  *form, FIELD *newfield)
                }
            }
          delwin(form->w);
+         form->w = (WINDOW *)0;
        }
       
       field = newfield;
@@ -1173,7 +1179,11 @@ _nc_Set_Current_Field(FORM  *form, FIELD *newfield)
        return(E_SYSTEM_ERROR);
 
       form->current = field;
+
+      if (form->w)
+       delwin(form->w);
       form->w       = new_window;
+
       form->status &= ~_WINDOW_MODIFIED;
       Set_Field_Window_Attributes(field,form->w);
 
@@ -2686,8 +2696,8 @@ static bool Check_Field(FIELDTYPE *typ, FIELD *field, TypeArgument *argp)
 |   Return Values :  TRUE  - field is valid
 |                    FALSE - field is invalid
 +--------------------------------------------------------------------------*/
-bool
-_nc_Internal_Validation(FORM *form)
+NCURSES_EXPORT(bool)
+_nc_Internal_Validation (FORM *form)
 {
   FIELD *field;
 
@@ -2776,8 +2786,8 @@ INLINE static FIELD *Next_Field_On_Page(FIELD * field)
 |
 |   Return Values :  Pointer to calculated field.
 +--------------------------------------------------------------------------*/
-FIELD*
-_nc_First_Active_Field(FORM * form)
+NCURSES_EXPORT(FIELD*)
+_nc_First_Active_Field (FORM * form)
 {
   FIELD **last_on_page = &form->field[form->page[form->curpage].pmax];
   FIELD *proposed = Next_Field_On_Page(*last_on_page);
@@ -3283,8 +3293,9 @@ static int FN_Down_Field(FORM * form)
 |   Return Values :  E_OK                - success
 |                    != E_OK             - error from subordinate call
 +--------------------------------------------------------------------------*/
-int
-_nc_Set_Form_Page(FORM * form, int page, FIELD * field)
+NCURSES_EXPORT(int)
+_nc_Set_Form_Page
+(FORM * form, int page, FIELD * field)
 {
   int res = E_OK;
 
@@ -3637,7 +3648,8 @@ static const Binding_Info bindings[MAX_FORM_COMMAND - MIN_FORM_COMMAND + 1] =
 |                    E_REQUEST_DENIED  - request failed
 |                    E_UNKNOWN_COMMAND - command not known
 +--------------------------------------------------------------------------*/
-int form_driver(FORM * form, int  c)
+NCURSES_EXPORT(int)
+form_driver (FORM * form, int  c)
 {
   const Binding_Info* BI = (Binding_Info *)0;
   int res = E_UNKNOWN_COMMAND;
@@ -3736,7 +3748,9 @@ int form_driver(FORM * form, int  c)
 |                    E_BAD_ARGUMENT  - invalid argument
 |                    E_SYSTEM_ERROR  - system error
 +--------------------------------------------------------------------------*/
-int set_field_buffer(FIELD * field, int buffer, const char * value)
+NCURSES_EXPORT(int)
+set_field_buffer
+(FIELD * field, int buffer, const char * value)
 {
   char *s, *p;
   int res = E_OK;
@@ -3778,7 +3792,7 @@ int set_field_buffer(FIELD * field, int buffer, const char * value)
              unsigned int i;
          
              for(i=len; i<vlen; i++)
-               if (!isprint(value[i]))
+               if (!isprint((unsigned char)value[i]))
                  RETURN(E_BAD_ARGUMENT);
            }
          len = vlen;
@@ -3832,7 +3846,8 @@ int set_field_buffer(FIELD * field, int buffer, const char * value)
 |
 |   Return Values :  Pointer to buffer or NULL if arguments were invalid.
 +--------------------------------------------------------------------------*/
-char *field_buffer(const FIELD * field, int  buffer)
+NCURSES_EXPORT(char *)
+field_buffer (const FIELD * field, int  buffer)
 {
   if (field && (buffer >= 0) && (buffer <= field->nbuf))
     return Address_Of_Nth_Buffer(field,buffer);