- Announcing ncurses 5.2
+ Announcing ncurses 5.3
- 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
+ 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
+ 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 ncurses code was developed under GNU/Linux. It has been in use for
+ some time with OpenBSD as the system curses library, and on FreeBSD
+ and NetBSD as an external package. 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
+ 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
+ The ncurses distribution is available via anonymous FTP at the GNU
distribution site [1]ftp://ftp.gnu.org/pub/gnu/ncurses.
- It is also available at [2]ftp://dickey.his.com/ncurses.
+ It is also available at [2]ftp://invisible-island.net/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.
+ This release is designed to be upward compatible from ncurses 5.0 and
+ 5.2; very few applications will require recompilation, depending on
+ the platform. These are the highlights from the change-log since
+ ncurses 5.2 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.
+ * change type for bool used in headers to NCURSES_BOOL, which
+ usually is the same as the compiler's definition for bool.
+ * add all but two functions for X/Open curses wide-character
+ support. These are only available if the library is configured
+ using the --enable-widec option. Missing functions are
+ + pecho_wchar()
+ + slk_wset()
+ * add environment variable $NCURSES_ASSUMED_COLORS to modify the
+ assume_default_colors() extension.
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.
+ * Improved support for termcap applications:
+ + add logic to dump_entry.c to remove function-key definitions
+ that do not fit into the 1023-byte limit for generated
+ termcaps. This makes hds200 fit.
+ + modify tgetent() to check if exit_attribute_mode resets the
+ alternate character set, and if so, attempt to adjust the
+ copy of the termcap "me" string which it will return to
+ eliminate that part. In particular, 'screen' would lose track
+ of line-drawing characters.
+ + add check/fix to comp_parse.c to suppress warning about
+ missing acsc string. This happens in configurations where raw
+ termcap information is processed; tic already does this and
+ other checks.
+ + add tic -A option to suppress capabilities which are
+ commented out when translating to termcap.
+ + modify logic in lib_baudrate.c for ospeed, for FreeBSD to
+ make it work properly for termcap applications (patch by
+ Andrey A Chernov).
+ * add a call to _nc_keypad() in keypad() to accommodate applications
+ such as nvi, which use curses for output but not for input (fixes
+ Debian #131263, cf: 20011215).
+ * correct logic for COLORFGBG environment variable: if rxvt is
+ compiled with xpm support, the variable has three fields, making
+ it slightly incompatible with itself. In either case, the
+ background color is the last field.
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.
+ * rewrote limit-checks in wscrl() and associated
+ _nc_scroll_window(), to ensure that if the parameter of wscrl() is
+ larger than the size of the scrolling region, then the scrolling
+ region will be cleared.
+ * modify tset to restore original I/O modes if an error is
+ encountered. Also modify to use buffered stderr consistently
+ rather than mixing with write().
+ * move calls to def_shell_mode() and def_prog_mode() before loop
+ with callbacks in lib_set_term.c, since the c++ demo otherwise
+ initialized the tty modes before saving them.
+ * modified wresize() to ensure that a failed realloc will not
+ corrupt the window structure, and to make subwindows fit within
+ the resized window.
+ * altered resizeterm() to avoid having it fail when a child window
+ cannot be resized because it would be larger than its parent.
+ * correct/improve logic to produce an exit status for errors in
+ tput, which did not exit with an error when told to put a string
+ not in the current terminfo entry.
+ * modify behavior of can_clear_with() so that if an application is
+ running in a non-bce terminals with default colors enabled, it
+ returns true, allowing the user to select/paste text without
+ picking up extraneous trailing blanks.
+ * add a check in relative_move() to guard against buffer overflow in
+ the overwrite logic.
+ * add some limit/pointer checks to -S option of tputs.
+ * modify mvcur() to avoid emitting newline characters when nonl()
+ mode is set. Normally this is not a problem since the actual
+ terminal mode is set to suppress nl/crlf translations, however it
+ is useful to allow the caller to manipulate the terminal mode to
+ avoid staircasing effects after spawning a process which writes
+ messages (for lynx 2.8.4).
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.
+ + modify check in --disable-overwrite option so that it is used
+ by default unless the --prefix/$prefix value is not /usr, in
+ attempt to work around packagers who do not read the INSTALL
+ notes.
+ + correct a typo in configure --enable-colorfgbg option, and
+ move it to the experimental section (cf: 20011208).
+ + modify configure script to allow building with termcap only,
+ or with fallbacks only. In this case, we do not build tic and
+ toe.
+ + modify run_tic.sh to check if the build is a cross-compile.
+ In that case, do not use the build's tic to install the
+ terminfo database.
+ + modify c++/Makefile.in to accommodate archive programs that
+ are different for C++ than for C, and add cases for vendor's
+ C++ compilers on Solaris and IRIX.
+ + add several configure script options to aid with
+ cross-compiling: --with-build-cc, --with-build-cflags,
+ --with-build-ldflags, and --with-build-libs.
+ + add experimental --with-caps=XXX option to customize to
+ similar terminfo database formats such as AIX 4.x
+ + add configure option --with-ospeed to assist packagers in
+ transition to 5.3 change to ospeed type.
* 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.
+ + implement a simple vsscanf() fallback function which uses the
+ %n conversion to help parse the input data.
+ + various fixes to build/work with different implementations of
+ vsscanf().
+ + add/use macro to suppress sign-extension of char type on
+ platforms where this is a problem in ctype macros, e.g.,
+ Solaris.
+ + finish changes needed to build dll's on cygwin.
+ + add #undef's before possible redefinition of ERR and OK in
+ curses.h
* 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).
+ + modify ifdef's in write_entry.c to allow use of symbolic
+ links on platforms with no hard links, e.g., BeOS.
+ + modify _nc_write_entry() to allow for the possibility that
+ linking aliases on a filesystem that ignores case would not
+ succeed because the source and destination differ only by
+ case, e.g., NCR260VT300WPP0 on cygwin.
+ + modify logic in tic, toe, tput and tset which checks for
+ basename of argv[0] to work properly on systems such as OS/2
+ which have case-independent filenames and/or program
+ suffixes, e.g., ".ext".
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
+ * 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
+ * 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
+ * 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
+ * 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
+ * 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
+ * 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
+ 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
+ * 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
+ 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
+ * 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
+ * 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
+ * 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
+ 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
+ * 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
+ * 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
+ * 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
+ * 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
+ 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
+ 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
+ * 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
+ * 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
+ 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
+ * 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
+ * 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
+ * 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
+ 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
+ * 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
+ 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
+ The ncurses code has been tested with a wide variety of applications
including (versions starting with those noted):
cdk
Curses Development Kit
- [3]http://www.vexus.ca/CDK.html
- [4]http://dickey.his.com/cdk.
+ [3]http://invisible-island.net/cdk.
+ [4]http://www.vexus.ca/CDK.html
ded
directory-editor
- [5]http://dickey.his.com/ded.
+ [5]http://invisible-island.net/ded.
dialog
- the underlying application used in Slackware's setup, and the
+ the underlying application used in Slackware's setup, and the
basis for similar applications on GNU/Linux.
- [6]http://dickey.his.com/dialog.
+ [6]http://invisible-island.net/dialog.
lynx
the character-screen WWW browser
[7]http://lynx.isc.org/release.
- Midnight Commander 4.1
+ Midnight Commander
file manager
[8]www.gnome.org/mc/.
vile
vi-like-emacs
- [16]http://dickey.his.com/vile.
+ [16]http://invisible-island.net/vile.
- The ncurses distribution includes a selection of test programs
+ 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 [17]Zeyd Ben-Halim and [18]Eric
- S. Raymond. Ongoing work is being done by [19]Thomas Dickey and
- [20]Jürgen Pfeifer. [21]Thomas Dickey acts as the maintainer for the
- Free Software Foundation, which holds the copyright on ncurses.
+ S. Raymond. Ongoing work is being done by [19]Thomas Dickey and
+ [20]Jürgen Pfeifer. [21]Thomas Dickey acts as the maintainer for the
+ Free Software Foundation, which holds the copyright on ncurses.
Contact the current maintainers at [22]bug-ncurses@gnu.org.
- To join the ncurses mailing list, please write email to
+ 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 [23]ftp://dickey.his.com/ncurses.
+ Beta versions of ncurses and patches to the current release are made
+ available at [23]ftp://invisible-island.net/ncurses.
Future Plans
- * Extended-level XPG4 conformance, with internationalization
+ * 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
+ 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.
+ The distribution includes and uses a version of the terminfo-format
+ terminal description file maintained by Eric Raymond.
[24]http://earthspace.net/~esr/terminfo.
- You can find lots of information on terminal-related topics not
+ You can find lots of information on terminal-related topics not
covered in the terminfo file at [25]Richard Shuford's archive.
References
1. ftp://ftp.gnu.org/pub/gnu/ncurses
- 2. ftp://dickey.his.com/ncurses
- 3. http://www.vexus.ca/CDK.html
- 4. http://dickey.his.com/cdk/cdk.html
- 5. http://dickey.his.com/ded/ded.html
- 6. http://dickey.his.com/dialog/dialog.html
+ 2. ftp://invisible-island.net/ncurses
+ 3. http://invisible-island.net/cdk/cdk.html
+ 4. http://www.vexus.ca/CDK.html
+ 5. http://invisible-island.net/ded/ded.html
+ 6. http://invisible-island.net/dialog/dialog.html
7. http://lynx.isc.org/release/
- 8. file://localhost/usr/build/ncurses/ncurses-5.2-20001021/doc/html/www.gnome.org/mc/
+ 8. file://localhost/usr/build/ncurses/ncurses-5.2-20021012/doc/html/www.gnome.org/mc/
9. http://www.mutt.org/
10. http://www.ncftp.com/
11. http://www.bostic.com/vi/
13. http://members.iinet.net.au/~yusuf/taper/
14. http://www.bg.debian.org/Packages/unstable/text/vh.html
15. http://www.pp.clinet.fi/~walker/minicom.html
- 16. http://dickey.his.com/vile/vile.html
+ 16. http://invisible-island.net/vile/vile.html
17. mailto:zmbenhal@netcom.com
18. http://www.ccil.org/~esr/home.html
19. mailto:dickey@herndon4.his.com
- 20. mailto:juergen.pfeifer@gmx.net
+ 20. http://www.familiepfeifer.de/Contact.aspx?Lang=en
21. mailto:dickey@herndon4.his.com
22. mailto:bug-ncurses@gnu.org
- 23. ftp://dickey.his.com/ncurses
+ 23. ftp://invisible-island.net/ncurses
24. http://earthspace.net/~esr/terminfo
25. http://www.cs.utk.edu/~shuford/terminal_index.html
# authorization. #
##############################################################################
#
-# Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1996
+# Author: Juergen Pfeifer, 1996
+# Contact: http://www.familiepfeifer.de/Contact.aspx?Lang=en
#
# Version Control
-# $Revision: 1.13 $
+# $Revision: 1.14 $
#
SHELL = /bin/sh
THIS = Makefile
-- authorization. --
-------------------------------------------------------------------------------
--- Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1996
+-- Author: Juergen Pfeifer, 1996
+-- Contact: http://www.familiepfeifer.de/Contact.aspx?Lang=en
The documentation is provided in HTML format in the ./html
subdirectory. The main document is named index.html
# authorization. #
##############################################################################
#
-# Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1996
+# Author: Juergen Pfeifer, 1996
+# Contact: http://www.familiepfeifer.de/Contact.aspx?Lang=en
#
# Version Control
-# $Revision: 1.34 $
+# $Revision: 1.41 $
#
.SUFFIXES:
GNATHTML = `type -p gnathtml || type -p gnathtml.pl`
GNATHP = www.gnat.com
-MAIL = juergen.pfeifer@gmx.net
-HOMEP = home.t-online.de/home/Juergen.Pfeifer
+MAIL = www.familiepfeifer.de/Contact.aspx?Lang=en
+HOMEP = www.familiepfeifer.de/juergen
################################################################################
ALIB = @cf_ada_package@
Linker_Options \
Base_Defs \
Window_Offsets \
- Version_Info
+ Version_Info \
+ Trace_Defs
GEN_FILES2 = Menu_Opt_Rep \
Menu_Base_Defs \
GEN_TARGETS = $(ADA_SRCDIR)/$(ABASE).ads \
$(ADA_SRCDIR)/$(ABASE)-aux.ads \
+ $(ADA_SRCDIR)/$(ABASE)-trace.ads \
$(ADA_SRCDIR)/$(ABASE)-menus.ads \
$(ADA_SRCDIR)/$(ABASE)-forms.ads \
$(ADA_SRCDIR)/$(ABASE)-mouse.ads \
GEN_SRC = $(srcdir)/$(ABASE).ads.m4 \
$(srcdir)/$(ABASE)-aux.ads.m4 \
+ $(srcdir)/$(ABASE)-trace.ads.m4 \
$(srcdir)/$(ABASE)-menus.ads.m4 \
$(srcdir)/$(ABASE)-forms.ads.m4 \
$(srcdir)/$(ABASE)-mouse.ads.m4 \
Window_Offsets: gen$x
$(GENERATE) B D >$@
+Trace_Defs: gen$x
+ $(GENERATE) B T >$@
+
Menu_Opt_Rep: gen$x
$(GENERATE) M R >$@
$(srcdir)/$(ABASE)-aux.ads.m4 |\
$(DEL_ADAMODE) >$@
+$(ADA_SRCDIR)/$(ABASE)-trace.ads: $(srcdir)/$(ABASE)-trace.ads.m4 \
+ $(GEN_FILES5) $(srcdir)/normal.m4
+ $(M4) $(M4FLAGS) -DM4MACRO=$(srcdir)/normal.m4 \
+ $(srcdir)/$(ABASE)-trace.ads.m4 |\
+ $(DEL_ADAMODE) >$@
+
$(ADA_SRCDIR)/$(ABASE)-menus.ads: $(srcdir)/$(ABASE)-menus.ads.m4 \
$(GEN_FILES2) $(srcdir)/normal.m4
$(M4) $(M4FLAGS) -DM4MACRO=$(srcdir)/normal.m4 \
sed -e 's%<A HREF%<A HREF%g' |\
sed -e 's%">%">%g' |\
sed -e 's/3X/3x/g' |\
- sed -e 's/$$\([A-Za-z0-9_]*:.*\)\$$/@\1@/' |\
+ sed -e 's/$$\([ABCDEFGHIJKLMNOPQRSTUVWXZabcdefghijklmnopqrstuvwxz0123456789_]*:.*\)\$$/@\1@/' |\
sed -e 's%Juergen Pfeifer%<A HREF="http://$(HOMEP)">J\ürgen Pfeifer</A>%g' |\
- sed -e 's%$(MAIL)%<A HREF="mailto:$(MAIL)">\<$(MAIL)\></A>%g' |\
+ sed -e 's%http://$(MAIL)%<A HREF="http://$(MAIL)">$(MAIL)</A>%g' |\
sed -e 's%</A>%</A>%g' > $$a.tmp ;\
mv $$a.tmp $$f ;\
done
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1996 *
+ * Author: Juergen Pfeifer, 1996 *
+ * Contact: http://www.familiepfeifer.de/Contact.aspx?Lang=en *
****************************************************************************/
/*
Version Control
- $Revision: 1.32 $
+ $Revision: 1.35 $
--------------------------------------------------------------------------*/
/*
This program generates various record structures and constants from the
gen_reps (nap, name, (len+7)/8, little_endian?start:0);
}
+static void gen_trace(const char *name)
+{
+ static const name_attribute_pair nap[] = {
+ {"Times", TRACE_TIMES},
+ {"Tputs", TRACE_TPUTS},
+ {"Update", TRACE_UPDATE},
+ {"Cursor_Move", TRACE_MOVE},
+ {"Character_Output", TRACE_CHARPUT},
+ {"Calls", TRACE_CALLS},
+ {"Virtual_Puts", TRACE_VIRTPUT},
+ {"Input_Events", TRACE_IEVENT},
+ {"TTY_State", TRACE_BITS},
+ {"Internal_Calls", TRACE_ICALLS},
+ {"Character_Calls", TRACE_CCALLS},
+ {"Termcap_TermInfo", TRACE_DATABASE},
+ {(char *)0, 0}
+ };
+ gen_reps(nap,name,sizeof(int),0);
+}
+
static void gen_menu_opt_rep(const char *name)
{
static const name_attribute_pair nap[] = {
#ifdef BUTTON_ALT
GEN_MEVENT(BUTTON_ALT);
#endif
+#ifdef REPORT_MOUSE_POSITION
+ GEN_MEVENT(REPORT_MOUSE_POSITION);
+#endif
#ifdef ALL_MOUSE_EVENTS
GEN_MEVENT(ALL_MOUSE_EVENTS);
#endif
*/
static void color_def (const char *name, int value)
{
- printf(" %-8s : constant Color_Number := %d;\n",name,value);
+ printf(" %-16s : constant Color_Number := %d;\n",name,value);
}
+#define HAVE_USE_DEFAULT_COLORS 1
+
/*
* Generate all color definitions
*/
static void gen_color (void)
{
+#ifdef HAVE_USE_DEFAULT_COLORS
+ color_def ("Default_Color",-1);
+#endif
#ifdef COLOR_BLACK
color_def ("Black",COLOR_BLACK);
#endif
o = offsetof(WINDOW, member); \
if ((o%sizeof(itype) == 0)) { \
printf(" Offset%-*s : constant Natural := %2ld; -- %s\n", \
- 8, #member, o/sizeof(itype),#itype); \
+ 12, #member, o/sizeof(itype),#itype); \
} \
}
GEN_OFFSET(_pary,int);
GEN_OFFSET(_parx,int);
if (sizeof(bool) == sizeof(char)) {
+ GEN_OFFSET(_notimeout,char);
+ GEN_OFFSET(_clear,char);
+ GEN_OFFSET(_leaveok,char);
GEN_OFFSET(_scroll,char);
+ GEN_OFFSET(_idlok,char);
+ GEN_OFFSET(_idcok,char);
+ GEN_OFFSET(_immed,char);
+ GEN_OFFSET(_sync,char);
+ GEN_OFFSET(_use_keypad,char);
s_bool = "char";
} else if (sizeof(bool) == sizeof(short)) {
+ GEN_OFFSET(_notimeout,short);
+ GEN_OFFSET(_clear,short);
+ GEN_OFFSET(_leaveok,short);
GEN_OFFSET(_scroll,short);
+ GEN_OFFSET(_idlok,short);
+ GEN_OFFSET(_idcok,short);
+ GEN_OFFSET(_immed,short);
+ GEN_OFFSET(_sync,short);
+ GEN_OFFSET(_use_keypad,short);
s_bool = "short";
} else if (sizeof(bool) == sizeof(int)) {
+ GEN_OFFSET(_notimeout,int);
+ GEN_OFFSET(_clear,int);
+ GEN_OFFSET(_leaveok,int);
GEN_OFFSET(_scroll,int);
+ GEN_OFFSET(_idlok,int);
+ GEN_OFFSET(_idcok,int);
+ GEN_OFFSET(_immed,int);
+ GEN_OFFSET(_sync,int);
+ GEN_OFFSET(_use_keypad,int);
s_bool = "int";
}
printf(" Sizeof%-*s : constant Natural := %2ld; -- %s\n",
- 8, "_bool", (long) sizeof(bool),"bool");
+ 12, "_bool", (long) sizeof(bool),"bool");
/* In ncurses _maxy and _maxx needs an offset for the "public"
* value
*/
printf(" Offset%-*s : constant Natural := %2d; -- %s\n",
- 8, "_XY",1,"int");
+ 12, "_XY",1,"int");
printf("\n");
printf(" type Curses_Bool is mod 2 ** Interfaces.C.%s'Size;\n",s_bool);
}
case 'V': /* generate version info */
gen_version_info();
break;
+ case 'T': /* generate the Trace info */
+ gen_trace("Trace_Attribute_Set");
+ break;
default:
break;
}
-- sale, use or other dealings in this Software without prior written --
-- authorization. --
------------------------------------------------------------------------------
--- Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1996
+-- Author: Juergen Pfeifer, 1996
+-- Contact: http://www.familiepfeifer.de/Contact.aspx?Lang=en
-- Version Control:
--- $Revision: 1.13 $
+-- $Revision: 1.14 $
-- Binding Version 01.00
------------------------------------------------------------------------------
include(`Base_Defs')
-- sale, use or other dealings in this Software without prior written --
-- authorization. --
------------------------------------------------------------------------------
--- Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1996
+-- Author: Juergen Pfeifer, 1996
+-- Contact: http://www.familiepfeifer.de/Contact.aspx?Lang=en
-- Version Control:
--- $Revision: 1.12 $
+-- $Revision: 1.13 $
-- Binding Version 01.00
------------------------------------------------------------------------------
with Interfaces.C;
-- sale, use or other dealings in this Software without prior written --
-- authorization. --
------------------------------------------------------------------------------
--- Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1996
+-- Author: Juergen Pfeifer, 1996
+-- Contact: http://www.familiepfeifer.de/Contact.aspx?Lang=en
-- Version Control:
--- $Revision: 1.13 $
+-- $Revision: 1.14 $
-- Binding Version 01.00
------------------------------------------------------------------------------
-- sale, use or other dealings in this Software without prior written --
-- authorization. --
------------------------------------------------------------------------------
--- Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1996
+-- Author: Juergen Pfeifer, 1996
+-- Contact: http://www.familiepfeifer.de/Contact.aspx?Lang=en
-- Version Control:
--- $Revision: 1.12 $
+-- $Revision: 1.13 $
-- Binding Version 01.00
------------------------------------------------------------------------------
-- sale, use or other dealings in this Software without prior written --
-- authorization. --
------------------------------------------------------------------------------
--- Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1996
+-- Author: Juergen Pfeifer, 1996
+-- Contact: http://www.familiepfeifer.de/Contact.aspx?Lang=en
-- Version Control:
--- $Revision: 1.24 $
+-- $Revision: 1.26 $
-- Binding Version 01.00
------------------------------------------------------------------------------
include(`Form_Base_Defs')
-- AKA
pragma Inline (Is_New_Page);
+ -- MANPAGE(`form_requestname.3x')
+ -- Not Implemented: form_request_name, form_request_by_name
+
------------------------------------------------------------------------------
private
type Field is new System.Storage_Elements.Integer_Address;
-- sale, use or other dealings in this Software without prior written --
-- authorization. --
------------------------------------------------------------------------------
--- Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1996
+-- Author: Juergen Pfeifer, 1996
+-- Contact: http://www.familiepfeifer.de/Contact.aspx?Lang=en
-- Version Control:
--- $Revision: 1.12 $
+-- $Revision: 1.13 $
-- Binding Version 01.00
------------------------------------------------------------------------------
-- sale, use or other dealings in this Software without prior written --
-- authorization. --
------------------------------------------------------------------------------
--- Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1996
+-- Author: Juergen Pfeifer, 1996
+-- Contact: http://www.familiepfeifer.de/Contact.aspx?Lang=en
-- Version Control:
--- $Revision: 1.12 $
+-- $Revision: 1.13 $
-- Binding Version 01.00
------------------------------------------------------------------------------
-- sale, use or other dealings in this Software without prior written --
-- authorization. --
------------------------------------------------------------------------------
--- Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1996
+-- Author: Juergen Pfeifer, 1996
+-- Contact: http://www.familiepfeifer.de/Contact.aspx?Lang=en
-- Version Control:
--- $Revision: 1.21 $
+-- $Revision: 1.23 $
-- Binding Version 01.00
------------------------------------------------------------------------------
include(`Menu_Base_Defs')
procedure Set_Format (Men : in Menu;
Lines : in Line_Count;
Columns : in Column_Count);
+ -- Not implemented: 0 argument for Lines or Columns;
+ -- instead use Format to get the current sizes
+ -- The default format is 16 rows, 1 column. Calling
+ -- set_menu_format with a null menu pointer will change this
+ -- default. A zero row or column argument to set_menu_format
+ -- is interpreted as a request not to change the current
+ -- value.
-- AKA
pragma Inline (Set_Format);
-- Reset Men to Null_Menu
-- Not inlined
- -- MANPAGE(`menu_new.3x')
+ -- MANPAGE(`menu_driver.3x')
type Driver_Result is (Menu_Ok,
Request_Denied,
-- AKA
-- Driver is not inlined
+ -- ANCHOR(`menu_requestname.3x')
+ -- Not Implemented: menu_request_name, menu_request_by_name
-------------------------------------------------------------------------------
private
type Item is new System.Storage_Elements.Integer_Address;
-- sale, use or other dealings in this Software without prior written --
-- authorization. --
------------------------------------------------------------------------------
--- Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1996
+-- Author: Juergen Pfeifer, 1996
+-- Contact: http://www.familiepfeifer.de/Contact.aspx?Lang=en
-- Version Control:
--- $Revision: 1.19 $
+-- $Revision: 1.21 $
-- Binding Version 01.00
------------------------------------------------------------------------------
include(`Mouse_Base_Defs')
-- is still marked as experimental. So also this binding will change
-- if the ncurses methods change.
--
+ -- mouse_trafo, wmouse_trafo are implemented as Transform_Coordinates
+ -- in the parent package.
+ --
+ -- Not implemented:
+ -- REPORT_MOUSE_POSITION (i.e. as a parameter to Register_Reportable_Event
+ -- or Start_Mouse)
type Event_Mask is private;
No_Events : constant Event_Mask;
All_Events : constant Event_Mask;
-- ANCHOR(`mousemask()',`Start_Mouse')
-- There is one difference to mousmask(): we return the value of the
-- old mask, that means the event mask value before this call.
+ -- Not Implemented: The library version
+ -- returns a Mouse_Mask that tells which events are reported.
function Start_Mouse (Mask : Event_Mask := All_Events)
return Event_Mask;
-- AKA
State : out Button_State);
-- !!! Warning: X and Y are screen coordinates. Due to ripped of lines they
-- may not be identical to window coordinates.
+ -- Not Implemented: Get_Event only reports one event, the C library
+ -- version supports multiple events, e.g. {click-1, click-3}
pragma Inline (Get_Event);
-- ANCHOR(`ungetmouse()',`Unget_Mouse')
-- sale, use or other dealings in this Software without prior written --
-- authorization. --
------------------------------------------------------------------------------
--- Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1996
+-- Author: Juergen Pfeifer, 1996
+-- Contact: http://www.familiepfeifer.de/Contact.aspx?Lang=en
-- Version Control:
--- $Revision: 1.12 $
+-- $Revision: 1.13 $
-- Binding Version 01.00
------------------------------------------------------------------------------
-- sale, use or other dealings in this Software without prior written --
-- authorization. --
------------------------------------------------------------------------------
--- Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1996
+-- Author: Juergen Pfeifer, 1996
+-- Contact: http://www.familiepfeifer.de/Contact.aspx?Lang=en
-- Version Control:
--- $Revision: 1.15 $
+-- $Revision: 1.16 $
-- Binding Version 01.00
------------------------------------------------------------------------------
with System;
--- /dev/null
+-- -*- ada -*-
+define(`HTMLNAME',`terminal_interface-curses-trace__ads.htm')dnl
+include(M4MACRO)------------------------------------------------------------------------------
+-- --
+-- GNAT ncurses Binding --
+-- --
+-- Terminal_Interface.Curses.Trace --
+-- --
+-- S P E C --
+-- --
+------------------------------------------------------------------------------
+-- Copyright (c) 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: Eugene V. Melaragno <aldomel@ix.netcom.com> 2000
+-- Version Control:
+-- $Revision: 1.1 $
+-- Binding Version 01.00
+------------------------------------------------------------------------------
+
+package Terminal_Interface.Curses.Trace is
+ pragma Preelaborate (Terminal_Interface.Curses.Trace);
+
+ pragma Warnings (Off);
+include(`Trace_Defs')
+
+ pragma Warnings (On);
+
+ Trace_Disable : constant Trace_Attribute_Set := (others => False);
+
+ Trace_Ordinary : constant Trace_Attribute_Set :=
+ (Times => True,
+ Tputs => True,
+ Update => True,
+ Cursor_Move => True,
+ Character_Output => True,
+ others => False);
+ Trace_Maximum : constant Trace_Attribute_Set := (others => True);
+
+------------------------------------------------------------------------------
+
+ -- MANPAGE(`curs_trace.3x')
+
+ -- ANCHOR(`trace()',`Trace_on')
+ procedure Trace_On (x : Trace_Attribute_Set);
+ -- The debugging library has trace.
+
+ -- ANCHOR(`_tracef()',`Trace_Put')
+ procedure Trace_Put (str : String);
+ -- AKA
+
+ Current_Trace_Setting : Trace_Attribute_Set;
+ pragma Import (C, Current_Trace_Setting, "_nc_tracing");
+
+end Terminal_Interface.Curses.Trace;
-- sale, use or other dealings in this Software without prior written --
-- authorization. --
------------------------------------------------------------------------------
--- Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1996
+-- Author: Juergen Pfeifer, 1996
+-- Contact: http://www.familiepfeifer.de/Contact.aspx?Lang=en
-- Version Control:
--- $Revision: 1.28 $
+-- $Revision: 1.30 $
-- Binding Version 01.00
------------------------------------------------------------------------------
include(`Base_Defs')
------------------------------------------------------------------------------
- type Color_Number is range 0 .. Integer (Interfaces.C.short'Last);
+ type Color_Number is range -1 .. Integer (Interfaces.C.short'Last);
for Color_Number'Size use Interfaces.C.short'Size;
-- (n)curses uses a short for the color index
-- The model is, that a Color_Number is an index into an array of
include(`ACS_Map')dnl
-- MANPAGE(`curs_initscr.3x')
- -- | Not implemented: newterm, set_term, delscreen
+ -- | Not implemented: newterm, set_term, delscreen, curscr
-- ANCHOR(`stdscr',`Standard_Window')
function Standard_Window return Window;
Line : in Line_Position;
Column : in Column_Position);
-- AKA
+ -- ALIAS(`move()')
pragma Inline (Move_Cursor);
-- MANPAGE(`curs_addch.3x')
procedure Add (Win : in Window := Standard_Window;
Ch : in Attributed_Character);
-- AKA
+ -- ALIAS(`addch()')
procedure Add (Win : in Window := Standard_Window;
Ch : in Character);
Column : in Column_Position;
Ch : in Attributed_Character);
-- AKA
+ -- ALIAS(`mvaddch()')
procedure Add
(Win : in Window := Standard_Window;
(Win : in Window := Standard_Window;
Ch : in Attributed_Character);
-- AKA
+ -- ALIAS(`echochar()')
procedure Add_With_Immediate_Echo
(Win : in Window := Standard_Window;
pragma Inline (Add_With_Immediate_Echo);
-- MANPAGE(`curs_window.3x')
+ -- Not Implemented: wcursyncup
-- ANCHOR(`newwin()',`Create')
function Create
Number_Of_Columns : Column_Count;
First_Line_Position : Line_Position;
First_Column_Position : Column_Position) return Window;
+ -- Not Implemented: Default Number_Of_Lines, Number_Of_Columns
+ -- the C version lets them be 0, see the man page.
-- AKA
pragma Inline (Create);
Len : in Integer := -1);
-- AKA
-- ALIAS(`waddstr()')
+ -- ALIAS(`addnstr()')
+ -- ALIAS(`addstr()')
-- ANCHOR(`mvwaddnstr()',`Add')
procedure Add (Win : in Window := Standard_Window;
Len : in Integer := -1);
-- AKA
-- ALIAS(`mvwaddstr()')
+ -- ALIAS(`mvaddnstr()')
+ -- ALIAS(`mvaddstr()')
-- MANPAGE(`curs_addchstr.3x')
Len : in Integer := -1);
-- AKA
-- ALIAS(`waddchstr()')
+ -- ALIAS(`addchnstr()')
+ -- ALIAS(`addchstr()')
-- ANCHOR(`mvwaddchnstr()',`Add')
procedure Add (Win : in Window := Standard_Window;
Len : in Integer := -1);
-- AKA
-- ALIAS(`mvwaddchstr()')
+ -- ALIAS(`mvaddchnstr()')
+ -- ALIAS(`mvaddchstr()')
pragma Inline (Add);
-- MANPAGE(`curs_border.3x')
+ -- | Not implemented: mvhline, mvwhline, mvvline, mvwvline
+ -- | use Move_Cursor then Horizontal_Line or Vertical_Line
-- ANCHOR(`wborder()',`Border')
procedure Border
Lower_Right_Corner_Symbol : in Attributed_Character := Default_Character
);
-- AKA
+ -- ALIAS(`border()')
pragma Inline (Border);
-- ANCHOR(`box()',`Box')
Line_Size : in Natural;
Line_Symbol : in Attributed_Character := Default_Character);
-- AKA
+ -- ALIAS(`hline()')
pragma Inline (Horizontal_Line);
-- ANCHOR(`wvline()',`Vertical_Line')
Line_Size : in Natural;
Line_Symbol : in Attributed_Character := Default_Character);
-- AKA
+ -- ALIAS(`vline()')
pragma Inline (Vertical_Line);
-- MANPAGE(`curs_getch.3x')
+ -- Not implemented: mvgetch, mvwgetch
-- ANCHOR(`wgetch()',`Get_Keystroke')
function Get_Keystroke (Win : Window := Standard_Window)
return Real_Key_Code;
-- AKA
+ -- ALIAS(`getch()')
-- Get a character from the keyboard and echo it - if enabled - to the
-- window.
-- If for any reason (i.e. a timeout) we couldn't get a character the
pragma Inline (Function_Key_Code);
-- MANPAGE(`curs_attr.3x')
+ -- | Not implemented attr_off, wattr_off,
+ -- | attr_on, wattr_on, attr_set, wattr_set
+
+ -- PAIR_NUMBER
+ -- PAIR_NUMBER(c) is the same as c.Color
+
+ -- ANCHOR(`standout()',`Standout')
+ procedure Standout (Win : Window := Standard_Window;
+ On : Boolean := True);
+ -- ALIAS(`wstandout()')
+ -- ALIAS(`wstandend()')
-- ANCHOR(`wattron()',`Switch_Character_Attribute')
procedure Switch_Character_Attribute
(Win : in Window := Standard_Window;
Attr : in Character_Attribute_Set := Normal_Video;
On : in Boolean := True); -- if False we switch Off.
+ -- Switches those Attributes set to true in the list.
-- AKA
-- ALIAS(`wattroff()')
+ -- ALIAS(`attron()')
+ -- ALIAS(`attroff()')
-- ANCHOR(`wattrset()',`Set_Character_Attributes')
procedure Set_Character_Attributes
Attr : in Character_Attribute_Set := Normal_Video;
Color : in Color_Pair := Color_Pair'First);
-- AKA
+ -- ALIAS(`attrset()')
pragma Inline (Set_Character_Attributes);
-- ANCHOR(`wattr_get()',`Get_Character_Attributes')
function Get_Character_Attribute
(Win : in Window := Standard_Window) return Character_Attribute_Set;
-- AKA
+ -- ALIAS(`attr_get()')
-- ANCHOR(`wattr_get()',`Get_Character_Attribute')
function Get_Character_Attribute
procedure Set_Color (Win : in Window := Standard_Window;
Pair : in Color_Pair);
-- AKA
+ -- ALIAS(`color_set()')
pragma Inline (Set_Color);
-- ANCHOR(`wchgat()',`Change_Attributes')
Attr : in Character_Attribute_Set := Normal_Video;
Color : in Color_Pair := Color_Pair'First);
-- AKA
+ -- ALIAS(`chgat()')
-- ANCHOR(`mvwchgat()',`Change_Attributes')
procedure Change_Attributes
Attr : in Character_Attribute_Set := Normal_Video;
Color : in Color_Pair := Color_Pair'First);
-- AKA
+ -- ALIAS(`mvchgat()')
pragma Inline (Change_Attributes);
-- MANPAGE(`curs_beep.3x')
-- AKA
pragma Inline (Set_KeyPad_Mode);
+ function Get_KeyPad_Mode (Win : in Window := Standard_Window)
+ return Boolean;
+ -- This has no pendant in C. There you've to look into the WINDOWS
+ -- structure to get the value. Bad practice, not repeated in Ada.
+
type Half_Delay_Amount is range 1 .. 255;
-- ANCHOR(`halfdelay()',`Half_Delay')
Mode : in Timeout_Mode;
Amount : in Natural); -- in Milliseconds
-- AKA
+ -- ALIAS(`timeout()')
-- Instead of overloading the semantic of the sign of amount, we
-- introduce the Timeout_Mode parameter. This should improve
-- readability. For Blocking and Non_Blocking, the Amount is not
Top_Line : in Line_Position;
Bottom_Line : in Line_Position);
-- AKA
+ -- ALIAS(`setscrreg()')
pragma Inline (Set_Scroll_Region);
-- MANPAGE(`curs_refresh.3x')
-- AKA
-- There is an overloaded Refresh for Pads.
-- The Inline pragma appears there
+ -- ALIAS(`refresh()')
-- ANCHOR(`wnoutrefresh()',`Refresh_Without_Update')
procedure Refresh_Without_Update
-- ANCHOR(`werase()',`Erase')
procedure Erase (Win : in Window := Standard_Window);
-- AKA
+ -- ALIAS(`erase()')
pragma Inline (Erase);
-- ANCHOR(`wclear()',`Clear')
procedure Clear
(Win : in Window := Standard_Window);
-- AKA
+ -- ALIAS(`clear()')
pragma Inline (Clear);
-- ANCHOR(`wclrtobot()',`Clear_To_End_Of_Screen')
procedure Clear_To_End_Of_Screen
(Win : in Window := Standard_Window);
-- AKA
+ -- ALIAS(`clrtobot()')
pragma Inline (Clear_To_End_Of_Screen);
-- ANCHOR(`wclrtoeol()',`Clear_To_End_Of_Line')
procedure Clear_To_End_Of_Line
(Win : in Window := Standard_Window);
-- AKA
+ -- ALIAS(`clrtoeol()')
pragma Inline (Clear_To_End_Of_Line);
-- MANPAGE(`curs_bkgd.3x')
-- ANCHOR(`wbkgdset()',`Set_Background')
+ -- TODO: we could have Set_Background(Window; Character_Attribute_Set)
+ -- because in C it is common to see bkgdset(A_BOLD) or
+ -- bkgdset(COLOR_PAIR(n))
procedure Set_Background
(Win : in Window := Standard_Window;
Ch : in Attributed_Character);
-- AKA
+ -- ALIAS(`bkgdset()')
pragma Inline (Set_Background);
-- ANCHOR(`wbkgd()',`Change_Background')
(Win : in Window := Standard_Window;
Ch : in Attributed_Character);
-- AKA
+ -- ALIAS(`bkgd()')
pragma Inline (Change_Background);
-- ANCHOR(`wbkgdget()',`Get_Background')
+ -- ? wbkgdget is not listed in curs_bkgd, getbkgd is thpough.
function Get_Background (Win : Window := Standard_Window)
return Attributed_Character;
-- AKA
+ -- ALIAS(`bkgdget()')
pragma Inline (Get_Background);
-- MANPAGE(`curs_touch.3x')
(Win : in Window := Standard_Window;
Lines : in Integer := 1); -- default is to insert one line above
-- AKA
+ -- ALIAS(`insdelln()')
pragma Inline (Insert_Delete_Lines);
-- ANCHOR(`wdeleteln()',`Delete_Line')
procedure Delete_Line (Win : in Window := Standard_Window);
-- AKA
+ -- ALIAS(`deleteln()')
pragma Inline (Delete_Line);
-- ANCHOR(`winsertln()',`Insert_Line')
procedure Insert_Line (Win : in Window := Standard_Window);
-- AKA
+ -- ALIAS(`insertln()')
pragma Inline (Insert_Line);
-- MANPAGE(`curs_getyx.3x')
procedure Scroll (Win : in Window := Standard_Window;
Amount : in Integer := 1);
-- AKA
+ -- ALIAS(`scroll()')
+ -- ALIAS(`scrl()')
pragma Inline (Scroll);
-- MANPAGE(`curs_delch.3x')
-- ANCHOR(`wdelch()',`Delete_Character')
procedure Delete_Character (Win : in Window := Standard_Window);
-- AKA
+ -- ALIAS(`delch()')
-- ANCHOR(`mvwdelch()',`Delete_Character')
procedure Delete_Character
Line : in Line_Position;
Column : in Column_Position);
-- AKA
+ -- ALIAS(`mvdelch()')
pragma Inline (Delete_Character);
-- MANPAGE(`curs_inch.3x')
-- ANCHOR(`winch()',`Peek')
function Peek (Win : Window := Standard_Window)
return Attributed_Character;
+ -- ALIAS(`inch()')
-- AKA
-- ANCHOR(`mvwinch()',`Peek')
Line : Line_Position;
Column : Column_Position) return Attributed_Character;
-- AKA
+ -- ALIAS(`mvinch()')
-- More Peek's follow, pragma Inline appears later.
- -- MANPAGE(`curs_winch.3x')
+ -- MANPAGE(`curs_insch.3x')
-- ANCHOR(`winsch()',`Insert')
procedure Insert (Win : in Window := Standard_Window;
Ch : in Attributed_Character);
-- AKA
+ -- ALIAS(`insch()')
-- ANCHOR(`mvwinsch()',`Insert')
procedure Insert (Win : in Window := Standard_Window;
Column : in Column_Position;
Ch : in Attributed_Character);
-- AKA
+ -- ALIAS(`mvinsch()')
- -- MANPAGE(`curs_winch.3x')
+ -- MANPAGE(`curs_insstr.3x')
-- ANCHOR(`winsnstr()',`Insert')
procedure Insert (Win : in Window := Standard_Window;
Len : in Integer := -1);
-- AKA
-- ALIAS(`winsstr()')
+ -- ALIAS(`insnstr()')
+ -- ALIAS(`insstr()')
-- ANCHOR(`mvwinsnstr()',`Insert')
procedure Insert (Win : in Window := Standard_Window;
Len : in Integer := -1);
-- AKA
-- ALIAS(`mvwinsstr()')
+ -- ALIAS(`mvinsnstr()')
+ -- ALIAS(`mvinsstr()')
pragma Inline (Insert);
-- MANPAGE(`curs_instr.3x')
Len : in Integer := -1);
-- AKA
-- ALIAS(`winstr()')
+ -- ALIAS(`innstr()')
+ -- ALIAS(`instr()')
-- ANCHOR(`mvwinnstr()',`Peek')
procedure Peek (Win : in Window := Standard_Window;
Len : in Integer := -1);
-- AKA
-- ALIAS(`mvwinstr()')
+ -- ALIAS(`mvinnstr()')
+ -- ALIAS(`mvinstr()')
-- MANPAGE(`curs_inchstr.3x')
Len : in Integer := -1);
-- AKA
-- ALIAS(`winchstr()')
+ -- ALIAS(`inchnstr()')
+ -- ALIAS(`inchstr()')
-- ANCHOR(`mvwinchnstr()',`Peek')
procedure Peek (Win : in Window := Standard_Window;
Len : in Integer := -1);
-- AKA
-- ALIAS(`mvwinchstr()')
+ -- ALIAS(`mvinchnstr()')
+ -- ALIAS(`mvinchstr()')
-- We don't inline the Peek procedures
-- MANPAGE(`curs_getstr.3x')
Len : in Integer := -1);
-- AKA
-- ALIAS(`wgetstr()')
+ -- ALIAS(`getnstr()')
+ -- ALIAS(`getstr()')
+ -- actually getstr is not supported because that results in buffer
+ -- overflows.
+ -- ANCHOR(`mvwgetnstr()',`Get')
procedure Get (Win : in Window := Standard_Window;
Line : in Line_Position;
Column : in Column_Position;
Str : out String;
Len : in Integer := -1);
-- AKA
- -- not specified in ncurses, should be: mvwgetnstr()
- -- and mvwgetstr() (which exists)
+ -- ALIAS(`mvwgetstr()')
+ -- ALIAS(`mvgetnstr()')
+ -- ALIAS(`mvgetstr()')
-- Get is not inlined
-- MANPAGE(`curs_slk.3x')
+ -- Not Implemented: slk_attr_on, slk_attr_off, slk_attr_set
+
type Soft_Label_Key_Format is (Three_Two_Three,
Four_Four,
PC_Style, -- ncurses specific
-- AKA
pragma Inline (Set_Soft_Label_Key_Color);
+ -- MANPAGE(`keybound.3x')
+ -- Not Implemented: keybound
+
-- MANPAGE(`keyok.3x')
-- ANCHOR(`keyok()',`Enable_Key')
-- MANPAGE(`curs_util.3x')
- -- | Not implemented : filter, use_env, putwin, getwin
+ -- | Not implemented : filter, use_env
+ -- | putwin, getwin are in the child package PutWin
--
+
-- ANCHOR(`keyname()',`Key_Name')
procedure Key_Name (Key : in Real_Key_Code;
Name : out String);
-- MANPAGE(`curs_color.3x')
+ -- COLOR_PAIR
+ -- COLOR_PAIR(n) in C is the same as
+ -- Attributed_Character(Ch => Nul, Color => n, Attr => Normal_Video)
+ -- In C you often see something like c = c | COLOR_PAIR(n);
+ -- This is equivalent to c.Color := n;
+
-- ANCHOR(`start_color()',`Start_Color')
procedure Start_Color;
-- AKA
pragma Inline (Color_Content);
-- MANPAGE(`curs_kernel.3x')
-
-- | Not implemented: getsyx, setsyx
--
type Curses_Mode is (Curses, Shell);
-- Window or if you pass the Null_Window as argument.
-- We don't inline this procedure
+ -- MANPAGE(`dft_fgbg.3x')
+
+ -- ANCHOR(`use_default_colors()',`Use_Default_Colors')
+ procedure Use_Default_Colors;
+ -- AKA
+ pragma Inline (Use_Default_Colors);
+
+ -- ANCHOR(`assume_default_colors()',`Assume_Default_Colors')
+ procedure Assume_Default_Colors (Fore : Color_Number := Default_Color;
+ Back : Color_Number := Default_Color);
+ -- AKA
+ pragma Inline (Assume_Default_Colors);
+
+ -- MANPAGE(`curs_extend.3x')
+
+ -- ANCHOR(`curses_version()',`Curses_Version')
+ function Curses_Version return String;
+ -- AKA
+
+ -- ANCHOR(`use_extended_names()',`Use_Extended_Names')
+ -- The returnvalue is the previous setting of the flag
+ function Use_Extended_Names (Enable : Boolean) return Boolean;
+ -- AKA
+
+ -- MANPAGE(`curs_scr_dump.3x')
+
+ -- ANCHOR(`scr_dump()',`Screen_Dump_To_File')
+ procedure Screen_Dump_To_File (Filename : in String);
+ -- AKA
+
+ -- ANCHOR(`scr_restore()',`Screen_Restore_From_File')
+ procedure Screen_Restore_From_File (Filename : in String);
+ -- AKA
+
+ -- ANCHOR(`scr_init()',`Screen_Init_From_File')
+ procedure Screen_Init_From_File (Filename : in String);
+ -- AKA
+
+ -- ANCHOR(`scr_set()',`Screen_Set_File')
+ procedure Screen_Set_File (Filename : in String);
+ -- AKA
+
+ -- MANPAGE(`curs_print.3x')
+ -- Not implemented: mcprint
+
+ -- MANPAGE(`curs_printw.3x')
+ -- Not implemented: printw, wprintw, mvprintw, mvwprintw, vwprintw,
+ -- vw_printw
+ -- Please use the Ada style Text_IO child packages for formatted
+ -- printing. It doesn't make a lot of sense to map the printf style
+ -- C functions to Ada.
+
+ -- MANPAGE(`curs_scanw.3x')
+ -- Not implemented: scanw, wscanw, mvscanw, mvwscanw, vwscanw, vw_scanw
+
+
+ -- MANPAGE(`resizeterm.3x')
+ -- Not Implemented: resizeterm
+
+ -- MANPAGE(`wresize.3x')
+
+ -- ANCHOR(`wresize()',`Resize')
+ procedure Resize (Win : Window := Standard_Window;
+ Number_Of_Lines : Line_Count;
+ Number_Of_Columns : Column_Count);
+ -- AKA
+
private
type Window is new System.Storage_Elements.Integer_Address;
Null_Window : constant Window := 0;
# authorization. #
##############################################################################
#
-# Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1996
+# Author: Juergen Pfeifer, 1996
+# Contact: http://www.familiepfeifer.de/Contact.aspx?Lang=en
#
# Version Control
-# $Revision: 1.25 $
+# $Revision: 1.29 $
#
.SUFFIXES:
ABASE = $(ALIB)-curses
CARGS =-cargs $(ADAFLAGS)
-LARGS =-largs -L../../lib $(LD_FLAGS) -lAdaCurses -lncurses@LIB_SUFFIX@
-
-PROGS = tour rain
+LARGS =-largs -L../../lib @TEST_ARGS@ $(LD_FLAGS) -lAdaCurses @EXTRA_LIBS@
+
+PROGS = tour rain ncurses
TOUR_OBJS = tour.o sample.o sample-curses_demo.o sample-explanation.o \
sample-form_demo.o sample-function_key_setting.o \
RAIN_OBJS = rain.o status.o
-all :: tour$x rain$x
+NCURSES_OBJS = ncurses.o ncurses2-getch_test.o \
+ ncurses2-acs_and_scroll.o ncurses2-m.o \
+ ncurses2-acs_display.o ncurses2-menu_test.o \
+ ncurses2-attr_test.o ncurses2-overlap_test.o \
+ ncurses2-color_edit.o ncurses2-slk_test.o \
+ ncurses2-color_test.o ncurses2-test_sgr_attributes.o \
+ ncurses2-demo_forms.o ncurses2-trace_set.o \
+ ncurses2-demo_pad.o ncurses2-util.o \
+ ncurses2-demo_panels.o ncurses2.o \
+ ncurses2-flushinp_test.o
+
+
+all :: tour$x rain$x ncurses$x
@
sources :
uninstall.libs ::
@
+ncurses$x :
+ $(ADAMAKE) $(ADAMAKEFLAGS) ncurses $(CARGS) $(LARGS)
+
tour$x : explain.msg
$(ADAMAKE) $(ADAMAKEFLAGS) tour $(CARGS) $(LARGS)
@
clean :: mostlyclean
- rm -f *.o *.ali b_t*.* *.s $(PROGS) a.out core b_*_test.c *.xr[bs] explain.msg
+ rm -f *.o *.ali b_t*.* *.s $(PROGS) a.out core b_*_test.c *.xr[bs] \
+ explain.msg trace screendump
distclean :: clean
rm -f Makefile
--- /dev/null
+------------------------------------------------------------------------------
+-- --
+-- GNAT ncurses Binding Samples --
+-- --
+-- ncurses --
+-- --
+-- B O D Y --
+-- --
+------------------------------------------------------------------------------
+-- Copyright (c) 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: Eugene V. Melaragno <aldomel@ix.netcom.com> 2000
+-- Version Control
+-- $Revision: 1.1 $
+-- Binding Version 01.00
+------------------------------------------------------------------------------
+with ncurses2.m; use ncurses2.m;
+with GNAT.OS_Lib; use GNAT.OS_Lib;
+
+procedure ncurses is
+begin
+ OS_Exit (main);
+end ncurses;
--- /dev/null
+------------------------------------------------------------------------------
+-- --
+-- GNAT ncurses Binding Samples --
+-- --
+-- ncurses --
+-- --
+-- B O D Y --
+-- --
+------------------------------------------------------------------------------
+-- Copyright (c) 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: Eugene V. Melaragno <aldomel@ix.netcom.com> 2000
+-- Version Control
+-- $Revision: 1.1 $
+-- Binding Version 01.00
+------------------------------------------------------------------------------
+-- Windows and scrolling tester.
+-- Demonstrate windows
+
+with Ada.Strings.Fixed;
+with Ada.Strings;
+
+with ncurses2.util; use ncurses2.util;
+with ncurses2.genericPuts;
+with Terminal_Interface.Curses; use Terminal_Interface.Curses;
+with Terminal_Interface.Curses.Mouse; use Terminal_Interface.Curses.Mouse;
+with Terminal_Interface.Curses.PutWin; use Terminal_Interface.Curses.PutWin;
+
+with Ada.Streams.Stream_IO; use Ada.Streams.Stream_IO;
+with Ada.Streams; use Ada.Streams;
+
+procedure ncurses2.acs_and_scroll is
+
+
+ Macro_Quit : constant Key_Code := Character'Pos ('Q') mod 16#20#;
+ Macro_Escape : constant Key_Code := Character'Pos ('[') mod 16#20#;
+
+ Quit : constant Key_Code := CTRL ('Q');
+ Escape : constant Key_Code := CTRL ('[');
+
+
+ Botlines : constant Line_Position := 4;
+
+ type pair is record
+ y : Line_Position;
+ x : Column_Position;
+ end record;
+
+ type Frame;
+ type FrameA is access Frame;
+
+ f : File_Type;
+ dumpfile : constant String := "screendump";
+
+ procedure Outerbox (ul, lr : pair; onoff : Boolean);
+ function HaveKeyPad (w : Window) return Boolean;
+ function HaveScroll (w : Window) return Boolean;
+ procedure newwin_legend (curpw : Window);
+ procedure transient (curpw : Window; msg : String);
+ procedure newwin_report (win : Window := Standard_Window);
+ procedure selectcell (uli : Line_Position;
+ ulj : Column_Position;
+ lri : Line_Position;
+ lrj : Column_Position;
+ p : out pair;
+ b : out Boolean);
+ function getwindow return Window;
+ procedure newwin_move (win : Window;
+ dy : Line_Position;
+ dx : Column_Position);
+ function delete_framed (fp : FrameA; showit : Boolean) return FrameA;
+
+ use Ada.Streams.Stream_IO;
+
+
+ -- A linked list
+ -- I wish there was a standard library linked list. Oh well.
+ type Frame is record
+ next, last : FrameA;
+ do_scroll : Boolean;
+ do_keypad : Boolean;
+ wind : Window;
+ end record;
+
+ current : FrameA;
+
+ c : Key_Code;
+
+ procedure Outerbox (ul, lr : pair; onoff : Boolean) is
+ begin
+ if onoff then
+ -- Note the fix of an obscure bug
+ -- try making a 1x1 box then enlarging it, the is a blank
+ -- upper left corner!
+ Add (Line => ul.y - 1, Column => ul.x - 1,
+ Ch => ACS_Map (ACS_Upper_Left_Corner));
+ Add (Line => ul.y - 1, Column => lr.x + 1,
+ Ch => ACS_Map (ACS_Upper_Right_Corner));
+ Add (Line => lr.y + 1, Column => lr.x + 1,
+ Ch => ACS_Map (ACS_Lower_Right_Corner));
+ Add (Line => lr.y + 1, Column => ul.x - 1,
+ Ch => ACS_Map (ACS_Lower_Left_Corner));
+
+ Move_Cursor (Line => ul.y - 1, Column => ul.x);
+ Horizontal_Line (Line_Symbol => ACS_Map (ACS_Horizontal_Line),
+ Line_Size => Integer (lr.x - ul.x) + 1);
+ Move_Cursor (Line => ul.y, Column => ul.x - 1);
+ Vertical_Line (Line_Symbol => ACS_Map (ACS_Vertical_Line),
+ Line_Size => Integer (lr.y - ul.y) + 1);
+ Move_Cursor (Line => lr.y + 1, Column => ul.x);
+ Horizontal_Line (Line_Symbol => ACS_Map (ACS_Horizontal_Line),
+ Line_Size => Integer (lr.x - ul.x) + 1);
+ Move_Cursor (Line => ul.y, Column => lr.x + 1);
+ Vertical_Line (Line_Symbol => ACS_Map (ACS_Vertical_Line),
+ Line_Size => Integer (lr.y - ul.y) + 1);
+ else
+ Add (Line => ul.y - 1, Column => ul.x - 1, Ch => ' ');
+ Add (Line => ul.y - 1, Column => lr.x + 1, Ch => ' ');
+ Add (Line => lr.y + 1, Column => lr.x + 1, Ch => ' ');
+ Add (Line => lr.y + 1, Column => ul.x - 1, Ch => ' ');
+
+ Move_Cursor (Line => ul.y - 1, Column => ul.x);
+ Horizontal_Line (Line_Symbol => Blank2,
+ Line_Size => Integer (lr.x - ul.x) + 1);
+ Move_Cursor (Line => ul.y, Column => ul.x - 1);
+ Vertical_Line (Line_Symbol => Blank2,
+ Line_Size => Integer (lr.y - ul.y) + 1);
+ Move_Cursor (Line => lr.y + 1, Column => ul.x);
+ Horizontal_Line (Line_Symbol => Blank2,
+ Line_Size => Integer (lr.x - ul.x) + 1);
+ Move_Cursor (Line => ul.y, Column => lr.x + 1);
+ Vertical_Line (Line_Symbol => Blank2,
+ Line_Size => Integer (lr.y - ul.y) + 1);
+ end if;
+ end Outerbox;
+
+ function HaveKeyPad (w : Window) return Boolean is
+ begin
+ return Get_KeyPad_Mode (w);
+ exception
+ when Curses_Exception => return False;
+ end HaveKeyPad;
+
+ function HaveScroll (w : Window) return Boolean is
+ begin
+ return Scrolling_Allowed (w);
+ exception
+ when Curses_Exception => return False;
+ end HaveScroll;
+
+
+ procedure newwin_legend (curpw : Window) is
+
+ package p is new genericPuts (200);
+ use p;
+ use p.BS;
+
+ type string_a is access String;
+
+ type rrr is record
+ msg : string_a;
+ code : Integer range 0 .. 3;
+ end record;
+
+ legend : constant array (Positive range <>) of rrr :=
+ (
+ (
+ new String'("^C = create window"), 0
+ ),
+ (
+ new String'("^N = next window"), 0
+ ),
+ (
+ new String'("^P = previous window"), 0
+ ),
+ (
+ new String'("^F = scroll forward"), 0
+ ),
+ (
+ new String'("^B = scroll backward"), 0
+ ),
+ (
+ new String'("^K = keypad(%s)"), 1
+ ),
+ (
+ new String'("^S = scrollok(%s)"), 2
+ ),
+ (
+ new String'("^W = save window to file"), 0
+ ),
+ (
+ new String'("^R = restore window"), 0
+ ),
+ (
+ new String'("^X = resize"), 0
+ ),
+ (
+ new String'("^Q%s = exit"), 3
+ )
+ );
+
+ buf : Bounded_String;
+ do_keypad : Boolean := HaveKeyPad (curpw);
+ do_scroll : Boolean := HaveScroll (curpw);
+
+ pos : Natural;
+
+ mypair : pair;
+
+ use Ada.Strings.Fixed;
+
+ begin
+ Move_Cursor (Line => Lines - 4, Column => 0);
+ for n in legend'Range loop
+ pos := Ada.Strings.Fixed.Index (Source => legend (n).msg.all,
+ Pattern => "%s");
+ -- buf := (others => ' ');
+ buf := To_Bounded_String (legend (n).msg.all);
+ case legend (n).code is
+ when 0 => null;
+ when 1 =>
+ if do_keypad then
+ Replace_Slice (buf, pos, pos + 1, "yes");
+ else
+ Replace_Slice (buf, pos, pos + 1, "no");
+ end if;
+ when 2 =>
+ if do_scroll then
+ Replace_Slice (buf, pos, pos + 1, "yes");
+ else
+ Replace_Slice (buf, pos, pos + 1, "no");
+ end if;
+ when 3 =>
+ if do_keypad then
+ Replace_Slice (buf, pos, pos + 1, "/ESC");
+ else
+ Replace_Slice (buf, pos, pos + 1, "");
+ end if;
+ end case;
+ Get_Cursor_Position (Line => mypair.y, Column => mypair.x);
+ if Columns < mypair.x + 3 + Column_Position (Length (buf)) then
+ Add (Ch => newl);
+ elsif n /= 1 then -- n /= legen'First
+ Add (Str => ", ");
+ end if;
+ myAdd (Str => buf);
+ end loop;
+ Clear_To_End_Of_Line;
+ end newwin_legend;
+
+
+ procedure transient (curpw : Window; msg : String) is
+ begin
+ newwin_legend (curpw);
+ if msg /= "" then
+ Add (Line => Lines - 1, Column => 0, Str => msg);
+ Refresh;
+ Nap_Milli_Seconds (1000);
+ end if;
+
+ Move_Cursor (Line => Lines - 1, Column => 0);
+
+ if HaveKeyPad (curpw) then
+ Add (Str => "Non-arrow");
+ else
+ Add (Str => "All other");
+ end if;
+ Add (str => " characters are echoed, window should ");
+ if not HaveScroll (curpw) then
+ Add (Str => "not ");
+ end if;
+ Add (str => "scroll");
+
+ Clear_To_End_Of_Line;
+ end transient;
+
+
+ procedure newwin_report (win : Window := Standard_Window) is
+ y : Line_Position;
+ x : Column_Position;
+ use Int_IO;
+ tmp2a : String (1 .. 2);
+ tmp2b : String (1 .. 2);
+ begin
+ if win /= Standard_Window then
+ transient (win, "");
+ end if;
+ Get_Cursor_Position (win, y, x);
+ Move_Cursor (Line => Lines - 1, Column => Columns - 17);
+ Put (tmp2a, Integer (y));
+ Put (tmp2b, Integer (x));
+ Add (Str => "Y = " & tmp2a & " X = " & tmp2b);
+ if win /= Standard_Window then
+ Refresh;
+ else
+ Move_Cursor (win, y, x);
+ end if;
+ end newwin_report;
+
+ procedure selectcell (uli : Line_Position;
+ ulj : Column_Position;
+ lri : Line_Position;
+ lrj : Column_Position;
+ p : out pair;
+ b : out Boolean) is
+ c : Key_Code;
+ res : pair;
+ i : Line_Position := 0;
+ j : Column_Position := 0;
+ si : Line_Position := lri - uli + 1;
+ sj : Column_Position := lrj - ulj + 1;
+ begin
+ res.y := uli;
+ res.x := ulj;
+ loop
+ Move_Cursor (Line => uli + i, Column => ulj + j);
+ newwin_report;
+
+ c := Getchar;
+ case c is
+ when
+ Macro_Quit |
+ Macro_Escape =>
+ -- on the same line macro calls interfere due to the # comment
+ -- this is needed because keypad off affects all windows.
+ -- try removing the ESCAPE and see what happens.
+ b := False;
+ return;
+ when KEY_UP =>
+ i := i + si - 1;
+ -- same as i := i - 1 because of Modulus arithetic,
+ -- on Line_Position, which is a Natural
+ -- the C version uses this form too, interestingly.
+ when KEY_DOWN =>
+ i := i + 1;
+ when KEY_LEFT =>
+ j := j + sj - 1;
+ when KEY_RIGHT =>
+ j := j + 1;
+ when Key_Mouse =>
+ declare
+ event : Mouse_Event;
+ y : Line_Position;
+ x : Column_Position;
+ Button : Mouse_Button;
+ State : Button_State;
+
+ begin
+ event := Get_Mouse;
+ Get_Event (Event => event,
+ Y => y,
+ X => x,
+ Button => Button,
+ State => State);
+ if y > uli and x > ulj then
+ i := y - uli;
+ j := x - ulj;
+ -- same as when others =>
+ res.y := uli + i;
+ res.x := ulj + j;
+ p := res;
+ b := True;
+ return;
+ else
+ Beep;
+ end if;
+ end;
+ when others =>
+ res.y := uli + i;
+ res.x := ulj + j;
+ p := res;
+ b := True;
+ return;
+ end case;
+ i := i mod si;
+ j := j mod sj;
+ end loop;
+ end selectcell;
+
+
+ function getwindow return Window is
+ rwindow : Window;
+ ul, lr : pair;
+ result : Boolean;
+ begin
+ Move_Cursor (Line => 0, Column => 0);
+ Clear_To_End_Of_Line;
+ Add (Str => "Use arrows to move cursor, anything else to mark corner 1");
+ Refresh;
+ selectcell (2, 1, Lines - Botlines - 2, Columns - 2, ul, result);
+ if not result then
+ return Null_Window;
+ end if;
+ Add (Line => ul.y - 1, Column => ul.x - 1,
+ Ch => ACS_Map (ACS_Upper_Left_Corner));
+ Move_Cursor (Line => 0, Column => 0);
+ Clear_To_End_Of_Line;
+ Add (Str => "Use arrows to move cursor, anything else to mark corner 2");
+ Refresh;
+ selectcell (ul.y, ul.x, Lines - Botlines - 2, Columns - 2, lr, result);
+ if not result then
+ return Null_Window;
+ end if;
+
+ rwindow := Sub_Window (Number_Of_Lines => lr.y - ul.y + 1,
+ Number_Of_Columns => lr.x - ul.x + 1,
+ First_Line_Position => ul.y,
+ First_Column_Position => ul.x);
+
+ Outerbox (ul, lr, True);
+ Refresh;
+
+ Refresh (rwindow);
+
+ Move_Cursor (Line => 0, Column => 0);
+ Clear_To_End_Of_Line;
+ return rwindow;
+ end getwindow;
+
+
+ procedure newwin_move (win : Window;
+ dy : Line_Position;
+ dx : Column_Position) is
+ cur_y, max_y : Line_Position;
+ cur_x, max_x : Column_Position;
+ begin
+ Get_Cursor_Position (win, cur_y, cur_x);
+ Get_Size (win, max_y, max_x);
+ cur_x := Column_Position'Min (Column_Position'Max (cur_x + dx, 0),
+ max_x - 1);
+ cur_y := Line_Position'Min (Line_Position'Max (cur_y + dy, 0),
+ max_y - 1);
+
+ Move_Cursor (win, Line => cur_y, Column => cur_x);
+ end newwin_move;
+
+ function delete_framed (fp : FrameA; showit : Boolean) return FrameA is
+ np : FrameA;
+ begin
+ fp.last.next := fp.next;
+ fp.next.last := fp.last;
+
+ if showit then
+ Erase (fp.wind);
+ Refresh (fp.wind);
+ end if;
+ Delete (fp.wind);
+
+ if fp = fp.next then
+ np := null;
+ else
+ np := fp.next;
+ end if;
+ -- TODO free(fp);
+ return np;
+ end delete_framed;
+
+ Mask : Event_Mask := No_Events;
+ Mask2 : Event_Mask;
+
+ usescr : Window;
+
+begin
+ if Has_Mouse then
+ Register_Reportable_Event (
+ Button => Left,
+ State => Clicked,
+ Mask => Mask);
+ Mask2 := Start_Mouse (Mask);
+ end if;
+ c := CTRL ('C');
+ Set_Raw_Mode (SwitchOn => True);
+ loop
+ transient (Standard_Window, "");
+ case c is
+ when Character'Pos ('c') mod 16#20# => -- Ctrl('c')
+ declare
+ neww : FrameA := new Frame'(null, null, False, False,
+ Null_Window);
+ begin
+ neww.wind := getwindow;
+ if neww.wind = Null_Window then
+ exit;
+ -- was goto breakout; ha ha ha
+ else
+
+ if current = null then
+ neww.next := neww;
+ neww.last := neww;
+ else
+ neww.next := current.next;
+ neww.last := current;
+ neww.last.next := neww;
+ neww.next.last := neww;
+ end if;
+ current := neww;
+
+ Set_KeyPad_Mode (current.wind, True);
+ current.do_keypad := HaveKeyPad (current.wind);
+ current.do_scroll := HaveScroll (current.wind);
+ end if;
+ end;
+ when Character'Pos ('N') mod 16#20# => -- Ctrl('N')
+ if current /= null then
+ current := current.next;
+ end if;
+ when Character'Pos ('P') mod 16#20# => -- Ctrl('P')
+ if current /= null then
+ current := current.last;
+ end if;
+ when Character'Pos ('F') mod 16#20# => -- Ctrl('F')
+ if current /= null and HaveScroll (current.wind) then
+ Scroll (current.wind, 1);
+ end if;
+ when Character'Pos ('B') mod 16#20# => -- Ctrl('B')
+ if current /= null and HaveScroll (current.wind) then
+ -- The C version of Scroll may return ERR which is ignored
+ -- we need to avoid the exception
+ -- with the 'and HaveScroll(current.wind)'
+ Scroll (current.wind, -1);
+ end if;
+ when Character'Pos ('K') mod 16#20# => -- Ctrl('K')
+ if current /= null then
+ current.do_keypad := not current.do_keypad;
+ Set_KeyPad_Mode (current.wind, current.do_keypad);
+ end if;
+ when Character'Pos ('S') mod 16#20# => -- Ctrl('S')
+ if current /= null then
+ current.do_scroll := not current.do_scroll;
+ Allow_Scrolling (current.wind, current.do_scroll);
+ end if;
+ when Character'Pos ('W') mod 16#20# => -- Ctrl('W')
+ if current /= current.next then
+ Create (f, Name => dumpfile); -- TODO error checking
+ if not Is_Open (f) then
+ raise Curses_Exception;
+ end if;
+ Put_Window (current.wind, f);
+ Close (f);
+ current := delete_framed (current, True);
+ end if;
+ when Character'Pos ('R') mod 16#20# => -- Ctrl('R')
+ declare
+ neww : FrameA := new Frame'(null, null, False, False,
+ Null_Window);
+ begin
+ Open (f, Mode => In_File, Name => dumpfile);
+ neww := new Frame'(null, null, False, False, Null_Window);
+
+ neww.next := current.next;
+ neww.last := current;
+ neww.last.next := neww;
+ neww.next.last := neww;
+
+ neww.wind := Get_Window (f);
+ Close (f);
+
+ Refresh (neww.wind);
+ end;
+ when Character'Pos ('X') mod 16#20# => -- Ctrl('X')
+ if current /= null then
+ declare
+ tmp, ul, lr : pair;
+ mx : Column_Position;
+ my : Line_Position;
+ tmpbool : Boolean;
+ begin
+ Move_Cursor (Line => 0, Column => 0);
+ Clear_To_End_Of_Line;
+ Add (Str => "Use arrows to move cursor, anything else " &
+ "to mark new corner");
+ Refresh;
+
+ Get_Window_Position (current.wind, ul.y, ul.x);
+
+ selectcell (ul.y, ul.x, Lines - Botlines - 2, Columns - 2,
+ tmp, tmpbool);
+ if not tmpbool then
+ -- the C version had a goto. I refuse gotos.
+ Beep;
+ else
+ Get_Size (current.wind, lr.y, lr.x);
+ lr.y := lr.y + ul.y - 1;
+ lr.x := lr.x + ul.x - 1;
+ Outerbox (ul, lr, False);
+ Refresh_Without_Update;
+
+ Get_Size (current.wind, my, mx);
+ if my > tmp.y - ul.y then
+ Get_Cursor_Position (current.wind, lr.y, lr.x);
+ Move_Cursor (current.wind, tmp.y - ul.y + 1, 0);
+ Clear_To_End_Of_Screen (current.wind);
+ Move_Cursor (current.wind, lr.y, lr.x);
+ end if;
+ if mx > tmp.x - ul.x then
+ for i in 0 .. my - 1 loop
+ Move_Cursor (current.wind, i, tmp.x - ul.x + 1);
+ Clear_To_End_Of_Line (current.wind);
+ end loop;
+ end if;
+ Refresh_Without_Update (current.wind);
+
+ lr := tmp;
+ -- The C version passes invalid args to resize
+ -- which returns an ERR. For Ada we avoid the exception.
+ if lr.y /= ul.y and lr.x /= ul.x then
+ Resize (current.wind, lr.y - ul.y + 0,
+ lr.x - ul.x + 0);
+ end if;
+
+ Get_Window_Position (current.wind, ul.y, ul.x);
+ Get_Size (current.wind, lr.y, lr.x);
+ lr.y := lr.y + ul.y - 1;
+ lr.x := lr.x + ul.x - 1;
+ Outerbox (ul, lr, True);
+ Refresh_Without_Update;
+
+ Refresh_Without_Update (current.wind);
+ Move_Cursor (Line => 0, Column => 0);
+ Clear_To_End_Of_Line;
+ Update_Screen;
+ end if;
+ end;
+ end if;
+ when Key_F10 =>
+ declare tmp : pair; tmpbool : Boolean;
+ begin
+ -- undocumented --- use this to test area clears
+ selectcell (0, 0, Lines - 1, Columns - 1, tmp, tmpbool);
+ Clear_To_End_Of_Screen;
+ Refresh;
+ end;
+ when Key_Cursor_Up =>
+ newwin_move (current.wind, -1, 0);
+ when Key_Cursor_Down =>
+ newwin_move (current.wind, 1, 0);
+ when Key_Cursor_Left =>
+ newwin_move (current.wind, 0, -1);
+ when Key_Cursor_Right =>
+ newwin_move (current.wind, 0, 1);
+ when Key_Backspace | Key_Delete_Char =>
+ declare
+ y : Line_Position;
+ x : Column_Position;
+ tmp : Line_Position;
+ begin
+ Get_Cursor_Position (current.wind, y, x);
+ -- x := x - 1;
+ -- I got tricked by the -1 = Max_Natural - 1 result
+ -- y := y - 1;
+ if not (x = 0 and y = 0) then
+ if x = 0 then
+ y := y - 1;
+ Get_Size (current.wind, tmp, x);
+ end if;
+ x := x - 1;
+ Delete_Character (current.wind, y, x);
+ end if;
+ end;
+ when others =>
+ -- TODO c = '\r' ?
+ if current /= null then
+ declare
+ begin
+ Add (current.wind, Ch => Code_To_Char (c));
+ exception
+ when Curses_Exception => null;
+ -- this happens if we are at the
+ -- lower right of a window and add a character.
+ end;
+ else
+ Beep;
+ end if;
+ end case;
+ newwin_report (current.wind);
+ if current /= null then
+ usescr := current.wind;
+ else
+ usescr := Standard_Window;
+ end if;
+ Refresh (usescr);
+ c := Getchar (usescr);
+ exit when c = Quit or (c = Escape and HaveKeyPad (usescr));
+ -- TODO when does c = ERR happen?
+ end loop;
+
+ -- TODO while current /= null loop
+ -- current := delete_framed(current, False);
+ -- end loop;
+
+ Allow_Scrolling (Mode => True);
+
+ End_Mouse;
+ Set_Raw_Mode (SwitchOn => True);
+ Erase;
+ End_Windows;
+
+end ncurses2.acs_and_scroll;
--- /dev/null
+------------------------------------------------------------------------------
+-- --
+-- GNAT ncurses Binding Samples --
+-- --
+-- ncurses --
+-- --
+-- B O D Y --
+-- --
+------------------------------------------------------------------------------
+-- Copyright (c) 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: Eugene V. Melaragno <aldomel@ix.netcom.com> 2000
+-- Version Control
+-- $Revision: 1.1 $
+-- Binding Version 01.00
+------------------------------------------------------------------------------
+procedure ncurses2.acs_and_scroll;
--- /dev/null
+------------------------------------------------------------------------------
+-- --
+-- GNAT ncurses Binding Samples --
+-- --
+-- ncurses --
+-- --
+-- B O D Y --
+-- --
+------------------------------------------------------------------------------
+-- Copyright (c) 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: Eugene V. Melaragno <aldomel@ix.netcom.com> 2000
+-- Version Control
+-- $Revision: 1.1 $
+-- Binding Version 01.00
+------------------------------------------------------------------------------
+with ncurses2.util; use ncurses2.util;
+with ncurses2.genericPuts;
+with Terminal_Interface.Curses; use Terminal_Interface.Curses;
+
+with Ada.Strings.Unbounded;
+with Ada.Strings.Fixed;
+
+procedure ncurses2.acs_display is
+ use Int_IO;
+
+ procedure show_upper_chars (first : Integer);
+ function show_1_acs (N : Integer;
+ name : String;
+ code : Attributed_Character)
+ return Integer;
+ procedure show_acs_chars;
+
+
+ procedure show_upper_chars (first : Integer) is
+ C1 : Boolean := (first = 128);
+ last : Integer := first + 31;
+ package p is new ncurses2.genericPuts (200);
+ use p;
+ use p.BS;
+ use Ada.Strings.Unbounded;
+
+ tmpa : Unbounded_String;
+ tmpb : BS.Bounded_String;
+ begin
+ Erase;
+ Switch_Character_Attribute
+ (Attr => (Bold_Character => True, others => False));
+ Move_Cursor (Line => 0, Column => 20);
+ tmpa := To_Unbounded_String ("Display of ");
+ if C1 then
+ tmpa := tmpa & "C1";
+ else
+ tmpa := tmpa & "GR";
+ end if;
+ tmpa := tmpa & " Character Codes ";
+ myPut (tmpb, first);
+ Append (tmpa, To_String (tmpb));
+ Append (tmpa, " to ");
+ myPut (tmpb, last);
+ Append (tmpa, To_String (tmpb));
+ Add (Str => To_String (tmpa));
+ Switch_Character_Attribute
+ (On => False,
+ Attr => (Bold_Character => True, others => False));
+ Refresh;
+
+ for code in first .. last loop
+ declare
+ row : Line_Position := Line_Position (4 + ((code - first) mod 16));
+ col : Column_Position := Column_Position (((code - first) / 16) *
+ Integer (Columns) / 2);
+ tmp3 : String (1 .. 3);
+ tmpx : String (1 .. Integer (Columns / 4));
+ reply : Key_Code;
+ begin
+ Put (tmp3, code);
+ myPut (tmpb, code, 16);
+ tmpa := To_Unbounded_String (tmp3 & " (" & To_String (tmpb) & ')');
+
+ Ada.Strings.Fixed.Move (To_String (tmpa), tmpx,
+ Justify => Ada.Strings.Right);
+ Add (Line => row, Column => col,
+ Str => tmpx & ' ' & ':' & ' ');
+ if C1 then
+ Set_NoDelay_Mode (Mode => True);
+ end if;
+ Add_With_Immediate_Echo (Ch => Code_To_Char (Key_Code (code)));
+ -- TODO check this
+ if C1 then
+ reply := Getchar;
+ while reply /= Key_None loop
+ Add (Ch => Code_To_Char (reply));
+ Nap_Milli_Seconds (10);
+ reply := Getchar;
+ end loop;
+ Set_NoDelay_Mode (Mode => False);
+ end if;
+ end;
+ end loop;
+ end show_upper_chars;
+
+ function show_1_acs (N : Integer;
+ name : String;
+ code : Attributed_Character)
+ return Integer is
+ height : constant Integer := 16;
+ row : Line_Position := Line_Position (4 + (N mod height));
+ col : Column_Position := Column_Position ((N / height) *
+ Integer (Columns) / 2);
+ tmpx : String (1 .. Integer (Columns) / 3);
+ begin
+ Ada.Strings.Fixed.Move (name, tmpx,
+ Justify => Ada.Strings.Right,
+ Drop => Ada.Strings.Left);
+ Add (Line => row, Column => col, Str => tmpx & ' ' & ':' & ' ');
+ -- we need more room than C because our identifiers are longer
+ -- 22 chars actually
+ Add (Ch => code);
+ return N + 1;
+ end show_1_acs;
+
+ procedure show_acs_chars is
+ n : Integer;
+ begin
+ Erase;
+ Switch_Character_Attribute
+ (Attr => (Bold_Character => True, others => False));
+ Add (Line => 0, Column => 20,
+ Str => "Display of the ACS Character Set");
+ Switch_Character_Attribute (On => False,
+ Attr => (Bold_Character => True,
+ others => False));
+ Refresh;
+
+ -- the following is useful to generate the below
+ -- grep '^[ ]*ACS_' ../src/terminal_interface-curses.ads |
+ -- awk '{print "n := show_1_acs(n, \""$1"\", ACS_Map("$1"));"}'
+
+ n := show_1_acs (0, "ACS_Upper_Left_Corner",
+ ACS_Map (ACS_Upper_Left_Corner));
+ n := show_1_acs (n, "ACS_Lower_Left_Corner",
+ ACS_Map (ACS_Lower_Left_Corner));
+ n := show_1_acs (n, "ACS_Upper_Right_Corner",
+ ACS_Map (ACS_Upper_Right_Corner));
+ n := show_1_acs (n, "ACS_Lower_Right_Corner",
+ ACS_Map (ACS_Lower_Right_Corner));
+ n := show_1_acs (n, "ACS_Left_Tee", ACS_Map (ACS_Left_Tee));
+ n := show_1_acs (n, "ACS_Right_Tee", ACS_Map (ACS_Right_Tee));
+ n := show_1_acs (n, "ACS_Bottom_Tee", ACS_Map (ACS_Bottom_Tee));
+ n := show_1_acs (n, "ACS_Top_Tee", ACS_Map (ACS_Top_Tee));
+ n := show_1_acs (n, "ACS_Horizontal_Line",
+ ACS_Map (ACS_Horizontal_Line));
+ n := show_1_acs (n, "ACS_Vertical_Line", ACS_Map (ACS_Vertical_Line));
+ n := show_1_acs (n, "ACS_Plus_Symbol", ACS_Map (ACS_Plus_Symbol));
+ n := show_1_acs (n, "ACS_Scan_Line_1", ACS_Map (ACS_Scan_Line_1));
+ n := show_1_acs (n, "ACS_Scan_Line_9", ACS_Map (ACS_Scan_Line_9));
+ n := show_1_acs (n, "ACS_Diamond", ACS_Map (ACS_Diamond));
+ n := show_1_acs (n, "ACS_Checker_Board", ACS_Map (ACS_Checker_Board));
+ n := show_1_acs (n, "ACS_Degree", ACS_Map (ACS_Degree));
+ n := show_1_acs (n, "ACS_Plus_Minus", ACS_Map (ACS_Plus_Minus));
+ n := show_1_acs (n, "ACS_Bullet", ACS_Map (ACS_Bullet));
+ n := show_1_acs (n, "ACS_Left_Arrow", ACS_Map (ACS_Left_Arrow));
+ n := show_1_acs (n, "ACS_Right_Arrow", ACS_Map (ACS_Right_Arrow));
+ n := show_1_acs (n, "ACS_Down_Arrow", ACS_Map (ACS_Down_Arrow));
+ n := show_1_acs (n, "ACS_Up_Arrow", ACS_Map (ACS_Up_Arrow));
+ n := show_1_acs (n, "ACS_Board_Of_Squares",
+ ACS_Map (ACS_Board_Of_Squares));
+ n := show_1_acs (n, "ACS_Lantern", ACS_Map (ACS_Lantern));
+ n := show_1_acs (n, "ACS_Solid_Block", ACS_Map (ACS_Solid_Block));
+ n := show_1_acs (n, "ACS_Scan_Line_3", ACS_Map (ACS_Scan_Line_3));
+ n := show_1_acs (n, "ACS_Scan_Line_7", ACS_Map (ACS_Scan_Line_7));
+ n := show_1_acs (n, "ACS_Less_Or_Equal", ACS_Map (ACS_Less_Or_Equal));
+ n := show_1_acs (n, "ACS_Greater_Or_Equal",
+ ACS_Map (ACS_Greater_Or_Equal));
+ n := show_1_acs (n, "ACS_PI", ACS_Map (ACS_PI));
+ n := show_1_acs (n, "ACS_Not_Equal", ACS_Map (ACS_Not_Equal));
+ n := show_1_acs (n, "ACS_Sterling", ACS_Map (ACS_Sterling));
+
+ end show_acs_chars;
+
+ c1 : Key_Code;
+ c : Character := 'a';
+begin
+ loop
+ case c is
+ when 'a' =>
+ show_acs_chars;
+ when '0' | '1' | '2' | '3' =>
+ show_upper_chars (ctoi (c) * 32 + 128);
+ when others =>
+ null;
+ end case;
+ Add (Line => Lines - 3, Column => 0,
+ Str => "Note: ANSI terminals may not display C1 characters.");
+ Add (Line => Lines - 2, Column => 0,
+ Str => "Select: a=ACS, 0=C1, 1,2,3=GR characters, q=quit");
+ Refresh;
+ c1 := Getchar;
+ c := Code_To_Char (c1);
+ exit when c = 'q' or c = 'x';
+ end loop;
+ Pause;
+ Erase;
+ End_Windows;
+end ncurses2.acs_display;
+
--- /dev/null
+------------------------------------------------------------------------------
+-- --
+-- GNAT ncurses Binding Samples --
+-- --
+-- ncurses --
+-- --
+-- B O D Y --
+-- --
+------------------------------------------------------------------------------
+-- Copyright (c) 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: Eugene V. Melaragno <aldomel@ix.netcom.com> 2000
+-- Version Control
+-- $Revision: 1.1 $
+-- Binding Version 01.00
+------------------------------------------------------------------------------
+procedure ncurses2.acs_display;
--- /dev/null
+------------------------------------------------------------------------------
+-- --
+-- GNAT ncurses Binding Samples --
+-- --
+-- ncurses --
+-- --
+-- B O D Y --
+-- --
+------------------------------------------------------------------------------
+-- Copyright (c) 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: Eugene V. Melaragno <aldomel@ix.netcom.com> 2000
+-- Version Control
+-- $Revision: 1.2 $
+-- Binding Version 01.00
+------------------------------------------------------------------------------
+with ncurses2.util; use ncurses2.util;
+with Terminal_Interface.Curses; use Terminal_Interface.Curses;
+with Terminal_Interface.Curses.Terminfo;
+use Terminal_Interface.Curses.Terminfo;
+with Ada.Characters.Handling;
+with Ada.Strings.Fixed;
+
+procedure ncurses2.attr_test is
+
+ function subset (super, sub : Character_Attribute_Set) return Boolean;
+ function intersect (b, a : Character_Attribute_Set) return Boolean;
+ function has_A_COLOR (attr : Attributed_Character) return Boolean;
+ function show_attr (row : Line_Position;
+ skip : Natural;
+ &nb