







     SSSSccccrrrreeeeeeeennnn UUUUppppddddaaaattttiiiinnnngggg aaaannnndddd CCCCuuuurrrrssssoooorrrr MMMMoooovvvveeeemmmmeeeennnntttt OOOOppppttttiiiimmmmiiiizzzzaaaattttiiiioooonnnn::::
                     AAAA LLLLiiiibbbbrrrraaaarrrryyyy PPPPaaaacccckkkkaaaaggggeeee

                  _K_e_n_n_e_t_h _C_. _R_. _C_. _A_r_n_o_l_d
                         _E_l_a_n _A_m_i_r

                 Computer Science Division
 Department of Electrical Engineering and Computer Science
             University of California, Berkeley
                Berkeley, California  94720



                          _AA_BB_SS_TT_RR_AA_CC_TT





     This  document  describes  a  package  of C library
functions which allow the user to:

1)   update a screen with reasonable optimization,

2)   get input from the terminal  in  a  screen-oriented
     fashion, and

3)   independent  from  the above, move the cursor opti-
     mally from one point to another.

     These routines all use the _t_e_r_m_c_a_p(5)  database  to
describe the capabilities of the terminal.

AAAAcccckkkknnnnoooowwwwlllleeeeddddggggeeeemmmmeeeennnnttttssss

     This  package  would not exist without the work of Bill
Joy, who, in writing his editor, created the  capability  to
generally  describe terminals, wrote the routines which read
this database, and, most importantly, those which  implement
optimal cursor movement, which routines I have simply lifted
nearly intact.  Doug  Merritt  and  Kurt  Shoens  also  were
extremely important, as were both willing to waste time lis-
tening to me rant and rave.  The help and/or support of  Ken
Abrams, Alan Char, Mark Horton, and Joe Kalash, was, and is,
also greatly appreciated.  _K_e_n _A_r_n_o_l_d    _1_6 _A_p_r_i_l _1_9_8_6

     The help and/or support  of  Kirk  McKusick  and  Keith
Bostic  (public vi!)  was invaluable in bringing the package
``into the 90's'', which now includes  completely  new  data
structures  and  screen refresh optimization routines.  _E_l_a_n
_A_m_i_r   _2_9 _D_e_c_e_m_b_e_r _1_9_9_2











SSSSccccrrrreeeeeeeennnn PPPPaaaacccckkkkaaaaggggeeee                                      PPPPSSSS1111::::11119999----1111


1111....  OOOOvvvveeeerrrrvvvviiiieeeewwww

     In making available the generalized  terminal  descrip-
tions  in _t_e_r_m_c_a_p(5), much information was made available to
the programmer, but little  work  was  taken  out  of  one's
hands.   The  purpose of this package is to allow the C pro-
grammer to do the most common  type  of  terminal  dependent
functions, those of movement optimization and optimal screen
updating, without doing any of  the  dirty  work,  and  with
nearly  as much ease as is necessary to simply print or read
things.

1111....1111....  TTTTeeeerrrrmmmmiiiinnnnoooollllooooggggyyyy

     In this document, the following terminology is used:

wwwwiiiinnnnddddoooowwww: An internal representation containing  an  image  of
     what  a section of the terminal screen may look like at
     some point in time.  This subsection can either  encom-
     pass the entire terminal screen, or any smaller portion
     down to a single character within that screen.

tttteeeerrrrmmmmiiiinnnnaaaallll: Sometimes called tttteeeerrrrmmmmiiiinnnnaaaallll ssssccccrrrreeeeeeeennnn.   The  package's
     idea  of  what  the  terminal's  screen currently looks
     like, _i_._e_., what the user sees now.  This is a  special
     _s_c_r_e_e_n:

ssssccccrrrreeeeeeeennnn:  This  is  a subset of windows which are as large as
     the terminal screen, _i_._e_., they start at the upper left
     hand  corner and encompass the lower right hand corner.
     One of these, _s_t_d_s_c_r, is automatically provided for the
     programmer.

1111....2222....  CCCCoooommmmppppiiiilllliiiinnnngggg AAAApppppppplllliiiiccccaaaattttiiiioooonnnnssss

     In  order  to  use the library, it is necessary to have
certain types and variables defined.   Therefore,  the  pro-
grammer must have a line:

    ####iiiinnnncccclllluuuuddddeeee <<<<ccccuuuurrrrsssseeeessss....hhhh>>>>

at  the top of the program source.  Compilations should have
the following form:

    _c_c [ flags ] file ... _-_l_c_u_r_s_e_s _-_l_t_e_r_m_c_a_p


1111....3333....  SSSSccccrrrreeeeeeeennnn UUUUppppddddaaaattttiiiinnnngggg

     In order to update the screen optimally, it  is  neces-
sary  for  the  routines  to  know what the screen currently
looks like and what the programmer wants  it  to  look  like
next.   For  this  purpose,  a  data  type (structure) named










SSSSccccrrrreeeeeeeennnn PPPPaaaacccckkkkaaaaggggeeee                                      PPPPSSSS1111::::11119999----3333


_W_I_N_D_O_W is defined which describes a window image to the rou-
tines,  including  its  starting position on the screen (the
(y, x) co-ordinates of the upper left hand corner)  and  its
size.   One of these (called _c_u_r_s_c_r for _c_u_r_r_e_n_t _s_c_r_e_e_n) is a
screen image of what  the  terminal  currently  looks  like.
Another  screen (called _s_t_d_s_c_r, for _s_t_a_n_d_a_r_d _s_c_r_e_e_n) is pro-
vided by default to make changes on.

     A window is a purely internal  representation.   It  is
used  to  build  and store a potential image of a portion of
the terminal.  It doesn't bear  any  necessary  relation  to
what  is  really on the terminal screen.  It is more like an
array of characters on which to make changes.

     When one has a window which describes  what  some  part
the  terminal  should  look  like, the routine refresh() (or
wrefresh()  if  the  window  is  not  _s_t_d_s_c_r)   is   called.
refresh()  makes  the  terminal,  in the area covered by the
window, look like that window.  Note, therefore, that chang-
ing  something  on  a  window  _d_o_e_s _nn_oo_tt _c_h_a_n_g_e _t_h_e _t_e_r_m_i_n_a_l.
Actual updates to the terminal screen are made only by call-
ing  refresh() or wrefresh().  This allows the programmer to
maintain several different ideas of what a  portion  of  the
terminal screen should look like.  Also, changes can be made
to windows in any order,  without  regard  to  motion  effi-
ciency.   Then,  at will, the programmer can effectively say
"make it look like this", and the package will  execute  the
changes in an optimal way.

1111....4444....  NNNNaaaammmmiiiinnnngggg CCCCoooonnnnvvvveeeennnnttttiiiioooonnnnssss

     As  hinted above, the routines can use several windows,
but two are always available: _c_u_r_s_c_r, which is the image  of
what  the  terminal looks like at present, and _s_t_d_s_c_r, which
is the image of what the programmer wants  the  terminal  to
look like next.  The user should not access _c_u_r_s_c_r directly.
Changes should be made to the appropriate screen,  and  then
the routine refresh() (or wrefresh()) should be called.

     Many  functions  are  set  up  to deal with _s_t_d_s_c_r as a
default screen.  For example, to add a character to  _s_t_d_s_c_r,
one  calls addch() with the desired character.  If a differ-
ent window is to be used, the routine waddch() (for  wwwwindow-
specific addch()) is provided1.  This convention of prepend-
ing function names with a "_w" when they are to be applied to
specific  windows is consistent.  The only routines which do
_n_o_t do this are those to  which  a  window  must  always  be
____________________
   1  Actually, addch() is really a "#define" macro with ar-
guments, as are most of the "functions" which act upon  _s_t_d_-
_s_c_r.












PPPPSSSS1111::::11119999----4444                                      SSSSccccrrrreeeeeeeennnn PPPPaaaacccckkkkaaaaggggeeee


specified.

     In  order  to move the current (y, x) co-ordinates from
one point to another, the routines move()  and  wmove()  are
provided.   However, it is often desirable to first move and
then perform some I/O operation.  In order to avoid  clumsi-
ness,  most  I/O routines can be preceded by the prefix "_m_v"
and the desired (y, x) co-ordinates can then be added to the
arguments to the function.  For example, the calls

    move(y, x);
    addch(ch);

can be replaced by

    mvaddch(y, x, ch);

and

    wmove(win, y, x);
    waddch(win, ch);

can be replaced by

    mvwaddch(win, y, x, ch);

Note  that the window description pointer (_w_i_n) comes before
the added (y, x)  co-ordinates.   If  a  window  pointer  is
needed, it is always the first parameter passed.

2222....  VVVVaaaarrrriiiiaaaabbbblllleeeessss

     Many  variables which are used to describe the terminal
environment are available to the programmer.  They are:


    type    name       description
    ----------------------------------------------------------------------
    WINDOW *curscr     current version of the screen (terminal screen).
    WINDOW *stdscr     standard screen.  Most updates  are  usually  done
                       here.
    char *  Def_term   default terminal type if type cannot be determined
    bool    My_term    use the terminal specification in _D_e_f___t_e_r_m as ter-
                       minal, irrelevant of real terminal type
    char *  ttytype    full name of the current terminal.
    int     LINES      number of lines on the terminal
    int     COLS       number of columns on the terminal
    int     COLORS     number of colors on the terminal
    int     COLOR_PAIRSnumber of color pairs on the terminal
    int     ERR        error flag returned by routines on a fail.
    int     OK         flag returned by routines upon success.












SSSSccccrrrreeeeeeeennnn PPPPaaaacccckkkkaaaaggggeeee                                      PPPPSSSS1111::::11119999----5555


3333....  UUUUssssaaaaggggeeee

     This is a description of how to actually use the screen
package.  For simplicity, we assume all  updating,  reading,
etc.   is applied to _s_t_d_s_c_r, although a different window can
of course be specified.

3333....1111....  IIIInnnniiiittttiiiiaaaalllliiiizzzzaaaattttiiiioooonnnn

     In order to use the screen package, the  routines  must
know  about  terminal  characteristics,  and  the  space for
_c_u_r_s_c_r and _s_t_d_s_c_r must be allocated.   These  functions  are
performed  by  initscr().   Since it must allocate space for
the windows, it can overflow core when attempting to do  so.
On   this  rather  rare  occasion,  initscr()  returns  ERR.
initscr() must _aa_ll_ww_aa_yy_ss be called before any of  the  routines
which  affect  windows  are used.  If it is not, the program
will core dump as soon as either _c_u_r_s_c_r or _s_t_d_s_c_r are refer-
enced.  However, it is usually best to wait to call it until
after you are sure you will need it, like after checking for
startup errors.  Terminal status changing routines like nl()
and cbreak() should be called after initscr().

     After the initial window allocation done by  initscr(),
specific  window  characteristics can be set.  Scrolling can
be enabled by calling scrollok().  If you want the cursor to
be left after the last change, use leaveok().  If this isn't
done, refresh() will move the cursor to the window's current
(y, x)  co-ordinates  after updating it.  Additional windows
can be created by using the functions newwin() and subwin().
delwin() allows you to delete an existing window.  The vari-
ables _L_I_N_E_S and _C_O_L_S control the size of the terminal.  They
are  initially  implicitly  set  by  initscr(),  but  can be
altered explicitly  by  the  user  followed  by  a  call  to
initscr().   Note  that  any  call to initscr(), will always
delete any existing _s_t_d_s_c_r and/or _c_u_r_s_c_r before creating new
ones  so this change is best done before the initial call to
initscr().

3333....2222....  OOOOuuuuttttppppuuuutttt

     The basic functions used to change what will  go  on  a
window  are addch() and move().  addch() adds a character at
the current (y, x) co-ordinates, returning ERR if  it  would
cause the window to illegally scroll, _i_._e_., printing a char-
acter in the lower right-hand corner  of  a  terminal  which
automatically  scrolls  if scrolling is not allowed.  move()
changes the current (y, x) co-ordinates to whatever you want
them  to be.  It returns ERR if you try to move off the win-
dow.  As mentioned above, you can combine the two into mvad-
dch() to do both things in one call.












