-<div class="ARTICLE">
-<div class="TITLEPAGE">
-<h1 class="TITLE"><a name="AEN2" id="AEN2">NCURSES Programming
-HOWTO</a></h1>
-<h3 class="AUTHOR"><a name="AEN4" id="AEN4">Pradeep Padala</a></h3>
-<div class="AFFILIATION">
-<div class="ADDRESS">
-<p class="ADDRESS"><code class="EMAIL"><<a href=
-"mailto:ppadala@gmail.com">ppadala@gmail.com</a>></code></p>
-</div>
-</div>
-<p class="PUBDATE">v1.9, 2005-06-20<br></p>
-<div class="REVHISTORY">
-<table width="100%" border="0">
-<tr>
-<th align="left" valign="top" colspan="3"><b>Revision
-History</b></th>
-</tr>
-<tr>
-<td align="left">Revision 1.9</td>
-<td align="left">2005-06-20</td>
-<td align="left">Revised by: ppadala</td>
-</tr>
-<tr>
-<td align="left" colspan="3">The license has been changed to the
-MIT-style license used by NCURSES. Note that the programs are also
-re-licensed under this.</td>
-</tr>
-<tr>
-<td align="left">Revision 1.8</td>
-<td align="left">2005-06-17</td>
-<td align="left">Revised by: ppadala</td>
-</tr>
-<tr>
-<td align="left" colspan="3">Lots of updates. Added references and
-perl examples. Changes to examples. Many grammatical and stylistic
-changes to the content. Changes to NCURSES history.</td>
-</tr>
-<tr>
-<td align="left">Revision 1.7.1</td>
-<td align="left">2002-06-25</td>
-<td align="left">Revised by: ppadala</td>
-</tr>
-<tr>
-<td align="left" colspan="3">Added a README file for building and
-instructions for building from source.</td>
-</tr>
-<tr>
-<td align="left">Revision 1.7</td>
-<td align="left">2002-06-25</td>
-<td align="left">Revised by: ppadala</td>
-</tr>
-<tr>
-<td align="left" colspan="3">Added "Other formats" section and made
-a lot of fancy changes to the programs. Inlining of programs is
-gone.</td>
-</tr>
-<tr>
-<td align="left">Revision 1.6.1</td>
-<td align="left">2002-02-24</td>
-<td align="left">Revised by: ppadala</td>
-</tr>
-<tr>
-<td align="left" colspan="3">Removed the old Changelog section,
-cleaned the makefiles</td>
-</tr>
-<tr>
-<td align="left">Revision 1.6</td>
-<td align="left">2002-02-16</td>
-<td align="left">Revised by: ppadala</td>
-</tr>
-<tr>
-<td align="left" colspan="3">Corrected a lot of spelling mistakes,
-added ACS variables section</td>
-</tr>
-<tr>
-<td align="left">Revision 1.5</td>
-<td align="left">2002-01-05</td>
-<td align="left">Revised by: ppadala</td>
-</tr>
-<tr>
-<td align="left" colspan="3">Changed structure to present proper
-TOC</td>
-</tr>
-<tr>
-<td align="left">Revision 1.3.1</td>
-<td align="left">2001-07-26</td>
-<td align="left">Revised by: ppadala</td>
-</tr>
-<tr>
-<td align="left" colspan="3">Corrected maintainers paragraph,
-Corrected stable release number</td>
-</tr>
-<tr>
-<td align="left">Revision 1.3</td>
-<td align="left">2001-07-24</td>
-<td align="left">Revised by: ppadala</td>
-</tr>
-<tr>
-<td align="left" colspan="3">Added copyright notices to main
-document (LDP license) and programs (GPL), Corrected
-printw_example.</td>
-</tr>
-<tr>
-<td align="left">Revision 1.2</td>
-<td align="left">2001-06-05</td>
-<td align="left">Revised by: ppadala</td>
-</tr>
-<tr>
-<td align="left" colspan="3">Incorporated ravi's changes. Mainly to
-introduction, menu, form, justforfun sections</td>
-</tr>
-<tr>
-<td align="left">Revision 1.1</td>
-<td align="left">2001-05-22</td>
-<td align="left">Revised by: ppadala</td>
-</tr>
-<tr>
-<td align="left" colspan="3">Added "a word about window" section,
-Added scanw_example.</td>
-</tr>
-</table>
-</div>
-<div>
-<div class="ABSTRACT"><a name="AEN67" id="AEN67"></a>
-<p><em>This document is intended to be an "All in One" guide for
-programming with ncurses and its sister libraries. We graduate from
-a simple "Hello World" program to more complex form manipulation.
-No prior experience in ncurses is assumed. Send comments to
-<a href="mailto:ppadala@gmail.com" target="_top">this
-address</a></em></p>
-</div>
-</div>
-<hr></div>
-<div class="TOC">
-<dl>
-<dt><b>Table of Contents</b></dt>
-<dt>1. <a href="#INTRO">Introduction</a></dt>
-<dd>
-<dl>
-<dt>1.1. <a href="#WHATIS">What is NCURSES?</a></dt>
-<dt>1.2. <a href="#WHATCANWEDO">What we can do with
-NCURSES</a></dt>
-<dt>1.3. <a href="#WHERETOGETIT">Where to get it</a></dt>
-<dt>1.4. <a href="#PURPOSE">Purpose/Scope of the document</a></dt>
-<dt>1.5. <a href="#ABOUTPROGRAMS">About the Programs</a></dt>
-<dt>1.6. <a href="#OTHERFORMATS">Other Formats of the
-document</a></dt>
-<dt>1.7. <a href="#CREDITS">Credits</a></dt>
-<dt>1.8. <a href="#WISHLIST">Wish List</a></dt>
-<dt>1.9. <a href="#COPYRIGHT">Copyright</a></dt>
-</dl>
-</dd>
-<dt>2. <a href="#HELLOWORLD">Hello World !!!</a></dt>
-<dd>
-<dl>
-<dt>2.1. <a href="#COMPILECURSES">Compiling With the NCURSES
-Library</a></dt>
-<dt>2.2. <a href="#DISSECTION">Dissection</a></dt>
-</dl>
-</dd>
-<dt>3. <a href="#GORY">The Gory Details</a></dt>
-<dt>4. <a href="#INIT">Initialization</a></dt>
-<dd>
-<dl>
-<dt>4.1. <a href="#ABOUTINIT">Initialization functions</a></dt>
-<dt>4.2. <a href="#RAWCBREAK">raw() and cbreak()</a></dt>
-<dt>4.3. <a href="#ECHONOECHO">echo() and noecho()</a></dt>
-<dt>4.4. <a href="#KEYPAD">keypad()</a></dt>
-<dt>4.5. <a href="#HALFDELAY">halfdelay()</a></dt>
-<dt>4.6. <a href="#MISCINIT">Miscellaneous Initialization
-functions</a></dt>
-<dt>4.7. <a href="#INITEX">An Example</a></dt>
-</dl>
-</dd>
-<dt>5. <a href="#AWORDWINDOWS">A Word about Windows</a></dt>
-<dt>6. <a href="#PRINTW">Output functions</a></dt>
-<dd>
-<dl>
-<dt>6.1. <a href="#ADDCHCLASS">addch() class of functions</a></dt>
-<dt>6.2. <a href="#AEN298">mvaddch(), waddch() and
-mvwaddch()</a></dt>
-<dt>6.3. <a href="#PRINTWCLASS">printw() class of
-functions</a></dt>
-<dt>6.4. <a href="#ADDSTRCLASS">addstr() class of
-functions</a></dt>
-<dt>6.5. <a href="#ACAUTION">A word of caution</a></dt>
-</dl>
-</dd>
-<dt>7. <a href="#SCANW">Input functions</a></dt>
-<dd>
-<dl>
-<dt>7.1. <a href="#GETCHCLASS">getch() class of functions</a></dt>
-<dt>7.2. <a href="#SCANWCLASS">scanw() class of functions</a></dt>
-<dt>7.3. <a href="#GETSTRCLASS">getstr() class of
-functions</a></dt>
-<dt>7.4. <a href="#GETSTREX">Some examples</a></dt>
-</dl>
-</dd>
-<dt>8. <a href="#ATTRIB">Attributes</a></dt>
-<dd>
-<dl>
-<dt>8.1. <a href="#ATTRIBDETAILS">The details</a></dt>
-<dt>8.2. <a href="#ATTRONVSATTRSET">attron() vs attrset()</a></dt>
-<dt>8.3. <a href="#ATTR_GET">attr_get()</a></dt>
-<dt>8.4. <a href="#ATTR_FUNCS">attr_ functions</a></dt>
-<dt>8.5. <a href="#WATTRFUNCS">wattr functions</a></dt>
-<dt>8.6. <a href="#CHGAT">chgat() functions</a></dt>
-</dl>
-</dd>
-<dt>9. <a href="#WINDOWS">Windows</a></dt>
-<dd>
-<dl>
-<dt>9.1. <a href="#WINDOWBASICS">The basics</a></dt>
-<dt>9.2. <a href="#LETBEWINDOW">Let there be a Window !!!</a></dt>
-<dt>9.3. <a href="#BORDEREXEXPL">Explanation</a></dt>
-<dt>9.4. <a href="#OTHERSTUFF">The other stuff in the
-example</a></dt>
-<dt>9.5. <a href="#OTHERBORDERFUNCS">Other Border
-functions</a></dt>
-</dl>
-</dd>
-<dt>10. <a href="#COLOR">Colors</a></dt>
-<dd>
-<dl>
-<dt>10.1. <a href="#COLORBASICS">The basics</a></dt>
-<dt>10.2. <a href="#CHANGECOLORDEFS">Changing Color
-Definitions</a></dt>
-<dt>10.3. <a href="#COLORCONTENT">Color Content</a></dt>
-</dl>
-</dd>
-<dt>11. <a href="#KEYS">Interfacing with the key board</a></dt>
-<dd>
-<dl>
-<dt>11.1. <a href="#KEYSBASICS">The Basics</a></dt>
-<dt>11.2. <a href="#SIMPLEKEYEX">A Simple Key Usage
-example</a></dt>
-</dl>
-</dd>
-<dt>12. <a href="#MOUSE">Interfacing with the mouse</a></dt>
-<dd>
-<dl>
-<dt>12.1. <a href="#MOUSEBASICS">The Basics</a></dt>
-<dt>12.2. <a href="#GETTINGEVENTS">Getting the events</a></dt>
-<dt>12.3. <a href="#MOUSETOGETHER">Putting it all Together</a></dt>
-<dt>12.4. <a href="#MISCMOUSEFUNCS">Miscellaneous
-Functions</a></dt>
-</dl>
-</dd>
-<dt>13. <a href="#SCREEN">Screen Manipulation</a></dt>
-<dd>
-<dl>
-<dt>13.1. <a href="#GETYX">getyx() functions</a></dt>
-<dt>13.2. <a href="#SCREENDUMP">Screen Dumping</a></dt>
-<dt>13.3. <a href="#WINDOWDUMP">Window Dumping</a></dt>
-</dl>
-</dd>
-<dt>14. <a href="#MISC">Miscellaneous features</a></dt>
-<dd>
-<dl>
-<dt>14.1. <a href="#CURSSET">curs_set()</a></dt>
-<dt>14.2. <a href="#TEMPLEAVE">Temporarily Leaving Curses
-mode</a></dt>
-<dt>14.3. <a href="#ACSVARS">ACS_ variables</a></dt>
-</dl>
-</dd>
-<dt>15. <a href="#OTHERLIB">Other libraries</a></dt>
-<dt>16. <a href="#PANELS">Panel Library</a></dt>
-<dd>
-<dl>
-<dt>16.1. <a href="#PANELBASICS">The Basics</a></dt>
-<dt>16.2. <a href="#COMPILEPANELS">Compiling With the Panels
-Library</a></dt>
-<dt>16.3. <a href="#PANELBROWSING">Panel Window Browsing</a></dt>
-<dt>16.4. <a href="#USERPTRUSING">Using User Pointers</a></dt>
-<dt>16.5. <a href="#PANELMOVERESIZE">Moving and Resizing
-Panels</a></dt>
-<dt>16.6. <a href="#PANELSHOWHIDE">Hiding and Showing
-Panels</a></dt>
-<dt>16.7. <a href="#PANELABOVE">panel_above() and panel_below()
-Functions</a></dt>
-</dl>
-</dd>
-<dt>17. <a href="#MENUS">Menus Library</a></dt>
-<dd>
-<dl>
-<dt>17.1. <a href="#MENUBASICS">The Basics</a></dt>
-<dt>17.2. <a href="#COMPILEMENUS">Compiling With the Menu
-Library</a></dt>
-<dt>17.3. <a href="#MENUDRIVER">Menu Driver: The work horse of the
-menu system</a></dt>
-<dt>17.4. <a href="#MENUWINDOWS">Menu Windows</a></dt>
-<dt>17.5. <a href="#SCROLLMENUS">Scrolling Menus</a></dt>
-<dt>17.6. <a href="#MULTICOLUMN">Multi Columnar Menus</a></dt>
-<dt>17.7. <a href="#MULTIVALUEMENUS">Multi Valued Menus</a></dt>
-<dt>17.8. <a href="#MENUOPT">Menu Options</a></dt>
-<dt>17.9. <a href="#MENUUSERPTR">The useful User Pointer</a></dt>
-</dl>
-</dd>
-<dt>18. <a href="#FORMS">Forms Library</a></dt>
-<dd>
-<dl>
-<dt>18.1. <a href="#FORMBASICS">The Basics</a></dt>
-<dt>18.2. <a href="#COMPILEFORMS">Compiling With the Forms
-Library</a></dt>
-<dt>18.3. <a href="#PLAYFIELDS">Playing with Fields</a></dt>
-<dt>18.4. <a href="#FORMWINDOWS">Form Windows</a></dt>
-<dt>18.5. <a href="#FILEDVALIDATE">Field Validation</a></dt>
-<dt>18.6. <a href="#FORMDRIVER">Form Driver: The work horse of the
-forms system</a></dt>
-</dl>
-</dd>
-<dt>19. <a href="#TOOLS">Tools and Widget Libraries</a></dt>
-<dd>
-<dl>
-<dt>19.1. <a href="#CDK">CDK (Curses Development Kit)</a></dt>
-<dt>19.2. <a href="#DIALOG">The dialog</a></dt>
-<dt>19.3. <a href="#PERLCURSES">Perl Curses Modules CURSES::FORM
-and CURSES::WIDGETS</a></dt>
-</dl>
-</dd>
-<dt>20. <a href="#JUSTFORFUN">Just For Fun !!!</a></dt>
-<dd>
-<dl>
-<dt>20.1. <a href="#GAMEOFLIFE">The Game of Life</a></dt>
-<dt>20.2. <a href="#MAGIC">Magic Square</a></dt>
-<dt>20.3. <a href="#HANOI">Towers of Hanoi</a></dt>
-<dt>20.4. <a href="#QUEENS">Queens Puzzle</a></dt>
-<dt>20.5. <a href="#SHUFFLE">Shuffle</a></dt>
-<dt>20.6. <a href="#TT">Typing Tutor</a></dt>
-</dl>
-</dd>
-<dt>21. <a href="#REF">References</a></dt>
-</dl>
-</div>
-<div class="SECT1">
-<h2 class="SECT1"><a name="INTRO" id="INTRO">1.
-Introduction</a></h2>
-<p>In the olden days of teletype terminals, terminals were away
-from computers and were connected to them through serial cables.
-The terminals could be configured by sending a series of bytes. All
-the capabilities (such as moving the cursor to a new location,
-erasing part of the screen, scrolling the screen, changing modes
-etc.) of terminals could be accessed through these series of bytes.
-These control seeuqnces are usually called escape sequences,
-because they start with an escape(0x1B) character. Even today, with
-proper emulation, we can send escape sequences to the emulator and
-achieve the same effect on a terminal window.</p>
-<p>Suppose you wanted to print a line in color. Try typing this on
-your console.</p>
-<table border="0" bgcolor="#E0E0E0" width="100%">
-<tr>
-<td>
-<pre class="PROGRAMLISTING">
-<font color="#000000">echo "^[[0;31;40mIn Color"</font>
-</pre></td>
-</tr>
-</table>
-<p>The first character is an escape character, which looks like two
-characters ^ and [. To be able to print it, you have to press
-CTRL+V and then the ESC key. All the others are normal printable
-characters. You should be able to see the string "In Color" in red.
-It stays that way and to revert back to the original mode type
-this.</p>
-<table border="0" bgcolor="#E0E0E0" width="100%">
-<tr>
-<td>
-<pre class="PROGRAMLISTING">
-<font color="#000000">echo "^[[0;37;40m"</font>
-</pre></td>
-</tr>
-</table>
-<p>Now, what do these magic characters mean? Difficult to
-comprehend? They might even be different for different terminals.
-So the designers of UNIX invented a mechanism named <var class=
-"LITERAL">termcap</var>. It is a file that lists all the
-capabilities of a particular terminal, along with the escape
-sequences needed to achieve a particular effect. In the later
-years, this was replaced by <var class="LITERAL">terminfo</var>.
-Without delving too much into details, this mechanism allows
-application programs to query the terminfo database and obtain the
-control characters to be sent to a terminal or terminal
-emulator.</p>
-<div class="SECT2">
-<hr>
-<h3 class="SECT2"><a name="WHATIS" id="WHATIS">1.1. What is
-NCURSES?</a></h3>
-<p>You might be wondering, what the import of all this technical
-gibberish is. In the above scenario, every application program is
-supposed to query the terminfo and perform the necessary stuff
-(sending control characters etc.). It soon became difficult to
-manage this complexity and this gave birth to 'CURSES'. Curses is a
-pun on the name "cursor optimization". The Curses library forms a
-wrapper over working with raw terminal codes, and provides highly
-flexible and efficient API (Application Programming Interface). It
-provides functions to move the cursor, create windows, produce
-colors, play with mouse etc. The application programs need not
-worry about the underlying terminal capabilities.</p>
-<p>So what is NCURSES? NCURSES is a clone of the original System V
-Release 4.0 (SVr4) curses. It is a freely distributable library,
-fully compatible with older version of curses. In short, it is a
-library of functions that manages an application's display on
-character-cell terminals. In the remainder of the document, the
-terms curses and ncurses are used interchangeably.</p>
-<p>A detailed history of NCURSES can be found in the NEWS file from
-the source distribution. The current package is maintained by
-<a href="mailto:dickey@his.com" target="_top">Thomas Dickey</a>.
-You can contact the maintainers at <a href=
-"mailto:bug-ncurses@gnu.org" target=
-"_top">bug-ncurses@gnu.org</a>.</p>
-</div>
-<div class="SECT2">
-<hr>
-<h3 class="SECT2"><a name="WHATCANWEDO" id="WHATCANWEDO">1.2. What
-we can do with NCURSES</a></h3>
-<p>NCURSES not only creates a wrapper over terminal capabilities,
-but also gives a robust framework to create nice looking UI (User
-Interface)s in text mode. It provides functions to create windows
-etc. Its sister libraries panel, menu and form provide an extension
-to the basic curses library. These libraries usually come along
-with curses. One can create applications that contain multiple
-windows, menus, panels and forms. Windows can be managed
-independently, can provide 'scrollability' and even can be
-hidden.</p>
-<p>Menus provide the user with an easy command selection option.
-Forms allow the creation of easy-to-use data entry and display
-windows. Panels extend the capabilities of ncurses to deal with
-overlapping and stacked windows.</p>
-<p>These are just some of the basic things we can do with ncurses.
-As we move along, We will see all the capabilities of these
-libraries.</p>
-</div>
-<div class="SECT2">
-<hr>
-<h3 class="SECT2"><a name="WHERETOGETIT" id="WHERETOGETIT">1.3.
-Where to get it</a></h3>
-<p>All right, now that you know what you can do with ncurses, you
-must be rearing to get started. NCURSES is usually shipped with
-your installation. In case you don't have the library or want to
-compile it on your own, read on.</p>
-<p><em>Compiling the package</em></p>
-<p>NCURSES can be obtained from <a href=
-"ftp://ftp.gnu.org/pub/gnu/ncurses/ncurses.tar.gz" target=
-"_top">ftp://ftp.gnu.org/pub/gnu/ncurses/ncurses.tar.gz</a> or any
-of the ftp sites mentioned in <a href=
-"http://www.gnu.org/order/ftp.html" target=
-"_top">http://www.gnu.org/order/ftp.html</a>.</p>
-<p>Read the README and INSTALL files for details on to how to
-install it. It usually involves the following operations.</p>
-<table border="0" bgcolor="#E0E0E0" width="100%">
-<tr>
-<td>
-<pre class="PROGRAMLISTING">
-<font color=
-"#000000"> tar zxvf ncurses<version>.tar.gz # unzip and untar the archive
+ <div class="ARTICLE">
+ <div class="TITLEPAGE">
+ <h1 class="TITLE"><a name="AEN2" id="AEN2">NCURSES
+ Programming HOWTO</a></h1>
+
+ <h3 class="AUTHOR"><a name="AEN4" id="AEN4">Pradeep
+ Padala</a></h3>
+
+ <div class="AFFILIATION">
+ <div class="ADDRESS">
+ <p class="ADDRESS"><code class="EMAIL"><<a href=
+ "mailto:ppadala@gmail.com">ppadala@gmail.com</a>></code></p>
+ </div>
+ </div>
+
+ <p class="PUBDATE">v1.9, 2005-06-20<br></p>
+
+ <div class="REVHISTORY">
+ <table width="100%" border="0" summary="revisions">
+ <tr>
+ <th align="left" valign="top" colspan="3"><b>Revision
+ History</b></th>
+ </tr>
+
+ <tr>
+ <td align="left">Revision 1.9</td>
+
+ <td align="left">2005-06-20</td>
+
+ <td align="left">Revised by: ppadala</td>
+ </tr>
+
+ <tr>
+ <td align="left" colspan="3">The license has been
+ changed to the MIT-style license used by NCURSES. Note
+ that the programs are also re-licensed under this.</td>
+ </tr>
+
+ <tr>
+ <td align="left">Revision 1.8</td>
+
+ <td align="left">2005-06-17</td>
+
+ <td align="left">Revised by: ppadala</td>
+ </tr>
+
+ <tr>
+ <td align="left" colspan="3">Lots of updates. Added
+ references and perl examples. Changes to examples. Many
+ grammatical and stylistic changes to the content.
+ Changes to NCURSES history.</td>
+ </tr>
+
+ <tr>
+ <td align="left">Revision 1.7.1</td>
+
+ <td align="left">2002-06-25</td>
+
+ <td align="left">Revised by: ppadala</td>
+ </tr>
+
+ <tr>
+ <td align="left" colspan="3">Added a README file for
+ building and instructions for building from
+ source.</td>
+ </tr>
+
+ <tr>
+ <td align="left">Revision 1.7</td>
+
+ <td align="left">2002-06-25</td>
+
+ <td align="left">Revised by: ppadala</td>
+ </tr>
+
+ <tr>
+ <td align="left" colspan="3">Added "Other formats"
+ section and made a lot of fancy changes to the
+ programs. Inlining of programs is gone.</td>
+ </tr>
+
+ <tr>
+ <td align="left">Revision 1.6.1</td>
+
+ <td align="left">2002-02-24</td>
+
+ <td align="left">Revised by: ppadala</td>
+ </tr>
+
+ <tr>
+ <td align="left" colspan="3">Removed the old Changelog
+ section, cleaned the makefiles</td>
+ </tr>
+
+ <tr>
+ <td align="left">Revision 1.6</td>
+
+ <td align="left">2002-02-16</td>
+
+ <td align="left">Revised by: ppadala</td>
+ </tr>
+
+ <tr>
+ <td align="left" colspan="3">Corrected a lot of
+ spelling mistakes, added ACS variables section</td>
+ </tr>
+
+ <tr>
+ <td align="left">Revision 1.5</td>
+
+ <td align="left">2002-01-05</td>
+
+ <td align="left">Revised by: ppadala</td>
+ </tr>
+
+ <tr>
+ <td align="left" colspan="3">Changed structure to
+ present proper TOC</td>
+ </tr>
+
+ <tr>
+ <td align="left">Revision 1.3.1</td>
+
+ <td align="left">2001-07-26</td>
+
+ <td align="left">Revised by: ppadala</td>
+ </tr>
+
+ <tr>
+ <td align="left" colspan="3">Corrected maintainers
+ paragraph, Corrected stable release number</td>
+ </tr>
+
+ <tr>
+ <td align="left">Revision 1.3</td>
+
+ <td align="left">2001-07-24</td>
+
+ <td align="left">Revised by: ppadala</td>
+ </tr>
+
+ <tr>
+ <td align="left" colspan="3">Added copyright notices to
+ main document (LDP license) and programs (GPL),
+ Corrected printw_example.</td>
+ </tr>
+
+ <tr>
+ <td align="left">Revision 1.2</td>
+
+ <td align="left">2001-06-05</td>
+
+ <td align="left">Revised by: ppadala</td>
+ </tr>
+
+ <tr>
+ <td align="left" colspan="3">Incorporated ravi's
+ changes. Mainly to introduction, menu, form, justforfun
+ sections</td>
+ </tr>
+
+ <tr>
+ <td align="left">Revision 1.1</td>
+
+ <td align="left">2001-05-22</td>
+
+ <td align="left">Revised by: ppadala</td>
+ </tr>
+
+ <tr>
+ <td align="left" colspan="3">Added "a word about
+ window" section, Added scanw_example.</td>
+ </tr>
+ </table>
+ </div>
+
+ <div>
+ <div class="ABSTRACT">
+ <a name="AEN67" id="AEN67"></a>
+
+ <p><span class="emphasis"><i class="EMPHASIS">This
+ document is intended to be an "All in One" guide for
+ programming with ncurses and its sister libraries. We
+ graduate from a simple "Hello World" program to more
+ complex form manipulation. No prior experience in ncurses
+ is assumed. Send comments to <a href=
+ "mailto:ppadala@gmail.com" target="_top">this
+ address</a></i></span></p>
+ </div>
+ </div>
+ <hr>
+ </div>
+
+ <div class="TOC">
+ <dl>
+ <dt><b>Table of Contents</b></dt>
+
+ <dt>1. <a href="#INTRO">Introduction</a></dt>
+
+ <dd>
+ <dl>
+ <dt>1.1. <a href="#WHATIS">What is NCURSES?</a></dt>
+
+ <dt>1.2. <a href="#WHATCANWEDO">What we can do with
+ NCURSES</a></dt>
+
+ <dt>1.3. <a href="#WHERETOGETIT">Where to get
+ it</a></dt>
+
+ <dt>1.4. <a href="#PURPOSE">Purpose/Scope of the
+ document</a></dt>
+
+ <dt>1.5. <a href="#ABOUTPROGRAMS">About the
+ Programs</a></dt>
+
+ <dt>1.6. <a href="#OTHERFORMATS">Other Formats of the
+ document</a></dt>
+
+ <dd>
+ <dl>
+ <dt>1.6.1. <a href="#LISTFORMATS">Readily available
+ formats from tldp.org</a></dt>
+
+ <dt>1.6.2. <a href="#BUILDSOURCE">Building from
+ source</a></dt>
+ </dl>
+ </dd>
+
+ <dt>1.7. <a href="#CREDITS">Credits</a></dt>
+
+ <dt>1.8. <a href="#WISHLIST">Wish List</a></dt>
+
+ <dt>1.9. <a href="#COPYRIGHT">Copyright</a></dt>
+ </dl>
+ </dd>
+
+ <dt>2. <a href="#HELLOWORLD">Hello World !!!</a></dt>
+
+ <dd>
+ <dl>
+ <dt>2.1. <a href="#COMPILECURSES">Compiling With the
+ NCURSES Library</a></dt>
+
+ <dt>2.2. <a href="#DISSECTION">Dissection</a></dt>
+
+ <dd>
+ <dl>
+ <dt>2.2.1. <a href="#ABOUT-INITSCR">About
+ initscr()</a></dt>
+
+ <dt>2.2.2. <a href="#MYST-REFRESH">The mysterious
+ refresh()</a></dt>
+
+ <dt>2.2.3. <a href="#ABOUT-ENDWIN">About
+ endwin()</a></dt>
+ </dl>
+ </dd>
+ </dl>
+ </dd>
+
+ <dt>3. <a href="#GORY">The Gory Details</a></dt>
+
+ <dt>4. <a href="#INIT">Initialization</a></dt>
+
+ <dd>
+ <dl>
+ <dt>4.1. <a href="#ABOUTINIT">Initialization
+ functions</a></dt>
+
+ <dt>4.2. <a href="#RAWCBREAK">raw() and
+ cbreak()</a></dt>
+
+ <dt>4.3. <a href="#ECHONOECHO">echo() and
+ noecho()</a></dt>
+
+ <dt>4.4. <a href="#KEYPAD">keypad()</a></dt>
+
+ <dt>4.5. <a href="#HALFDELAY">halfdelay()</a></dt>
+
+ <dt>4.6. <a href="#MISCINIT">Miscellaneous
+ Initialization functions</a></dt>
+
+ <dt>4.7. <a href="#INITEX">An Example</a></dt>
+ </dl>
+ </dd>
+
+ <dt>5. <a href="#AWORDWINDOWS">A Word about
+ Windows</a></dt>
+
+ <dt>6. <a href="#PRINTW">Output functions</a></dt>
+
+ <dd>
+ <dl>
+ <dt>6.1. <a href="#ADDCHCLASS">addch() class of
+ functions</a></dt>
+
+ <dt>6.2. <a href="#AEN298">mvaddch(), waddch() and
+ mvwaddch()</a></dt>
+
+ <dt>6.3. <a href="#PRINTWCLASS">printw() class of
+ functions</a></dt>
+
+ <dd>
+ <dl>
+ <dt>6.3.1. <a href="#PRINTWMVPRINTW">printw() and
+ mvprintw</a></dt>
+
+ <dt>6.3.2. <a href="#WPRINTWMVWPRINTW">wprintw()
+ and mvwprintw</a></dt>
+
+ <dt>6.3.3. <a href="#VWPRINTW">vw_printw()</a></dt>
+
+ <dt>6.3.4. <a href="#SIMPLEPRINTWEX">A Simple
+ printw example</a></dt>
+ </dl>
+ </dd>
+
+ <dt>6.4. <a href="#ADDSTRCLASS">addstr() class of
+ functions</a></dt>
+
+ <dt>6.5. <a href="#ACAUTION">A word of caution</a></dt>
+ </dl>
+ </dd>
+
+ <dt>7. <a href="#SCANW">Input functions</a></dt>
+
+ <dd>
+ <dl>
+ <dt>7.1. <a href="#GETCHCLASS">getch() class of
+ functions</a></dt>
+
+ <dt>7.2. <a href="#SCANWCLASS">scanw() class of
+ functions</a></dt>
+
+ <dd>
+ <dl>
+ <dt>7.2.1. <a href="#SCANWMVSCANW">scanw() and
+ mvscanw</a></dt>
+
+ <dt>7.2.2. <a href="#WSCANWMVWSCANW">wscanw() and
+ mvwscanw()</a></dt>
+
+ <dt>7.2.3. <a href="#VWSCANW">vw_scanw()</a></dt>
+ </dl>
+ </dd>
+
+ <dt>7.3. <a href="#GETSTRCLASS">getstr() class of
+ functions</a></dt>
+
+ <dt>7.4. <a href="#GETSTREX">Some examples</a></dt>
+ </dl>
+ </dd>
+
+ <dt>8. <a href="#ATTRIB">Attributes</a></dt>
+
+ <dd>
+ <dl>
+ <dt>8.1. <a href="#ATTRIBDETAILS">The details</a></dt>
+
+ <dt>8.2. <a href="#ATTRONVSATTRSET">attron() vs
+ attrset()</a></dt>
+
+ <dt>8.3. <a href="#ATTRGET">attr_get()</a></dt>
+
+ <dt>8.4. <a href="#ATTRFUNCS">attr_ functions</a></dt>
+
+ <dt>8.5. <a href="#WATTRFUNCS">wattr functions</a></dt>
+
+ <dt>8.6. <a href="#CHGAT">chgat() functions</a></dt>
+ </dl>
+ </dd>
+
+ <dt>9. <a href="#WINDOWS">Windows</a></dt>
+
+ <dd>
+ <dl>
+ <dt>9.1. <a href="#WINDOWBASICS">The basics</a></dt>
+
+ <dt>9.2. <a href="#LETBEWINDOW">Let there be a Window
+ !!!</a></dt>
+
+ <dt>9.3. <a href="#BORDEREXEXPL">Explanation</a></dt>
+
+ <dt>9.4. <a href="#OTHERSTUFF">The other stuff in the
+ example</a></dt>
+
+ <dt>9.5. <a href="#OTHERBORDERFUNCS">Other Border
+ functions</a></dt>
+ </dl>
+ </dd>
+
+ <dt>10. <a href="#COLOR">Colors</a></dt>
+
+ <dd>
+ <dl>
+ <dt>10.1. <a href="#COLORBASICS">The basics</a></dt>
+
+ <dt>10.2. <a href="#CHANGECOLORDEFS">Changing Color
+ Definitions</a></dt>
+
+ <dt>10.3. <a href="#COLORCONTENT">Color
+ Content</a></dt>
+ </dl>
+ </dd>
+
+ <dt>11. <a href="#KEYS">Interfacing with the key
+ board</a></dt>
+
+ <dd>
+ <dl>
+ <dt>11.1. <a href="#KEYSBASICS">The Basics</a></dt>
+
+ <dt>11.2. <a href="#SIMPLEKEYEX">A Simple Key Usage
+ example</a></dt>
+ </dl>
+ </dd>
+
+ <dt>12. <a href="#MOUSE">Interfacing with the
+ mouse</a></dt>
+
+ <dd>
+ <dl>
+ <dt>12.1. <a href="#MOUSEBASICS">The Basics</a></dt>
+
+ <dt>12.2. <a href="#GETTINGEVENTS">Getting the
+ events</a></dt>
+
+ <dt>12.3. <a href="#MOUSETOGETHER">Putting it all
+ Together</a></dt>
+
+ <dt>12.4. <a href="#MISCMOUSEFUNCS">Miscellaneous
+ Functions</a></dt>
+ </dl>
+ </dd>
+
+ <dt>13. <a href="#SCREEN">Screen Manipulation</a></dt>
+
+ <dd>
+ <dl>
+ <dt>13.1. <a href="#GETYX">getyx() functions</a></dt>
+
+ <dt>13.2. <a href="#SCREENDUMP">Screen Dumping</a></dt>
+
+ <dt>13.3. <a href="#WINDOWDUMP">Window Dumping</a></dt>
+ </dl>
+ </dd>
+
+ <dt>14. <a href="#MISC">Miscellaneous features</a></dt>
+
+ <dd>
+ <dl>
+ <dt>14.1. <a href="#CURSSET">curs_set()</a></dt>
+
+ <dt>14.2. <a href="#TEMPLEAVE">Temporarily Leaving
+ Curses mode</a></dt>
+
+ <dt>14.3. <a href="#ACSVARS">ACS_ variables</a></dt>
+ </dl>
+ </dd>
+
+ <dt>15. <a href="#OTHERLIB">Other libraries</a></dt>
+
+ <dt>16. <a href="#PANELS">Panel Library</a></dt>
+
+ <dd>
+ <dl>
+ <dt>16.1. <a href="#PANELBASICS">The Basics</a></dt>
+
+ <dt>16.2. <a href="#COMPILEPANELS">Compiling With the
+ Panels Library</a></dt>
+
+ <dt>16.3. <a href="#PANELBROWSING">Panel Window
+ Browsing</a></dt>
+
+ <dt>16.4. <a href="#USERPTRUSING">Using User
+ Pointers</a></dt>
+
+ <dt>16.5. <a href="#PANELMOVERESIZE">Moving and
+ Resizing Panels</a></dt>
+
+ <dt>16.6. <a href="#PANELSHOWHIDE">Hiding and Showing
+ Panels</a></dt>
+
+ <dt>16.7. <a href="#PANELABOVE">panel_above() and
+ panel_below() Functions</a></dt>
+ </dl>
+ </dd>
+
+ <dt>17. <a href="#MENUS">Menus Library</a></dt>
+
+ <dd>
+ <dl>
+ <dt>17.1. <a href="#MENUBASICS">The Basics</a></dt>
+
+ <dt>17.2. <a href="#COMPILEMENUS">Compiling With the
+ Menu Library</a></dt>
+
+ <dt>17.3. <a href="#MENUDRIVER">Menu Driver: The work
+ horse of the menu system</a></dt>
+
+ <dt>17.4. <a href="#MENUWINDOWS">Menu Windows</a></dt>
+
+ <dt>17.5. <a href="#SCROLLMENUS">Scrolling
+ Menus</a></dt>
+
+ <dt>17.6. <a href="#MULTICOLUMN">Multi Columnar
+ Menus</a></dt>
+
+ <dt>17.7. <a href="#MULTIVALUEMENUS">Multi Valued
+ Menus</a></dt>
+
+ <dt>17.8. <a href="#MENUOPT">Menu Options</a></dt>
+
+ <dt>17.9. <a href="#MENUUSERPTR">The useful User
+ Pointer</a></dt>
+ </dl>
+ </dd>
+
+ <dt>18. <a href="#FORMS">Forms Library</a></dt>
+
+ <dd>
+ <dl>
+ <dt>18.1. <a href="#FORMBASICS">The Basics</a></dt>
+
+ <dt>18.2. <a href="#COMPILEFORMS">Compiling With the
+ Forms Library</a></dt>
+
+ <dt>18.3. <a href="#PLAYFIELDS">Playing with
+ Fields</a></dt>
+
+ <dd>
+ <dl>
+ <dt>18.3.1. <a href="#FETCHINFO">Fetching Size and
+ Location of Field</a></dt>
+
+ <dt>18.3.2. <a href="#MOVEFIELD">Moving the
+ field</a></dt>
+
+ <dt>18.3.3. <a href="#JUSTIFYFIELD">Field
+ Justification</a></dt>
+
+ <dt>18.3.4. <a href="#FIELDDISPATTRIB">Field
+ Display Attributes</a></dt>
+
+ <dt>18.3.5. <a href="#FIELDOPTIONBITS">Field Option
+ Bits</a></dt>
+
+ <dt>18.3.6. <a href="#FIELDSTATUS">Field
+ Status</a></dt>
+
+ <dt>18.3.7. <a href="#FIELDUSERPTR">Field User
+ Pointer</a></dt>
+
+ <dt>18.3.8. <a href=
+ "#VARIABLESIZEFIELDS">Variable-Sized
+ Fields</a></dt>
+ </dl>
+ </dd>
+
+ <dt>18.4. <a href="#FORMWINDOWS">Form Windows</a></dt>
+
+ <dt>18.5. <a href="#FILEDVALIDATE">Field
+ Validation</a></dt>
+
+ <dt>18.6. <a href="#FORMDRIVER">Form Driver: The work
+ horse of the forms system</a></dt>
+
+ <dd>
+ <dl>
+ <dt>18.6.1. <a href="#PAGENAVREQ">Page Navigation
+ Requests</a></dt>
+
+ <dt>18.6.2. <a href="#INTERFIELDNAVREQ">Inter-Field
+ Navigation Requests</a></dt>
+
+ <dt>18.6.3. <a href="#INTRAFIELDNAVREQ">Intra-Field
+ Navigation Requests</a></dt>
+
+ <dt>18.6.4. <a href="#SCROLLREQ">Scrolling
+ Requests</a></dt>
+
+ <dt>18.6.5. <a href="#EDITREQ">Editing
+ Requests</a></dt>
+
+ <dt>18.6.6. <a href="#ORDERREQ">Order
+ Requests</a></dt>
+
+ <dt>18.6.7. <a href="#APPLICCOMMANDS">Application
+ Commands</a></dt>
+ </dl>
+ </dd>
+ </dl>
+ </dd>
+
+ <dt>19. <a href="#TOOLS">Tools and Widget
+ Libraries</a></dt>
+
+ <dd>
+ <dl>
+ <dt>19.1. <a href="#CDK">CDK (Curses Development
+ Kit)</a></dt>
+
+ <dd>
+ <dl>
+ <dt>19.1.1. <a href="#WIDGETLIST">Widget
+ List</a></dt>
+
+ <dt>19.1.2. <a href="#CDKATTRACT">Some Attractive
+ Features</a></dt>
+
+ <dt>19.1.3. <a href=
+ "#CDKCONCLUSION">Conclusion</a></dt>
+ </dl>
+ </dd>
+
+ <dt>19.2. <a href="#DIALOG">The dialog</a></dt>
+
+ <dt>19.3. <a href="#PERLCURSES">Perl Curses Modules
+ CURSES::FORM and CURSES::WIDGETS</a></dt>
+ </dl>
+ </dd>
+
+ <dt>20. <a href="#JUSTFORFUN">Just For Fun !!!</a></dt>
+
+ <dd>
+ <dl>
+ <dt>20.1. <a href="#GAMEOFLIFE">The Game of
+ Life</a></dt>
+
+ <dt>20.2. <a href="#MAGIC">Magic Square</a></dt>
+
+ <dt>20.3. <a href="#HANOI">Towers of Hanoi</a></dt>
+
+ <dt>20.4. <a href="#QUEENS">Queens Puzzle</a></dt>
+
+ <dt>20.5. <a href="#SHUFFLE">Shuffle</a></dt>
+
+ <dt>20.6. <a href="#TT">Typing Tutor</a></dt>
+ </dl>
+ </dd>
+
+ <dt>21. <a href="#REF">References</a></dt>
+ </dl>
+ </div>
+
+ <div class="SECT1">
+ <h2 class="SECT1"><a name="INTRO" id="INTRO">1.
+ Introduction</a></h2>
+
+ <p>In the olden days of teletype terminals, terminals were
+ away from computers and were connected to them through serial
+ cables. The terminals could be configured by sending a series
+ of bytes. All the capabilities (such as moving the cursor to
+ a new location, erasing part of the screen, scrolling the
+ screen, changing modes etc.) of terminals could be accessed
+ through these series of bytes. These control seeuqnces are
+ usually called escape sequences, because they start with an
+ escape(0x1B) character. Even today, with proper emulation, we
+ can send escape sequences to the emulator and achieve the
+ same effect on a terminal window.</p>
+
+ <p>Suppose you wanted to print a line in color. Try typing
+ this on your console.</p>
+ <pre class="PROGRAMLISTING">
+echo "^[[0;31;40mIn Color"
+</pre>
+
+ <p>The first character is an escape character, which looks
+ like two characters ^ and [. To be able to print it, you have
+ to press CTRL+V and then the ESC key. All the others are
+ normal printable characters. You should be able to see the
+ string "In Color" in red. It stays that way and to revert
+ back to the original mode type this.</p>
+ <pre class="PROGRAMLISTING">
+echo "^[[0;37;40m"
+</pre>
+
+ <p>Now, what do these magic characters mean? Difficult to
+ comprehend? They might even be different for different
+ terminals. So the designers of UNIX invented a mechanism
+ named <tt class="LITERAL">termcap</tt>. It is a file that
+ lists all the capabilities of a particular terminal, along
+ with the escape sequences needed to achieve a particular
+ effect. In the later years, this was replaced by <tt class=
+ "LITERAL">terminfo</tt>. Without delving too much into
+ details, this mechanism allows application programs to query
+ the terminfo database and obtain the control characters to be
+ sent to a terminal or terminal emulator.</p>
+
+ <div class="SECT2">
+ <hr>
+
+ <h3 class="SECT2"><a name="WHATIS" id="WHATIS">1.1. What is
+ NCURSES?</a></h3>
+
+ <p>You might be wondering, what the import of all this
+ technical gibberish is. In the above scenario, every
+ application program is supposed to query the terminfo and
+ perform the necessary stuff (sending control characters
+ etc.). It soon became difficult to manage this complexity
+ and this gave birth to 'CURSES'. Curses is a pun on the
+ name "cursor optimization". The Curses library forms a
+ wrapper over working with raw terminal codes, and provides
+ highly flexible and efficient API (Application Programming
+ Interface). It provides functions to move the cursor,
+ create windows, produce colors, play with mouse etc. The
+ application programs need not worry about the underlying
+ terminal capabilities.</p>
+
+ <p>So what is NCURSES? NCURSES is a clone of the original
+ System V Release 4.0 (SVr4) curses. It is a freely
+ distributable library, fully compatible with older version
+ of curses. In short, it is a library of functions that
+ manages an application's display on character-cell
+ terminals. In the remainder of the document, the terms
+ curses and ncurses are used interchangeably.</p>
+
+ <p>A detailed history of NCURSES can be found in the NEWS
+ file from the source distribution. The current package is
+ maintained by <a href="mailto:dickey@his.com" target=
+ "_top">Thomas Dickey</a>. You can contact the maintainers
+ at <a href="mailto:bug-ncurses@gnu.org" target=
+ "_top">bug-ncurses@gnu.org</a>.</p>
+ </div>
+
+ <div class="SECT2">
+ <hr>
+
+ <h3 class="SECT2"><a name="WHATCANWEDO" id=
+ "WHATCANWEDO">1.2. What we can do with NCURSES</a></h3>
+
+ <p>NCURSES not only creates a wrapper over terminal
+ capabilities, but also gives a robust framework to create
+ nice looking UI (User Interface)s in text mode. It provides
+ functions to create windows etc. Its sister libraries
+ panel, menu and form provide an extension to the basic
+ curses library. These libraries usually come along with
+ curses. One can create applications that contain multiple
+ windows, menus, panels and forms. Windows can be managed
+ independently, can provide 'scrollability' and even can be
+ hidden.</p>
+
+ <p>Menus provide the user with an easy command selection
+ option. Forms allow the creation of easy-to-use data entry
+ and display windows. Panels extend the capabilities of
+ ncurses to deal with overlapping and stacked windows.</p>
+
+ <p>These are just some of the basic things we can do with
+ ncurses. As we move along, We will see all the capabilities
+ of these libraries.</p>
+ </div>
+
+ <div class="SECT2">
+ <hr>
+
+ <h3 class="SECT2"><a name="WHERETOGETIT" id=
+ "WHERETOGETIT">1.3. Where to get it</a></h3>
+
+ <p>All right, now that you know what you can do with
+ ncurses, you must be rearing to get started. NCURSES is
+ usually shipped with your installation. In case you don't
+ have the library or want to compile it on your own, read
+ on.</p>
+
+ <p><span class="emphasis"><i class="EMPHASIS">Compiling the
+ package</i></span></p>
+
+ <p>NCURSES can be obtained from <a href=
+ "ftp://ftp.gnu.org/pub/gnu/ncurses/ncurses.tar.gz" target=
+ "_top">ftp://ftp.gnu.org/pub/gnu/ncurses/ncurses.tar.gz</a>
+ or any of the ftp sites mentioned in <a href=
+ "http://www.gnu.org/order/ftp.html" target=
+ "_top">http://www.gnu.org/order/ftp.html</a>.</p>
+
+ <p>Read the README and INSTALL files for details on to how
+ to install it. It usually involves the following
+ operations.</p>
+ <pre class="PROGRAMLISTING">
+ tar zxvf ncurses<version>.tar.gz # unzip and untar the archive