  
  [1m[4m[31m2. Interface to the [22m[32mncurses[1m[4m[31m Library[0m
  
  In  this  chapter  we  describe  the [1mGAP[0m interface to the [1mGNU[0m [22m[32mcurses[0m/[22m[32mncurses[0m
  [22m[32mC[0m-library.  This  library  contains  routines  to manipulate the contents of
  terminal  windows.  It  allows  one to write programs which should work on a
  wide variety of terminal emulations with different sets of capabilities.
  
  This  technical  chapter  is  intended  for  readers who want to program new
  applications  using the [22m[32mncurses[0m functionality. If you are only interested in
  the  function [1m[34mNCurses.BrowseGeneric[0m ([1m4.3-1[0m) from this package or some of its
  applications you can skip this chapter.
  
  Detailed  documentation of the [22m[32mncurses[0m library is probably available in your
  operating system (try [22m[32mman ncurses[0m) and from the web (see for example [xxx]).
  Here,  we  only give short reminders about the functions provided in the [1mGAP[0m
  interface and explain how to use the [1mGAP[0m functions.
  
  
  [1m[4m[31m2.1 The [22m[32mncurses[1m[4m[31m Library[0m
  
  In  this  section we list the functions from the GNU [22m[32mncurses[0m library and its
  [22m[32mpanel[0m  extension which are made available in [1mGAP[0m via the [1mBrowse[0m package. See
  the  following  section [1m2.2[0m for explanations how to use these functions from
  within [1mGAP[0m.
  
  The  basic  objects  to  manipulate  are  called [22m[36mwindows[0m, they correspond to
  rectangular  regions of the terminal screen. Windows can overlap but [22m[32mncurses[0m
  cannot  handle  this  for  the  display. Therefore windows can be wrapped in
  [22m[36mpanels[0m,  they provide a display depth for windows and it is possible to move
  panels to the top and bottom of the display or to hide a panel.
  
  We  will  not  import  all  the functions of the [22m[32mncurses[0m library to [1mGAP[0m. For
  example,  there  are many pairs of functions with the same name except for a
  leading  [22m[32mw[0m (like [22m[32mmove[0m and [22m[32mwmove[0m for moving the cursor in a window). Here, we
  only  import  the versions with [22m[32mw[0m, which get a window as first argument. The
  functions  without [22m[32mw[0m are for the [22m[32mncurses[0m standard screen window [22m[32mstdscr[0m which
  is  available  as  window  [22m[32m0[0m in [1mGAP[0m. Similarly, there are functions with the
  same  name  except  for  an extra [22m[32mn[0m (like [22m[32mwaddstr[0m and [22m[32mwaddnstr[0m for placing a
  string into a window). Here, we only import the safer functions with [22m[32mn[0m which
  get  the  number  of  characters  to  write  as  argument.  (More convenient
  functions are then implemented on the [1mGAP[0m level.)
  
  
  [1m[4m[31m2.1-1 Setting the terminal[0m
  
  We  first  list  flags  for  setting  the basic behavior of a terminal. With
  [22m[32msavetty[0m/[22m[32mresetty[0m a setting can be stored and recovered.
  
  [1m[33m[22m[32msavetty()[0m[0m
        This stores the current setting of the terminal in a buffer.
  
  [1m[33m[22m[32mresetty()[0m[0m
        This  resets  the  terminal  to  what  was  stored in the last call to
        [22m[32msavetty[0m.
  
  [1m[33m[22m[32mcbreak()/nocbreak()[0m[0m
        In  [22m[32mcbreak[0m  mode  each  input  character  from  a terminal is directly
        forwarded to the application (but see [22m[32mkeypad[0m). With [22m[32mnocbreak[0m this only
        happens after a newline or return is typed.
  
  [1m[33m[22m[32mkeypad(win, bool)[0m[0m
        If  set  to [22m[32mtrue[0m some special input like arrow or function keys can be
        read  as single characters from the input (such keys actually generate
        certain sequences of characters), see also [1m2.1-4[0m. (The [22m[34mwin[0m argument is
        irrelevant.)
  
  [1m[33m[22m[32mecho()[0m/[22m[32mnoecho()[0m[0m
        This  determines  if  input characters are automatically echoed by the
        terminal at the current cursor position.
  
  [1m[33m[22m[32mcurs_set(vis)[0m[0m
        This determines the visibility of the cursor. The argument [22m[34mvis[0m=0 makes
        the  cursor  invisible.  With [22m[34mvis[0m=1 it becomes visible; some terminals
        allow also higher levels of visibility.
  
  [1m[33m[22m[32mwtimeout(win, delay)[0m[0m
        Here [22m[34mdelay[0m determines a timeout in milliseconds for reading characters
        from  the  input of a window. Negative values mean infinity, that is a
        blocking read.
  
  [1m[33m[22m[32mnl()[0m/[22m[32mnonl()[0m[0m
        With  [22m[32mnl[0m  a return on input is translated to a newline character and a
        newline on output is interpreted as return and linefeed.
  
  [1m[33m[22m[32mintrflush(win, bool)[0m[0m
        This  flag  determines  if  after  an  interrupt pending output to the
        terminal is flushed. (The [22m[34mwin[0m argument is irrelevant.)
  
  [1m[33m[22m[32midlok(win, bool)[0m[0m
        With  [22m[32mtrue[0m  the  library  tries  to  use  a  hardware  line  insertion
        functionality (in particular for scrolling).
  
  [1m[33m[22m[32mscrollok(win, bool)[0m[0m
        If  set  to [22m[32mtrue[0m moving the cursor down from the last line of a window
        causes scrolling of the whole window, otherwise nothing happens.
  
  [1m[33m[22m[32mleaveok(win, bool)[0m[0m
        If  set  to  [22m[32mtrue[0m  a  refresh  of  the window leaves the cursor at its
        current location, otherwise this is not guaranteed.
  
  [1m[33m[22m[32mclearok(win, bool)[0m[0m
        If  set  to  [22m[32mtrue[0m the next refresh of the window will clear the screen
        completely and redraw everything.
  
  [1m[33m[22m[32mimmedok(win, bool)[0m[0m
        If  set to [22m[32mtrue[0m all changes of the window will automatically also call
        a [22m[32mwrefresh[0m.
  
  [1m[33m[22m[32mraw()[0m/[22m[32mnoraw()[0m[0m
        Similar  to  [22m[32mcbreak[0m, usually not needed (see the [22m[32mncurses[0m documentation
        for details).
  
  
  [1m[4m[31m2.1-2 Manipulating windows[0m
  
  In  [22m[32mncurses[0m  an  arbitrary number of windows which correspond to rectangular
  regions  (maybe overlapping) of the screen can be handled. You should always
  delete  windows  which  are  no  longer  needed.  To get a proper display of
  overlapping  windows  (which may occur by recursively called functions using
  this library) we suggest that you always wrap windows in panels, see [1m2.1-3[0m.
  
  For functions which involve coordinates recall that the upper left corner of
  the screen or internally of any window has the coordinates (0,0).
  
  [1m[33m[22m[32mnewwin(nlines, ncols, y, x)[0m[0m
        This  creates a new window whose upper left corner has the coordinates
        ([22m[34my[0m,[22m[34mx[0m) on the screen and has [22m[34mnlines[0m lines and [22m[34mncols[0m columns, if this is
        possible.  The  arguments  [22m[34mnlines[0m  and  [22m[34mncols[0m  can be zero, then their
        maximal possible values are assumed.
  
  [1m[33m[22m[32mdelwin(win)[0m[0m
        Deletes a window.
  
  [1m[33m[22m[32mmvwin(win, y, x)[0m[0m
        Moves the upper left corner of the window to the given coordinates, if
        the  window  still  fits  on  the  screen.  With panels don't use this
        function, but use [22m[32mmove_panel[0m mentioned below.
  
  [1m[33m[22m[32mwrefresh(win)[0m[0m
        Writing  to a window only changes some internal buffers, this function
        copies the window content to the actual display screen. You don't need
        this  function  if  you wrap your windows in panels, use [22m[32mupdate_panels[0m
        and [22m[32mdoupdate[0m instead.
  
  [1m[33m[22m[32mdoupdate()[0m[0m
        Use  this function to update the content of your display screen to the
        current  content of all windows. If your terminal is not yet in visual
        mode this function changes to visual mode.
  
  [1m[33m[22m[32mendwin()[0m[0m
        Use this function to leave the visual mode of your terminal.
  
  [1m[33m[22m[32mgetbegyx(win)[0m[0m
        Get  the  coordinates  of  the  upper  left  corner of a window on the
        screen.
  
  [1m[33m[22m[32mgetmaxyx(win)[0m[0m
        Get the number of lines and columns of a window.
  
  
  [1m[4m[31m2.1-3 Manipulating panels[0m
  
  Wrap  windows  in  panels to get a proper handling of overlapping windows on
  the   display.   Don't   forget  to  delete  a  panel  before  deleting  the
  corresponding window.
  
  [1m[33m[22m[32mnew_panel(win)[0m[0m
        Create a panel for a window.
  
  [1m[33m[22m[32mdel_panel(pan)[0m[0m
        Delete a panel.
  
  [1m[33m[22m[32mupdate_panels()[0m[0m
        Use  this  function  to copy changes of windows and panels to a screen
        buffer. Then call [22m[32mdoupdate()[0m to update the display screen.
  
  [1m[33m[22m[32mmove_panel(pan, y, x)[0m[0m
        Move top left corner of a panel wrapped window to coordinates ([22m[34my[0m,[22m[34mx[0m) if
        possible.
  
  [1m[33m[22m[32mhide_panel(pan)[0m/[22m[32mshow_panel(pan)[0m[0m
        Hide  or  show,  respectively,  the  content of a panel on the display
        screen.
  
  [1m[33m[22m[32mtop_panel(pan)[0m/[22m[32mbottom_panel(pan)[0m[0m
        Move a panel to the top or bottom of all panels, respectively.
  
  [1m[33m[22m[32mpanel_below(pan)[0m/[22m[32mpanel_above(pan)[0m[0m
        Return the panel directly below or above the given one, respectively.
  
  
  [1m[4m[31m2.1-4 Getting keyboard input[0m
  
  If  you  want to read input from the user first adjust the terminal settings
  of [22m[32mcbreak[0m, [22m[32mkeypad[0m, [22m[32mecho[0m, [22m[32mwtimeout[0m and [22m[32mcurs_set[0m to your needs, see [1m2.1-1[0m. The
  basic functions are as follows.
  
  [1m[33m[22m[32mwgetch(win)[0m[0m
        Reads one character from user input (returned as integer). If [22m[32mwtimeout[0m
        was set with a positive [22m[34mdelay[0m then the function returns [22m[32mfalse[0m if there
        was  no input for [22m[34mdelay[0m milliseconds. Note that in [22m[32mnocbreak[0m mode typed
        characters  reach  the  application only after typing a return. If the
        [22m[32mkeypad[0m  flag  is set to [22m[32mtrue[0m some special keys can be read like single
        characters; the keys are explained below. (Note that there is only one
        input queue for all windows.)
  
  [1m[33m[22m[32mungetch(char)[0m[0m
        Puts back the character [22m[34mchar[0m on the input queue.
  
  Some  terminals allow one to read special keys like one character, we import
  some  of  the  symbolic  names of such keys into [1mGAP[0m. You can check for such
  characters  by  comparing  with  the  components of the record [22m[32mNCurses.keys[0m,
  these are
  
  [1m[33m[22m[32mUP[0m/[22m[32mDOWN[0m/[22m[32mLEFT[0m/[22m[32mRIGHT[0m[0m
        the arrow keys
  
  [1m[33m[22m[32mPPAGE[0m/[22m[32mNPAGE[0m[0m
        the page up and page down keys
  
  [1m[33m[22m[32mHOME[0m/[22m[32mEND[0m[0m
        the home and end keys
  
  [1m[33m[22m[32mBACKSPACE[0m/[22m[32mDC[0m[0m
        the backspace and delete keys
  
  [1m[33m[22m[32mIC[0m[0m
        the insert key
  
  [1m[33m[22m[32mENTER[0m[0m
        the enter key
  
  [1m[33m[22m[32mF1[0m/[22m[32mF2[0m/../[22m[32mF24[0m[0m
        the function keys
  
  [1m[33m[22m[32mMOUSE[0m[0m
        a pseudo key to detect mouse events
  
  [1m[33m[22m[32mA1[0m/[22m[32mA3[0m/[22m[32mB2[0m/[22m[32mC1[0m/[22m[32mC3[0m[0m
        the keys around the arrow keys on a num pad
  
  It can happen that on a specific keyboard there is no key for some of these.
  Also,  not all terminals can interpret all of these keys. You can check this
  with the function
  
  [1m[33m[22m[32mhas_key(key)[0m[0m
        Checks if the special key [22m[34mkey[0m is recognized by the terminal.
  
  
  [1m[4m[31m2.1-5 Writing to windows[0m
  
  The  display of text in [22m[32mncurses[0m windows has two aspects. The first is to get
  actual  characters  on the screen. The second is to specify attributes which
  influence  the  display,  for  example  normal or bold fonts or colors. This
  subsection  is for the first aspect. Possible attributes are explained below
  in [1m2.1-7[0m.
  
  [1m[33m[22m[32mwmove(win, y, x)[0m[0m
        Moves  the  cursor  to position ([22m[34my[0m,[22m[34mx[0m), recall that the coordinates are
        zero based, (0,0) being the top left corner.
  
  [1m[33m[22m[32mwaddnstr(win, str, len)[0m[0m
        Writes  the  string [22m[34mstr[0m to the window starting from the current cursor
        position.  Writes  at  most  [22m[34mlen[0m characters. At end of line the cursor
        moves  to  the  beginning of next line. The behavior at the end of the
        window depends on the setting of [22m[32mscrollok[0m, see [1m2.1-1[0m.
  
  [1m[33m[22m[32mwaddch(win, char)[0m[0m
        Writes  a  character  to the window at the current cursor position and
        moves  the  cursor  on. The character [22m[34mchar[0m is given as integer and can
        include attribute information.
  
  [1m[33m[22m[32mwborder(win, charlist)[0m[0m
        Draws a border around the window. If [22m[34mcharlist[0m is a plain list of eight
        [1mGAP[0m  characters  these  are  taken for left/right/top/bottom sides and
        top-left/top-right/bottom-left/bottom-right corners. Otherwise default
        characters  are  used.  (See  [1m[34mNCurses.WBorder[0m  ([1m2.2-9[0m) for a more user
        friendly interface.)
  
  [1m[33m[22m[32mwvline(win, char, len)[0m[0m
        Writes  a  vertical line of length [22m[34mlen[0m (or as long as fitting into the
        window) starting from the current cursor position to the bottom, using
        the character [22m[34mchar[0m. If [22m[34mchar[0m=[22m[32m0[0m the default character is used.
  
  [1m[33m[22m[32mwhline(win, char, len)[0m[0m
        Same  as  [22m[32mwvline[0m  but  for  horizontal  lines starting from the cursor
        position to the right.
  
  [1m[33m[22m[32mwerase(win)[0m[0m
        Deletes all characters in the window.
  
  [1m[33m[22m[32mwclear(win)[0m[0m
        Like [22m[32mwerase[0m, but also calls [22m[32mclearok[0m.
  
  [1m[33m[22m[32mwclrtobot(win)[0m[0m
        Deletes all characters from cursor position to the right and bottom.
  
  [1m[33m[22m[32mwclrtoeol(win)[0m[0m
        Deletes all characters from cursor position to end of line.
  
  [1m[33m[22m[32mwinch(win)[0m[0m
        Returns  the  character  at  current  cursor  position, as integer and
        including color and attribute information.
  
  [1m[33m[22m[32mgetyx(win)[0m[0m
        Returns the current cursor position.
  
  [1m[33m[22m[32mwaddstr(win, str)[0m[0m
        Delegates to [22m[32mwaddnstr(win, str, Length(str))[0m.
  
  
  [1m[4m[31m2.1-6 Line drawing characters[0m
  
  For  drawing  lines  and  grids  in  a  terminal  window you should use some
  "virtual"  characters  which  are  available  as  components  of  the record
  [22m[32mNCurses.lineDraw[0m.  On  some  terminals  these are nicely displayed as proper
  lines (on others they are simulated by ASCII characters). These are:
  
  [1m[33m[22m[32mBLOCK[0m[0m
        solid block
  
  [1m[33m[22m[32mBOARD[0m[0m
        board of squares
  
  [1m[33m[22m[32mBTEE/LTEE/RTEE/TTEE[0m[0m
        bottom/left/right/top tee
  
  [1m[33m[22m[32mBULLET[0m[0m
        bullet
  
  [1m[33m[22m[32mCKBOARD[0m[0m
        checker board
  
  [1m[33m[22m[32mDARROW/LARROW/RARROW/UARROW[0m[0m
        down/left/right/up arrow
  
  [1m[33m[22m[32mDEGREE[0m[0m
        degree symbol
  
  [1m[33m[22m[32mDIAMOND[0m[0m
        diamond
  
  [1m[33m[22m[32mGEQUAL[0m[0m
        greater than or equal
  
  [1m[33m[22m[32mHLINE/VLINE[0m[0m
        horizontal/vertical line
  
  [1m[33m[22m[32mLANTERN[0m[0m
        lantern symbol
  
  [1m[33m[22m[32mLEQUAL[0m[0m
        less than or equal
  
  [1m[33m[22m[32mLLCORNER/LRCORNER/ULCORNER/URCORNER[0m[0m
        lower left/lower right/upper left/upper right corner
  
  [1m[33m[22m[32mNEQUAL[0m[0m
        not equal
  
  [1m[33m[22m[32mPI[0m[0m
        letter pi
  
  [1m[33m[22m[32mPLMINUS[0m[0m
        plus-minus
  
  [1m[33m[22m[32mPLUS[0m[0m
        crossing lines like a plus
  
  [1m[33m[22m[32mS1/S3/S7/S9[0m[0m
        scan line 1/3/7/9
  
  [1m[33m[22m[32mSTERLING[0m[0m
        pound sterling
  
  
  [1m[4m[31m2.1-7 Text attributes and colors[0m
  
  In  addition  to  the  actual characters to be written to the screen the way
  they are displayed can be changed by additional [22m[36mattributes[0m. (There should be
  no  danger  to  mix  up  this  notion  of attributes with the one introduced
  in [1m`Reference:  Attributes'[0m.)  The  available  attributes  are stored in the
  record [22m[32mNCurses.attrs[0m, they are
  
  [1m[33m[22m[32mNORMAL[0m[0m
        normal display with no extra attributes.
  
  [1m[33m[22m[32mSTANDOUT[0m[0m
        displays text in the best highlighting mode of the terminal.
  
  [1m[33m[22m[32mUNDERLINE[0m[0m
        underlines the text.
  
  [1m[33m[22m[32mREVERSE[0m[0m
        display  in  reverse video by exchanging the foreground and background
        color.
  
  [1m[33m[22m[32mBLINK[0m[0m
        displays the text blinking.
  
  [1m[33m[22m[32mDIM[0m[0m
        displays the text half bright.
  
  [1m[33m[22m[32mBOLD[0m[0m
        displays the text in a bold font.
  
  Note  that  not  all  of these work with all types of terminals, or some may
  cause  the  same  display.  Furthermore, if [22m[32mNCurses.attrs.has_colors[0m is [22m[32mtrue[0m
  there is a list [22m[32mNCurses.attrs.ColorPairs[0m of attributes to set the foreground
  and   background   color.   These   should   be   accessed  indirectly  with
  [1m[34mNCurses.ColorAttr[0m ([1m2.2-1[0m). Attributes can be combined by adding their values
  (internally,  they  are  represented by integers). They can also be added to
  the integer representing a character for use with [22m[32mwaddch[0m.
  
  The library functions for setting attributes are:
  
  [1m[33m[22m[32mwattrset(win, attr)[0m[0m
        This  sets  the  default  (combined)  attributes for a window which is
        added  to  all characters written to it; using [22m[32mNCurses.attrs.NORMAL[0m as
        attribute is a reset.
  
  [1m[33m[22m[32mwattron(win, attr)[0m/[22m[32mwattroff(win, attr)[0m[0m
        This  sets  or  unsets  one  or  some default attributes of the window
        without changing the others.
  
  [1m[33m[22m[32mwattr_get(win)[0m[0m
        This returns the current default attribute and default color pair of a
        window.
  
  [1m[33m[22m[32mwbkgdset(win, attr)[0m[0m
        This  is  similar to [22m[32mwattrset[0m but you can also add a character to [22m[34mattr[0m
        which is used as default instead of blanks.
  
  [1m[33m[22m[32mwbkgd(win, attr)[0m[0m
        This  function changes the attributes for all characters in the window
        to [22m[34mattr[0m, also used for further characters written to that window.
  
  
  [1m[4m[31m2.1-8 Miscellaneous function[0m
  
  We  also  provide  the [22m[32mncurses[0m function [22m[32mmnap(msec)[0m which is a sleep for [22m[34mmsec[0m
  milliseconds.
  
  
  [1m[4m[31m2.2 The [22m[32mncurses[1m[4m[31m [1mGAP[1m[4m[31m functions[0m
  
  The  functions  of the [22m[32mncurses[0m library are used within [1mGAP[0m very similarly to
  their  [22m[32mC[0m  equivalents. The functions are available as components of a record
  [22m[32mNCurses[0m with the name of the [22m[32mC[0m function (e.g., [22m[32mNCurses.newwin[0m).
  
  In  [1mGAP[0m  the  [22m[32mncurses[0m  windows  are  accessed  via  integers (as returned by
  [22m[32mNCurses.newwin[0m).  The  standard  screen  [22m[32mstdscr[0m  from the [22m[32mncurses[0m library is
  available  as  window  number  [22m[32m0[0m.  But  this  should  not  be used; to allow
  recursive  applications  of [22m[32mncurses[0m always create a new window, wrap it in a
  panel and delete both when they are no longer needed.
  
  Each  window  can  be  wrapped  in  one  panel which is accessed by the same
  integer. (Window [22m[32m0[0m cannot be used with a panel.)
  
  Coordinates  in  windows  are  the  same  zero  based  integers  as  in  the
  corresponding   [22m[32mC[0m   functions.  The  interface  of  functions  which  [22m[36mreturn[0m
  coordinates is slightly different from the [22m[32mC[0m version; they just return lists
  of   integers   and   you   just   give   the   window  as  argument,  e.g.,
  [22m[32mNCurses.getmaxyx(win)[0m returns a list [22m[32m[nrows, ncols][0m of two integers.
  
  Characters  to  be written to a window can be given either as [1mGAP[0m characters
  like  [22m[32m'a'[0m  or  as  integers  like [22m[32mINT_CHAR('a') = 97[0m. If you use the integer
  version  you  can also add attributes including color settings to it for use
  with [22m[32mNCurses.waddch[0m.
  
  When writing an application decide about an appropriate terminal setting for
  your visual mode windows, see [1m2.1-1[0m and the utility function [1m[34mNCurses.SetTerm[0m
  ([1m2.2-2[0m)  below.  Use  [22m[32mNCurses.savetty()[0m  and  [22m[32mNCurses.resetty()[0m  to save and
  restore the previous setting.
  
  We  also  provide  some  higher level functionality for displaying marked up
  text, see [1m[34mNCurses.PutLine[0m ([1m2.2-6[0m) and [1m[34mNCurses.IsAttributeLine[0m ([1m2.2-3[0m).
  
  We  now  describe  some  utility  functions  for  putting text on a terminal
  window.
  
  [1m[4m[31m2.2-1 NCurses.ColorAttr[0m
  
  [1m[34m> NCurses.ColorAttr( [0m[22m[34mfgcolor, bgcolor[0m[1m[34m ) ____________________________[0mfunction
  [1m[34m> NCurses.attrs.has_colors___________________________________[0mglobal variable
  [1mReturns:[0m  an attribute for setting the foreground and background color to be
            used on a terminal window (it is a [1mGAP[0m integer).
  
  The return value can be used like any other attribute as described in [1m2.1-7[0m.
  The arguments [22m[34mfgcolor[0m and [22m[34mbgcolor[0m can be given as strings, allowed are those
  in  [22m[32m[  "black", "red", "green", "yellow", "blue", "magenta", "cyan", "white"
  ][0m.  These  are  the  default  foreground  colors  0  to 7 on ANSI terminals.
  Alternatively, the numbers 0 to 7 can be used directly as arguments.
  
  Note  that terminals can be configured in a way such that these named colors
  are not the colors which are actually displayed.
  
  The  variable  [1m[34mNCurses.attrs.has_colors[0m  is  set  to  [22m[32mtrue[0m  or  [22m[32mfalse[0m if the
  terminal  supports  colors  or  not,  respectively.  If  a terminal does not
  support colors then [1m[34mNCurses.ColorAttr[0m always returns [22m[32mNCurses.attrs.NORMAL[0m.
  
  For  an  attribute  setting the foreground color with the default background
  color of the terminal use [22m[32m-1[0m as [22m[34mbgcolor[0m or the same as [22m[34mfgcolor[0m.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> win := NCurses.newwin(0,0,0,0);; pan := NCurses.new_panel(win);;[0m
    [22m[35mgap> defc := NCurses.defaultColors;;[0m
    [22m[35mgap> NCurses.wmove(win, 0, 0);;[0m
    [22m[35mgap> for a in defc do for b in defc do[0m
    [22m[35m>      NCurses.wattrset(win, NCurses.ColorAttr(a, b));[0m
    [22m[35m>      NCurses.waddstr(win, Concatenation(a,"/",b,"\t"));[0m
    [22m[35m>    od; od; [0m
    [22m[35mgap> NCurses.update_panels();; NCurses.doupdate();;[0m
    [22m[35mgap> NCurses.napms(5000); # show for 5 seconds[0m
    [22m[35mgap> NCurses.endwin();; NCurses.del_panel(pan);; NCurses.delwin(win);;[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m2.2-2 NCurses.SetTerm[0m
  
  [1m[34m> NCurses.SetTerm( [0m[22m[34m[record][0m[1m[34m ) ______________________________________[0mfunction
  
  This  function  provides a unified interface to the various terminal setting
  functions of [22m[32mncurses[0m listed in [1m2.1-1[0m. The optional argument is a record with
  components  which  are assigned to [22m[32mtrue[0m or [22m[32mfalse[0m. Recognised components are:
  [22m[32mcbreak[0m,  [22m[32mecho[0m,  [22m[32mnl[0m,  [22m[32mintrflush[0m,  [22m[32mleaveok[0m,  [22m[32mscrollok[0m,  [22m[32mkeypad[0m,  [22m[32mraw[0m (with the
  obvious meaning if set to [22m[32mtrue[0m or [22m[32mfalse[0m, respectively).
  
  The  default, if no argument is given, is [22m[32mrec(cbreak := true, echo := false,
  nl  := false, intrflush := false, leaveok := true, scrollok := false, keypad
  :=  true)[0m.  (This is a useful setting for many applications.) If there is an
  argument  [22m[34mrecord[0m,  then  the  given  components  overwrite the corresponding
  defaults.
  
  [1m[4m[31m2.2-3 NCurses.IsAttributeLine[0m
  
  [1m[34m> NCurses.IsAttributeLine( [0m[22m[34mobj[0m[1m[34m ) ___________________________________[0mfunction
  [1mReturns:[0m  [22m[32mtrue[0m if the argument describes a string with attributes.
  
  An  [22m[36mattribute  line[0m describes a string with attributes. It is represented by
  either  a  string  or  a  dense  list  of  strings,  integers,  and Booleans
  immediately  following integers, where at least one list entry must [22m[36mnot[0m be a
  string.  (The  reason  is  that we want to be able to distinguish between an
  attribute  line and a list of such lines, and that the case of plain strings
  is  perhaps  the  most  usual  one, so we do not want to force wrapping each
  string  in  a  list.)  The integers denote attribute values such as color or
  font  information,  the  Booleans  denote  that  the  attribute given by the
  preceding integer is set or reset.
  
  If  an integer is not followed by a Boolean then it is used as the attribute
  for  the  following  characters,  that  is  it overwrites all previously set
  attributes. Note that in some applications the variant with explicit Boolean
  values  is preferable, because such a line can nicely be highlighted just by
  prepending a [22m[32mNCurses.attrs.STANDOUT[0m attribute.
  
  For an overview of attributes, see [1m2.1-7[0m.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> NCurses.IsAttributeLine( "abc" );[0m
    [22m[35mtrue[0m
    [22m[35mgap> NCurses.IsAttributeLine( [ "abc", "def" ] );[0m
    [22m[35mfalse[0m
    [22m[35mgap> NCurses.IsAttributeLine( [ NCurses.attrs.UNDERLINE, true, "abc" ] );[0m
    [22m[35mtrue[0m
    [22m[35mgap> NCurses.IsAttributeLine( "" );  NCurses.IsAttributeLine( [] );[0m
    [22m[35mtrue[0m
    [22m[35mfalse[0m
  [22m[35m------------------------------------------------------------------[0m
  
  The  [22m[36mempty  string[0m is an attribute line whereas the [22m[36mempty list[0m (which is not
  in   [22m[32mIsStringRep[0m,   see [1m[34mIsStringRep[0m  ([1mReference:  IsStringRep[0m))  is  [22m[36mnot[0m  an
  attribute line.
  
  [1m[4m[31m2.2-4 NCurses.ConcatenationAttributeLines[0m
  
  [1m[34m> NCurses.ConcatenationAttributeLines( [0m[22m[34mlines[, keep][0m[1m[34m ) _____________[0mfunction
  [1mReturns:[0m  an attribute line.
  
  For  a  list [22m[34mlines[0m of attribute lines (see [1m[34mNCurses.IsAttributeLine[0m ([1m2.2-3[0m)),
  [22m[32mNCurses.ConcatenationAttributeLines[0m  returns  the attribute line obtained by
  concatenating the attribute lines in [22m[34mlines[0m.
  
  If  the  optional  argument  [22m[34mkeep[0m is [22m[32mtrue[0m then attributes set in an entry of
  [22m[34mlines[0m  are  valid  also  for  the  following entries of [22m[34mlines[0m. Otherwise (in
  particular  if  there  is  no  second  argument) the attributes are reset to
  [22m[32mNCurses.attrs.NORMAL[0m between the entries of [22m[34mlines[0m.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> plain_str:= "hello";;[0m
    [22m[35mgap> with_attr:= [ NCurses.attrs.BOLD, "bold" ];;[0m
    [22m[35mgap> NCurses.ConcatenationAttributeLines( [ plain_str, plain_str ] );[0m
    [22m[35m"hellohello"[0m
    [22m[35mgap> NCurses.ConcatenationAttributeLines( [ plain_str, with_attr ] );[0m
    [22m[35m[ "hello", 2097152, "bold" ][0m
    [22m[35mgap> NCurses.ConcatenationAttributeLines( [ with_attr, plain_str ] );[0m
    [22m[35m[ 2097152, "bold", 0, "hello" ][0m
    [22m[35mgap> NCurses.ConcatenationAttributeLines( [ with_attr, with_attr ] );[0m
    [22m[35m[ 2097152, "bold", 0, 2097152, "bold" ][0m
    [22m[35mgap> NCurses.ConcatenationAttributeLines( [ with_attr, with_attr ], true );[0m
    [22m[35m[ 2097152, "bold", 2097152, "bold" ][0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m2.2-5 NCurses.RepeatedAttributeLine[0m
  
  [1m[34m> NCurses.RepeatedAttributeLine( [0m[22m[34mline, width[0m[1m[34m ) _____________________[0mfunction
  [1mReturns:[0m  an attribute line.
  
  For  an  attribute  line  [22m[34mline[0m  (see  [1m[34mNCurses.IsAttributeLine[0m ([1m2.2-3[0m)) and a
  positive  integer  [22m[34mwidth[0m, [22m[32mNCurses.RepeatedAttributeLine[0m returns an attribute
  line   with   [22m[34mwidth[0m   displayed  characters  (see [1m[34mNCurses.WidthAttributeLine[0m
  ([1m2.2-7[0m))  that is obtained by concatenating sufficiently many copies of [22m[34mline[0m
  and cutting off a tail if applicable.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> NCurses.RepeatedAttributeLine( "12345", 23 );[0m
    [22m[35m"12345123451234512345123"[0m
    [22m[35mgap> NCurses.RepeatedAttributeLine( [ NCurses.attrs.BOLD, "12345" ], 13 );[0m
    [22m[35m[ 2097152, "12345", 0, 2097152, "12345", 0, 2097152, "123" ][0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m2.2-6 NCurses.PutLine[0m
  
  [1m[34m> NCurses.PutLine( [0m[22m[34mwin, y, x, lines[, skip][0m[1m[34m ) ______________________[0mfunction
  [1mReturns:[0m  [22m[32mtrue[0m if [22m[34mlines[0m were written, otherwise [22m[32mfalse[0m.
  
  The   argument   [22m[34mlines[0m   can   be   a   list   of   attribute   lines   (see
  [1m[34mNCurses.IsAttributeLine[0m  ([1m2.2-3[0m))  or a single attribute line. This function
  writes the attribute lines to window [22m[34mwin[0m at and below of position [22m[34my[0m, [22m[34mx[0m.
  
  If  the  argument  [22m[34mskip[0m  is given, it must be a nonnegative integer. In that
  case  the  first  [22m[34mskip[0m  characters of each given line are not written to the
  window (but the attributes are).
  
  [1m[4m[31m2.2-7 NCurses.WidthAttributeLine[0m
  
  [1m[34m> NCurses.WidthAttributeLine( [0m[22m[34mline[0m[1m[34m ) _______________________________[0mfunction
  [1mReturns:[0m  number of displayed characters in an attribute line.
  
  For  an  attribute  line  [22m[34mline[0m  (see  [1m[34mNCurses.IsAttributeLine[0m  ([1m2.2-3[0m)), the
  function returns the number of displayed characters of [22m[34mline[0m.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> NCurses.WidthAttributeLine( "abcde" );[0m
    [22m[35m5[0m
    [22m[35mgap> NCurses.WidthAttributeLine( [ NCurses.attrs.BOLD, "abc",[0m
    [22m[35m>        NCurses.attrs.NORMAL, "de" ] );[0m
    [22m[35m5[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m2.2-8 NCurses.Grid[0m
  
  [1m[34m> NCurses.Grid( [0m[22m[34mwin, trow, brow, lcol, rcol, rowinds, colinds[0m[1m[34m ) ____[0mfunction
  
  This  function  draws  a grid of horizontal and vertical lines on the window
  [22m[34mwin[0m,  using  the  line  drawing  characters  explained  in  [1m2.1-6[0m. The given
  arguments  specify  the  top  and bottom row of the grid, its left and right
  column, and lists of row and column numbers where lines should be drawn.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> fun := function() local win, pan;[0m
    [22m[35m>      win := NCurses.newwin(0,0,0,0);[0m
    [22m[35m>      pan := NCurses.new_panel(win);[0m
    [22m[35m>      NCurses.Grid(win, 2, 11, 5, 22, [5, 6], [13, 14]);[0m
    [22m[35m>      NCurses.PutLine(win, 12, 0, "Press <Enter> to quit");[0m
    [22m[35m>      NCurses.update_panels(); NCurses.doupdate();[0m
    [22m[35m>      NCurses.wgetch(win);[0m
    [22m[35m>      NCurses.endwin();[0m
    [22m[35m>      NCurses.del_panel(pan); NCurses.delwin(win);[0m
    [22m[35m> end;;[0m
    [22m[35mgap> fun();[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m2.2-9 NCurses.WBorder[0m
  
  [1m[34m> NCurses.WBorder( [0m[22m[34mwin[, chars][0m[1m[34m ) __________________________________[0mfunction
  
  This  is  a convenient interface to the [22m[32mncurses[0m function [22m[32mwborder[0m. It draws a
  border  around  the  window  [22m[34mwin[0m. If no second argument is given the default
  line drawing characters are used, see [1m2.1-6[0m. Otherwise, [22m[34mchars[0m must be a list
  of   [1mGAP[0m   characters  or  integers  specifying  characters,  possibly  with
  attributes.  If  [22m[34mchars[0m  has  length  8  the  characters  are  used  for  the
  left/right/top/bottom  sides and top-left/top-right/bottom-left/bottom-right
  corners.  If [22m[34mchars[0m contains 2 characters the first is used for the sides and
  the  second for all corners. If [22m[34mchars[0m contains just one character it is used
  for all sides including the corners.
  
  [1m[4m[31m2.2-10 NCurses.SaveWin[0m
  
  [1m[34m> NCurses.SaveWin( [0m[22m[34mwin[0m[1m[34m ) ___________________________________________[0mfunction
  [1m[34m> NCurses.StringsSaveWin( [0m[22m[34mcont[0m[1m[34m ) ___________________________________[0mfunction
  [1m[34m> NCurses.RestoreWin( [0m[22m[34mwin, cont[0m[1m[34m ) __________________________________[0mfunction
  [1m[34m> NCurses.ShowSaveWin( [0m[22m[34mcont[0m[1m[34m ) ______________________________________[0mfunction
  [1mReturns:[0m  a [1mGAP[0m object describing the contents of a window.
  
  These  functions  can  be  used  to save and restore the contents of [22m[32mncurses[0m
  windows.  [1m[34mNCurses.SaveWin[0m  returns  a  list [22m[32m[nrows, ncols, chars][0m giving the
  number  of  rows,  number  of columns, and a list of integers describing the
  content  of  window  [22m[34mwin[0m.  The  integers in the latter contain the displayed
  characters plus the attributes for the display.
  
  The  function  [1m[34mNCurses.StringsSaveWin[0m  translates  data  [22m[34mcont[0m in form of the
  output  of [1m[34mNCurses.SaveWin[0m to a list of [22m[32mnrows[0m strings giving the text of the
  rows  of  the  saved  window,  and ignoring the attributes. You can view the
  result with [1m[34mNCurses.Pager[0m ([1m3.1-4[0m).
  
  The  argument  [22m[34mcont[0m for [1m[34mNCurses.RestoreWin[0m must be of the same format as the
  output  of [1m[34mNCurses.SaveWin[0m. The content of the saved window is copied to the
  window [22m[34mwin[0m, starting from the top-left corner as much as it fits.
  
  The  utility  [1m[34mNCurses.ShowSaveWin[0m  can  be  used  to  display  the output of
  [1m[34mNCurses.SaveWin[0m (as much of the top-left corner as fits on the screen).
  
