-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd">
-<HTML
-><HEAD
-><TITLE
-> NCURSES Programming HOWTO </TITLE
-><META
-NAME="GENERATOR"
-CONTENT="Modular DocBook HTML Stylesheet Version 1.79"></HEAD
-><BODY
-CLASS="ARTICLE"
-BGCOLOR="#FFFFFF"
-TEXT="#000000"
-LINK="#0000FF"
-VLINK="#840084"
-ALINK="#0000FF"
-><DIV
-CLASS="ARTICLE"
-><DIV
-CLASS="TITLEPAGE"
-><H1
-CLASS="TITLE"
-><A
-NAME="AEN2"
->NCURSES Programming HOWTO</A
-></H1
-><H3
-CLASS="AUTHOR"
-><A
-NAME="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"
-><P
-></P
-><A
-NAME="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
-><P
-></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"
->vwprintw()</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"
->vwscanw()</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="#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
-><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"
->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"
->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"
->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"
->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
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
+"http://www.w3.org/TR/html4/strict.dtd">
+
+<html>
+<head>
+ <meta name="generator" content=
+ "HTML Tidy for Linux (vers 25 March 2009), see www.w3.org">
+
+ <title>NCURSES Programming HOWTO</title>
+ <meta name="GENERATOR" content=
+ "Modular DocBook HTML Stylesheet Version 1.79">
+</head>
+
+<body class="ARTICLE" bgcolor="#FFFFFF" text="#000000" link=
+"#0000FF" vlink="#840084" alink="#0000FF">
+ <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