home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_400 / 414_02 / private / _rmwin.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-17  |  1.3 KB  |  72 lines

  1. #define    CURSES_LIBRARY    1
  2. #include <curses.h>
  3.  
  4. #ifdef    REGISTERWINDOWS
  5. #ifdef PDCDEBUG
  6. char *rcsid__rmwin = "$Header: C:\CURSES\private\RCS\_rmwin.c 2.1 1993/06/18 20:23:35 MH Rel MH $";
  7. #endif
  8.  
  9.  
  10.  
  11.  
  12. /*man-start*********************************************************************
  13.  
  14.   _rmwin()    - Unregister window
  15.  
  16.   PDCurses Description:
  17.      This routine removes a window from the current visible list
  18.      of windows.
  19.  
  20.   PDCurses Return Value:
  21.      This function returns OK on success and ERR on error.
  22.  
  23.   PDCurses Errors:
  24.      It is an error to call this function with a NULL window pointer.
  25.  
  26.   Portability:
  27.      PDCurses    int _rmwin( WINDOW* win );
  28.  
  29. **man-end**********************************************************************/
  30.  
  31. int    _rmwin(WINDOW *win)
  32. {
  33. extern    void    (*fre)();
  34.  
  35.     WINDS  *w = _findwin(win);
  36.     WINDS  *next;
  37.     WINDS  *prev;
  38.  
  39. #ifdef PDCDEBUG
  40.     if (trace_on) PDC_debug("PDC_rmwin() - called\n");
  41. #endif
  42.  
  43.     if (w != (WINDS *)NULL)
  44.     {
  45.         if (_cursvar.visible == w)
  46.         {
  47.             _cursvar.visible = w->next;
  48.             (*fre)(w);
  49.         }
  50.         else
  51.         if (w->next == NULL)
  52.         {
  53.             if (w->prev != NULL)
  54.             {
  55.                 w->prev->next = NULL;
  56.                 (*fre)(w);
  57.             }
  58.         }
  59.         else
  60.         {
  61.             next = w->next;
  62.             prev = w->prev;
  63.             next->prev = prev;
  64.             prev->next = next;
  65.             (*fre)(w);
  66.         }
  67.         return( OK );
  68.     }
  69.     return( ERR );
  70. }
  71. #endif
  72.