PPPPSSSS1111::::11119999----6666                                      SSSSccccrrrreeeeeeeennnn PPPPaaaacccckkkkaaaaggggeeee


     The  other  output  functions  (such  as  addstr()  and
printw()) all call addch() to add characters to the  window.

     After  a  change  has been made to the window, you must
call refresh().  when you want the portion of  the  terminal
covered  by  the  window to reflect the change.  In order to
optimize finding changes, refresh() assumes that any part of
the window not changed since the last refresh() of that win-
dow has not been changed on the  terminal,  _i_._e_.,  that  you
have  not  refreshed a portion of the terminal with an over-
lapping window.  If this  is  not  the  case,  the  routines
touchwin(),  touchline(), and touchoverlap() are provided to
make it look like a desired part of window has been changed,
thus forcing refresh() to check that whole subsection of the
terminal for changes.

     If you call wrefresh() with _c_u_r_s_c_r, it  will  make  the
screen  look  like  the image of _c_u_r_s_c_r.  This is useful for
implementing a command which would redraw the screen in case
it got messed up.

3333....3333....  IIIInnnnppppuuuutttt

     Input  is  essentially  a  mirror image of output.  The
complementary function to addch() is getch() which, if  echo
is  set, will call addch() to echo the character.  Since the
screen package needs to know what is on the terminal at  all
times,  if  characters  are to be echoed, the tty must be in
raw or cbreak mode.  If it is not, getch()  sets  it  to  be
cbreak, and then reads in the character.

3333....4444....  TTTTeeeerrrrmmmmiiiinnnnaaaattttiiiioooonnnn

     In order to perform certain optimizations, and, on some
terminals, to work at all, some things must be  done  before
the screen routines start up.  These functions are performed
in getttmode() and setterm(), which are called by initscr().
In  order  to  clean up after the routines, the routine end-
win() is provided.  It restores tty modes to what they  were
when  initscr() was first called.  The terminal state module
uses the variable _c_u_r_s_e_s___t_e_r_m_i_o_s to save the original termi-
nal  state  which  is then restored upon a call to endwin().
Thus, anytime after the call to initscr, endwin() should  be
called  before  exiting.  Note however, that endwin() should
always be called bbbbeeeeffffoooorrrreeee the final calls to  delwin(),  which
free the storage of the windows.

4444....  CCCCuuuurrrrssssoooorrrr MMMMoooovvvveeeemmmmeeeennnntttt OOOOppppttttiiiimmmmiiiizzzzaaaattttiiiioooonnnnssss

     One  of  the  most  difficult  things to do properly is
motion optimization.  After using gettmode()  and  setterm()
to get the terminal descriptions, the function mvcur() deals
with this task.  It usage is simple: simply  tell  it  where










SSSSccccrrrreeeeeeeennnn PPPPaaaacccckkkkaaaaggggeeee                                      PPPPSSSS1111::::11119999----7777


you are now and where you want to go.  For example

    mvcur(0, 0, LINES/2, COLS/2);


would  move  the cursor from the home position (0, 0) to the
middle of  the  screen.   If  you  wish  to  force  absolute
addressing,  you  can  use  the  function  tgoto()  from the
tttteeeerrrrmmmmlllliiiibbbb(7) routines, or you can tell mvcur()  that  you  are
impossibly  far away, For example, to absolutely address the
lower left hand corner of  the  screen  from  anywhere  just
claim that you are in the upper right hand corner:

    mvcur(0, COLS-1, LINES-1, 0);


5555....  CCCChhhhaaaarrrraaaacccctttteeeerrrr OOOOuuuuttttppppuuuutttt aaaannnndddd SSSSccccrrrroooolllllllliiiinnnngggg

     The  character  output  policy deals with the following
problems.  First, where is the location of the cursor  after
a  character  is printed, and secondly, when does the screen
scroll if scrolling is enabled.

     In  the  normal  case  the  characters  are  output  as
expected, with the cursor occupying the position of the next
character to be output.  However, when the cursor is on  the
last  column  of  the  line,  the cursor will remain on that
position after the last character on the line is output  and
will only assume the position on the next line when the next
character (the first on the next line) is output.

     Likewise, if scrolling is enabled,  a  scroll  will  be
invoked  only when the first character on he first line past
the bottom line of the window is output.   If  scrolling  is
not  enabled  the  chracters will to be output to the bottom
right corner of the window which is the cursor location.

     This policy allows consistent behavior of the cursor at
the  boundary conditions.  Furthermore, it prevents a scroll
from happening before it is actually needed (the old package
used  to  scroll when the bottom right position was output a
character).  As a precedent, it models the  _x_t_e_r_m  character
output conventions.

6666....  TTTTeeeerrrrmmmmiiiinnnnaaaallll SSSSttttaaaatttteeee HHHHaaaannnnddddlllliiiinnnngggg

     The variable _c_u_r_s_e_s___t_e_r_m_i_o_s contains the terminal state
of the terminal.  Certain historical routines return  infor-
mation:  baudrate(),  erasechar(), killchar(), and ospeed().
These routines are obsolete and exist only for backward com-
patibility.   If  you  wish  to  use  the information in the
_c_u_r_s_e_s___t_e_r_m_i_o_s structure, you  should  use  the  _t_s_e_t_a_t_t_r(3)
routines.










PPPPSSSS1111::::11119999----8888                                      SSSSccccrrrreeeeeeeennnn PPPPaaaacccckkkkaaaaggggeeee


7777....  SSSSuuuubbbbwwwwiiiinnnnddddoooowwwwssss

     Subwindows are windows which do not have an independent
text structure, _i_._e_., they are windows whose text is a  sub-
set  of the text of a larger window: the _p_a_r_e_n_t window.  One
consequence of this is that changes to either the parent  or
the  child  window  are  destructive  to  the other, _i_._e_., a
change to the subwindow is also a change to the parent  win-
dow  and a change to the parent window in the region defined
by the subwindow is implicitly a change to the subwindow  as
well.   Apart from this detail, subwindows function like any
other window.

8888....  TTTThhhheeee FFFFuuuunnnnccccttttiiiioooonnnnssss

     In the  following  definitions,  "[*]"  means  that  if
___C_U_R_S_E_S___U_S_E___M_A_C_R_O_S  is  defined,  the "function" is really a
"#define" macro with arguments.


addbytes(_c_h_a_r _*_s_t_r, _i_n_t _l_e_n);

     This function is the low level character  output  func-
     tion.   _L_e_n  characters of the string _s_t_r are output to
     the current (y, x) co-ordinates position of the window.


addch(_c_h_t_y_p_e _c_h);[+]

     Add  the  character  _c_h  on  the  window at the current
     (y, x) co-ordinates.  If the  character  is  a  newline
     ('\n')  the  line  will  be cleared to the end, and the
     current (y, x) co-ordinates  will  be  changed  to  the
     beginning  off  the next line if newline mapping is on,
     or to the next line at the same x co-ordinate if it  is
     off.  A return ('\r') will move to the beginning of the
     line on the window.  Tabs ('\t') will be expanded  into
     spaces  in  the normal tabstop positions of every eight
     characters.  This returns ERR if  it  would  cause  the
     screen to scroll illegally.


addchstr(_c_h_t_y_p_e _*_s_t_r);[+]

     Add the characters and attributes in the string pointed
     to by _s_t_r on the window at the current (y, x)  co-ordi-
     nates.   This  returns ERR if it would cause the screen
     to scroll illegally.  In this case, it will put  on  as
     much as it can.


addchnstr(_c_h_t_y_p_e _*_s_t_r, _i_n_t _l_e_n);[+]











SSSSccccrrrreeeeeeeennnn PPPPaaaacccckkkkaaaaggggeeee                                      PPPPSSSS1111::::11119999----9999


     Add  no  more than _l_e_n characters and attributes of the
     string pointed to by _s_t_r on the window at  the  current
     (y, x)  co-ordinates.   This  returns  ERR  if it would
     cause the screen to scroll illegally.  In this case, it
     will put on as much as it can.


addstr(_c_h_a_r _*_s_t_r);[+]

     Add  the  string pointed to by _s_t_r on the window at the
     current (y, x) co-ordinates.  This returns  ERR  if  it
     would  cause  the  screen to scroll illegally.  In this
     case, it will put on as much as it can.


addnstr(_c_h_a_r _*_s_t_r, _i_n_t _l_e_n);[+]

     Add no more than _l_e_n characters of the  string  pointed
     to  by _s_t_r on the window at the current (y, x) co-ordi-
     nates.  This returns ERR if it would cause  the  screen
     to  scroll  illegally.  In this case, it will put on as
     much as it can.


assume_default_colors(_s_h_o_r_t _f_o_r_e, _s_h_o_r_t _b_a_c_k);

     Set the curses default foreground and background colors
     to _f_o_r_e and _b_a_c_k.


attr_get(_a_t_t_r___t _*_a_t_t_r, _s_h_o_r_t _*_p_a_i_r, _v_o_i_d _*_o_p_t);[+]

     Get  the  attributes  and  colour  pair for the window.
     Either _a_t_t_r or _p_a_i_r may be NULL.  The _o_p_t  argument  is
     not used.


attr_off(_a_t_t_r___t _a_t_t_r, _v_o_i_d _*_o_p_t);[+]

     Remove   character   attributes  set  by  attr_on()  or
     attr_set().


attr_on(_a_t_t_r___t _a_t_t_r, _v_o_i_d _*_o_p_t);[+]

     Add character attributes for any  characters  added  to
     the window (if it has that capability).  The attributes
     that can be set are  AAAA____UUUUNNNNDDDDEEEERRRRLLLLIIIINNNNEEEE,  AAAA____RRRREEEEVVVVEEEERRRRSSSSEEEE,  AAAA____BBBBLLLLIIIINNNNKKKK,
     AAAA____DDDDIIIIMMMM,  AAAA____BBBBOOOOLLLLDDDD,  AAAA____BBBBLLLLAAAANNNNKKKK,  AAAA____PPPPRRRROOOOTTTTEEEECCCCTTTT,,,,  AAAA____AAAALLLLTTTTCCCCHHHHAAAARRRRSSSSEEEETTTT and
     CCCCOOOOLLLLOOOORRRR____PPPPAAAAIIIIRRRR((((nnnn)))).













PPPPSSSS1111::::11119999----11110000                                     SSSSccccrrrreeeeeeeennnn PPPPaaaacccckkkkaaaaggggeeee


attr_set(_a_t_t_r___t _a_t_t_r, _s_h_o_r_t _p_a_i_r, _v_o_i_d _*_o_p_t);[+]

     Set character attributes and color pair for any charac-
     ters added to the window (if it has that capability).


attroff(_i_n_t _a_t_t_r_i_b_u_t_e);[+]

     Remove   character   attributes   set  by  attron()  or
     attrset().  To  clear  all  character  attributes,  use
     attroff(_A___A_T_T_R_I_B_U_T_E_S).  attroff(_A___S_T_A_N_D_O_U_T); is equiva-
     lent to standend().  attroff(_A___U_N_D_E_R_L_I_N_E);  is  equiva-
     lent to underend().


attron(_i_n_t _a_t_t_r_i_b_u_t_e);[+]

     Add  character  attributes  for any characters added to
     the   window   (if    it    has    that    capability).
     attron(_A___S_T_A_N_D_O_U_T);   is   equivalent   to  standout().
     attron(_A___U_N_D_E_R_L_I_N_E); is equivalent to underscore().


attrset(_i_n_t _a_t_t_r_i_b_u_t_e);[+]

     Set character attributes for any  characters  added  to
     the window (if it has that capability).


baudrate();[+]

     Returns  the output baud rate of the terminal.  This is
     a system dependent constant (defined in <<<<ssssyyyyssss////ttttttttyyyy....hhhh>>>>  on
     BSD systems, which is included by <<<<ccccuuuurrrrsssseeeessss....hhhh>>>>).


beep();

     Sound  the  terminal bell.  If the terminal has no bell
     capability, but has the ability to flash the screen, do
     that instead.  See also flash()


bkgd(_c_h_t_y_p_e _c_h);

     Sets the background rendition to _c_h.


bkgdset(_c_h_t_y_p_e _c_h);

     Sets  the  background  rendition to _c_h and applies this
     rendition to the window.











