# Announcing ncurses 5.2

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.

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.

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!

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.

The ncurses distribution is available via anonymous FTP at the GNU distribution site ftp://ftp.gnu.org/pub/gnu/ncurses.
It is also available at ftp://dickey.his.com/ncurses.

# Release Notes

This release is designed to be upward compatible from ncurses 5.0 and 5.1; very few applications will require recompilation, depending on the platform. These are the highlights from the change-log since ncurses 5.1 release.

Interface changes:

- change type of `ospeed` variable back to `short` to match its use in legacy applications. It was altered after ncurses 4.2 to `speed_t` to repair a type mismatch which was introduced after 1.9.4 in 1995. The principal users of termcap continued to use `short`, which is not the same size.

  NOTE: A few applications will have to be recompiled (about 1% of the programs in a typical Linux distribution, 10% of the programs that use ncurses). These are easy to identify with `nm` or `strings`.

- remove a private function `_nc_can_clear_with()`, which was built with the configure --enable-expanded option but not used.
- add several private functions (prefixed with "_nc_") for tracing `chtype` values in the debug library, and for better access and buffer limit checking.

New features and improvements:

- rewrote `tgoto()` to make it better support existing termcap applications which use hardcoded strings rather than obtain all of their information from the termcap file. If the string does not appear to be a terminfo string (i.e., does not refer to a "%p" parameter, or terminfo-style padding), and termcap support is configured, `tgoto()` will interpret it as termcap. Otherwise, as before, it will use `tparm()`.
- to ensure that the `tgoto()` changes work properly, added checks to `tic` which report capabilities that do not reference the expected number of parameters.
- new configure script options:
  - option `--disable-root-environ` adds runtime checks which tell ncurses to disregard $TERMINFO and similar environment variables if the current user is root, or running setuid/setgid.
  - option `--disable-assumed-color` allows you to use the pre-5.1 convention of default colors used for color-pair 0 to be configured (see assume_default_colors()).
  - implement configure script options that transform installed program names, e.g., `--program-prefix`, including the manpage names and cross references.
  - option `--with-database` allows you to specify a different terminfo source-file to install. On OS/2 EMX, the default is misc/emx.src, otherwise misc/terminfo.src
  - option `--with-default-terminfo-dir` allows you to specify the default terminfo database directory.
  - option `--with-libtool` allows you to build with `libtool`.

    NOTE: `libtool` uses a different notation for numbering shared library versions from the existing ncurses configuration.

  - option `--with-manpage-tbl` causes the manpages to be preprocessed by tbl(1) prior to installation,
  - option `--without-curses-h` causes the installation process to install curses.h as ncurses.h and make appropriate changes to headers and manpages.
- modified configure script options:
  - change symbol used by the `--install-prefix` configure option from `INSTALL_PREFIX` to `DESTDIR` (the latter has become common usage although the name is misleading).
  - modify `ld -rpath` options (e.g., Linux, and Solaris) to use an absolute pathname for the build tree's lib directory, avoiding confusion with directories relative to the current one with the installed programs.
  - modified `misc/run_tic.in` to use `tic -o`, to eliminate dependency on `$TERMINFO` variable for installs.
- terminfo database:
  - updated xterm terminfo entries to match XFree86 xterm patch #146.
  - added amiga-vnc, Matrix Orbital, and QNX qansi to misc/terminfo.src.
  - added os2 entry to misc/emx.src.
  - add S0 and E0 extensions to `screen`'s terminfo entry since otherwise the FreeBSD port makes it pass termcap equivalents to `tgoto`, which would be misinterpreted by older versions of ncurses.
- improvements to program usability:
  - modify programs to use `curses_version()` string to report the version of ncurses with which they are compiled rather than the NCURSES_VERSION string. The function returns the patch level in addition to the major and minor version numbers.
  - modify `tput` program so it can be renamed or invoked via a link as 'reset' or 'init', producing the same effect as `tput reset` or `tput init`.
  - add error checking to infocmp's -v and -m options to ensure that the option value is indeed a number.
- improved performance:
  - replace a lookup table in lib_vidattr.c used to decode `no_color_video` with a logic expression which is faster.

Major bug fixes:

- correct `manlinks.sed` script introduced in ncurses 5.1 to avoid using ERE "\+", which is not understood by standard versions of `sed`. This happens to work with GNU `sed`, but is not portable, and was the initial motivation for this release.
- remove "hpux10.*" case from CF_SHARED_OPTS configure script macro. This differed from the "hpux*" case by using reversed symbolic links, which made the 5.1 version not match the configuration of 5.0 shared libraries.
- guard against corrupt terminfo data:
  - modify `tparm()` to disallow arithmetic on strings, analyze the varargs list to read strings as strings and numbers as numbers.
  - modify `tparm()`'s internal function `spop()` to treat a null pointer as an empty string.
  - modify `parse_format()` in lib_tparm.c to ignore precision if it is longer than 10000.
  - rewrote limit checks in lib_mvcur.c using new functions `_nc_safe_strcat()`, etc. Made other related changes to check lengths used for `strcat()` and `strcpy()`.
