This commit was generated by cvs2svn to compensate for changes in r76732,

which included commits to RCS files with non-trunk default branches.
This commit is contained in:
Peter Wemm 2001-05-17 08:39:21 +00:00
parent 2493e89366
commit edfeb4834f
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=76733
9 changed files with 0 additions and 7562 deletions

View File

@ -1,391 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 3.0//EN">
<!--
$Id: announce.html,v 1.34 1999/10/23 21:13:11 tom Exp $
-->
<HTML>
<HEAD>
<TITLE>Announcing ncurses 5.0</TITLE>
<link rev=made href="mailto:bug-ncurses@gnu.org">
</HEAD>
<BODY>
<H1>Announcing ncurses 5.0</H1>
The ncurses (new curses) library is a free software emulation of
curses in System V Release 4.0, and more. It uses terminfo format,
supports pads and color
and multiple highlights and forms characters and function-key mapping,
and has all the other SYSV-curses enhancements over BSD curses.<P>
In mid-June 1995, the maintainer of 4.4BSD curses declared that he
considered 4.4BSD curses obsolete, and is encouraging the keepers of
Unix releases such as BSD/OS, freeBSD and netBSD to switch over to
ncurses.<P>
The ncurses code was developed under GNU/Linux. It should port easily to
any ANSI/POSIX-conforming UNIX. It has even been ported to OS/2 Warp!<P>
The distribution includes the library and support utilities, including a
terminfo compiler tic(1), a decompiler infocmp(1), clear(1), tput(1), tset(1),
and a termcap conversion tool captoinfo(1). Full manual pages are provided for
the library and tools.<P>
The ncurses distribution is available via anonymous FTP at
the GNU distribution site
<A HREF="ftp://ftp.gnu.org/pub/gnu/ncurses">ftp://ftp.gnu.org/pub/gnu/ncurses</A>.
It is also available at
<A HREF="ftp://ftp.clark.net/pub/dickey/ncurses">ftp://ftp.clark.net/pub/dickey/ncurses</A>.
<H1>Release Notes</H1>
We decided to release ncurses as a new whole number release (5.0) because it
incorporates several interface changes, including some that would invalidate
existing shared libraries. These are the highlights from the change-log
since ncurses 4.2 release.
<p>
Interface changes:
<ul>
<li>The principal source of changes to the interface comes from the
release of X/Open Curses in 1997. Earlier versions of ncurses (4.0
and before) were based on a draft version of the specification. The
release version adds parameters to some functions to support the
evolving internationalization of curses. These summarize the impact:
<ul>
<li>modified several prototypes to correspond with 1997 version of
X/Open Curses (affects ABI since developers have used attr_get).
<li>corrected prototypes for slk_* functions, using chtype rather than
attr_t.
<li>the slk_attr_{set,off,on} functions need an additional void*
parameter according to XSI.
<li>correct macros for wattr_set, wattr_get, separate wattrset macro from
these to preserve behavior that allows attributes to be combined with
color pair numbers.
<li>reviewed/updated curses.h, term.h against X/Open Curses Issue 4
Version 2. This includes making some parameters NCURSES_CONST
rather than const, e.g., in termcap.h.
<li>reviewed/corrected macros in curses.h as per XSI document.
<li>add set_a_attributes and set_pglen_inch to terminfo structure, as per
XSI and Solaris 2.5.
</ul>
<li>The newest version of the X/Open Curses is implemented on Solaris
and other vendor's systems. It adds new features to the terminfo
descriptions:
<ul>
<li>implement tparm %l format.
<li>implement tparm printf-style width and precision for %s, %d, %x, %o
as per XSI.
</ul>
<li>We made additional changes to reduce impact by future interface
changes:
<ul>
<li>rename key_names[] array to _nc_key_names since it is not part of
the curses interface.
<li>move macro winch to a function, to hide details of struct ldat
</ul>
<li>modify configure script to embed ABI in shared libraries for HP-UX
10.x (detailed request by Tim Mooney).
<li>modify configuration of shared libraries on Digital Unix so that
versioning is embedded in the library, rather than implied by
links (patch by Tim Mooney).
</ul>
New features:
<ul>
<li>enable sigwinch handler by default.
<li>turn on hashmap scrolling code by default
<li>improved support for termcap applications
<ul>
<li>modify tput to accept termcap names as an alternative to terminfo
names.
<li>provide support for termcap PC variable by copying it from terminfo
data and using it as the padding character in tputs.
<li>provide support for termcap ospeed variable by copying it from the
internal cur_term member, and using ospeed as the baudrate
reference for the delay_output and tputs functions.
<li>change name-comparisons in lib_termcap to compare no more than 2
characters.
<li>add configure option --enable-tcap-names, which essentially
allows users to define new capabilities as in termcap.
</ul>
<li>add mouse support to ncurses menus.
<li>add mouse and dll support for OS/2 EMX
<li>modify terminfo parsing to accept octal and hexadecimal constants
<li>add configure option --enable-no-padding, to allow environment
variable $NCURSES_NO_PADDING to eliminate non-mandatory padding,
thereby making terminal emulators (e.g., for vt100) a little more
efficient.
<li>modify lib_color.c to eliminate dependency on orig_colors and
orig_pair, since SVr4 curses does not require these either, but
uses them when they are available.
<li>add -f option to infocmp and tic, which formats the terminfo
if/then/else/endif so that they are readable (with newlines and
tabs).
<li>modify tic to compile into %'char' form in preference to %{number},
since that is a little more efficient.
</ul>
Major bug fixes:
<ul>
<li>modify lib_tstp.c to block SIGTTOU when handling SIGTSTP, fixes a
problem where ncurses applications which were run via a shell script
would hang when given a ^Z. Also, check if the terminal's process
group is consistent, i.e., a shell has not taken ownership of it,
before deciding to save the current terminal settings in the SIGTSTP
handler.
<li>suppress sc/rc capabilities from terminal description if they appear
in smcup/rmcup. This affects only scrolling optimization, to fix a
problem reported by several people with xterm's alternate screen,
though the problem is more general.
<li>modify relative_move and tputs to avoid an interaction with the
BSD-style padding. The relative_move function could produce a string
to replace on the screen which began with a numeric character, which
was then interpreted by tputs as padding.
<li>modify setupterm so that cancelled strings are treated the same as
absent strings, cancelled and absent booleans false (does not affect
tic, infocmp).
<li>modify lib_vidattr.c to allow for terminal types (e.g., xterm-color)
which may reset all attributes in the 'op' capability, so that colors
are set before turning on bold and other attributes, but still after
turning attributes off.
<li>use 'access()' to check if ncurses library should be permitted to
open or modify files with fopen/open/link/unlink/remove calls, in
case the calling application is running in setuid mode.
<li>correction to doupdate, for case where terminal does not support
insert/delete character. The logic did not check that there was a
difference in alignment of changes to old/new screens before
repainting the whole non-blank portion of the line. Modified to fall
through into logic that reduces by the portion which does not differ.
</ul>
<H1>Features of Ncurses</H1>
The ncurses package is fully compatible with SVr4 (System V Release 4) curses:
<UL>
<LI>All 257 of the SVr4 calls have been implemented (and are documented).
<LI>Full support for SVr4 curses features including keyboard mapping, color,
forms-drawing with ACS characters, and automatic recognition of keypad
and function keys.
<LI>An emulation of the SVr4 panels library, supporting
a stack of windows with backing store, is included.
<LI>An emulation of the SVr4 menus library, supporting
a uniform but flexible interface for menu programming, is included.
<LI>An emulation of the SVr4 form library, supporting
data collection through on-screen forms, is included.
<LI>Binary terminfo entries generated by the ncurses tic(1) implementation
are bit-for-bit-compatible with the entry format SVr4 curses uses.
<LI>The utilities have options to allow you to filter terminfo
entries for use with less capable <STRONG>curses</STRONG>/<STRONG>terminfo</STRONG>
versions such as the HP/UX and AIX ports.</UL>
The ncurses package also has many useful extensions over SVr4:
<UL>
<LI>The API is 8-bit clean and base-level conformant with the X/OPEN curses
specification, XSI curses (that is, it implements all BASE level features,
but not all EXTENDED features). Most EXTENDED-level features not directly
concerned with wide-character support are implemented, including many
function calls not supported under SVr4 curses (but portability of all
calls is documented so you can use the SVr4 subset only).
<LI>Unlike SVr3 curses, ncurses can write to the rightmost-bottommost corner
of the screen if your terminal has an insert-character capability.
<LI>Ada95 and C++ bindings.
<LI>Support for mouse event reporting with X Window xterm and OS/2 console windows.
<LI>Extended mouse support via Alessandro Rubini's gpm package.
<LI>The function <CODE>wresize()</CODE> allows you to resize windows, preserving
their data.
<LI>The function <CODE>use_default_colors()</CODE> allows you to
use the terminal's default colors for the default color pair,
achieving the effect of transparent colors.
<LI>The functions <CODE>keyok()</CODE>
and <CODE>define_key()</CODE> allow
you to better control the use of function keys,
e.g., disabling the ncurses KEY_MOUSE,
or by defining more than one control sequence to map to a given key code.
<LI>Support for 16-color terminals, such as aixterm and XFree86 xterm.
<LI>Better cursor-movement optimization. The package now features a
cursor-local-movement computation more efficient than either BSD's
or System V's.
<LI>Super hardware scrolling support. The screen-update code incorporates
a novel, simple, and cheap algorithm that enables it to make optimal
use of hardware scrolling, line-insertion, and line-deletion
for screen-line movements. This algorithm is more powerful than
the 4.4BSD curses quickch() routine.
<LI>Real support for terminals with the magic-cookie glitch. The
screen-update code will refrain from drawing a highlight if the magic-
cookie unattributed spaces required just before the beginning and
after the end would step on a non-space character. It will
automatically shift highlight boundaries when doing so would make it
possible to draw the highlight without changing the visual appearance
of the screen.
<LI>It is possible to generate the library with a list of pre-loaded
fallback entries linked to it so that it can serve those terminal types even
when no terminfo tree or termcap file is accessible (this may be useful
for support of screen-oriented programs that must run in single-user mode).
<LI>The tic(1)/captoinfo utility provided with ncurses has the
ability to translate many termcaps from the XENIX, IBM and
AT&amp;T extension sets.
<LI>A BSD-like tset(1) utility is provided.
<LI>The ncurses library and utilities will automatically read terminfo
entries from $HOME/.terminfo if it exists, and compile to that directory
if it exists and the user has no write access to the system directory.
This feature makes it easier for users to have personal terminfo entries
without giving up access to the system terminfo directory.
<LI>You may specify a path of directories to search for compiled
descriptions with the environment variable TERMINFO_DIRS (this
generalizes the feature provided by TERMINFO under stock System V.)
<LI>In terminfo source files, use capabilities may refer not just to
other entries in the same source file (as in System V) but also to
compiled entries in either the system terminfo directory or the user's
$HOME/.terminfo directory.
<LI>A script (<STRONG>capconvert</STRONG>) is provided to help BSD users
transition from termcap to terminfo. It gathers the information in a
TERMCAP environment variable and/or a ~/.termcap local entries file
and converts it to an equivalent local terminfo tree under $HOME/.terminfo.
<LI>Automatic fallback to the /etc/termcap file can be compiled in
when it is not possible to build a terminfo tree. This feature is neither
fast nor cheap, you don't want to use it unless you have to,
but it's there.
<LI>The table-of-entries utility <STRONG>toe</STRONG> makes it easy for users to
see exactly what terminal types are available on the system.
<LI>The library meets the XSI requirement that every macro entry
point have a corresponding function which may be linked (and will be
prototype-checked) if the macro definition is disabled with
<CODE>#undef</CODE>.
<LI>An HTML "Introduction to Programming with NCURSES" document provides
a narrative introduction to the curses programming interface.
</UL>
<H1>State of the Package</H1>
Numerous bugs present in earlier versions have been fixed; the
library is far more reliable than it used to be. Bounds checking in many
`dangerous' entry points has been improved. The code is now type-safe
according to gcc -Wall. The library has been checked for malloc leaks and
arena corruption by the Purify memory-allocation tester.<P>
The ncurses code has been tested with a wide variety of applications
including (versions starting with those noted):
<DL>
<DT> cdk
<DD> Curses Development Kit
<A HREF="http://www.vexus.ca/CDK.html">Curses Development Kit</a>
<A HREF="ftp://ftp.clark.net/pub/dickey/cdk">ftp://ftp.clark.net/pub/dickey/cdk</A>.
<DT> ded
<DD> directory-editor
<A HREF="ftp://ftp.clark.net/pub/dickey/ded">ftp://ftp.clark.net/pub/dickey/ded</A>.
<DT> dialog
<DD> the underlying application used in Slackware's setup, and the basis
for similar applications on GNU/Linux.
<DT> lynx
<DD> the character-screen WWW browser
<DT> Midnight Commander 4.1
<DD> file manager
<DT> mutt
<DD> mail utility
<DT> ncftp
<DD> file-transfer utility
<DT> nvi
<DD> New vi versions 1.50 are able to use ncurses versions 1.9.7 and later.
<DT> tin
<DD> newsreader, supporting color, MIME
<A HREF="ftp://ftp.akk.uni-karlsruhe.de/pub/news/clients/tin-unoff">ftp://ftp.akk.uni-karlsruhe.de/pub/news/clients/tin-unoff</A>.
<DT> taper
<DD> tape archive utility
<DT> vh-1.6
<DD> Volks-Hypertext browser for the Jargon File
</DL>
as well as some that use ncurses for the terminfo support alone:
<DL>
<DT> minicom
<DD> terminal emulator
<DT> vile
<DD> vi-like-emacs
<A HREF="ftp://ftp.clark.net/pub/dickey/vile">ftp://ftp.clark.net/pub/dickey/vile</A>.
</DL>
<P>
The ncurses distribution includes a selection of test programs (including
a few games).
<H2>Who's Who and What's What</H2>
The original developers of ncurses are <A
HREF="mailto:zmbenhal@netcom.com">Zeyd Ben-Halim</A> and
<A HREF="http://www.ccil.org/~esr/home.html">Eric S. Raymond</A>.
Ongoing work is being done by
<A HREF="mailto:dickey@clark.net">Thomas Dickey</A>
and
<A HREF="mailto:juergen.pfeifer@gmx.net">J&uuml;rgen Pfeifer</A>.
<A HREF="mailto:dickey@clark.net">Thomas Dickey</A>
acts as the maintainer for the Free Software Foundation, which holds the
copyright on ncurses.
Contact the current maintainers at
<A HREF="mailto:bug-ncurses@gnu.org">bug-ncurses@gnu.org</A>.
<P>
To join the ncurses mailing list, please write email to
<CODE>bug-ncurses-request@gnu.org</CODE> containing the line:
<PRE>
subscribe &lt;name&gt;@&lt;host.domain&gt;
</PRE>
This list is open to anyone interested in helping with the development and
testing of this package.<P>
Beta versions of ncurses and patches to the current release are made available at
<A HREF="ftp://ftp.clark.net/pub/dickey/ncurses">ftp://ftp.clark.net/pub/dickey/ncurses</A>.
<H2>Future Plans</H2>
<UL>
<LI>Extended-level XPG4 conformance, with internationalization support.
<LI>Ports to more systems, including DOS and Windows.
</UL>
We need people to help with these projects. If you are interested in working
on them, please join the ncurses list.
<H2>Other Related Resources</H2>
The distribution includes and uses a version of the terminfo-format
terminal description file maintained by Eric Raymond.
<A HREF="http://earthspace.net/~esr/terminfo">http://earthspace.net/~esr/terminfo</A>.<P>
You can find lots of information on terminal-related topics
not covered in the terminfo file at
<A HREF="http://www.cs.utk.edu/~shuford/terminal_index.html">Richard Shuford's
archive</A>.
</BODY>
</HTML>
<!--
# The following sets edit modes for GNU EMACS
# Local Variables:
# mode:html
# case-fold-search:nil
# fill-column:70
# End:
-->

View File

@ -1,110 +0,0 @@
.\"***************************************************************************
.\" Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
.\" "Software"), to deal in the Software without restriction, including *
.\" without limitation the rights to use, copy, modify, merge, publish, *
.\" distribute, distribute with modifications, sublicense, and/or sell *
.\" copies of the Software, and to permit persons to whom the Software is *
.\" furnished to do so, subject to the following conditions: *
.\" *
.\" The above copyright notice and this permission notice shall be included *
.\" in all copies or substantial portions of the Software. *
.\" *
.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
.\" IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
.\" DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
.\" OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
.\" THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
.\" *
.\" Except as contained in this notice, the name(s) of the above copyright *
.\" holders shall not be used in advertising or otherwise to promote the *
.\" sale, use or other dealings in this Software without prior written *
.\" authorization. *
.\"***************************************************************************
.\"
.\" Author: Thomas E. Dickey <dickey@clark.net> 1997,1999
.\"
.\" $Id: dft_fgbg.3x,v 1.10 2000/07/01 16:33:31 tom Exp $
.TH use_default_colors 3X ""
.SH NAME
\fBdft_fgbg\fR:
\fBuse_default_colors\fR,
\fBassume_default_colors\fR \- use terminal's default colors
..
.SH SYNOPSIS
\fB#include <curses.h>\fP
\fBint use_default_colors(void);\fP
.br
\fBint assume_default_colors(int fg, int bg);\fP
..
.SH DESCRIPTION
The
.I use_default_colors()
and
.I assume_default_colors()
functions are extensions to the curses library.
They are used with terminals that support ISO 6429 color, or equivalent.
These terminals allow the application to reset color to an unspecified
default value (e.g., with SGR 39 or SGR 49).
.PP
Applications that paint a colored background over the whole screen
do not take advantage of SGR 39 and SGR 49.
Some applications are designed to work with the default background.
.PP
The first function,
.I use_default_colors()
tells the curses library to assign terminal default
foreground/background colors to color number -1. So init_pair(x,COLOR_RED,-1)
will initialize pair x as red on default background and init_pair(x,-1,COLOR_BLUE) will
initialize pair x as default foreground on blue.
.PP
The other,
.I assume_default_colors()
is a refinement which tells which colors to paint for color pair 0, and -1 means default terminal color.
The following are equivalent:
.RS
.br
.I use_default_colors();
.br
.I assume_default_colors(-1,-1);
.RE
.PP
This is a ncurses extension and for other curses implementations color
number -1 does not mean anything, just as for ncurses before a
successful call of use_default_colors or assume_default_colors.
..
.SH RETURN VALUE
These functions return the integer \fBERR\fP upon failure and \fBOK\fP on success.
They will fail if either the terminal does not support
the \fIorig_pair\fP or \fIorig_colors\fP capability.
If the \fIinitialize_pair\fP capability is found, this causes an
error as well.
..
.SH NOTES
Associated with this extension, the \fBinit_pair\fR(3X) function accepts
negative arguments to specify default foreground or background
colors.
..
.SH PORTABILITY
These routines are specific to ncurses. They were not supported on
Version 7, BSD or System V implementations. It is recommended that
any code depending on them be conditioned using NCURSES_VERSION.
..
.SH SEE ALSO
\fBcurs_color\fR(3X),
\fBded\fP(1).
..
.SH AUTHOR
Thomas Dickey (from an analysis of the requirements for color xterm
for XFree86 3.1.2C, February 1996).
.\"#
.\"# The following sets edit modes for GNU EMACS
.\"# Local Variables:
.\"# mode:nroff
.\"# fill-column:79
.\"# End:

View File

@ -1,100 +0,0 @@
'\" t
.\"***************************************************************************
.\" Copyright (c) 1998 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
.\" "Software"), to deal in the Software without restriction, including *
.\" without limitation the rights to use, copy, modify, merge, publish, *
.\" distribute, distribute with modifications, sublicense, and/or sell *
.\" copies of the Software, and to permit persons to whom the Software is *
.\" furnished to do so, subject to the following conditions: *
.\" *
.\" The above copyright notice and this permission notice shall be included *
.\" in all copies or substantial portions of the Software. *
.\" *
.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
.\" IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
.\" DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
.\" OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
.\" THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
.\" *
.\" Except as contained in this notice, the name(s) of the above copyright *
.\" holders shall not be used in advertising or otherwise to promote the *
.\" sale, use or other dealings in this Software without prior written *
.\" authorization. *
.\"***************************************************************************
.\"
.\" $Id: menu_attribs.3x,v 1.6 1998/11/29 01:09:20 Rick.Ohnemus Exp $
.TH menu_attributes 3X ""
.SH NAME
\fBmenu_attributes\fR - color and attribute control for menus
.SH SYNOPSIS
\fB#include <menu.h>\fR
.br
int set_menu_fore(MENU *menu, chtype attr);
.br
chtype menu_fore(const MENU *menu);
.br
int set_menu_back(MENU *menu, chtype attr);
.br
chtype menu_back(const MENU *menu);
.br
int set_menu_grey(MENU *menu, chtype attr);
.br
chtype menu_grey(const MENU *menu);
.br
int set_menu_pad(MENU *menu, int pad);
.br
int menu_pad(const MENU *menu);
.br
.SH DESCRIPTION
The function \fBset_menu_fore\fR sets the foreground attribute of
\fImenu\fR. This is the highlight used for selected menu items.
\fBmenu_fore\fR returns the foreground attribute. The default
is \fBA_STANDOUT\fR.
The function \fBset_menu_back\fR sets the background attribute of
\fImenu\fR. This is the highlight used for selectable (but not currently
selected) menu items. The function \fBmenu_back\fR returns the background
attribute. The default is \fBA_NORMAL\fR.
The function \fBset_menu_grey\fR sets the grey attribute of \fImenu\fR. This is
the highlight used for un-selectable menu items in menus that permit more than
one selection. The function \fBmenu_grey\fR returns the grey attribute.
The default is \fBA_UNDERLINE\fR.
The function \fBset_menu_pad\fR sets the character used to fill the space
between the name and description parts of a menu item. \fBmenu_pad\fR returns
the given menu's pad character. The default is a blank.
.SH RETURN VALUE
These routines return one of the following:
.TP 5
\fBE_OK\fR
The routine succeeded.
.TP 5
\fBE_SYSTEM_ERROR\fR
System error occurred (see \fBerrno\fR).
.TP 5
\fBE_BAD_ARGUMENT\fR
Routine detected an incorrect or out-of-range argument.
.SH SEE ALSO
\fBcurses\fR(3X) and 3X pages whose names begin "menu_" for detailed
descriptions of the entry points.
.SH NOTES
The header file \fB<menu.h>\fR automatically includes the header file
\fB<curses.h>\fR.
.SH PORTABILITY
These routines emulate the System V menu library. They were not supported on
Version 7 or BSD versions.
.SH AUTHORS
Juergen Pfeifer. Manual pages and adaptation for new curses by Eric
S. Raymond.
.\"#
.\"# The following sets edit modes for GNU EMACS
.\"# Local Variables:
.\"# mode:nroff
.\"# fill-column:79
.\"# End:

View File

@ -1,692 +0,0 @@
A Hacker's Guide to NCURSES
Contents
* Abstract
* Objective of the Package
+ Why System V Curses?
+ How to Design Extensions
* Portability and Configuration
* Documentation Conventions
* How to Report Bugs
* A Tour of the Ncurses Library
+ Library Overview
+ The Engine Room
+ Keyboard Input
+ Mouse Events
+ Output and Screen Updating
* The Forms and Menu Libraries
* A Tour of the Terminfo Compiler
+ Translation of Non-use Capabilities
+ Use Capability Resolution
+ Source-Form Translation
* Other Utilities
* Style Tips for Developers
* Porting Hints
Abstract
This document is a hacker's tour of the ncurses library and utilities.
It discusses design philosophy, implementation methods, and the
conventions used for coding and documentation. It is recommended
reading for anyone who is interested in porting, extending or
improving the package.
Objective of the Package
The objective of the ncurses package is to provide a free software API
for character-cell terminals and terminal emulators with the following
characteristics:
* Source-compatible with historical curses implementations
(including the original BSD curses and System V curses.
* Conformant with the XSI Curses standard issued as part of XPG4 by
X/Open.
* High-quality -- stable and reliable code, wide portability, good
packaging, superior documentation.
* Featureful -- should eliminate as much of the drudgery of C
interface programming as possible, freeing programmers to think at
a higher level of design.
These objectives are in priority order. So, for example, source
compatibility with older version must trump featurefulness -- we
cannot add features if it means breaking the portion of the API
corresponding to historical curses versions.
Why System V Curses?
We used System V curses as a model, reverse-engineering their API, in
order to fulfill the first two objectives.
System V curses implementations can support BSD curses programs with
just a recompilation, so by capturing the System V API we also capture
BSD's.
More importantly for the future, the XSI Curses standard issued by
X/Open is explicitly and closely modeled on System V. So conformance
with System V took us most of the way to base-level XSI conformance.
How to Design Extensions
The third objective (standards conformance) requires that it be easy
to condition source code using ncurses so that the absence of
nonstandard extensions does not break the code.
Accordingly, we have a policy of associating with each nonstandard
extension a feature macro, so that ncurses client code can use this
macro to condition in or out the code that requires the ncurses
extension.
For example, there is a macro NCURSES_MOUSE_VERSION which XSI Curses
does not define, but which is defined in the ncurses library header.
You can use this to condition the calls to the mouse API calls.
Portability and Configuration
Code written for ncurses may assume an ANSI-standard C compiler and
POSIX-compatible OS interface. It may also assume the presence of a
System-V-compatible select(2) call.
We encourage (but do not require) developers to make the code friendly
to less-capable UNIX environments wherever possible.
We encourage developers to support OS-specific optimizations and
methods not available under POSIX/ANSI, provided only that:
* All such code is properly conditioned so the build process does
not attempt to compile it under a plain ANSI/POSIX environment.
* Adding such implementation methods does not introduce
incompatibilities in the ncurses API between platforms.
We use GNU autoconf(1) as a tool to deal with portability issues. The
right way to leverage an OS-specific feature is to modify the autoconf
specification files (configure.in and aclocal.m4) to set up a new
feature macro, which you then use to condition your code.
Documentation Conventions
There are three kinds of documentation associated with this package.
Each has a different preferred format:
* Package-internal files (README, INSTALL, TO-DO etc.)
* Manual pages.
* Everything else (i.e., narrative documentation).
Our conventions are simple:
1. Maintain package-internal files in plain text. The expected viewer
for them more(1) or an editor window; there's no point in
elaborate mark-up.
2. Mark up manual pages in the man macros. These have to be viewable
through traditional man(1) programs.
3. Write everything else in HTML.
When in doubt, HTMLize a master and use lynx(1) to generate plain
ASCII (as we do for the announcement document).
The reason for choosing HTML is that it's (a) well-adapted for on-line
browsing through viewers that are everywhere; (b) more easily readable
as plain text than most other mark-ups, if you don't have a viewer;
and (c) carries enough information that you can generate a
nice-looking printed version from it. Also, of course, it make
exporting things like the announcement document to WWW pretty trivial.
How to Report Bugs
The reporting address for bugs is bug-ncurses@gnu.org. This is a
majordomo list; to join, write to bug-ncurses-request@gnu.org with a
message containing the line:
subscribe <name>@<host.domain>
The ncurses code is maintained by a small group of volunteers. While
we try our best to fix bugs promptly, we simply don't have a lot of
hours to spend on elementary hand-holding. We rely on intelligent
cooperation from our users. If you think you have found a bug in
ncurses, there are some steps you can take before contacting us that
will help get the bug fixed quickly.
In order to use our bug-fixing time efficiently, we put people who
show us they've taken these steps at the head of our queue. This means
that if you don't, you'll probably end up at the tail end and have to
wait a while.
1. Develop a recipe to reproduce the bug.
Bugs we can reproduce are likely to be fixed very quickly, often
within days. The most effective single thing you can do to get a
quick fix is develop a way we can duplicate the bad behavior --
ideally, by giving us source for a small, portable test program
that breaks the library. (Even better is a keystroke recipe using
one of the test programs provided with the distribution.)
2. Try to reproduce the bug on a different terminal type.
In our experience, most of the behaviors people report as library
bugs are actually due to subtle problems in terminal descriptions.
This is especially likely to be true if you're using a traditional
asynchronous terminal or PC-based terminal emulator, rather than
xterm or a UNIX console entry.
It's therefore extremely helpful if you can tell us whether or not
your problem reproduces on other terminal types. Usually you'll
have both a console type and xterm available; please tell us
whether or not your bug reproduces on both.
If you have xterm available, it is also good to collect xterm
reports for different window sizes. This is especially true if you
normally use an unusual xterm window size -- a surprising number
of the bugs we've seen are either triggered or masked by these.
3. Generate and examine a trace file for the broken behavior.
Recompile your program with the debugging versions of the
libraries. Insert a trace() call with the argument set to
TRACE_UPDATE. (See "Writing Programs with NCURSES" for details on
trace levels.) Reproduce your bug, then look at the trace file to
see what the library was actually doing.
Another frequent cause of apparent bugs is application coding
errors that cause the wrong things to be put on the virtual
screen. Looking at the virtual-screen dumps in the trace file will
tell you immediately if this is happening, and save you from the
possible embarrassment of being told that the bug is in your code
and is your problem rather than ours.
If the virtual-screen dumps look correct but the bug persists,
it's possible to crank up the trace level to give more and more
information about the library's update actions and the control
sequences it issues to perform them. The test directory of the
distribution contains a tool for digesting these logs to make them
less tedious to wade through.
Often you'll find terminfo problems at this stage by noticing that
the escape sequences put out for various capabilities are wrong.
If not, you're likely to learn enough to be able to characterize
any bug in the screen-update logic quite exactly.
4. Report details and symptoms, not just interpretations.
If you do the preceding two steps, it is very likely that you'll
discover the nature of the problem yourself and be able to send us
a fix. This will create happy feelings all around and earn you
good karma for the first time you run into a bug you really can't
characterize and fix yourself.
If you're still stuck, at least you'll know what to tell us.
Remember, we need details. If you guess about what is safe to
leave out, you are too likely to be wrong.
If your bug produces a bad update, include a trace file. Try to
make the trace at the least voluminous level that pins down the
bug. Logs that have been through tracemunch are OK, it doesn't
throw away any information (actually they're better than
un-munched ones because they're easier to read).
If your bug produces a core-dump, please include a symbolic stack
trace generated by gdb(1) or your local equivalent.
Tell us about every terminal on which you've reproduced the bug --
and every terminal on which you can't. Ideally, sent us terminfo
sources for all of these (yours might differ from ours).
Include your ncurses version and your OS/machine type, of course!
You can find your ncurses version in the curses.h file.
If your problem smells like a logic error or in cursor movement or
scrolling or a bad capability, there are a couple of tiny test frames
for the library algorithms in the progs directory that may help you
isolate it. These are not part of the normal build, but do have their
own make productions.
The most important of these is mvcur, a test frame for the
cursor-movement optimization code. With this program, you can see
directly what control sequences will be emitted for any given cursor
movement or scroll/insert/delete operations. If you think you've got a
bad capability identified, you can disable it and test again. The
program is command-driven and has on-line help.
If you think the vertical-scroll optimization is broken, or just want
to understand how it works better, build hashmap and read the header
comments of hardscroll.c and hashmap.c; then try it out. You can also
test the hardware-scrolling optimization separately with hardscroll.
There's one other interactive tester, tctest, that exercises
translation between termcap and terminfo formats. If you have a
serious need to run this, you probably belong on our development team!
A Tour of the Ncurses Library
Library Overview
Most of the library is superstructure -- fairly trivial convenience
interfaces to a small set of basic functions and data structures used
to manipulate the virtual screen (in particular, none of this code
does any I/O except through calls to more fundamental modules
described below). The files
lib_addch.c lib_bkgd.c lib_box.c lib_chgat.c lib_clear.c
lib_clearok.c lib_clrbot.c lib_clreol.c lib_colorset.c lib_data.c
lib_delch.c lib_delwin.c lib_echo.c lib_erase.c lib_gen.c
lib_getstr.c lib_hline.c lib_immedok.c lib_inchstr.c lib_insch.c
lib_insdel.c lib_insstr.c lib_instr.c lib_isendwin.c lib_keyname.c
lib_leaveok.c lib_move.c lib_mvwin.c lib_overlay.c lib_pad.c
lib_printw.c lib_redrawln.c lib_scanw.c lib_screen.c lib_scroll.c
lib_scrollok.c lib_scrreg.c lib_set_term.c lib_slk.c
lib_slkatr_set.c lib_slkatrof.c lib_slkatron.c lib_slkatrset.c
lib_slkattr.c lib_slkclear.c lib_slkcolor.c lib_slkinit.c
lib_slklab.c lib_slkrefr.c lib_slkset.c lib_slktouch.c lib_touch.c
lib_unctrl.c lib_vline.c lib_wattroff.c lib_wattron.c lib_window.c
are all in this category. They are very unlikely to need change,
barring bugs or some fundamental reorganization in the underlying data
structures.
These files are used only for debugging support:
lib_trace.c lib_traceatr.c lib_tracebits.c lib_tracechr.c
lib_tracedmp.c lib_tracemse.c trace_buf.c
It is rather unlikely you will ever need to change these, unless you
want to introduce a new debug trace level for some reasoon.
There is another group of files that do direct I/O via tputs(),
computations on the terminal capabilities, or queries to the OS
environment, but nevertheless have only fairly low complexity. These
include:
lib_acs.c lib_beep.c lib_color.c lib_endwin.c lib_initscr.c
lib_longname.c lib_newterm.c lib_options.c lib_termcap.c lib_ti.c
lib_tparm.c lib_tputs.c lib_vidattr.c read_entry.c.
They are likely to need revision only if ncurses is being ported to an
environment without an underlying terminfo capability representation.
These files have serious hooks into the tty driver and signal
facilities:
lib_kernel.c lib_baudrate.c lib_raw.c lib_tstp.c lib_twait.c
If you run into porting snafus moving the package to another UNIX, the
problem is likely to be in one of these files. The file lib_print.c
uses sleep(2) and also falls in this category.
Almost all of the real work is done in the files
hardscroll.c hashmap.c lib_addch.c lib_doupdate.c lib_getch.c
lib_mouse.c lib_mvcur.c lib_refresh.c lib_setup.c lib_vidattr.c
Most of the algorithmic complexity in the library lives in these
files. If there is a real bug in ncurses itself, it's probably here.
We'll tour some of these files in detail below (see The Engine Room).
Finally, there is a group of files that is actually most of the
terminfo compiler. The reason this code lives in the ncurses library
is to support fallback to /etc/termcap. These files include
alloc_entry.c captoinfo.c comp_captab.c comp_error.c comp_hash.c
comp_parse.c comp_scan.c parse_entry.c read_termcap.c write_entry.c
We'll discuss these in the compiler tour.
The Engine Room
Keyboard Input
All ncurses input funnels through the function wgetch(), defined in
lib_getch.c. This function is tricky; it has to poll for keyboard and
mouse events and do a running match of incoming input against the set
of defined special keys.
The central data structure in this module is a FIFO queue, used to
match multiple-character input sequences against special-key
capabilities; also to implement pushback via ungetch().
The wgetch() code distinguishes between function key sequences and the
same sequences typed manually by doing a timed wait after each input
character that could lead a function key sequence. If the entire
sequence takes less than 1 second, it is assumed to have been
generated by a function key press.
Hackers bruised by previous encounters with variant select(2) calls
may find the code in lib_twait.c interesting. It deals with the
problem that some BSD selects don't return a reliable time-left value.
The function timed_wait() effectively simulates a System V select.
Mouse Events
If the mouse interface is active, wgetch() polls for mouse events each
call, before it goes to the keyboard for input. It is up to
lib_mouse.c how the polling is accomplished; it may vary for different
devices.
Under xterm, however, mouse event notifications come in via the
keyboard input stream. They are recognized by having the kmous
capability as a prefix. This is kind of klugey, but trying to wire in
recognition of a mouse key prefix without going through the
function-key machinery would be just too painful, and this turns out
to imply having the prefix somewhere in the function-key capabilities
at terminal-type initialization.
This kluge only works because kmous isn't actually used by any
historic terminal type or curses implementation we know of. Best guess
is it's a relic of some forgotten experiment in-house at Bell Labs
that didn't leave any traces in the publicly-distributed System V
terminfo files. If System V or XPG4 ever gets serious about using it
again, this kluge may have to change.
Here are some more details about mouse event handling:
The lib_mouse()code is logically split into a lower level that accepts
event reports in a device-dependent format and an upper level that
parses mouse gestures and filters events. The mediating data structure
is a circular queue of event structures.
Functionally, the lower level's job is to pick up primitive events and
put them on the circular queue. This can happen in one of two ways:
either (a) _nc_mouse_event() detects a series of incoming mouse
reports and queues them, or (b) code in lib_getch.c detects the kmous
prefix in the keyboard input stream and calls _nc_mouse_inline to
queue up a series of adjacent mouse reports.
In either case, _nc_mouse_parse() should be called after the series is
accepted to parse the digested mouse reports (low-level events) into a
gesture (a high-level or composite event).
Output and Screen Updating
With the single exception of character echoes during a wgetnstr() call
(which simulates cooked-mode line editing in an ncurses window), the
library normally does all its output at refresh time.
The main job is to go from the current state of the screen (as
represented in the curscr window structure) to the desired new state
(as represented in the newscr window structure), while doing as little
I/O as possible.
The brains of this operation are the modules hashmap.c, hardscroll.c
and lib_doupdate.c; the latter two use lib_mvcur.c. Essentially, what
happens looks like this:
The hashmap.c module tries to detect vertical motion changes between
the real and virtual screens. This information is represented by the
oldindex members in the newscr structure. These are modified by
vertical-motion and clear operations, and both are re-initialized
after each update. To this change-journalling information, the hashmap
code adds deductions made using a modified Heckel algorithm on hash
values generated from the line contents.
The hardscroll.c module computes an optimum set of scroll, insertion,
and deletion operations to make the indices match. It calls
_nc_mvcur_scrolln() in lib_mvcur.c to do those motions.
Then lib_doupdate.c goes to work. Its job is to do line-by-line
transformations of curscr lines to newscr lines. Its main tool is the
routine mvcur() in lib_mvcur.c. This routine does cursor-movement
optimization, attempting to get from given screen location A to given
location B in the fewest output characters posible.
If you want to work on screen optimizations, you should use the fact
that (in the trace-enabled version of the library) enabling the
TRACE_TIMES trace level causes a report to be emitted after each
screen update giving the elapsed time and a count of characters
emitted during the update. You can use this to tell when an update
optimization improves efficiency.
In the trace-enabled version of the library, it is also possible to
disable and re-enable various optimizations at runtime by tweaking the
variable _nc_optimize_enable. See the file include/curses.h.in for
mask values, near the end.
The Forms and Menu Libraries
The forms and menu libraries should work reliably in any environment
you can port ncurses to. The only portability issue anywhere in them
is what flavor of regular expressions the built-in form field type
TYPE_REGEXP will recognize.
The configuration code prefers the POSIX regex facility, modeled on
System V's, but will settle for BSD regexps if the former isn't
available.
Historical note: the panels code was written primarily to assist in
porting u386mon 2.0 (comp.sources.misc v14i001-4) to systems lacking
panels support; u386mon 2.10 and beyond use it. This version has been
slightly cleaned up for ncurses.
A Tour of the Terminfo Compiler
The ncurses implementation of tic is rather complex internally; it has
to do a trying combination of missions. This starts with the fact
that, in addition to its normal duty of compiling terminfo sources
into loadable terminfo binaries, it has to be able to handle termcap
syntax and compile that too into terminfo entries.
The implementation therefore starts with a table-driven, dual-mode
lexical analyzer (in comp_scan.c). The lexer chooses its mode (termcap
or terminfo) based on the first `,' or `:' it finds in each entry. The
lexer does all the work of recognizing capability names and values;
the grammar above it is trivial, just "parse entries till you run out
of file".
Translation of Non-use Capabilities
Translation of most things besides use capabilities is pretty
straightforward. The lexical analyzer's tokenizer hands each
capability name to a hash function, which drives a table lookup. The
table entry yields an index which is used to look up the token type in
another table, and controls interpretation of the value.
One possibly interesting aspect of the implementation is the way the
compiler tables are initialized. All the tables are generated by
various awk/sed/sh scripts from a master table include/Caps; these
scripts actually write C initializers which are linked to the
compiler. Furthermore, the hash table is generated in the same way, so
it doesn't have to be generated at compiler startup time (another
benefit of this organization is that the hash table can be in
shareable text space).
Thus, adding a new capability is usually pretty trivial, just a matter
of adding one line to the include/Caps file. We'll have more to say
about this in the section on Source-Form Translation.
Use Capability Resolution
The background problem that makes tic tricky isn't the capability
translation itself, it's the resolution of use capabilities. Older
versions would not handle forward use references for this reason (that
is, a using terminal always had to follow its use target in the source
file). By doing this, they got away with a simple implementation
tactic; compile everything as it blows by, then resolve uses from
compiled entries.
This won't do for ncurses. The problem is that that the whole
compilation process has to be embeddable in the ncurses library so
that it can be called by the startup code to translate termcap entries
on the fly. The embedded version can't go promiscuously writing
everything it translates out to disk -- for one thing, it will
typically be running with non-root permissions.
So our tic is designed to parse an entire terminfo file into a
doubly-linked circular list of entry structures in-core, and then do
use resolution in-memory before writing everything out. This design
has other advantages: it makes forward and back use-references equally
easy (so we get the latter for free), and it makes checking for name
collisions before they're written out easy to do.
And this is exactly how the embedded version works. But the
stand-alone user-accessible version of tic partly reverts to the
historical strategy; it writes to disk (not keeping in core) any entry
with no use references.
This is strictly a core-economy kluge, implemented because the
terminfo master file is large enough that some core-poor systems swap
like crazy when you compile it all in memory...there have been reports
of this process taking three hours, rather than the twenty seconds or
less typical on the author's development box.
So. The executable tic passes the entry-parser a hook that immediately
writes out the referenced entry if it has no use capabilities. The
compiler main loop refrains from adding the entry to the in-core list
when this hook fires. If some other entry later needs to reference an
entry that got written immediately, that's OK; the resolution code
will fetch it off disk when it can't find it in core.
Name collisions will still be detected, just not as cleanly. The
write_entry() code complains before overwriting an entry that
postdates the time of tic's first call to write_entry(), Thus it will
complain about overwriting entries newly made during the tic run, but
not about overwriting ones that predate it.
Source-Form Translation
Another use of tic is to do source translation between various termcap
and terminfo formats. There are more variants out there than you might
think; the ones we know about are described in the captoinfo(1) manual
page.
The translation output code (dump_entry() in ncurses/dump_entry.c) is
shared with the infocmp(1) utility. It takes the same internal
representation used to generate the binary form and dumps it to
standard output in a specified format.
The include/Caps file has a header comment describing ways you can
specify source translations for nonstandard capabilities just by
altering the master table. It's possible to set up capability aliasing
or tell the compiler to plain ignore a given capability without
writing any C code at all.
For circumstances where you need to do algorithmic translation, there
are functions in parse_entry.c called after the parse of each entry
that are specifically intended to encapsulate such translations. This,
for example, is where the AIX box1 capability get translated to an
acsc string.
Other Utilities
The infocmp utility is just a wrapper around the same entry-dumping
code used by tic for source translation. Perhaps the one interesting
aspect of the code is the use of a predicate function passed in to
dump_entry() to control which capabilities are dumped. This is
necessary in order to handle both the ordinary De-compilation case and
entry difference reporting.
The tput and clear utilities just do an entry load followed by a
tputs() of a selected capability.
Style Tips for Developers
See the TO-DO file in the top-level directory of the source
distribution for additions that would be particularly useful.
The prefix _nc_ should be used on library public functions that are
not part of the curses API in order to prevent pollution of the
application namespace. If you have to add to or modify the function
prototypes in curses.h.in, read ncurses/MKlib_gen.sh first so you can
avoid breaking XSI conformance. Please join the ncurses mailing list.
See the INSTALL file in the top level of the distribution for details
on the list.
Look for the string FIXME in source files to tag minor bugs and
potential problems that could use fixing.
Don't try to auto-detect OS features in the main body of the C code.
That's the job of the configuration system.
To hold down complexity, do make your code data-driven. Especially, if
you can drive logic from a table filtered out of include/Caps, do it.
If you find you need to augment the data in that file in order to
generate the proper table, that's still preferable to ad-hoc code --
that's why the fifth field (flags) is there.
Have fun!
Porting Hints
The following notes are intended to be a first step towards DOS and
Macintosh ports of the ncurses libraries.
The following library modules are `pure curses'; they operate only on
the curses internal structures, do all output through other curses
calls (not including tputs() and putp()) and do not call any other
UNIX routines such as signal(2) or the stdio library. Thus, they
should not need to be modified for single-terminal ports.
lib_addch.c lib_addstr.c lib_bkgd.c lib_box.c lib_clear.c
lib_clrbot.c lib_clreol.c lib_delch.c lib_delwin.c lib_erase.c
lib_inchstr.c lib_insch.c lib_insdel.c lib_insstr.c lib_keyname.c
lib_move.c lib_mvwin.c lib_newwin.c lib_overlay.c lib_pad.c
lib_printw.c lib_refresh.c lib_scanw.c lib_scroll.c lib_scrreg.c
lib_set_term.c lib_touch.c lib_tparm.c lib_tputs.c lib_unctrl.c
lib_window.c panel.c
This module is pure curses, but calls outstr():
lib_getstr.c
These modules are pure curses, except that they use tputs() and
putp():
lib_beep.c lib_color.c lib_endwin.c lib_options.c lib_slk.c
lib_vidattr.c
This modules assist in POSIX emulation on non-POSIX systems:
sigaction.c
signal calls
The following source files will not be needed for a
single-terminal-type port.
alloc_entry.c captoinfo.c clear.c comp_captab.c comp_error.c
comp_hash.c comp_main.c comp_parse.c comp_scan.c dump_entry.c
infocmp.c parse_entry.c read_entry.c tput.c write_entry.c
The following modules will use open()/read()/write()/close()/lseek()
on files, but no other OS calls.
lib_screen.c
used to read/write screen dumps
lib_trace.c
used to write trace data to the logfile
Modules that would have to be modified for a port start here:
The following modules are `pure curses' but contain assumptions
inappropriate for a memory-mapped port.
lib_longname.c
assumes there may be multiple terminals
lib_acs.c
assumes acs_map as a double indirection
lib_mvcur.c
assumes cursor moves have variable cost
lib_termcap.c
assumes there may be multiple terminals
lib_ti.c
assumes there may be multiple terminals
The following modules use UNIX-specific calls:
lib_doupdate.c
input checking
lib_getch.c
read()
lib_initscr.c
getenv()
lib_newterm.c
lib_baudrate.c
lib_kernel.c
various tty-manipulation and system calls
lib_raw.c
various tty-manipulation calls
lib_setup.c
various tty-manipulation calls
lib_restart.c
various tty-manipulation calls
lib_tstp.c
signal-manipulation calls
lib_twait.c
gettimeofday(), select().
_________________________________________________________________
Eric S. Raymond <esr@snark.thyrsus.com>
(Note: This is not the bug address!)