SSSSccccrrrreeeeeeeennnn PPPPaaaacccckkkkaaaaggggeeee                                     PPPPSSSS1111::::11119999----11111111


border(_c_h_t_y_p_e _l_e_f_t, _c_h_t_y_p_e _r_i_g_h_t, _c_h_t_y_p_e _t_o_p, _c_h_t_y_p_e _b_o_t_t_o_m, _c_h_t_y_p_e _t_o_p_l_e_f_t, _c_h_t_y_p_e _t_o_p_r_i_g_h_t, _c_h_t_y_p_e _b_o_t_l_e_f_t, _c_h_t_y_p_e _b_o_t_r_i_g_h_t);

     Draws a border around the window using the  characters:
     _l_e_f_t  for  drawing the left side, _r_i_g_h_t for drawing the
     left side, _t_o_p for drawing the  top  edge,  _b_o_t_t_o_m  for
     drawing  the top edge, _t_o_p_l_e_f_t for drawing the top-left
     corner, _t_o_p_r_i_g_h_t  for  drawing  the  top-right  corner,
     _b_o_t_l_e_f_t   for   drawing  the  bottom-left  corner,  and
     _b_o_t_r_i_g_h_t  for  drawing  the  bottom-right  corner.   If
     scrolling  is  not  allowed, and the window encompasses
     the lower right-hand corner of the terminal,  the  cor-
     ners are left blank to avoid a scroll.


box(_W_I_N_D_O_W _w_i_n, _c_h_t_y_p_e _v_e_r_t, _c_h_t_y_p_e _h_o_r);

     Draws a box around the window using _v_e_r_t as the charac-
     ter for drawing the vertical sides, and _h_o_r for drawing
     the horizontal lines.  If scrolling is not allowed, and
     the window encompasses the lower right-hand  corner  of
     the  terminal,  the  corners  are left blank to avoid a
     scroll.


can_change_color();

     Check if terminal can change colors.


cbreak();

     Set the terminal to cbreak mode.


clear();[+]

     Resets the entire  window  to  blanks.   If  _w_i_n  is  a
     screen,  this  sets  the clear flag, which will cause a
     clear-screen sequence to be sent on the next  refresh()
     call.   This also moves the current (y, x) co-ordinates
     to (0, 0).


clearok(_W_I_N_D_O_W _*_s_c_r, _i_n_t _b_o_o_l_f);[+]

     Sets the clear flag for the screen _s_c_r.   If  _b_o_o_l_f  is
     non-zero,  this will force a clear-screen to be printed
     on the next refresh(), or stop  it  from  doing  so  if
     _b_o_o_l_f  is  0.   This only works on screens, and, unlike
     clear(), does not alter the contents of the screen.  If
     _s_c_r  is  _c_u_r_s_c_r,  the  next refresh() call will cause a
     clear-screen, even if the window passed to refresh() is
     not a screen.










PPPPSSSS1111::::11119999----11112222                                     SSSSccccrrrreeeeeeeennnn PPPPaaaacccckkkkaaaaggggeeee


clrtobot();[+]

     Wipes the window clear from the current (y, x) co-ordi-
     nates to the bottom.  This  does  not  force  a  clear-
     screen  sequence  on the next refresh under any circum-
     stances.  This has no associated "mmmmvvvv" command.


clrtoeol();[+]

     Wipes the window clear from the current (y, x) co-ordi-
     nates  to  the end of the line.  This has no associated
     "mmmmvvvv" command.


color_content(_s_h_o_r_t _c_o_l_o_r, _s_h_o_r_t _*_r_e_d, _s_h_o_r_t _*_g_r_e_e_n, _s_h_o_r_t _*_b_l_u_e);

     Get the red, green and blue values of color _c_o_l_o_r.


color_set(_s_h_o_r_t _p_a_i_r, _v_o_i_d _*_o_p_t);[+]

     Set color pair for any characters added to  the  window
     (if it has that capability).


copywin(_c_o_n_s_t _W_I_N_D_O_W _*_s_r_c, _W_I_N_D_O_W _*_d_s_t, _i_n_t _s_m_i_n_r_o_w, _i_n_t _s_m_i_n_c_o_l, _i_n_t _d_m_i_n_r_o_w, _i_n_t _d_m_i_n_c_o_l, _i_n_t _d_m_a_x_r_o_w, _i_n_t _d_m_a_x_c_o_l);

     Copies  the  contents  of  the window _s_r_c starting at (
     _s_m_i_n_r_o_w, _s_m_i_n_c_o_l) to the destination window _d_s_t  start-
     ing at ( _d_m_i_n_r_o_w, _d_m_i_n_c_o_l) and ending at either the end
     of the source window or ( _d_m_a_x_r_o_w,  _d_m_a_x_c_o_l)  whichever
     is  the  lesser.   The parameter _o_v_e_r_l_a_y determines the
     nature of the copy.  If _o_v_e_r_l_a_y is TRUE then  only  the
     non-space  characters  from  _s_r_c are copied to _d_s_t.  If
     _o_v_e_r_l_a_y is FALSE then all characters  are  copied  from
     _s_r_c to _d_s_t_.


curs_set(_i_n_t _v_i_s_i_b_i_l_i_t_y);

     Sets  the visibility of the screen cursor.  The parame-
     ter _v_i_s_i_b_i_l_i_t_y can be one of three values, 0 means make
     the  cursor invisible, 1 means set the cursor to normal
     visibility and 2 sets the cursor  to  high  visibility.
     In  all cases the old mode of the cursor is returned if
     the call was successful and EEEERRRRRRRR is returned if the ter-
     minal cannot support the requested visibility mode.


crmode();[+]












SSSSccccrrrreeeeeeeennnn PPPPaaaacccckkkkaaaaggggeeee                                     PPPPSSSS1111::::11119999----11113333


     Identical to cbreak().  The misnamed macro crmode() and
     nocrmode() is retained for backwards compatibility with
     ealier versions of the library.


delay_output(_i_n_t _m_s);

     Pause output for _m_s milliseconds using the terminal pad
     character.


def_prog_mode();

     Save the current terminal  modes  as  the  'in  curses'
     state for use with reset_prog_mode().


def_shell_mode();

     Save  the current terminal modes as the 'not in curses'
     state for use with reset_shell_mode().


define_key(_c_h_a_r _*_s_e_q_u_e_n_c_e, _i_n_t _k_e_y___s_y_m_b_o_l);

     Assigns the character sequence given in _s_e_q_u_e_n_c_e to the
     key  symbol  _k_e_y___s_y_m_b_o_l.   If keypad() has set been set
     TRUE and the character sequence is found in  the  input
     stream  then  the  key symbol defined will be returned.
     Normally the sequences are found in the  tttteeeerrrrmmmmccccaaaapppp  data-
     base but this function allows extensions to be added by
     the application.  If _s_e_q_u_e_n_c_e is a  NULL  pointer  then
     all  the  sequences  associated with _k_e_y___s_y_m_b_o_l will be
     removed, including any definitions inserted by tttteeeerrrrmmmmccccaaaapppp.


delch();

     Delete  the  character  at  the current (y, x) co-ordi-
     nates.  Each character after it on the line  shifts  to
     the left, and the last character becomes blank.


deleteln();

     Delete  the current line.  Every line below the current
     one will move up,  and  the  bottom  line  will  become
     blank.   The  current  (y, x)  co-ordinates will remain
     unchanged.


delscreen(_S_C_R_E_E_N _*_s_c_r_e_e_n);











PPPPSSSS1111::::11119999----11114444                                     SSSSccccrrrreeeeeeeennnn PPPPaaaacccckkkkaaaaggggeeee


     Delete the screen and frees all associated resources.


delwin(_W_I_N_D_O_W _*_w_i_n);

     Deletes the window from existence.  All  resources  are
     freed  for  future use by ccccaaaalllllllloooocccc(3).  If a window has a
     subwin() allocated window inside of  it,  deleting  the
     outer window the subwindow is not affected, even though
     this does invalidate it.  Therefore, subwindows  should
     be deleted before their outer windows are.


derwin(_W_I_N_D_O_W _*_o_r_i_g, _i_n_t _n_l_i_n_e_s, _i_n_t _n_c_o_l_s, _i_n_t _b_y, _i_n_t _b_x);

     Performs  a  function very similar to that of subwin().
     The difference being that with derwin() the  origin  of
     the  child window given by ( _b_y, _b_x) is relative to the
     origin of the parent window _o_r_i_g instead of being abso-
     lute screen coordinates as they are in subwin().


doupdate();

     Synchronize the terminal screen with the virtual screen
     that has had window contents added to it  by  calls  to
     wnoutrefresh().


dupwin(_W_I_N_D_O_W _*_w_i_n);

     Creates an exact copy of the window _w_i_n.


echo();[+]

     Sets the terminal to echo characters.


echochar(_c_o_n_s_t _c_h_t_y_p_e _c_h);[+]

     Add  the  character  _c_h  on  the  window at the current
     (y, x) co-ordinates and immediately refresh the window.


endwin();

     Finish  up  window routines before exit.  This restores
     the terminal to the state it was before  initscr()  (or
     gettmode() and setterm()) was called.  It should always
     be called before exiting and before the final calls  to
     delwin().  It does not exit.  This is especially useful
     for resetting  tty  stats  when  trapping  rubouts  via










SSSSccccrrrreeeeeeeennnn PPPPaaaacccckkkkaaaaggggeeee                                     PPPPSSSS1111::::11119999----11115555


     ssssiiiiggggnnnnaaaallll(2).


erase();[+]

     Erases  the  window to blanks without setting the clear
     flag.  This is analagous to  clear(),  except  that  it
     never causes a clear-screen sequence to be generated on
     a refresh().  This has no associated "mmmmvvvv" command.


erasechar();[+]

     Returns the erase character for the terminal, _i_._e_., the
     character  used by the user to erase a single character
     from the input.


flash();

     Flash the terminal screen.   If  the  terminal  has  no
     flash  capability,  but  has  the  ability to sound the
     bell, do that instead.  See also bell()


flushinp();

     Throw away any input that has been typed  by  the  user
     but has not yet been read by the program.