- corrections to screen optimization:
  - added special case in lib_vidattr.c to reset underline and standout for devices that have no sgr0 defined.
  - change handling of `non_dest_scroll_region` in tty_update.c to clear text after it is shifted in rather than before shifting out. Also correct row computation.
  - modify `rs2` capability in xterm-r6 and similar entries where cursor save/restore bracketed the sequence for resetting video attributes. The cursor restore would undo that.
- UTF-8 support:
  - when checking LC_ALL, LC_CTYPE, and LANG environment variables for UTF-8 locale, ignore those which are set to an empty value, as per SUSV2.
  - encode 0xFFFD in UTF-8 with 3 bytes, not 2.
  - modify `_nc_utf8_outch()` to avoid sign-extension when checking for out-of-range value.
- other library fixes:
  - added checks for an empty `$HOME` environment variable, to avoid retrieving terminfo descriptions from `./.terminfo` .
  - change functions `_nc_parse_entry()` and `postprocess_termcap()` to avoid using `strtok()`, because it is non-reentrant.
  - initialize `fds[]` array to 0's in `_nc_timed_wait()`; apparently `poll()` only sets the `revents` members of that array when there is activity corresponding to the related file.
  - add a check for null pointer in `Make_Enum_Type()`.
  - fix a heap problem with the c++ binding.
  - correct missing includes for <string.h> in several places, including the C++ binding. This is not noted by gcc unless we use the `-fno-builtin` option.
- several fixes for tic:
  - add a check for empty buffers returned by `fgets()` in comp_scan.c `next_char()` function, in case `tic` is run on a non-text file (fixes a core dump).
  - modify `tic` to verify that its inputs are really files, in case someone tries to read a directory (or `/dev/zero`).
  - correct an uninitialized parameter to `open_tempfile()` in tic.c which made "tic -I" give an ambiguous error message about `tmpnam`.
  - correct logic in `adjust_cancels()`, which did not check both alternatives when reclassifying an extended name between boolean, number and string, causing an infinite loop in `tic`.
- using new checks in `tic` for parameter counts in capability strings, found/fixed several errors both in the terminfo database and in the include/Caps file.
  - modified several terminfo capability strings, including the definitions for setaf, setab, in include/Caps to indicate that the entries are parameterized. This information is used to tell which strings are translated when converting to termcap. This fixes a problem where the generated termcap would contain a spurious "%p1" for the terminfo "%p1%d".
  - correct parameter counts in include/Caps for dclk as well as some printer-specific capabilities: csnm, defc, scs, scsd, smgtp, smglp.
- various fixes for install scripts used to support configure `--srcdir` and `--with-install-prefix`.
- correct several mismatches between manpage filename and ".TH" directives, renaming dft_fgbg.3x to default_colors.3x and menu_attribs.3x to menu_attributes.3x.

Portability:

