Binding to the [wn]curses library. From the ncurses man page:
The curses library routines give the user a terminal-inde-
pendent method of updating character screens with reason-
Sections of the quoted documentation are from the OpenBSD man pages,
which are distributed under a BSD license.
A useful reference is:
Writing Programs with NCURSES, by Eric S. Raymond and Zeyd
M. Ben-Halim, http://dickey.his.com/ncurses/
attrs dont work with Irix curses.h. This should be fixed.
|Start it all up
|A bunch of settings we need
|The standard screen
The program must call endwin for each terminal being used before
exiting from curses.
|Enable the keypad of the user's terminal.
|get the dimensions of the screen
|refresh curses windows and lines. curs_refresh(3)
read a character from the window
When ESC followed by another key is pressed before the ESC timeout,
that second character is not returned until a third character is
pressed. wtimeout, nodelay and timeout don't appear to change this
On emacs, we really would want Alt to be our meta key, I think.
Be warned, getCh will block the whole process without noDelay
move the cursor associated with the window
to line y and column x. This routine does not move the
physical cursor of the terminal until refresh is called.
The position specified is relative to the upper left-hand
corner of the window, which is (0,0).
|Some constants for easy symbolic manipulation.
NB we don't map keys to an abstract type anymore, as we can't use
Alex lexers then.
Set the cursor state
The curs_set routine sets the cursor state is set to
invisible, normal, or very visible for visibility equal to
0, 1, or 2 respectively. If the terminal supports the
visibility requested, the previous cursor state is
returned; otherwise, ERR is returned.
|Get the current cursor coordinates
curses support color attributes on terminals with that
capability. To use these routines start_color must be
called, usually right after initscr. Colors are always
used in pairs (referred to as color-pairs). A color-pair
consists of a foreground color (for characters) and a
background color (for the blank field on which the charac-
ters are displayed). A programmer initializes a color-
pair with the routine init_pair. After it has been ini-
tialized, COLOR_PAIR(n), a macro defined in <curses.h>,
can be used as a new video attribute.
If a terminal is capable of redefining colors, the pro-
grammer can use the routine init_color to change the defi-
nition of a color.
The init_pair routine changes the definition of a color-
pair. It takes three arguments: the number of the color-
pair to be changed, the foreground color number, and the
background color number. For portable applications:
- The value of the first argument must be between 1 and
- The value of the second and third arguments must be
between 0 and COLORS (the 0 color pair is wired to
white on black and cannot be changed).
|Produced by Haddock version 2.4.2|