flushok(_W_I_N_D_O_W _*_w_i_n, _i_n_t _b_o_o_l_f);

     Normally,  refresh() fflush(_'_s); _s_t_d_o_u_t when it is fin-
     ished.  flushok() allows you to control this.  if _b_o_o_l_f
     is  non-zero  (_i_._e_., non-zero) it will do the fflush(),
     otherwise it will not.


getattrs(_W_I_N_D_O_W _*_w_i_n);

     Gets the attributes for _w_i_n.


getbkgd(_W_I_N_D_O_W _*_w_i_n);

     Gets the background rendition for _w_i_n.


getcap(_c_h_a_r _*_n_a_m_e);

     Get the terminal capability _n_a_m_e.











PPPPSSSS1111::::11119999----11116666                                     SSSSccccrrrreeeeeeeennnn PPPPaaaacccckkkkaaaaggggeeee


getch();[+]

     Gets a character from the terminal and  (if  necessary)
     echos  it  on the window.  This returns ERR if it would
     cause the screen to scroll illegally.   Otherwise,  the
     character  gotten is returned.  If _n_o_e_c_h_o has been set,
     then the window is left unaltered.  In order to  retain
     control of the terminal, it is necessary to have one of
     _n_o_e_c_h_o, _c_b_r_e_a_k, or _r_a_w_m_o_d_e set.  If you do not set one,
     whatever  routine  you call to read characters will set
     _c_b_r_e_a_k for you, and then reset  to  the  original  mode
     when finished.


getcury(_W_I_N_D_O_W _*_w_i_n);

     Get current y position on _w_i_n.


getcurx(_W_I_N_D_O_W _*_w_i_n);

     Get current x position on _w_i_n.


getbegy(_W_I_N_D_O_W _*_w_i_n);

     Get start y position on _w_i_n.


getbegx(_W_I_N_D_O_W _*_w_i_n);

     Get start x position on _w_i_n.


getmaxy(_W_I_N_D_O_W _*_w_i_n);

     Get maximum y position on _w_i_n.


getmaxx(_W_I_N_D_O_W _*_w_i_n);

     Get maximum x position on _w_i_n.


getnstr(_c_h_a_r _*_s_t_r);[+]

     Get a string through the window and put it in the loca-
     tion pointed to by _s_t_r.  A maximum of _n  characters  is
     returned  (including  the  trailing null).  It sets tty
     modes  if  necessary,  and  then  calls   getch()   (or
     wgetch())  to  get the characters needed to fill in the
     string until a newline or EOF is encountered.  The new-
     line  stripped  off the string.  This returns ERR if it










SSSSccccrrrreeeeeeeennnn PPPPaaaacccckkkkaaaaggggeeee                                     PPPPSSSS1111::::11119999----11117777


     would cause the screen to scroll illegally.


getstr(_c_h_a_r _*_s_t_r);[+]

     Get a string through the window and put it in the loca-
     tion  pointed  to  by _s_t_r, which is assumed to be large
     enough to handle it.  It sets tty modes  if  necessary,
     and then calls getch() (or wgetch()) to get the charac-
     ters needed to fill in the string until  a  newline  or
     EOF  is  encountered.   The  newline  stripped  off the
     string.  This returns ERR if it would cause the  screen
     to scroll illegally.


getparx(_W_I_N_D_O_W _*_w_i_n);

     Returns  the x location of the given subwindow relative
     to the parent window.  If the window is not a subwindow
     then -1 is returned.


getpary(_W_I_N_D_O_W _*_w_i_n);

     Returns  the y location of the given subwindow relative
     to the parent window.  If the window is not a subwindow
     then -1 is returned.


getpary(_W_I_N_D_O_W _*_w_i_n, _i_n_t _y, _i_n_t _x);

     Is  a  macro  that  sets  the _y and _x parameters to the
     respective coordinates of the top left hand  corner  of
     the  subwindow  relative  to the parent window.  If the
     given window _w_i_n is not a subwindow then both _y  and  _x
     will be set to -1.


gettmode();

     Get   the  tty  stats.   This  is  normally  called  by
     initscr().


getwin(_F_I_L_E _*_f_p);

     Creates a window from a file written by putwin().


getyx(_W_I_N_D_O_W _*_w_i_n, _i_n_t _y, _i_n_t _x);

     Puts the current (y, x)  co-ordinates  of  _w_i_n  in  the
     variables  _y  and  _x.   Since  it  is  a  macro,  not a










PPPPSSSS1111::::11119999----11118888                                     SSSSccccrrrreeeeeeeennnn PPPPaaaacccckkkkaaaaggggeeee


     function, you do not pass the address of _y and _x.


halfdelay(_i_n_t _t_i_m_e_o_u_t);

     Sets the terminal into a mode similar to that  done  by
     cbreak()  with  the  exception  that the input routines
     will wait for _t_i_m_e_o_u_t number of tenths of a second,  if
     at  this  time  there  is  no  input  then  ERR will be
     returned.


has_colors();

     Check if terminal has colors.


hline(_c_h_t_y_p_e _c_h, _i_n_t _c_o_u_n_t);

     Draw a horizontal line of the character ch starting  at
     the  current  cursor  position  and  moving towards the
     rightmost column.  At most  _c_o_u_n_t  characters  will  be
     written,  less  if  the  edge  of the screen is reached
     before _c_o_u_n_t is reached.


idcok(_W_I_N_D_O_W _*_w_i_n, _i_n_t _b_o_o_l_f);

     Reserved for future use.  This will  eventually  signal
     to refresh() that it is all right to use the insert and
     delete char sequences when updating the window.


idlok(_W_I_N_D_O_W _*_w_i_n, _i_n_t _b_o_o_l_f);

     Reserved for future use.  This will  eventually  signal
     to refresh() that it is all right to use the insert and
     delete line sequences when updating the window.


inch();[+]

     Returns the character at the current  position  on  the
     given  window.   This  does not make any changes to the
     window.


inchnstr(_c_h_t_y_p_e _*_c_h_s_t_r, _i_n_t _n);

     Get an array of at most  _n  characters  and  renditions
     starting  at  the current cursor position and ending at
     the end of the line and put it in the location  pointed
     to by _c_h_s_t_r.










SSSSccccrrrreeeeeeeennnn PPPPaaaacccckkkkaaaaggggeeee                                     PPPPSSSS1111::::11119999----11119999


inchstr(_c_h_t_y_p_e _*_c_h_s_t_r);

     Get  an  array of characters and renditions starting at
     the current cursor position and ending at  the  end  of
     the  line  and  put  it  in  the location pointed to by
     _c_h_s_t_r, which is assumed to be large  enough  to  handle
     it.


innstr(_c_h_a_r _*_s_t_r, _i_n_t _n);

     Get  a  string  of at most _n characters starting at the
     current cursor position and ending at the  end  of  the
     line and put it in the location pointed to by _s_t_r.


init_color(_s_h_o_r_t _c_o_l_o_r, _s_h_o_r_t _r_e_d, _s_h_o_r_t _g_r_e_e_n, _s_h_o_r_t _b_l_u_e);

     Set the red, green and blue values of color _c_o_l_o_r.


init_pair(_s_h_o_r_t _p_a_i_r, _s_h_o_r_t _f_o_r_e, _s_h_o_r_t _b_a_c_k);

     Set  the foreground and background colors of pair _p_a_i_r.


initscr();

     Initialize the screen routines.  This  must  be  called
     before  any  of  the screen routines are used.  It ini-
     tializes the terminal-type data and such,  and  without
     it none of the routines can operate.  If standard input
     is not a tty, it sets the specifications to the  termi-
     nal  whose  name  is  pointed to by _D_e_f___t_e_r_m (initially
     "dumb").  If the boolean _M_y___t_e_r_m is non-zero,  _D_e_f___t_e_r_m
     is  always used.  If the system supports the TTTTIIIIOOOOCCCCGGGGWWWWIIIINNNNSSSSZZZZ
     _i_o_c_t_l_(_2_) call, it is used to get the  number  of  lines
     and  columns  for  the  terminal, otherwise it is taken
     from the tttteeeerrrrmmmmccccaaaapppp description.


insch(_c_h_a_r _c);

     Insert _c at the current (y, x) co-ordinates Each  char-
     acter  after it shifts to the right, and the last char-
     acter disappears.  This returns ERR if it  would  cause
     the screen to scroll illegally.


insdelln(_i_n_t _n);

     If  _n is positive insert _n lines above the current one.
     Every line below the current line will be shifted down,










PPPPSSSS1111::::11119999----22220000                                     SSSSccccrrrreeeeeeeennnn PPPPaaaacccckkkkaaaaggggeeee


     and the last _n lines will disappear.  If _n is negative,
     delete _n lines starting from the current one.  The last
     _n  lines  are cleared.  The current (y, x) co-ordinates
     will remain unchanged.


insertln();

     Insert a line above the current one.  Every line  below
     the  current  line will be shifted down, and the bottom
     line will disappear.   The  current  line  will  become
     blank,  and the current (y, x) co-ordinates will remain
     unchanged.


instr(_c_h_a_r _*_s_t_r);

     Get an string starting at the current  cursor  position
     and  ending  at  the  end of the line and put it in the
     location pointed to by _s_t_r,  which  is  assumed  to  be
     large enough to handle it.


is_linetouched(_W_I_N_D_O_W _*_w_i_n, _i_n_t _l_i_n_e);

     Returns  TRUE  if _l_i_n_e in the window _w_i_n has been modi-
     fied since the last call to wrefresh().


is_wintouched(_W_I_N_D_O_W _*_w_i_n, _i_n_t _l_i_n_e);

     Returns TRUE if the window _w_i_n has been modified  since
     the last call to wrefresh().


isendwin();

     Returns TRUE if endwin() has been called without a sub-
     sequent call to wrefresh(), and FALSE otherwise.


intrflush(_W_I_N_D_O_W _*_w_i_n, _i_n_t _b_o_o_l_f);

     Sets the terminal flush on interrupt mode.  If _b_o_o_l_f is
     non-zero, flushing of the output buffer will occur when
     an interrupt key is pressed.  The default is  inherited
     from the terminal settings.


keyok(_i_n_t _k_e_y___s_y_m_b_o_l, _b_o_o_l _f_l_a_g);

     Controls  the recognition of the key symbol _k_e_y___s_y_m_b_o_l.
     By  setting  _f_l_a_g  to  FALSE  the  recognition  of  any










SSSSccccrrrreeeeeeeennnn PPPPaaaacccckkkkaaaaggggeeee                                     PPPPSSSS1111::::11119999----22221111


     sequence  of  characters that have been associated with
     the key symbol will be disabled.  By default, this flag
     is TRUE so sequences will be recognised.


keyname(_i_n_t _k_e_y);

     Returns a description of the key _k_e_y.


keypad(_W_I_N_D_O_W _*_w_i_n, _i_n_t _b_o_o_l_f);

     Sets  the  boolean  flag  for  interpretation of escape
     sequences.  If _b_o_o_l_f is non-zero, escape sequences from
     terminal  keypad  and function keys will be interpreted
     by the library.  Escape sequences are  not  interpreted
     by  default.   The include file <<<<ccccuuuurrrrsssseeeessss....hhhh>>>> contains the
     list of recognised keypad and function keys.  See  also
     notimeout().


killchar();[+]

     Returns the line kill character for the terminal, _i_._e_.,
     the character used by the user to erase an entire  line
     from the input.


leaveok(_W_I_N_D_O_W _*_w_i_n, _i_n_t _b_o_o_l_f);[+]

     Sets  the boolean flag for leaving the cursor after the
     last change.  If _b_o_o_l_f is non-zero, the cursor will  be
     left  after  the  last  update on the terminal, and the
     current (y, x) co-ordinates for  _w_i_n  will  be  changed
     accordingly.  If _b_o_o_l_f
      is  0  the  cursor will be moved to the current (y, x)
     co-ordinates.  This  flag  (initially  0)  retains  its
     value until changed by the user.


longname();[+]

     Returns  a string containing the verbose description of
     the terminal.


meta(_W_I_N_D_O_W _*_w_i_n, _b_o_o_l _b_f);

     Manipulates the meta mode  on  terminals  that  support
     this capability.  Note that _w_i_n is always ignored.













PPPPSSSS1111::::11119999----22222222                                     SSSSccccrrrreeeeeeeennnn PPPPaaaacccckkkkaaaaggggeeee


move(_i_n_t _y, _i_n_t _x);

     Change the current (y, x) co-ordinates of the window to
     (_y_, _x).  This returns ERR if it would cause the  screen
     to scroll illegally.


mvaddch(_i_n_t _y, _i_n_t _x, _c_h_t_y_p_e _c_h);

     Moves the cursor to the position _(_y, _x) and then adds a
     character in the same manner as addch().


mvaddchstr(_i_n_t _y, _i_n_t _x, _c_h_t_y_p_e _*_s_t_r);[+]

     Moves the cursor to the position _(_y, _x) and  then  adds
     characters  and attributes in the same manner as addch-
     str().


mvaddchnstr(_i_n_t _y, _i_n_t _x, _c_h_t_y_p_e _*_s_t_r);[+]

     Moves the cursor to the position _(_y, _x) and  then  adds
     characters and attributes in the same manner as addchn-
     str().


mvaddstr(_i_n_t _y, _i_n_t _x, _c_h_a_r _*_s_t_r);[+]

     Moves the cursor to the position _(_y, _x) and then adds a
     string in the same manner as addstr().


mvaddnstr(_i_n_t _y, _i_n_t _x, _c_h_a_r _*_s_t_r);[+]

     Moves the cursor to the position _(_y, _x) and then adds a
     string in the same manner as addnstr().


mvcur(_i_n_t _l_a_s_t_y, _i_n_t _l_a_s_t_x, _i_n_t _n_e_w_y, _i_n_t _n_e_w_x);

     Moves the  terminal's  cursor  from  (_l_a_s_t_y_, _l_a_s_t_x)  to
     (_n_e_w_y_, _n_e_w_x)  in  an  approximation of optimal fashion.
     This routine uses the functions borrowed from  _e_x  ver-
     sion  2.6.   It  is  possible  to use this optimization
     without the benefit of the screen routines.   With  the
     screen routines, this should not be called by the user.
     move() and refresh() should be used to move the  cursor
     position, so that the routines know what's going on.


mvderwin(_W_I_N_D_O_W _*_w_i_n, _i_n_t _y, _i_n_t _x);











SSSSccccrrrreeeeeeeennnn PPPPaaaacccckkkkaaaaggggeeee                                     PPPPSSSS1111::::11119999----22223333


     Moves  the  subwindow  _w_i_n to the location (_y_, _x) where
     the location is relative to the top left hand corner of
     the parent window.  This call will return ERR if _w_i_n is
     not a subwindow or if the relocated  window  would  lie
     outside the parent window.


mvhline(_i_n_t _y, _i_n_t _x, _c_h_t_y_p_e _c_h, _i_n_t _c_o_u_n_t);

     Moves  the cursor to the position _(_y, _x) and then draws
     a horizontal line in the same manner as hline().


mvprintw(_i_n_t _y, _i_n_t _x, _c_o_n_s_t _c_h_a_r _*_f_m_t, _._._.);

     Equivalent to:

         move(y, x);
         printw(fmt, ...);



mvscanw(_i_n_t _y, _i_n_t _x, _c_o_n_s_t _c_h_a_r _*_f_m_t, _._._.);

     Equivalent to:

         move(y, x);
         scanw(fmt, ...);



mvvline(_i_n_t _y, _i_n_t _x, _c_h_t_y_p_e _c_h, _i_n_t _c_o_u_n_t);

     Moves the cursor to the position _(_y, _x) and then  draws
     a vertical line in the same manner as vline().


mvwhline(_W_I_N_D_O_W _*_w_i_n, _i_n_t _y, _i_n_t _x, _c_h_t_y_p_e _c_h, _i_n_t _c_o_u_n_t);

     Moves  the  cursor to the position _(_y, _x) on window _w_i_n
     and then draws a horizontal line in the same manner  as
     whline().


mvwvline(_W_I_N_D_O_W _*_w_i_n, _i_n_t _y, _i_n_t _x, _c_h_t_y_p_e _c_h, _i_n_t _c_o_u_n_t);

     Moves  the  cursor to the position _(_y, _x) on window _w_i_n
     and then draws a horizontal line in the same manner  as
     wvline().


mvwin(_W_I_N_D_O_W _*_w_i_n, _i_n_t _y, _i_n_t _x);











PPPPSSSS1111::::11119999----22224444                                     SSSSccccrrrreeeeeeeennnn PPPPaaaacccckkkkaaaaggggeeee


     Move  the home position of the window _w_i_n from its cur-
     rent starting coordinates to (_y_, _x).  If that would put
     part  or all of the window off the edge of the terminal
     screen, mvwin() returns ERR and does  not  change  any-
     thing.  For subwindows, mvwin() also returns ERR if you
     attempt to move it off its main window.  If you move  a
     main window, all subwindows are moved along with it.


mvwprintw(_W_I_N_D_O_W _*_w_i_n, _i_n_t _y, _i_n_t _x, _c_o_n_s_t _c_h_a_r _*_f_m_t, _._._.);

     Equivalent to:

         wmove(win, y, x);
         printw(fmt, ...);



mvwscanw(_W_I_N_D_O_W _*_w_i_n, _i_n_t _y, _i_n_t _x, _c_o_n_s_t _c_h_a_r _*_f_m_t, _._._.);

     Equivalent to:

         wmove(win, y, x);
         scanw(fmt, ...);



napms(_i_n_t _m_s);

     Sleep for _m_s milliseconds.


newpad(_i_n_t _l_i_n_e_s, _i_n_t _c_o_l_s);

     Create a new pad with _l_i_n_e_s lines and _c_o_l_s columns.


newterm(_c_h_a_r _*_t_y_p_e, _F_I_L_E _*_o_u_t_f_d, _F_I_L_E _*_i_n_f_d);

     Iinitialise the curses subsystem to use the terminal of
     type _t_y_p_e connected via the input  and  output  streams
     _i_n_f_d_,_o_u_t_f_d_.   The  newterm()  is used in multi-terminal
     applications and returns a pointer to a structure  that
     holds  the  state  for  that  particular terminal.  The
     application may swap between the terminals  by  calling
     the set_term() function.  If the _t_y_p_e parameter is NULL
     then the $TERM variable is used as the terminal type.


newwin(_i_n_t _l_i_n_e_s, _i_n_t _c_o_l_s, _i_n_t _b_e_g_i_n___y, _i_n_t _b_e_g_i_n___x);

     Create a new window with _l_i_n_e_s lines and  _c_o_l_s  columns
     starting  at  position  (_b_e_g_i_n___y_, _b_e_g_i_n___x).   If either










SSSSccccrrrreeeeeeeennnn PPPPaaaacccckkkkaaaaggggeeee                                     PPPPSSSS1111::::11119999----22225555


     _l_i_n_e_s or _c_o_l_s is 0 (zero), that dimension will  be  set
     to  (_L_I_N_E_S _- _b_e_g_i_n___y) or (_C_O_L_S _- _b_e_g_i_n___x) respectively.
     Thus, to get a new window of dimensions _L_I_N_E_S  x  _C_O_L_S,
     use newwin(_0, _0, _0, _0).


nl();

     Set  the terminal to nl mode, _i_._e_., start/stop the sys-
     tem from mapping <<<<RRRREEEETTTTUUUURRRRNNNN>>>> to <<<<LLLLIIIINNNNEEEE----FFFFEEEEEEEEDDDD>>>>.  If the  map-
     ping  is  not done, refresh() can do more optimization,
     so it is recommended, but not required, to turn it off.


no_color_video();

     Return attributes that cannot be combined with color.


nocbreak();

     Unset the terminal from cbreak mode.


nocrmode();[+]

     Identical to nocbreak().  The misnamed macro nocrmode()
     is retained for  backwards  compatibility  with  ealier
     versions of the library.


nodelay(_W_I_N_D_O_W _*_w_i_n_1, _i_n_t _b_o_o_l_f);

     Sets  the  boolean  flag  for non-blocking getch().  If
     _b_o_o_l_f is non-zero, getch() will return ERR is no  input
     is  waiting.   The  default  is to for getch() to block
     indefinitely.  See also timeout().


noecho();[+]

     Turn echoing of characters off.


nonl();

     Unset the terminal to from nl mode.  See nl().


noqiflush();[+]

     Unset the terminal flush on interrupt  mode.   This  is
     equivalent to intrflush(_s_t_d_s_c_r, _F_A_L_S_E).










PPPPSSSS1111::::11119999----22226666                                     SSSSccccrrrreeeeeeeennnn PPPPaaaacccckkkkaaaaggggeeee


noraw();

     Unset the terminal from raw mode.  See raw().


notimeout(_W_I_N_D_O_W _*_w_i_n_1, _i_n_t _b_o_o_l_f);

     Sets the boolean flag for inter-key timeouts for escape
     sequences  interpreted  when  keypad()  is   set.    By
     default,  keypad()  sets  a timer while waiting for the
     next character of an escape sequence.  If _b_o_o_l_f is non-
     zero,  getch()  will  wait  indefinitely between escape
     sequence characters, or until a delay set by  timeout()
     expires.


overlay(_W_I_N_D_O_W _*_w_i_n_1, _W_I_N_D_O_W _*_w_i_n_2);

     Overlay _w_i_n_1 on _w_i_n_2.  The contents of _w_i_n_1, insofar as
     they fit, are placed on _w_i_n_2 at their  starting  (y, x)
     co-ordinates.   This  is  done non-destructively, i.e.,
     blanks on _w_i_n_1 leave the contents of the space on  _w_i_n_2
     untouched.   Note  that  all  non-blank  characters are
     overwritten destructively in the overlay.


overwrite(_W_I_N_D_O_W _*_w_i_n_1, _W_I_N_D_O_W _*_w_i_n_2);

     Overwrite _w_i_n_1 on _w_i_n_2.  The contents of _w_i_n_1,  insofar
     as  they  fit,  are  placed  on  _w_i_n_2 at their starting
     (y, x) co-ordinates.  This is done destructively, _i_._e_.,
     blanks on _w_i_n_1 become blank on _w_i_n_2.


pair_content(_s_h_o_r_t _p_a_i_r, _s_h_o_r_t _*_f_o_r_e, _s_h_o_r_t _*_b_a_c_k);

     Get  the foreground and background colors of pair _p_a_i_r.


pechochar(_c_o_n_s_t _c_h_t_y_p_e _c_h);[+]

     Add the character _c_h on the pad at the  current  (y, x)
     co-ordinates and immediately refresh the pad.


pnoutrefresh(_W_I_N_D_O_W _*_p_a_d, _i_n_t _p_b_e_g___y, _i_n_t _p_b_e_g___x, _i_n_t _s_b_e_g___y, _i_n_t _s_b_e_g___x, _i_n_t _s_m_a_x___y, _i_n_t _s_m_a_x___x);

     Add the pad contents to a virtual screen.  Several pads
     can be added before a call to doupdate(), thus allowing
     the screen to updated in an efficient manner.













SSSSccccrrrreeeeeeeennnn PPPPaaaacccckkkkaaaaggggeeee                                     PPPPSSSS1111::::11119999----22227777


prefresh(_W_I_N_D_O_W _*_p_a_d, _i_n_t _p_b_e_g___y, _i_n_t _p_b_e_g___x, _i_n_t _s_b_e_g___y, _i_n_t _s_b_e_g___x, _i_n_t _s_m_a_x___y, _i_n_t _s_m_a_x___x);

     Synchronize the terminal screen with the desired pad.


printw(_c_h_a_r _*_f_m_t, _._._.);

     Performs  a printf() on the window starting at the cur-
     rent (y, x) co-ordinates.  It uses addstr() to add  the
     string on the window.  It is often advisable to use the
     field width options of printf() to avoid leaving things
     on  the window from earlier calls.  This returns ERR if
     it would cause the screen to scroll illegally.


putwin(_W_I_N_D_O_W _*_w_i_n, _F_I_L_E _*_f_p);

     Writes the window data to a file.


qiflush();[+]

     Set the terminal flush  on  interrupt  mode.   This  is
     equivalent to intrflush(_s_t_d_s_c_r, _T_R_U_E).


raw();

     Set  the terminal to raw mode.  On version 7 UUUUNNNNIIIIXXXX2222 this
     also turns off newline mapping (see nl()).


redrawwin(_W_I_N_D_O_W _*_w_i_n);[+]

     Mark the entire window as having been corrupted.   This
     is equivalent to the touchwin() function.


refresh();[+]

     Synchronize  the  terminal screen with the desired win-
     dow.  If the window is not a  screen,  only  that  part
     covered by it is updated.  This returns ERR if it would
     cause the screen to scroll illegally.  In this case, it
     will update whatever it can without causing the scroll.

     As a special case, if wrefresh()  is  called  with  the
     window _c_u_r_s_c_r the screen is cleared and repainted as it
     is currently.  This is very  useful  for  allowing  the
____________________
   2 UUUUNNNNIIIIXXXX is a trademark of Unix System Laboratories.












PPPPSSSS1111::::11119999----22228888                                     SSSSccccrrrreeeeeeeennnn PPPPaaaacccckkkkaaaaggggeeee


     redrawing  of  the  screen  when  the  user has garbage
     dumped on his terminal.


reset_prog_mode();

     Restore the terminal to the 'in curses' state.


reset_shell_mode();

     Restore the terminal to the 'not in curses' state.


resetty();[+]

     resetty()  restores  them  to  what  savetty()  stored.
     These   functions   are   performed   automatically  by
     initscr() and endwin().  This function  should  not  be
     used by the user.


resizeterm(_i_n_t _l_i_n_e_s, _i_n_t _c_o_l_u_m_n_s);[+]

     Resizes  the  curses  terminal  to the given size.  All
     internal curses  structures  are  resized  to  the  new
     dimensions  and  all  curses  windows  that  would have
     boundaries  outside  the  new  terminal  size  will  be
     resized  to fit within the new boundaries.  All windows
     will be cleared and it is expected that the application
     will redraw the window contents.


savetty();[+]

     savetty()  saves  the current tty characteristic flags.
     See resetty().  This function should not be used by the
     user.


scanw(_c_h_a_r _*_f_m_t, _._._.);

     Perform  a  scanf()  through  the window using _f_m_t.  It
     does  this  using  consecutive  calls  to  getch()  (or
     wgetch()).   This  returns  ERR  if  it would cause the
     screen to scroll illegally.


scrl(_i_n_t _n);

     Scroll the window by _n lines. If _n is positive,  scroll
     upward, otherwise scroll downward.











SSSSccccrrrreeeeeeeennnn PPPPaaaacccckkkkaaaaggggeeee                                     PPPPSSSS1111::::11119999----22229999


scroll(_W_I_N_D_O_W _*_w_i_n);

     Scroll  the  window  upward one line.  This is normally
     not used by the user.


scrollok(_W_I_N_D_O_W _*_w_i_n, _i_n_t _b_o_o_l_f);[+]

     Set the scroll flag for the given window.  If _b_o_o_l_f  is
     0,  scrolling is not allowed.  This is its default set-
     ting.


set_term(_S_C_R_E_E_N _*_n_e_w);

     Sets the current screen for input and output to be  the
     one given.  The _n_e_w structure must be one that has been
     previously created  by  the  newterm()  function.   The
     set_term() function returns the previous screen on suc-
     cessful completion.


standend();[+]

     End standout mode initiated by standout().  This  func-
     tion  is  provided  for compatibility with older curses
     implementations.


standout();[+]

     Causes any characters added to the window to be put  in
     standout  mode on the terminal (if it has that capabil-
     ity).  This function is provided for compatibility with
     older  curses implementations.  A larger range of char-
     acter attributes supported by modern terminals  can  be
     accessed using attron() and attrset().


start_color();

     Initialize  the  color  routines.   This must be called
     before any of the color routines are used.  The  termi-
     nal  is setup to use the curses default colors of white
     foreground     on     black     background,      unless
     assume_default_colors()   or  use_default_colors()  are
     called.


subpad(_W_I_N_D_O_W _*_w_i_n, _i_n_t _l_i_n_e_s, _i_n_t _c_o_l_s, _i_n_t _b_e_g_i_n___y, _i_n_t _b_e_g_i_n___x);

     Create a new pad with  _l_i_n_e_s  lines  and  _c_o_l_s  columns
     starting  at position (_b_e_g_i_n___y_, _b_e_g_i_n___x) inside the pad










PPPPSSSS1111::::11119999----33330000                                     SSSSccccrrrreeeeeeeennnn PPPPaaaacccckkkkaaaaggggeeee


     _w_i_n.  This means that any change made to either pad  in
     the  area  covered  by  the subpad will be made on both
     pads.  _b_e_g_i_n___y_, _b_e_g_i_n___x are specified relative  to  the
     relative (0, 0) of _w_i_n.


subwin(_W_I_N_D_O_W _*_w_i_n, _i_n_t _l_i_n_e_s, _i_n_t _c_o_l_s, _i_n_t _b_e_g_i_n___y, _i_n_t _b_e_g_i_n___x);

     Create  a  new window with _l_i_n_e_s lines and _c_o_l_s columns
     starting at position (_b_e_g_i_n___y_, _b_e_g_i_n___x) inside the win-
     dow  _w_i_n.   This  means  that any change made to either
     window in the area covered by  the  subwindow  will  be
     made  on  both windows.  _b_e_g_i_n___y_, _b_e_g_i_n___x are specified
     relative to the overall screen, not the relative (0, 0)
     of  _w_i_n.   If  either  _l_i_n_e_s  or _c_o_l_s is 0 (zero), that
     dimension will be set to (_L_I_N_E_S _- _b_e_g_i_n___y) or  (_C_O_L_S  _-
     _b_e_g_i_n___x) respectively.


termattrs();

     Returns  the  attributes  that  can  be  applied to the
     screen.


term_attrs();

     Returns the wide attributes that can be applied to  the
     screen.


timeout(_i_n_t _d_e_l_a_y);[+]

     Sets  blocking  or  non-blocking  getch().  If _d_e_l_a_y is
     positive, getch() will  block  for  _d_e_l_a_y  milliseconds
     before  returning.   If  _d_e_l_a_y  is  zero,  getch() will
     return ERR is no input is waiting.  If _d_e_l_a_y  is  nega-
     tive,  getch()  will block indefinitely.  See also key-
     pad(), nodelay() and notimeout().


touchline(_W_I_N_D_O_W _*_w_i_n, _i_n_t _y, _i_n_t _s_t_a_r_t_x, _i_n_t _e_n_d_x);

     This function performs a function similar to touchwin()
     on  a  single  line.  It marks the first change for the
     given line to be _s_t_a_r_t_x, if it is  before  the  current
     first  change  mark, and the last change mark is set to
     be _e_n_d_x if it is currently less than _e_n_d_x.


touchoverlap(_W_I_N_D_O_W _*_w_i_n_1, _W_I_N_D_O_W _*_w_i_n_2);












SSSSccccrrrreeeeeeeennnn PPPPaaaacccckkkkaaaaggggeeee                                     PPPPSSSS1111::::11119999----33331111


     Touch the window _w_i_n_2 in the area which  overlaps  with
     _w_i_n_1.  If they do not overlap, no changes are made.


touchwin(_W_I_N_D_O_W _*_w_i_n);

     Make  it  appear  that the every location on the window
     has been changed.  This  is  usually  only  needed  for
     refreshes with overlapping windows.


tstp()

     This  function will save the current tty state and then
     put the  process  to  sleep.   When  the  process  gets
     restarted,  it  restores  the  saved tty state and then
     calls   wrefresh(_c_u_r_s_c_r);   to   redraw   the   screen.
     Initscr()  sets the signal SIGTSTP to trap to this rou-
     tine.


unctrl(_c_h_a_r _*_c_h);[+]

     Returns a string which is an  ASCII  representation  of
     _c_h.  Characters are 8 bits long.


unctrllen(_c_h_a_r _*_c_h);[+]

     Returns the length of the ASCII representation of _c_h.


underend();[+]

     End underscore mode initiated by underscore().  This is
     equivalent to attroff(_A___U_N_D_E_R_L_I_N_E).


underscore();[+]

     Causes any characters added to the window to be put  in
     underscore  mode  on the terminal (if it has that capa-
     bility).  This is equivalent to attron(_A___U_N_D_E_R_L_I_N_E).


ungetch(_i_n_t _c);

     Places the contents of _c converted to a character  back
     into  the input queue.  Only one character of push back
     before a subsequent call  to  getch()  or  wgetch()  is
     guaranteed  to  function  correctly.   The  results  of
     attempting more than one  character  of  push  back  is
     undefined.










PPPPSSSS1111::::11119999----33332222                                     SSSSccccrrrreeeeeeeennnn PPPPaaaacccckkkkaaaaggggeeee


untouchwin(_W_I_N_D_O_W _*_w_i_n);

     Make the window appear to have not been updated even if
     it has been.


use_default_colors();

     Use the terminal foreground and  background  colors  as
     the curses default foreground and background colors.


vline(_c_h_t_y_p_e _c_h, _i_n_t _c_o_u_n_t);

     Draws  a  vertical line of character _c_h starting at the
     current cursor location and moving towards  the  bottom
     of  the  screen.   At  most _c_o_u_n_t characters are drawn,
     less if the bottom of  the  screen  is  reached  before
     _c_o_u_n_t expires.


vwprintw(_W_I_N_D_O_W _*_w_i_n, _c_o_n_s_t _c_h_a_r _*_f_m_t, _v_a___l_i_s_t _a_p);

     Identical  to printw() except that it takes both a win-
     dow specification and a pointer to  a  variable  length
     argument list.


vwscanw(_W_I_N_D_O_W _*_w_i_n, _c_o_n_s_t _c_h_a_r _*_f_m_t, _v_a___l_i_s_t _a_p);

     Identical to scanw() except that it takes both a window
     specification and a pointer to a variable length  argu-
     ment list.


wnoutrefresh(_W_I_N_D_O_W _*_w_i_n);

     Add  the  window contents to a virtual screen.  Several
     windows can be added before a call to doupdate(),  thus
     allowing  the screen to updated in an efficient manner.


wredrawln(_W_I_N_D_O_W _*_w_i_n, _i_n_t _l_i_n_e, _i_n_t _n);[+]

     Mark _n lines starting at _l_i_n_e in  the  window  as  cor-
     rupted.   This  is equivalent to wtouchln(_w_i_n, _l_i_n_e, _n,
     _1).


wresize(_W_I_N_D_O_W _*_w_i_n, _i_n_t _l_i_n_e_s, _i_n_t _c_o_l_u_m_n_s);

     Resize the specified window to  the  given  dimensions.
     The  window  will  be  cleared  and  the application is










SSSSccccrrrreeeeeeeennnn PPPPaaaacccckkkkaaaaggggeeee                                     PPPPSSSS1111::::11119999----33333333


     expected to redraw the window contents.


wtouchln(_W_I_N_D_O_W _*_w_i_n, _i_n_t _l_i_n_e, _i_n_t _n, _i_n_t _c_h_a_n_g_e_d);

     If _c_h_a_n_g_e_d is 1 then _n lines starting at  _l_i_n_e  in  the
     window  are  touched.   If  _c_h_a_n_g_e_d  is  0 then _n lines
     starting at _l_i_n_e in the window are untouched.



     _T_h_e _f_o_l_l_o_w_i_n_g _f_u_n_c_t_i_o_n_s _d_i_f_f_e_r _f_r_o_m _t_h_e _s_t_a_n_d_a_r_d  _f_u_n_c_-
_t_i_o_n_s  _o_n_l_y  _i_n _t_h_e_i_r _s_p_e_c_i_f_i_c_a_t_i_o_n _o_f _a _w_i_n_d_o_w_, _r_a_t_h_e_r _t_h_a_n
_t_h_e _u_s_e _o_f _t_h_e _d_e_f_a_u_l_t _s_t_d_s_c_r_.


waddbytes(_W_I_N_D_O_W _*_w_i_n, _c_h_a_r_* _s_t_r, _i_n_t _l_e_n);
waddch(_W_I_N_D_O_W _*_w_i_n, _c_h_t_y_p_e _c_h);
waddchnstr(_W_I_N_D_O_W _*_w_i_n, _c_h_t_y_p_e _*_s_t_r, _i_n_t _l_e_n);
waddchstr(_W_I_N_D_O_W _*_w_i_n, _c_h_t_y_p_e _*_s_t_r, _i_n_t _l_e_n);
waddnstr(_W_I_N_D_O_W _*_w_i_n, _c_h_a_r _*_s_t_r, _i_n_t _l_e_n);
waddstr(_W_I_N_D_O_W _*_w_i_n, _c_h_a_r _*_s_t_r);
wattroff(_W_I_N_D_O_W _*_w_i_n, _i_n_t _a_t_t_r);
wattron(_W_I_N_D_O_W _*_w_i_n, _i_n_t _a_t_t_r);
wattrset(_W_I_N_D_O_W _*_w_i_n, _i_n_t _a_t_t_r);
wbkgd(_W_I_N_D_O_W _*_w_i_n, _c_h_t_y_p_e _c_h);
wbkgdset(_W_I_N_D_O_W _*_w_i_n, _c_h_t_y_p_e _c_h);
wborder(_W_I_N_D_O_W _*_w_i_n, _c_h_t_y_p_e _l_e_f_t, _c_h_t_y_p_e _r_i_g_h_t, _c_h_t_y_p_e _t_o_p, _c_h_t_y_p_e _b_o_t_t_o_m, _c_h_t_y_p_e _t_o_p_l_e_f_t, _c_h_t_y_p_e _t_o_p_r_i_g_h_t, _c_h_t_y_p_e _b_o_t_l_e_f_t);
wclear(_W_I_N_D_O_W _*_w_i_n);
wclrtobot(_W_I_N_D_O_W _*_w_i_n);
wclrtoeol(_W_I_N_D_O_W _*_w_i_n);
wdelch(_W_I_N_D_O_W _*_w_i_n);
wdeleteln(_W_I_N_D_O_W _*_w_i_n);
wechochar(_W_I_N_D_O_W _*_w_i_n, _c_h_t_y_p_e _c_h);
werase(_W_I_N_D_O_W _*_w_i_n);
wgetch(_W_I_N_D_O_W _*_w_i_n);
wgetnstr(_W_I_N_D_O_W _*_w_i_n, _c_h_a_r _*_s_t_r, _i_n_t _l_e_n);
wgetstr(_W_I_N_D_O_W _*_w_i_n, _c_h_a_r _*_s_t_r);
whline(_W_I_N_D_O_W _*_w_i_n, _c_h_t_y_p_e _c_h, _i_n_t _c_o_u_n_t);
winch(_W_I_N_D_O_W _*_w_i_n);[+]
winchnstr(_W_I_N_D_O_W _*_w_i_n, _c_h_t_y_p_e _*_c_h_s_t_r, _i_n_t _n);
winchstr(_W_I_N_D_O_W _*_w_i_n, _c_h_t_y_p_e _*_c_h_s_t_r);
winnstr(_W_I_N_D_O_W _*_w_i_n, _c_h_a_r _*_s_t_r, _i_n_t _n);
winsch(_W_I_N_D_O_W _*_w_i_n, _c_h_a_r _c);
winsdelln(_W_I_N_D_O_W _*_w_i_n, _i_n_t _n);
winsertln(_W_I_N_D_O_W _*_w_i_n);
winstr(_W_I_N_D_O_W _*_w_i_n, _c_h_a_r _*_s_t_r);
wmove(_W_I_N_D_O_W _*_w_i_n, _i_n_t _y, _i_n_t, _x_");
wprintw(_W_I_N_D_O_W _*_w_i_n, _c_h_a_r _*_f_m_t, _._._.);
wrefresh(_W_I_N_D_O_W _*_w_i_n);
wscanw(_W_I_N_D_O_W _*_w_i_n, _c_h_a_r _*_f_m_t, _._._.);
wscrl(_W_I_N_D_O_W _*_w_i_n, _i_n_t _n);
wstandend(_W_I_N_D_O_W _*_w_i_n);










PPPPSSSS1111::::11119999----33334444                                     SSSSccccrrrreeeeeeeennnn PPPPaaaacccckkkkaaaaggggeeee


wstandout(_W_I_N_D_O_W _*_w_i_n);
wtimeout(_W_I_N_D_O_W _*_w_i_n, _i_n_t _d_e_l_a_y);
wunderend(_W_I_N_D_O_W _*_w_i_n);
wunderscore(_W_I_N_D_O_W _*_w_i_n);
wvline(_W_I_N_D_O_W _*_w_i_n, _c_h_t_y_p_e _c_h, _i_n_t _c_o_u_n_t);
mvwaddch(_W_I_N_D_O_W _*_w_i_n, _i_n_t _y, _i_n_t _x, _c_h_t_y_p_e _c_h);
mvwaddchstr(_W_I_N_D_O_W _*_w_i_n, _i_n_t _y, _i_n_t _x, _c_h_t_y_p_e _*_s_t_r);[+]
mvwaddchnstr(_W_I_N_D_O_W _*_w_i_n, _i_n_t _y, _i_n_t _x, _c_h_t_y_p_e _*_s_t_r);[+]
mvwaddnstr(_W_I_N_D_O_W _*_w_i_n, _i_n_t _y, _i_n_t _x, _c_h_a_r _*_s_t_r, _i_n_t _l_e_n);
mvwaddstr(_W_I_N_D_O_W _*_w_i_n, _i_n_t _y, _i_n_t _x, _c_h_a_r _*_s_t_r);
mvwgetnstr(_W_I_N_D_O_W _*_w_i_n, _i_n_t _y, _i_n_t _x, _c_h_a_r _*_s_t_r, _i_n_t _l_e_n);
mvwgetstr(_W_I_N_D_O_W _*_w_i_n, _i_n_t _y, _i_n_t _x, _c_h_a_r _*_s_t_r);
mvwhline(_W_I_N_D_O_W _*_w_i_n, _i_n_t _y, _i_n_t _x, _c_h_t_y_p_e _c_h, _i_n_t _c_o_u_n_t);
mvwvline(_W_I_N_D_O_W _*_w_i_n, _i_n_t _y, _i_n_t _x, _c_h_t_y_p_e _c_h, _i_n_t _c_o_u_n_t);

















































SSSSccccrrrreeeeeeeennnn PPPPaaaacccckkkkaaaaggggeeee                                     PPPPSSSS1111::::11119999----33335555


1111....  EEEExxxxaaaammmmpppplllleeeessss

     Here we present a few examples of how to use the  pack-
age.   They attempt to be representative, though not compre-
hensive.  Further examples can be found in the games section
of  the  source  tree  and in various utilities that use the
screen such as _s_y_s_t_a_t_(_1_).

     The following examples are intended to demonstrate  the
basic  structure  of  a program using the package.  An addi-
tional, more comprehensive, program  can  be  found  in  the
source code in the _e_x_a_m_p_l_e_s subdirectory.

1111....1111....  SSSSiiiimmmmpppplllleeee CCCChhhhaaaarrrraaaacccctttteeeerrrr OOOOuuuuttttppppuuuutttt

     This  program  demonstrates  how to set up a window and
output characters to it.   Also,  it  demonstrates  how  one
might  control  the  output  to the window.  If you run this
program, you will get a demonstration of the character  out-
put  chracteristics  discussed in the above Character Output
section.

    _#_i_n_c_l_u_d_e <sys_/types.h>
    _#_i_n_c_l_u_d_e <curses.h>
    _#_i_n_c_l_u_d_e <stdio.h>
    _#_i_n_c_l_u_d_e <signal.h>


    _#_d_e_f_i_n_e YSIZE 10
    _#_d_e_f_i_n_e XSIZE 20

    _i_n_t quit();

    main()
    _{
               _i_n_t i, j, c;
               size_t len;
               _c_h_a_r id[100];
               FILE _*fp;
               _c_h_a_r _*s;

               initscr();                              _/_* _A_l_w_a_y_s _c_a_l_l _i_n_i_t_s_c_r_(_) _f_i_r_s_t _*_/
               signal(SIGINT, quit);                   _/_* _M_a_k_e _s_u_r_e _w_o_u _h_a_v_e _a _'_c_l_e_a_n_u_p_' _f_n _*_/
               crmode();                               _/_* _W_e _w_a_n_t _c_b_r_e_a_k _m_o_d_e _*_/
               noecho();                               _/_* _W_e _w_a_n_t _t_o _h_a_v_e _c_o_n_t_r_o_l _o_f _c_h_a_r_s _*_/
               delwin(stdscr);                         _/_* _C_r_e_a_t_e _o_u_r _o_w_n _s_t_d_s_c_r _*_/
               stdscr = newwin(YSIZE, XSIZE, 10, 35);
               flushok(stdscr, TRUE);                  _/_* _E_n_a_b_l_e _f_l_u_s_h_i_n_g _o_f _s_t_d_o_u_t _*_/
               scrollok(stdscr, TRUE);                 _/_* _E_n_a_b_l_e _s_c_r_o_l_l_i_n_g _*_/
               erase();                                _/_* _I_n_i_t_i_a_l_l_y_, _c_l_e_a_r _t_h_e _s_c_r_e_e_n _*_/

               standout();
               move(0,0);










                         _A_p_p_e_n_d_i_x _A


               _w_h_i_l_e (1) _{
                         c = getchar();
                         _s_w_i_t_c_h(c) _{
                         _c_a_s_e 'q':                     _/_* _Q_u_i_t _o_n _'_q_' _*_/
                                   quit();
                                   _b_r_e_a_k;
                         _c_a_s_e 's':                     _/_* _G_o _i_n_t_o _s_t_a_n_d_o_u_t _m_o_d_e _o_n _'_s_' _*_/
                                   standout();
                                   _b_r_e_a_k;
                         _c_a_s_e 'e':                     _/_* _E_x_i_t _s_t_a_n_d_o_u_t _m_o_d_e _o_n _'_e_' _*_/
                                   standend();
                                   _b_r_e_a_k;
                         _c_a_s_e 'r':                     _/_* _F_o_r_c_e _a _r_e_f_r_e_s_h _o_n _'_r_' _*_/
                                   wrefresh(curscr);
                                   _b_r_e_a_k;
                         _d_e_f_a_u_l_t:                      _/_* _B_y _d_e_f_a_u_l_t _o_u_t_p_u_t _t_h_e _c_h_a_r_a_c_t_e_r _*_/
                                   addch(c);
                                   refresh();
                         _}
               _}
    _}


    _i_n_t
    quit()
    _{
               erase();                      _/_* _T_e_r_m_i_n_a_t_e _b_y _e_r_a_s_i_n_g _t_h_e _s_c_r_e_e_n _*_/
               refresh();
               endwin();                     _/_* _A_l_w_a_y_s _e_n_d _w_i_t_h _e_n_d_w_i_n_(_) _*_/
               delwin(curscr);               _/_* _R_e_t_u_r_n _s_t_o_r_a_g_e _*_/
               delwin(stdscr);
               putchar('\n');
               exit(0);
    _}






1111....2222....  TTTTwwwwiiiinnnnkkkklllleeee

     This is a moderately simple program which  prints  pat-
terns on the screen.  It switches between patterns of aster-
isks, putting them on one by one in random order,  and  then
taking  them  off in the same fashion.  It is more efficient
to write this using only  the  motion  optimization,  as  is
demonstrated below.

    _/_*           _$_N_e_t_B_S_D_: _t_w_i_n_k_l_e_1_._c_,_v _1_._6 _2_0_0_5_/_0_5_/_2_3 _0_4_:_0_4_:_4_9 _c_h_r_i_s_t_o_s _E_x_p _$                    _*_/













                         _A_p_p_e_n_d_i_x _A


    _/_*
     _*
     _*  _C_o_p_y_r_i_g_h_t _(_c_) _1_9_8_0_, _1_9_9_3
     _*          _T_h_e _R_e_g_e_n_t_s _o_f _t_h_e _U_n_i_v_e_r_s_i_t_y _o_f _C_a_l_i_f_o_r_n_i_a_.  _A_l_l _r_i_g_h_t_s _r_e_s_e_r_v_e_d_.
     _*
     _*  _R_e_d_i_s_t_r_i_b_u_t_i_o_n _a_n_d _u_s_e _i_n _s_o_u_r_c_e _a_n_d _b_i_n_a_r_y _f_o_r_m_s_, _w_i_t_h _o_r _w_i_t_h_o_u_t
     _*  _m_o_d_i_f_i_c_a_t_i_o_n_, _a_r_e _p_e_r_m_i_t_t_e_d _p_r_o_v_i_d_e_d _t_h_a_t _t_h_e _f_o_l_l_o_w_i_n_g _c_o_n_d_i_t_i_o_n_s
     _*  _a_r_e _m_e_t_:
     _*  _1_. _R_e_d_i_s_t_r_i_b_u_t_i_o_n_s _o_f _s_o_u_r_c_e _c_o_d_e _m_u_s_t _r_e_t_a_i_n _t_h_e _a_b_o_v_e _c_o_p_y_r_i_g_h_t
     _*     _n_o_t_i_c_e_, _t_h_i_s _l_i_s_t _o_f _c_o_n_d_i_t_i_o_n_s _a_n_d _t_h_e _f_o_l_l_o_w_i_n_g _d_i_s_c_l_a_i_m_e_r_.
     _*  _2_. _R_e_d_i_s_t_r_i_b_u_t_i_o_n_s _i_n _b_i_n_a_r_y _f_o_r_m _m_u_s_t _r_e_p_r_o_d_u_c_e _t_h_e _a_b_o_v_e _c_o_p_y_r_i_g_h_t
     _*     _n_o_t_i_c_e_, _t_h_i_s _l_i_s_t _o_f _c_o_n_d_i_t_i_o_n_s _a_n_d _t_h_e _f_o_l_l_o_w_i_n_g _d_i_s_c_l_a_i_m_e_r _i_n _t_h_e
     _*     _d_o_c_u_m_e_n_t_a_t_i_o_n _a_n_d_/_o_r _o_t_h_e_r _m_a_t_e_r_i_a_l_s _p_r_o_v_i_d_e_d _w_i_t_h _t_h_e _d_i_s_t_r_i_b_u_t_i_o_n_.
     _*  _3_. _N_e_i_t_h_e_r _t_h_e _n_a_m_e _o_f _t_h_e _U_n_i_v_e_r_s_i_t_y _n_o_r _t_h_e _n_a_m_e_s _o_f _i_t_s _c_o_n_t_r_i_b_u_t_o_r_s
     _*     _m_a_y _b_e _u_s_e_d _t_o _e_n_d_o_r_s_e _o_r _p_r_o_m_o_t_e _p_r_o_d_u_c_t_s _d_e_r_i_v_e_d _f_r_o_m _t_h_i_s _s_o_f_t_w_a_r_e
     _*     _w_i_t_h_o_u_t _s_p_e_c_i_f_i_c _p_r_i_o_r _w_r_i_t_t_e_n _p_e_r_m_i_s_s_i_o_n_.
     _*
     _*  _T_H_I_S _S_O_F_T_W_A_R_E _I_S _P_R_O_V_I_D_E_D _B_Y _T_H_E _R_E_G_E_N_T_S _A_N_D _C_O_N_T_R_I_B_U_T_O_R_S _`_`_A_S _I_S_'_' _A_N_D
     _*  _A_N_Y _E_X_P_R_E_S_S _O_R _I_M_P_L_I_E_D _W_A_R_R_A_N_T_I_E_S_, _I_N_C_L_U_D_I_N_G_, _B_U_T _N_O_T _L_I_M_I_T_E_D _T_O_, _T_H_E
     _*  _I_M_P_L_I_E_D _W_A_R_R_A_N_T_I_E_S _O_F _M_E_R_C_H_A_N_T_A_B_I_L_I_T_Y _A_N_D _F_I_T_N_E_S_S _F_O_R _A _P_A_R_T_I_C_U_L_A_R _P_U_R_P_O_S_E
     _*  _A_R_E _D_I_S_C_L_A_I_M_E_D_.  _I_N _N_O _E_V_E_N_T _S_H_A_L_L _T_H_E _R_E_G_E_N_T_S _O_R _C_O_N_T_R_I_B_U_T_O_R_S _B_E _L_I_A_B_L_E
     _*  _F_O_R _A_N_Y _D_I_R_E_C_T_, _I_N_D_I_R_E_C_T_, _I_N_C_I_D_E_N_T_A_L_, _S_P_E_C_I_A_L_, _E_X_E_M_P_L_A_R_Y_, _O_R _C_O_N_S_E_Q_U_E_N_T_I_A_L
     _*  _D_A_M_A_G_E_S _(_I_N_C_L_U_D_I_N_G_, _B_U_T _N_O_T _L_I_M_I_T_E_D _T_O_, _P_R_O_C_U_R_E_M_E_N_T _O_F _S_U_B_S_T_I_T_U_T_E _G_O_O_D_S
     _*  _O_R _S_E_R_V_I_C_E_S_; _L_O_S_S _O_F _U_S_E_, _D_A_T_A_, _O_R _P_R_O_F_I_T_S_; _O_R _B_U_S_I_N_E_S_S _I_N_T_E_R_R_U_P_T_I_O_N_)
     _*  _H_O_W_E_V_E_R _C_A_U_S_E_D _A_N_D _O_N _A_N_Y _T_H_E_O_R_Y _O_F _L_I_A_B_I_L_I_T_Y_, _W_H_E_T_H_E_R _I_N _C_O_N_T_R_A_C_T_, _S_T_R_I_C_T
     _*  _L_I_A_B_I_L_I_T_Y_, _O_R _T_O_R_T _(_I_N_C_L_U_D_I_N_G _N_E_G_L_I_G_E_N_C_E _O_R _O_T_H_E_R_W_I_S_E_) _A_R_I_S_I_N_G _I_N _A_N_Y _W_A_Y
     _*  _O_U_T _O_F _T_H_E _U_S_E _O_F _T_H_I_S _S_O_F_T_W_A_R_E_, _E_V_E_N _I_F _A_D_V_I_S_E_D _O_F _T_H_E _P_O_S_S_I_B_I_L_I_T_Y _O_F
     _*  _S_U_C_H _D_A_M_A_G_E_.
     _*
     _*         _@_(_#_)_t_w_i_n_k_l_e_1_._c      _8_._1 _(_B_e_r_k_e_l_e_y_) _6_/_8_/_9_3
     _*_/
    _#_i_n_c_l_u_d_e             <curses.h>
    _#_i_n_c_l_u_d_e             <signal.h>

    _/_*
     _* _t_h_e _i_d_e_a _f_o_r _t_h_i_s _p_r_o_g_r_a_m _w_a_s _a _p_r_o_d_u_c_t _o_f _t_h_e _i_m_a_g_i_n_a_t_i_o_n _o_f
     _* _K_u_r_t _S_c_h_o_e_n_s_.  _N_o_t _r_e_s_p_o_n_s_i_b_l_e _f_o_r _m_i_n_d_s _l_o_s_t _o_r _s_t_o_l_e_n_.
     _*_/

    _#_d_e_f_i_n_e    NCOLS     80
    _#_d_e_f_i_n_e    NLINES    24
    _#_d_e_f_i_n_e    MAXPATTERNS         4

    _t_y_p_e_d_e_f _s_t_r_u_c_t _{
               _i_n_t       y, x;
    _} LOCS;

    _s_t_a_t_i_c LOCS          Layout[NCOLS _* NLINES];       _/_* _c_u_r_r_e_n_t _b_o_a_r_d _l_a_y_o_u_t _*_/

    _s_t_a_t_i_c _i_n_t           Pattern,                      _/_* _c_u_r_r_e_n_t _p_a_t_t_e_r_n _n_u_m_b_e_r _*_/
                         Numstars;                     _/_* _n_u_m_b_e_r _o_f _s_t_a_r_s _i_n _p_a_t_t_e_r_n _*_/

    _s_t_a_t_i_c _v_o_i_d puton(_c_h_a_r);










                         _A_p_p_e_n_d_i_x _A


    _s_t_a_t_i_c _v_o_i_d makeboard(_v_o_i_d);
    _s_t_a_t_i_c _i_n_t ison(_i_n_t, _i_n_t);
    _s_t_a_t_i_c _v_o_i_d die(_i_n_t);

    _i_n_t
    main(_v_o_i_d)
    _{
               srand(getpid());                        _/_* _i_n_i_t_i_a_l_i_z_e _r_a_n_d_o_m _s_e_q_u_e_n_c_e _*_/

               initscr();
               signal(SIGINT, die);
               noecho();
               nonl();
               leaveok(stdscr, TRUE);
               scrollok(stdscr, FALSE);

               _f_o_r (;;) _{
                         makeboard();                  _/_* _m_a_k_e _t_h_e _b_o_a_r_d _s_e_t_u_p _*_/
                         puton('_*');                   _/_* _p_u_t _o_n _'_*_'_s _*_/
                         puton(' ');                   _/_* _c_o_v_e_r _u_p _w_i_t_h _' _'_s _*_/
               _}
    _}

    _/_*
     _* _O_n _p_r_o_g_r_a_m _e_x_i_t_, _m_o_v_e _t_h_e _c_u_r_s_o_r _t_o _t_h_e _l_o_w_e_r _l_e_f_t _c_o_r_n_e_r _b_y
     _* _d_i_r_e_c_t _a_d_d_r_e_s_s_i_n_g_, _s_i_n_c_e _c_u_r_r_e_n_t _l_o_c_a_t_i_o_n _i_s _n_o_t _g_u_a_r_a_n_t_e_e_d_.
     _* _W_e _l_i_e _a_n_d _s_a_y _w_e _u_s_e_d _t_o _b_e _a_t _t_h_e _u_p_p_e_r _r_i_g_h_t _c_o_r_n_e_r _t_o _g_u_a_r_a_n_t_e_e
     _* _a_b_s_o_l_u_t_e _a_d_d_r_e_s_s_i_n_g_.
     _*_/
    _s_t_a_t_i_c _v_o_i_d
    die(_i_n_t n)
    _{
               signal(SIGINT, SIG_IGN);
               mvcur(0, COLS - 1, LINES - 1, 0);
               endwin();
               exit(n);
    _}


    _/_*
     _* _M_a_k_e _t_h_e _c_u_r_r_e_n_t _b_o_a_r_d _s_e_t_u_p_.  _I_t _p_i_c_k_s _a _r_a_n_d_o_m _p_a_t_t_e_r_n _a_n_d
     _* _c_a_l_l_s _i_s_o_n_(_) _t_o _d_e_t_e_r_m_i_n_e _i_f _t_h_e _c_h_a_r_a_c_t_e_r _i_s _o_n _t_h_a_t _p_a_t_t_e_r_n
     _* _o_r _n_o_t_.
     _*_/
    _s_t_a_t_i_c _v_o_i_d
    makeboard(_v_o_i_d)
    _{
               _i_n_t                 y, x;
               LOCS      _*lp;

               Pattern = rand() % MAXPATTERNS;
               lp = Layout;
               _f_o_r (y = 0; y < NLINES; y++)










                         _A_p_p_e_n_d_i_x _A


                         _f_o_r (x = 0; x < NCOLS; x++)
                                   _i_f (ison(y, x)) _{
                                             lp->y = y;
                                             lp->x = x;
                                             lp++;
                                   _}
               Numstars = lp - Layout;
    _}

    _/_*
     _* _R_e_t_u_r_n _T_R_U_E _i_f _(_y_, _x_) _i_s _o_n _t_h_e _c_u_r_r_e_n_t _p_a_t_t_e_r_n_.
     _*_/
    _s_t_a_t_i_c _i_n_t
    ison(_i_n_t y, _i_n_t x)
    _{
               _s_w_i_t_c_h (Pattern) _{
                 _c_a_s_e 0:           _/_* _a_l_t_e_r_n_a_t_i_n_g _l_i_n_e_s _*_/
                         _r_e_t_u_r_n !(y & 01);
                 _c_a_s_e 1:           _/_* _b_o_x _*_/
                         _i_f (x >= LINES && y >= NCOLS)
                                   _r_e_t_u_r_n FALSE;
                         _i_f (y < 3 || y >= NLINES - 3)
                                   _r_e_t_u_r_n TRUE;
                         _r_e_t_u_r_n (x < 3 || x >= NCOLS - 3);
                 _c_a_s_e 2:           _/_* _h_o_l_y _p_a_t_t_e_r_n_! _*_/
                         _r_e_t_u_r_n ((x + y) & 01);
                 _c_a_s_e 3:           _/_* _b_a_r _a_c_r_o_s_s _c_e_n_t_e_r _*_/
                         _r_e_t_u_r_n (y >= 9 && y <= 15);
               _}
               _/_* _N_O_T_R_E_A_C_H_E_D _*_/
    _}

    _s_t_a_t_i_c _v_o_i_d
    puton(_c_h_a_r ch)
    _{
               LOCS      _*lp;
               _i_n_t       r;
               LOCS      _*end;
               LOCS      temp;

               end = &Layout[Numstars];
               _f_o_r (lp = Layout; lp < end; lp++) _{
                         r = rand() % Numstars;
                         temp = _*lp;
                         _*lp = Layout[r];
                         Layout[r] = temp;
               _}

               _f_o_r (lp = Layout; lp < end; lp++) _{
                         mvaddch(lp->y, lp->x, ch);
                         refresh();
               _}
    _}










                         _A_p_p_e_n_d_i_x _A


_CC_oo_nn_tt_ee_nn_tt_ss

1 Overview ............................................    1
   1.1 Terminology ....................................    1
   1.2 Compiling Applications .........................    1
   1.3 Screen Updating ................................    1
   1.4 Naming Conventions .............................    3
2 Variables ...........................................    4
3 Usage ...............................................    5
   3.1 Initialization .................................    5
   3.2 Output .........................................    5
   3.3 Input ..........................................    6
   3.4 Termination ....................................    6
4 Cursor Movement Optimizations .......................    6
5 Character Output and Scrolling ......................    7
6 Terminal State Handling .............................    7
7 Subwindows ..........................................    8
8 The Functions .......................................    8
AAAAppppppppeeeennnnddddiiiixxxx AAAA ............................................   35
1 Examples ............................................   35
   1.1 Simple Character Output ........................   35
   1.2 Twinkle ........................................   36





