- configure script:
  - newer config.guess, config.sub, including changes to support OS/2 EMX. The configure script for OS/2 EMX still relies on a patch since there is no (working) support for that platform in the main autoconf distribution.
  - make configure script checks on variables `$GCC` and `$GXX` consistently compare against 'yes' rather than test if they are nonnull, since either may be set to the corresponding name of the C or C++ compiler.
  - change configure script to use AC_CANONICAL_SYSTEM rather than AC_CANONICAL_HOST, which means that `configure --target` will set a default program-prefix.
  - modify the check for big-core to force a couple of memory accesses, which may work as needed for older/less-capable machines (if not, there's still the explicit configure option).
  - modify configure test for `tcgetattr()` to allow for old implementations, e.g., on BeOS, which only defined it as a macro.
  - add configure check for filesystems (such as OS/2 EMX) which do not distinguish between upper/lowercase filenames, use this to fix tags rules in makefiles.
  - add MKncurses_def.sh to generate fallback definitions for ncurses_cfg.h, to quiet gcc -Wundef warnings, modified ifdef's in code to consistently use "#if" rather than "#ifdef".
  - change most remaining unquoted parameters of `test` in configure script to use quotes, for instance fixing a problem in the `--disable-database` option.
  - modify scripts so that "make install.data" works on OS/2 EMX.
  - modify scripts and makefiles so the Ada95 directory builds on OS/2 EMX.
- library:
  - replaced case-statement in `_nc_tracebits()` for CSIZE with a table to simplify working around implementations that define random combinations of the related macros to zero.
  - improved OS/2 mouse support by retrying as a 2-button mouse if code fails to set up a 3-button mouse.
  - added private entrypoint `_nc_basename()`, used to consolidate related code in progs, as well as accommodating OS/2 EMX pathnames.
  - alter definition of NCURSES_CONST to make it non-empty.
  - redefine 'TEXT' in menu.h for AMIGA, since it is reported to have an (unspecified) symbol conflict.
- programs:
  - modified progs/tset.c and tack/sysdep.c to build with sgttyb interface if neither termio or termios is available. Tested this with FreeBSD 2.1.5 (which does have termios - but the sgttyb does work).

# Features of Ncurses

The ncurses package is fully compatible with SVr4 (System V Release 4) curses:

- All 257 of the SVr4 calls have been implemented (and are documented).
- Full support for SVr4 curses features including keyboard mapping, color, forms-drawing with ACS characters, and automatic recognition of keypad and function keys.
- An emulation of the SVr4 panels library, supporting a stack of windows with backing store, is included.
- An emulation of the SVr4 menus library, supporting a uniform but flexible interface for menu programming, is included.
- An emulation of the SVr4 form library, supporting data collection through on-screen forms, is included.
- Binary terminfo entries generated by the ncurses tic(1) implementation are bit-for-bit-compatible with the entry format SVr4 curses uses.
- The utilities have options to allow you to filter terminfo entries for use with less capable curses/terminfo versions such as the HP/UX and AIX ports.

The ncurses package also has many useful extensions over SVr4:

- 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).
- Unlike SVr3 curses, ncurses can write to the rightmost-bottommost corner of the screen if your terminal has an insert-character capability.
- Ada95 and C++ bindings.
- Support for mouse event reporting with X Window xterm and OS/2 console windows.
- Extended mouse support via Alessandro Rubini's gpm package.
- The function `wresize()` allows you to resize windows, preserving their data.
- The function `use_default_colors()` allows you to use the terminal's default colors for the default color pair, achieving the effect of transparent colors.
- The functions `keyok()` and `define_key()` 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.
- Support for 16-color terminals, such as aixterm and XFree86 xterm.
- Better cursor-movement optimization. The package now features a cursor-local-movement computation more efficient than either BSD's or System V's.
- 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.
- 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.
- 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).
- The tic(1)/captoinfo utility provided with ncurses has the ability to translate many termcaps from the XENIX, IBM and AT&T extension sets.
- A BSD-like tset(1) utility is provided.
- 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.
- 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.)
- 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.
- A script (capconvert) 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.
- 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.
- The table-of-entries utility toe makes it easy for users to see exactly what terminal types are available on the system.
- 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 `#undef`.
- An HTML "Introduction to Programming with NCURSES" document provides a narrative introduction to the curses programming interface.

# State of the Package

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.

The ncurses code has been tested with a wide variety of applications including (versions starting with those noted):

cdk
  Curses Development Kit
  http://www.vexus.ca/CDK.html
  http://dickey.his.com/cdk.
ded
  directory-editor
  http://dickey.his.com/ded.
dialog
  the underlying application used in Slackware's setup, and the basis for similar applications on GNU/Linux.
  http://dickey.his.com/dialog.
lynx
  the character-screen WWW browser
  http://lynx.isc.org/release.
Midnight Commander 4.1
  file manager
  www.gnome.org/mc/.
mutt
  mail utility
  http://www.mutt.org.
ncftp
  file-transfer utility
  http://www.ncftp.com.
nvi
  New vi versions 1.50 are able to use ncurses versions 1.9.7 and later.
  http://www.bostic.com/vi/.
tin
  newsreader, supporting color, MIME
  http://www.tin.org.
taper
  tape archive utility
  http://members.iinet.net.au/~yusuf/taper/.
vh-1.6
  Volks-Hypertext browser for the Jargon File
  http://www.bg.debian.org/Packages/unstable/text/vh.html.

as well as some that use ncurses for the terminfo support alone:

minicom
  terminal emulator
  http://www.pp.clinet.fi/~walker/minicom.html.
vile
  vi-like-emacs
  http://dickey.his.com/vile.

The ncurses distribution includes a selection of test programs (including a few games).

## Who's Who and What's What

The original developers of ncurses are Zeyd Ben-Halim and Eric S. Raymond. Ongoing work is being done by Thomas Dickey and Jürgen Pfeifer. Thomas Dickey acts as the maintainer for the Free Software Foundation, which holds the copyright on ncurses. Contact the current maintainers at bug-ncurses@gnu.org.

To join the ncurses mailing list, please write email to `bug-ncurses-request@gnu.org` containing the line:

                 subscribe <name>@<host.domain>

This list is open to anyone interested in helping with the development and testing of this package.

Beta versions of ncurses and patches to the current release are made available at ftp://dickey.his.com/ncurses.

## Future Plans

- Extended-level XPG4 conformance, with internationalization support.
- Ports to more systems, including DOS and Windows.

We need people to help with these projects. If you are interested in working on them, please join the ncurses list.

## Other Related Resources

The distribution includes and uses a version of the terminfo-format terminal description file maintained by Eric Raymond. http://earthspace.net/~esr/terminfo.

You can find lots of information on terminal-related topics not covered in the terminfo file at Richard Shuford's archive.