View File

@ -1,883 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 3.0//EN">
<!--
$Id: hackguide.html,v 1.23 1999/01/17 00:15:48 tom Exp $
-->
<HTML>
<HEAD>
<TITLE>A Hacker's Guide to Ncurses Internals</TITLE>
<link rev="made" href="mailto:bugs-ncurses@gnu.org">
<!--
This document is self-contained, *except* that there is one relative link to
the ncurses-intro.html document, expected to be in the same directory with
this one.
-->
</HEAD>
<BODY>
<H1>A Hacker's Guide to NCURSES</H1>
<H1>Contents</H1>
<UL>
<LI><A HREF="#abstract">Abstract</A>
<P>
<LI><A HREF="#objective">Objective of the Package</A>
<UL>
<LI><A HREF="#whysvr4">Why System V Curses?</A>
<LI><A HREF="#extensions">How to Design Extensions</A>
</UL>
<LI><A HREF="#portability">Portability and Configuration</A><UL>
</UL>
<LI><A HREF="#documentation">Documentation Conventions</A>
<P>
<LI><A HREF="#bugtrack">How to Report Bugs</A>
<P>
<LI><A HREF="#ncurslib">A Tour of the Ncurses Library</A>
<UL>
<LI><A HREF="#loverview">Library Overview</A>
<LI><A HREF="#engine">The Engine Room</A>
<LI><A HREF="#input">Keyboard Input</A>
<LI><A HREF="#mouse">Mouse Events</A>
<LI><A HREF="#output">Output and Screen Updating</A>
</UL>
<LI><A HREF="#fmnote">The Forms and Menu Libraries</A>
<P>
<LI><A HREF="#tic">A Tour of the Terminfo Compiler</A>
<UL>
<LI><A HREF="#nonuse">Translation of Non-<STRONG>use</STRONG> Capabilities</A>
<LI><A HREF="#uses">Use Capability Resolution</A>
<LI><A HREF="#translation">Source-Form Translation</A>
</UL>
<LI><A HREF="#utils">Other Utilities</A>
<P>
<LI><A HREF="#style">Style Tips for Developers</A>
<P>
<LI><A HREF="#port">Porting Hints</A>
</UL>
<H1><A NAME="abstract">Abstract</A></H1>
This document is a hacker's tour of the <STRONG>ncurses</STRONG> library and utilities.
It discusses design philosophy, implementation methods, and the
conventions used for coding and documentation. It is recommended
reading for anyone who is interested in porting, extending or improving the
package. <P>
<H1><A NAME="objective">Objective of the Package</A></H1>
The objective of the <STRONG>ncurses</STRONG> package is to provide a free software API for
character-cell terminals and terminal emulators with the following
characteristics: <P>
<UL>
<LI>Source-compatible with historical curses implementations (including
the original BSD curses and System V curses.
<P>
<LI>Conformant with the XSI Curses standard issued as part of XPG4 by
X/Open.
<P>
<LI>High-quality -- stable and reliable code, wide portability, good
packaging, superior documentation.
<P>
<LI>Featureful -- should eliminate as much of the drudgery of C interface
programming as possible, freeing programmers to think at a higher
level of design.
</UL>
These objectives are in priority order. So, for example, source
compatibility with older version must trump featurefulness -- we cannot
add features if it means breaking the portion of the API corresponding
to historical curses versions. <P>
<H2><A NAME="whysvr4">Why System V Curses?</A></H2>
We used System V curses as a model, reverse-engineering their API, in
order to fulfill the first two objectives. <P>
System V curses implementations can support BSD curses programs with
just a recompilation, so by capturing the System V API we also
capture BSD's. <P>
More importantly for the future, the XSI Curses standard issued by X/Open
is explicitly and closely modeled on System V. So conformance with
System V took us most of the way to base-level XSI conformance. <P>
<H2><A NAME="extensions">How to Design Extensions</A></H2>
The third objective (standards conformance) requires that it be easy to
condition source code using <STRONG>ncurses</STRONG> so that the absence of nonstandard
extensions does not break the code. <P>
Accordingly, we have a policy of associating with each nonstandard extension
a feature macro, so that ncurses client code can use this macro to condition
in or out the code that requires the <STRONG>ncurses</STRONG> extension. <P>
For example, there is a macro <CODE>NCURSES_MOUSE_VERSION</CODE> which XSI Curses
does not define, but which is defined in the <STRONG>ncurses</STRONG> library header.
You can use this to condition the calls to the mouse API calls. <P>
<H1><A NAME="portability">Portability and Configuration</A></H1>
Code written for <STRONG>ncurses</STRONG> may assume an ANSI-standard C compiler and
POSIX-compatible OS interface. It may also assume the presence of a
System-V-compatible <EM>select(2)</EM> call. <P>
We encourage (but do not require) developers to make the code friendly
to less-capable UNIX environments wherever possible. <P>
We encourage developers to support OS-specific optimizations and methods
not available under POSIX/ANSI, provided only that: <P>
<UL>
<LI>All such code is properly conditioned so the build process does not
attempt to compile it under a plain ANSI/POSIX environment.
<P>
<LI>Adding such implementation methods does not introduce incompatibilities
in the <STRONG>ncurses</STRONG> API between platforms.
</UL>
We use GNU <CODE>autoconf(1)</CODE> as a tool to deal with portability issues.
The right way to leverage an OS-specific feature is to modify the autoconf
specification files (configure.in and aclocal.m4) to set up a new feature
macro, which you then use to condition your code. <P>
<H1><A NAME="documentation">Documentation Conventions</A></H1>
There are three kinds of documentation associated with this package. Each
has a different preferred format: <P>
<UL>
<LI>Package-internal files (README, INSTALL, TO-DO etc.)
<LI>Manual pages.
<LI>Everything else (i.e., narrative documentation).
</UL>
Our conventions are simple: <P>
<OL>
<LI><STRONG>Maintain package-internal files in plain text.</STRONG>
The expected viewer for them <EM>more(1)</EM> or an editor window; there's
no point in elaborate mark-up. <P>
<LI><STRONG>Mark up manual pages in the man macros.</STRONG> These have to be viewable
through traditional <EM>man(1)</EM> programs. <P>
<LI><STRONG>Write everything else in HTML.</STRONG>
</OL>
When in doubt, HTMLize a master and use <EM>lynx(1)</EM> to generate
plain ASCII (as we do for the announcement document). <P>
The reason for choosing HTML is that it's (a) well-adapted for on-line
browsing through viewers that are everywhere; (b) more easily readable
as plain text than most other mark-ups, if you don't have a viewer; and (c)
carries enough information that you can generate a nice-looking printed
version from it. Also, of course, it make exporting things like the
announcement document to WWW pretty trivial.<P>
<H1><A NAME="bugtrack">How to Report Bugs</A></H1>
The <A NAME="bugreport">reporting address for bugs</A> is
<A HREF="mailto:bug-ncurses@gnu.org">bug-ncurses@gnu.org</A>.
This is a majordomo list; to join, write
to <CODE>bug-ncurses-request@gnu.org</CODE> with a message containing the line:
<PRE>
subscribe &lt;name&gt;@&lt;host.domain&gt;
</PRE>
The <CODE>ncurses</CODE> code is maintained by a small group of
volunteers. While we try our best to fix bugs promptly, we simply
don't have a lot of hours to spend on elementary hand-holding. We rely
on intelligent cooperation from our users. If you think you have
found a bug in <CODE>ncurses</CODE>, there are some steps you can take
before contacting us that will help get the bug fixed quickly. <P>
In order to use our bug-fixing time efficiently, we put people who
show us they've taken these steps at the head of our queue. This
means that if you don't, you'll probably end up at the tail end and
have to wait a while. <P>
<OL>
<LI>Develop a recipe to reproduce the bug. <P>
Bugs we can reproduce are likely to be fixed very quickly, often
within days. The most effective single thing you can do to get a
quick fix is develop a way we can duplicate the bad behavior --
ideally, by giving us source for a small, portable test program that
breaks the library. (Even better is a keystroke recipe using one of
the test programs provided with the distribution.) <P>
<LI>Try to reproduce the bug on a different terminal type. <P>
In our experience, most of the behaviors people report as library bugs
are actually due to subtle problems in terminal descriptions. This is
especially likely to be true if you're using a traditional
asynchronous terminal or PC-based terminal emulator, rather than xterm
or a UNIX console entry. <P>
It's therefore extremely helpful if you can tell us whether or not your
problem reproduces on other terminal types. Usually you'll have both
a console type and xterm available; please tell us whether or not your
bug reproduces on both. <P>
If you have xterm available, it is also good to collect xterm reports for
different window sizes. This is especially true if you normally use an
unusual xterm window size -- a surprising number of the bugs we've seen
are either triggered or masked by these. <P>
<LI>Generate and examine a trace file for the broken behavior. <P>
Recompile your program with the debugging versions of the libraries.
Insert a <CODE>trace()</CODE> call with the argument set to <CODE>TRACE_UPDATE</CODE>.
(See <A HREF="ncurses-intro.html#debugging">"Writing Programs with
NCURSES"</A> for details on trace levels.)
Reproduce your bug, then look at the trace file to see what the library
was actually doing. <P>
Another frequent cause of apparent bugs is application coding errors
that cause the wrong things to be put on the virtual screen. Looking
at the virtual-screen dumps in the trace file will tell you immediately if
this is happening, and save you from the possible embarrassment of being
told that the bug is in your code and is your problem rather than ours. <P>
If the virtual-screen dumps look correct but the bug persists, it's
possible to crank up the trace level to give more and more information
about the library's update actions and the control sequences it issues
to perform them. The test directory of the distribution contains a
tool for digesting these logs to make them less tedious to wade
through. <P>
Often you'll find terminfo problems at this stage by noticing that the
escape sequences put out for various capabilities are wrong. If not,
you're likely to learn enough to be able to characterize any bug in
the screen-update logic quite exactly. <P>
<LI>Report details and symptoms, not just interpretations. <P>
If you do the preceding two steps, it is very likely that you'll discover
the nature of the problem yourself and be able to send us a fix. This
will create happy feelings all around and earn you good karma for the first
time you run into a bug you really can't characterize and fix yourself. <P>
If you're still stuck, at least you'll know what to tell us. Remember, we
need details. If you guess about what is safe to leave out, you are too
likely to be wrong. <P>
If your bug produces a bad update, include a trace file. Try to make
the trace at the <EM>least</EM> voluminous level that pins down the
bug. Logs that have been through tracemunch are OK, it doesn't throw
away any information (actually they're better than un-munched ones because
they're easier to read). <P>
If your bug produces a core-dump, please include a symbolic stack trace
generated by gdb(1) or your local equivalent. <P>
Tell us about every terminal on which you've reproduced the bug -- and
every terminal on which you can't. Ideally, sent us terminfo sources
for all of these (yours might differ from ours). <P>
Include your ncurses version and your OS/machine type, of course! You can
find your ncurses version in the <CODE>curses.h</CODE> file.
</OL>
If your problem smells like a logic error or in cursor movement or
scrolling or a bad capability, there are a couple of tiny test frames
for the library algorithms in the progs directory that may help you
isolate it. These are not part of the normal build, but do have their
own make productions. <P>
The most important of these is <CODE>mvcur</CODE>, a test frame for the
cursor-movement optimization code. With this program, you can see
directly what control sequences will be emitted for any given cursor
movement or scroll/insert/delete operations. If you think you've got
a bad capability identified, you can disable it and test again. The
program is command-driven and has on-line help. <P>
If you think the vertical-scroll optimization is broken, or just want to
understand how it works better, build <CODE>hashmap</CODE> and read the
header comments of <CODE>hardscroll.c</CODE> and <CODE>hashmap.c</CODE>; then try
it out. You can also test the hardware-scrolling optimization separately
with <CODE>hardscroll</CODE>. <P>
There's one other interactive tester, <CODE>tctest</CODE>, that exercises
translation between termcap and terminfo formats. If you have a serious
need to run this, you probably belong on our development team! <P>
<H1><A NAME="ncurslib">A Tour of the Ncurses Library</A></H1>
<H2><A NAME="loverview">Library Overview</A></H2>
Most of the library is superstructure -- fairly trivial convenience
interfaces to a small set of basic functions and data structures used
to manipulate the virtual screen (in particular, none of this code
does any I/O except through calls to more fundamental modules
described below). The files
<blockquote>
<CODE>
lib_addch.c
lib_bkgd.c
lib_box.c
lib_chgat.c
lib_clear.c
lib_clearok.c
lib_clrbot.c
lib_clreol.c
lib_colorset.c
lib_data.c
lib_delch.c
lib_delwin.c
lib_echo.c
lib_erase.c
lib_gen.c
lib_getstr.c
lib_hline.c
lib_immedok.c
lib_inchstr.c
lib_insch.c
lib_insdel.c
lib_insstr.c
lib_instr.c
lib_isendwin.c
lib_keyname.c
lib_leaveok.c
lib_move.c
lib_mvwin.c
lib_overlay.c
lib_pad.c
lib_printw.c
lib_redrawln.c
lib_scanw.c
lib_screen.c
lib_scroll.c
lib_scrollok.c
lib_scrreg.c
lib_set_term.c
lib_slk.c
lib_slkatr_set.c
lib_slkatrof.c
lib_slkatron.c
lib_slkatrset.c
lib_slkattr.c
lib_slkclear.c
lib_slkcolor.c
lib_slkinit.c
lib_slklab.c
lib_slkrefr.c
lib_slkset.c
lib_slktouch.c
lib_touch.c
lib_unctrl.c
lib_vline.c
lib_wattroff.c
lib_wattron.c
lib_window.c
</CODE>
</blockquote>
are all in this category. They are very
unlikely to need change, barring bugs or some fundamental
reorganization in the underlying data structures. <P>
These files are used only for debugging support:
<blockquote><code>
lib_trace.c
lib_traceatr.c
lib_tracebits.c
lib_tracechr.c
lib_tracedmp.c
lib_tracemse.c
trace_buf.c
</blockquote></code>
It is rather unlikely you will ever need to change these, unless
you want to introduce a new debug trace level for some reasoon.<P>
There is another group of files that do direct I/O via <EM>tputs()</EM>,
computations on the terminal capabilities, or queries to the OS
environment, but nevertheless have only fairly low complexity. These
include:
<blockquote><code>
lib_acs.c
lib_beep.c
lib_color.c
lib_endwin.c
lib_initscr.c
lib_longname.c
lib_newterm.c
lib_options.c
lib_termcap.c
lib_ti.c
lib_tparm.c
lib_tputs.c
lib_vidattr.c
read_entry.c.
</blockquote></code>
They are likely to need revision only if
ncurses is being ported to an environment without an underlying
terminfo capability representation. <P>
These files
have serious hooks into
the tty driver and signal facilities:
<blockquote><code>
lib_kernel.c
lib_baudrate.c
lib_raw.c
lib_tstp.c
lib_twait.c
</blockquote></code>
If you run into porting snafus
moving the package to another UNIX, the problem is likely to be in one
of these files.
The file <CODE>lib_print.c</CODE> uses sleep(2) and also
falls in this category.<P>
Almost all of the real work is done in the files
<blockquote><code>
hardscroll.c
hashmap.c
lib_addch.c
lib_doupdate.c
lib_getch.c
lib_mouse.c
lib_mvcur.c
lib_refresh.c
lib_setup.c
lib_vidattr.c
</blockquote></code>
Most of the algorithmic complexity in the
library lives in these files.
If there is a real bug in <STRONG>ncurses</STRONG> itself, it's probably here.
We'll tour some of these files in detail
below (see <A HREF="#engine">The Engine Room</A>). <P>
Finally, there is a group of files that is actually most of the
terminfo compiler. The reason this code lives in the <STRONG>ncurses</STRONG>
library is to support fallback to /etc/termcap. These files include
<blockquote><code>
alloc_entry.c
captoinfo.c
comp_captab.c
comp_error.c
comp_hash.c
comp_parse.c
comp_scan.c
parse_entry.c
read_termcap.c
write_entry.c
</blockquote></code>
We'll discuss these in the compiler tour. <P>
<H2><A NAME="engine">The Engine Room</A></H2>
<H3><A NAME="input">Keyboard Input</A></H3>
All <CODE>ncurses</CODE> input funnels through the function
<CODE>wgetch()</CODE>, defined in <CODE>lib_getch.c</CODE>. This function is
tricky; it has to poll for keyboard and mouse events and do a running
match of incoming input against the set of defined special keys. <P>
The central data structure in this module is a FIFO queue, used to
match multiple-character input sequences against special-key
capabilities; also to implement pushback via <CODE>ungetch()</CODE>. <P>
The <CODE>wgetch()</CODE> code distinguishes between function key
sequences and the same sequences typed manually by doing a timed wait
after each input character that could lead a function key sequence.
If the entire sequence takes less than 1 second, it is assumed to have
been generated by a function key press. <P>
Hackers bruised by previous encounters with variant <CODE>select(2)</CODE>
calls may find the code in <CODE>lib_twait.c</CODE> interesting. It deals
with the problem that some BSD selects don't return a reliable
time-left value. The function <CODE>timed_wait()</CODE> effectively
simulates a System V select. <P>
<H3><A NAME="mouse">Mouse Events</A></H3>
If the mouse interface is active, <CODE>wgetch()</CODE> polls for mouse
events each call, before it goes to the keyboard for input. It is
up to <CODE>lib_mouse.c</CODE> how the polling is accomplished; it may vary
for different devices. <P>
Under xterm, however, mouse event notifications come in via the keyboard
input stream. They are recognized by having the <STRONG>kmous</STRONG> capability
as a prefix. This is kind of klugey, but trying to wire in recognition of
a mouse key prefix without going through the function-key machinery would
be just too painful, and this turns out to imply having the prefix somewhere
in the function-key capabilities at terminal-type initialization. <P>
This kluge only works because <STRONG>kmous</STRONG> isn't actually used by any
historic terminal type or curses implementation we know of. Best
guess is it's a relic of some forgotten experiment in-house at Bell
Labs that didn't leave any traces in the publicly-distributed System V
terminfo files. If System V or XPG4 ever gets serious about using it
again, this kluge may have to change. <P>
Here are some more details about mouse event handling: <P>
The <CODE>lib_mouse()</CODE>code is logically split into a lower level that
accepts event reports in a device-dependent format and an upper level that
parses mouse gestures and filters events. The mediating data structure is a
circular queue of event structures. <P>
Functionally, the lower level's job is to pick up primitive events and
put them on the circular queue. This can happen in one of two ways:
either (a) <CODE>_nc_mouse_event()</CODE> detects a series of incoming
mouse reports and queues them, or (b) code in <CODE>lib_getch.c</CODE> detects the
<STRONG>kmous</STRONG> prefix in the keyboard input stream and calls _nc_mouse_inline
to queue up a series of adjacent mouse reports. <P>
In either case, <CODE>_nc_mouse_parse()</CODE> should be called after the
series is accepted to parse the digested mouse reports (low-level
events) into a gesture (a high-level or composite event). <P>
<H3><A NAME="output">Output and Screen Updating</A></H3>
With the single exception of character echoes during a <CODE>wgetnstr()</CODE>
call (which simulates cooked-mode line editing in an ncurses window),
the library normally does all its output at refresh time. <P>
The main job is to go from the current state of the screen (as represented
in the <CODE>curscr</CODE> window structure) to the desired new state (as
represented in the <CODE>newscr</CODE> window structure), while doing as
little I/O as possible. <P>
The brains of this operation are the modules <CODE>hashmap.c</CODE>,
<CODE>hardscroll.c</CODE> and <CODE>lib_doupdate.c</CODE>; the latter two use
<CODE>lib_mvcur.c</CODE>. Essentially, what happens looks like this: <P>
The <CODE>hashmap.c</CODE> module tries to detect vertical motion
changes between the real and virtual screens. This information
is represented by the oldindex members in the newscr structure.
These are modified by vertical-motion and clear operations, and both are
re-initialized after each update. To this change-journalling
information, the hashmap code adds deductions made using a modified Heckel
algorithm on hash values generated from the line contents. <P>
The <CODE>hardscroll.c</CODE> module computes an optimum set of scroll,
insertion, and deletion operations to make the indices match. It calls
<CODE>_nc_mvcur_scrolln()</CODE> in <CODE>lib_mvcur.c</CODE> to do those motions. <P>
Then <CODE>lib_doupdate.c</CODE> goes to work. Its job is to do line-by-line
transformations of <CODE>curscr</CODE> lines to <CODE>newscr</CODE> lines. Its main
tool is the routine <CODE>mvcur()</CODE> in <CODE>lib_mvcur.c</CODE>. This routine
does cursor-movement optimization, attempting to get from given screen
location A to given location B in the fewest output characters posible. <P>
If you want to work on screen optimizations, you should use the fact
that (in the trace-enabled version of the library) enabling the
<CODE>TRACE_TIMES</CODE> trace level causes a report to be emitted after
each screen update giving the elapsed time and a count of characters
emitted during the update. You can use this to tell when an update
optimization improves efficiency. <P>
In the trace-enabled version of the library, it is also possible to disable
and re-enable various optimizations at runtime by tweaking the variable
<CODE>_nc_optimize_enable</CODE>. See the file <CODE>include/curses.h.in</CODE>
for mask values, near the end. <P>
<H1><A NAME="fmnote">The Forms and Menu Libraries</A></H1>
The forms and menu libraries should work reliably in any environment you
can port ncurses to. The only portability issue anywhere in them is what
flavor of regular expressions the built-in form field type TYPE_REGEXP
will recognize. <P>
The configuration code prefers the POSIX regex facility, modeled on
System V's, but will settle for BSD regexps if the former isn't available. <P>
Historical note: the panels code was written primarily to assist in
porting u386mon 2.0 (comp.sources.misc v14i001-4) to systems lacking
panels support; u386mon 2.10 and beyond use it. This version has been
slightly cleaned up for <CODE>ncurses</CODE>. <P>
<H1><A NAME="tic">A Tour of the Terminfo Compiler</A></H1>
The <STRONG>ncurses</STRONG> implementation of <STRONG>tic</STRONG> is rather complex
internally; it has to do a trying combination of missions. This starts
with the fact that, in addition to its normal duty of compiling
terminfo sources into loadable terminfo binaries, it has to be able to
handle termcap syntax and compile that too into terminfo entries. <P>
The implementation therefore starts with a table-driven, dual-mode
lexical analyzer (in <CODE>comp_scan.c</CODE>). The lexer chooses its
mode (termcap or terminfo) based on the first `,' or `:' it finds in
each entry. The lexer does all the work of recognizing capability
names and values; the grammar above it is trivial, just "parse entries
till you run out of file". <P>
<H2><A NAME="nonuse">Translation of Non-<STRONG>use</STRONG> Capabilities</A></H2>
Translation of most things besides <STRONG>use</STRONG> capabilities is pretty
straightforward. The lexical analyzer's tokenizer hands each capability
name to a hash function, which drives a table lookup. The table entry
yields an index which is used to look up the token type in another table,
and controls interpretation of the value. <P>
One possibly interesting aspect of the implementation is the way the
compiler tables are initialized. All the tables are generated by various
awk/sed/sh scripts from a master table <CODE>include/Caps</CODE>; these
scripts actually write C initializers which are linked to the compiler.
Furthermore, the hash table is generated in the same way, so it doesn't
have to be generated at compiler startup time (another benefit of this
organization is that the hash table can be in shareable text space). <P>
Thus, adding a new capability is usually pretty trivial, just a matter
of adding one line to the <CODE>include/Caps</CODE> file. We'll have more
to say about this in the section on <A HREF="#translation">Source-Form
Translation</A>. <P>
<H2><A NAME="uses">Use Capability Resolution</A></H2>
The background problem that makes <STRONG>tic</STRONG> tricky isn't the capability
translation itself, it's the resolution of <STRONG>use</STRONG> capabilities. Older
versions would not handle forward <STRONG>use</STRONG> references for this reason
(that is, a using terminal always had to follow its use target in the
source file). By doing this, they got away with a simple implementation
tactic; compile everything as it blows by, then resolve uses from compiled
entries. <P>
This won't do for <STRONG>ncurses</STRONG>. The problem is that that the whole
compilation process has to be embeddable in the <STRONG>ncurses</STRONG> library
so that it can be called by the startup code to translate termcap
entries on the fly. The embedded version can't go promiscuously writing
everything it translates out to disk -- for one thing, it will typically
be running with non-root permissions. <P>
So our <STRONG>tic</STRONG> is designed to parse an entire terminfo file into a
doubly-linked circular list of entry structures in-core, and then do
<STRONG>use</STRONG> resolution in-memory before writing everything out. This
design has other advantages: it makes forward and back use-references
equally easy (so we get the latter for free), and it makes checking for
name collisions before they're written out easy to do. <P>
And this is exactly how the embedded version works. But the stand-alone
user-accessible version of <STRONG>tic</STRONG> partly reverts to the historical
strategy; it writes to disk (not keeping in core) any entry with no
<STRONG>use</STRONG> references. <P>
This is strictly a core-economy kluge, implemented because the
terminfo master file is large enough that some core-poor systems swap
like crazy when you compile it all in memory...there have been reports of
this process taking <STRONG>three hours</STRONG>, rather than the twenty seconds
or less typical on the author's development box. <P>
So. The executable <STRONG>tic</STRONG> passes the entry-parser a hook that
<EM>immediately</EM> writes out the referenced entry if it has no use
capabilities. The compiler main loop refrains from adding the entry
to the in-core list when this hook fires. If some other entry later
needs to reference an entry that got written immediately, that's OK;
the resolution code will fetch it off disk when it can't find it in
core. <P>
Name collisions will still be detected, just not as cleanly. The
<CODE>write_entry()</CODE> code complains before overwriting an entry that
postdates the time of <STRONG>tic</STRONG>'s first call to
<CODE>write_entry()</CODE>, Thus it will complain about overwriting
entries newly made during the <STRONG>tic</STRONG> run, but not about
overwriting ones that predate it. <P>
<H2><A NAME="translation">Source-Form Translation</A></H2>
Another use of <STRONG>tic</STRONG> is to do source translation between various termcap
and terminfo formats. There are more variants out there than you might
think; the ones we know about are described in the <STRONG>captoinfo(1)</STRONG>
manual page. <P>
The translation output code (<CODE>dump_entry()</CODE> in
<CODE>ncurses/dump_entry.c</CODE>) is shared with the <STRONG>infocmp(1)</STRONG>
utility. It takes the same internal representation used to generate
the binary form and dumps it to standard output in a specified
format. <P>
The <CODE>include/Caps</CODE> file has a header comment describing ways you
can specify source translations for nonstandard capabilities just by
altering the master table. It's possible to set up capability aliasing
or tell the compiler to plain ignore a given capability without writing
any C code at all. <P>
For circumstances where you need to do algorithmic translation, there
are functions in <CODE>parse_entry.c</CODE> called after the parse of each
entry that are specifically intended to encapsulate such
translations. This, for example, is where the AIX <STRONG>box1</STRONG> capability
get translated to an <STRONG>acsc</STRONG> string.<P>
<H1><A NAME="utils">Other Utilities</A></H1>
The <STRONG>infocmp</STRONG> utility is just a wrapper around the same
entry-dumping code used by <STRONG>tic</STRONG> for source translation. Perhaps
the one interesting aspect of the code is the use of a predicate
function passed in to <CODE>dump_entry()</CODE> to control which
capabilities are dumped. This is necessary in order to handle both
the ordinary De-compilation case and entry difference reporting. <P>
The <STRONG>tput</STRONG> and <STRONG>clear</STRONG> utilities just do an entry load
followed by a <CODE>tputs()</CODE> of a selected capability. <P>
<H1><A NAME="style">Style Tips for Developers</A></H1>
See the TO-DO file in the top-level directory of the source distribution
for additions that would be particularly useful. <P>
The prefix <CODE>_nc_</CODE> should be used on library public functions that are
not part of the curses API in order to prevent pollution of the
application namespace.
If you have to add to or modify the function prototypes in curses.h.in,
read ncurses/MKlib_gen.sh first so you can avoid breaking XSI conformance.
Please join the ncurses mailing list. See the INSTALL file in the
top level of the distribution for details on the list. <P>
Look for the string <CODE>FIXME</CODE> in source files to tag minor bugs
and potential problems that could use fixing. <P>
Don't try to auto-detect OS features in the main body of the C code.
That's the job of the configuration system. <P>
To hold down complexity, do make your code data-driven. Especially,
if you can drive logic from a table filtered out of
<CODE>include/Caps</CODE>, do it. If you find you need to augment the
data in that file in order to generate the proper table, that's still
preferable to ad-hoc code -- that's why the fifth field (flags) is
there. <P>
Have fun! <P>
<H1><A NAME="port">Porting Hints</A></H1>
The following notes are intended to be a first step towards DOS and Macintosh
ports of the ncurses libraries. <P>
The following library modules are `pure curses'; they operate only on
the curses internal structures, do all output through other curses
calls (not including <CODE>tputs()</CODE> and <CODE>putp()</CODE>) and do not
call any other UNIX routines such as signal(2) or the stdio library.
Thus, they should not need to be modified for single-terminal
ports. <P>
<blockquote><code>
lib_addch.c
lib_addstr.c
lib_bkgd.c
lib_box.c
lib_clear.c
lib_clrbot.c
lib_clreol.c
lib_delch.c
lib_delwin.c
lib_erase.c
lib_inchstr.c
lib_insch.c
lib_insdel.c
lib_insstr.c
lib_keyname.c
lib_move.c
lib_mvwin.c
lib_newwin.c
lib_overlay.c
lib_pad.c
lib_printw.c
lib_refresh.c
lib_scanw.c
lib_scroll.c
lib_scrreg.c
lib_set_term.c
lib_touch.c
lib_tparm.c
lib_tputs.c
lib_unctrl.c
lib_window.c
panel.c
</blockquote></code>
<P>
This module is pure curses, but calls outstr(): <P>
<blockquote><code>
lib_getstr.c
</blockquote></code>
<P>
These modules are pure curses, except that they use <CODE>tputs()</CODE>
and <CODE>putp()</CODE>: <P>
<blockquote><code>
lib_beep.c
lib_color.c
lib_endwin.c
lib_options.c
lib_slk.c
lib_vidattr.c
</blockquote></code>
<P>
This modules assist in POSIX emulation on non-POSIX systems: <P>
<DL>
<DT> sigaction.c
<DD> signal calls
</DL>
The following source files will not be needed for a
single-terminal-type port. <P>
<blockquote><code>
alloc_entry.c
captoinfo.c
clear.c
comp_captab.c
comp_error.c
comp_hash.c
comp_main.c
comp_parse.c
comp_scan.c
dump_entry.c
infocmp.c
parse_entry.c
read_entry.c
tput.c
write_entry.c
</blockquote></code>
<P>
The following modules will use open()/read()/write()/close()/lseek() on files,
but no other OS calls. <P>
<DL>
<DT>lib_screen.c
<DD>used to read/write screen dumps
<DT>lib_trace.c
<DD>used to write trace data to the logfile
</DL>
Modules that would have to be modified for a port start here: <P>
The following modules are `pure curses' but contain assumptions inappropriate
for a memory-mapped port. <P>
<dl>
<dt>lib_longname.c<dd>assumes there may be multiple terminals
<dt>lib_acs.c<dd>assumes acs_map as a double indirection
<dt>lib_mvcur.c<dd>assumes cursor moves have variable cost
<dt>lib_termcap.c<dd>assumes there may be multiple terminals
<dt>lib_ti.c<dd>assumes there may be multiple terminals
</dl>
The following modules use UNIX-specific calls:
<dl>
<dt>lib_doupdate.c<dd>input checking
<dt>lib_getch.c<dd>read()
<dt>lib_initscr.c<dd>getenv()
<dt>lib_newterm.c
<dt>lib_baudrate.c
<dt>lib_kernel.c<dd>various tty-manipulation and system calls
<dt>lib_raw.c<dd>various tty-manipulation calls
<dt>lib_setup.c<dd>various tty-manipulation calls
<dt>lib_restart.c<dd>various tty-manipulation calls
<dt>lib_tstp.c<dd>signal-manipulation calls
<dt>lib_twait.c<dd>gettimeofday(), select().
</dl>
<HR>
<ADDRESS>Eric S. Raymond &lt;esr@snark.thyrsus.com&gt;</ADDRESS>
(Note: This is <EM>not</EM> the <A HREF="#bugtrack">bug address</A>!)
</BODY>
</HTML>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,170 +0,0 @@
#!/bin/sh
##############################################################################
# Copyright (c) 1998,2000 Free Software Foundation, Inc. #
# #
# Permission is hereby granted, free of charge, to any person obtaining a #
# copy of this software and associated documentation files (the "Software"), #
# to deal in the Software without restriction, including without limitation #
# the rights to use, copy, modify, merge, publish, distribute, distribute #
# with modifications, sublicense, and/or sell copies of the Software, and to #
# permit persons to whom the Software is furnished to do so, subject to the #
# following conditions: #
# #
# The above copyright notice and this permission notice shall be included in #
# all copies or substantial portions of the Software. #
# #
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR #
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, #
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL #
# THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER #
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING #
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER #
# DEALINGS IN THE SOFTWARE. #
# #
# Except as contained in this notice, the name(s) of the above copyright #
# holders shall not be used in advertising or otherwise to promote the sale, #
# use or other dealings in this Software without prior written #
# authorization. #
##############################################################################
#
# Author: Thomas E. Dickey <dickey@clark.net> 1996
#
# $Id: run_tic.sh,v 1.12 2000/07/01 19:25:13 tom Exp $
# This script is used to install terminfo.src using tic. We use a script
# because the path checking is too awkward to do in a makefile.
#
# Parameters:
# $1 = nominal directory in which to find 'tic', i.e., $(bindir).
# $2 = source-directory, i.e., $(srcdir)
# $3 = destination-directory path, i.e., $(ticdir)
# $4 = install-prefix, if any
#
# Assumes:
# The leaf directory names (bin, lib, shared, tabset, terminfo)
#
echo '** Building terminfo database, please wait...'
#
# Parameter parsing is primarily for debugging. The script is designed to
# be run from the misc/Makefile as
# make install.data
prefix=/usr/local
if test $# != 0 ; then
bindir=$1
shift
PREFIX=`echo $bindir | sed -e 's/\/bin$//'`
test -n "$PREFIX" && test "x$PREFIX" != "x$bindir" && prefix=$PREFIX
else
bindir=$prefix/bin
fi
if test $# != 0 ; then
srcdir=$1
shift
else
srcdir=.
fi
if test $# != 0 ; then
ticdir=$1
shift
else
ticdir=$prefix/share/terminfo
fi
if test $# != 0 ; then
IP=$1
shift
else
IP=""
fi
# Allow tic to run either from the install-path, or from the build-directory
case "$PATH" in
:*) PATH=../progs:$IP$bindir$PATH ;;
*) PATH=../progs:$IP$bindir:$PATH ;;
esac
export PATH
#
# set another env var that doesn't get reset when `shlib' runs, so `shlib' uses
# the PATH we just set.
#
NEWPATH=$PATH
export NEWPATH
PROG_BIN_DIR=$IP$bindir
export PROG_BIN_DIR
TERMINFO=$IP$ticdir ; export TERMINFO
umask 022
# Construct the name of the old (obsolete) pathname, e.g., /usr/lib/terminfo.
TICDIR=`echo $TERMINFO | sed -e 's/\/share\//\/lib\//'`
# Remove the old terminfo stuff; we don't care if it existed before, and it
# would generate a lot of confusing error messages if we tried to overwrite it.
# We explicitly remove its contents rather than the directory itself, in case
# the directory is actually a symbolic link.
( rm -fr $TERMINFO/[0-9A-Za-z] 2>/dev/null )
# If we're not installing into /usr/share/, we'll have to adjust the location
# of the tabset files in terminfo.src (which are in a parallel directory).
TABSET=`echo $ticdir | sed -e 's/\/terminfo$/\/tabset/'`
SRC=$srcdir/terminfo.src
if test "x$TABSET" != "x/usr/share/tabset" ; then
echo '** adjusting tabset paths'
TMP=${TMPDIR-/tmp}/$$
sed -e s:/usr/share/tabset:$TABSET:g $SRC >$TMP
trap "rm -f $TMP" 0 1 2 5 15
SRC=$TMP
fi
cat <<EOF
Running tic to install $TERMINFO ...
You may see messages regarding unknown capabilities, e.g., AX.
These are extended terminal capabilities which can be compiled
using
tic -x
Read the INSTALL document before doing this - it can cause
problems for older ncurses applications.
EOF
if ( $srcdir/shlib tic -s $SRC )
then
echo '** built new '$TERMINFO
else
echo '? tic could not build '$TERMINFO
exit 1
fi
# Make a symbolic link to provide compatibility with applications that expect
# to find terminfo under /usr/lib. That is, we'll _try_ to do that. Not
# all systems support symbolic links, and those that do provide a variety
# of options for 'test'.
if test "$TICDIR" != "$TERMINFO" ; then
( rm -f $TICDIR 2>/dev/null )
if ( cd $TICDIR 2>/dev/null )
then
cd $TICDIR
TICDIR=`pwd`
if test $TICDIR != $TERMINFO ; then
# Well, we tried. Some systems lie to us, so the
# installer will have to double-check.
echo "Verify if $TICDIR and $TERMINFO are the same."
echo "The new terminfo is in $TERMINFO; the other should be a link to it."
echo "Otherwise, remove $TICDIR and link it to $TERMINFO."
fi
else
cd $IP$prefix
# Construct a symbolic link that only assumes $ticdir has the
# same $prefix as the other installed directories.
RELATIVE=`echo $ticdir|sed -e 's:^'$prefix'/::'`
if test "$RELATIVE" != "$ticdir" ; then
RELATIVE=../`echo $ticdir|sed -e 's:^'$prefix'/::' -e 's:^/::'`
fi
if ( ln -s $RELATIVE $TICDIR )
then
echo '** linked '$TICDIR' for compatibility'
fi
fi
fi

View File

@ -1,4 +0,0 @@
.*-.*-linux.* libform=4
.*-.*-linux.* libmenu=4
.*-.*-linux.* libncurses=4
.*-.*-linux.* libpanel=4