# curs_kernel

## NAME



           **def_prog_mode** , **def_shell_mode** , **reset_prog_mode** , **reset_shell_mode** ,
           **resetty** , **savetty** , **getsyx** , **setsyx** , **ripoffline** , **curs_set** , **napms** -
           low-level **curses** routines
    


## SYNOPSIS



           **#include <curses.h>**
    
           **int def_prog_mode(void);**
           **int def_shell_mode(void);**
    
           **int reset_prog_mode(void);**
           **int reset_shell_mode(void);**
    
           **int resetty(void);**
           **int savetty(void);**
    
           **void getsyx(int** _y_**, int** _x_**);**
           **void setsyx(int** _y_**, int** _x_**);**
    
           **int ripoffline(int** _line_**, int (***_init_**)(WINDOW *, int));**
           **int curs_set(int** _visibility_**);**
           **int napms(int** _ms_**);**
    


## DESCRIPTION



           The following routines give low-level access to various **curses** ca‐
           pabilities.  These routines typically are used inside library rou‐
           tines.
    
       **def_prog_mode, def_shell_mode**
           The  **def_prog_mode** and  **def_shell_mode** routines save the current
           terminal modes as the “program” (in **curses**)  or  “shell”  (not  in
           **curses**)  state for use by the **reset_prog_mode** and **reset_shell_mode**
           routines.  This is done automatically by **initscr**.   There  is  one
           such save area for each screen context allocated by **newterm**.
    
       **reset_prog_mode, reset_shell_mode**
           The **reset_prog_mode** and **reset_shell_mode** routines restore the ter‐
           minal  to  “program” (in **curses**) or “shell” (out of **curses**) state.
           These are done automatically by **endwin**(3X) and, after  an  **endwin** ,
           by **doupdate** , so they normally are not called.
    
       **resetty, savetty**
           The **resetty** and **savetty** routines save and restore the state of the
           terminal  modes.   **savetty** saves the current state in a buffer and
           **resetty** restores the state to what it was  at  the  last  call  to
           **savetty**.
    
       **getsyx**
           The  **getsyx** routine returns the current coordinates of the _virtual_
           _screen_ cursor in _y_ and _x_.  If  **leaveok** is  currently  **TRUE** ,  then
           **-1** ,**-1** is returned.  If lines have been removed from the top of the
           screen,  using **ripoffline** , _y_ and _x_ include these lines; therefore,
           _y_ and _x_ should be used only as arguments for **setsyx**.
    
           Few applications will use this feature, most use **getyx** instead.
    
       **setsyx**
           The **setsyx** routine sets the _virtual screen_ cursor to _y_ , _x_.   If  _y_
           and  _x_  are both **-1** , then **leaveok** is set.  The two routines **getsyx**
           and **setsyx** are designed to be used by a library routine, which ma‐
           nipulates **curses** windows but does not want to change  the  current
           position  of the program's cursor.  The library routine would call
           **getsyx** at the beginning, do its manipulation of its  own  windows,
           do a **wnoutrefresh** on its windows, call **setsyx** , and then call **doup‐**
           **date**.
    
           Few applications will use this feature, most use **wmove** instead.
    
       **ripoffline**
           The  **ripoffline** routine provides access to the same facility that
           **slk_init**[see **curs_slk**(3X)] uses to reduce the size of the screen.
           **ripoffline** must be called before **initscr** or **newterm** is called,  to
           prepare these initial actions:
    
           •   If _line_ is positive, a line is removed from the top of **stdscr**.
    
           •   if _line_ is negative, a line is removed from the bottom.
    
           When the resulting initialization is done inside **initscr** , the rou‐
           tine **init**(supplied by the user) is called with two arguments:
    
           •   a window pointer to the one-line window that has been allocat‐
               ed and
    
           •   an integer with the number of columns in the window.
    
           Inside this initialization routine, the integer variables **LINES**
           and **COLS**(defined in **< curses.h>**) are not guaranteed to be accurate
           and **wrefresh** or **doupdate** must not be called.  It is allowable to
           call **wnoutrefresh** during the initialization routine.
    
           **ripoffline** can be called up to five times before calling **initscr**
           or **newterm**.
    
       **curs_set**
           The **curs_set** routine sets the cursor state to invisible, normal,
           or very visible for **visibility** equal to **0** , **1** , or **2** respectively.
           If the terminal supports the _visibility_ requested, the previous
           _cursor_ state is returned; otherwise, **ERR** is returned.
    
       **napms**
           The **napms** routine is used to sleep for _ms_ milliseconds.
    


## RETURN VALUE



           Except for **curs_set** , these routines always return **OK**.
    
           **curs_set** returns the previous cursor state, or **ERR** if the request‐
           ed _visibility_ is not supported.
    
           X/Open defines no error conditions.  In this implementation
    
           **def_prog_mode** , **def_shell_mode** , **reset_prog_mode** , **reset_shell_mode**
                return  an  error  if the terminal was not initialized, or if
                the I/O call to obtain the terminal settings fails.
    
           **ripoffline**
                returns an error if the maximum number of ripped-off lines
                exceeds the maximum (NRIPS = 5).
    


## NOTES



           Note that **getsyx** is a macro, so **& **is not necessary before the
           variables _y_ and _x_.
    
           Older SVr4 man pages warn that the return value of **curs_set** “is
           currently incorrect”.  This implementation gets it right, but it
           may be unwise to count on the correctness of the return value any‐
           where else.
    
           Both ncurses and SVr4 will call **curs_set** in **endwin** if **curs_set** has
           been called to make the cursor other than normal, i.e., either in‐
           visible or very visible.  There is no way for ncurses to determine
           the initial cursor state to restore that.
    


## PORTABILITY



           The _virtual screen_ functions **setsyx** and **getsyx** are not described
           in the XSI Curses standard, Issue 4.  All other functions are as
           described in XSI Curses.
    
           The SVr4 documentation describes **setsyx** and **getsyx** as having re‐
           turn type int.  This is misleading, as they are macros with no
           documented semantics for the return value.
    


* * *