Curses

Curses

Curses based applications should be linked with -lcurses and _not_ with
-ltermlib. It has also been reported that some problems with curses are
avoided if your application is compiled with -DNLS.

Peter Jeffe also notes:

>the escape sequences for cursor and function keys are *sometimes*
>treated as several characters: eg. the getch() - call does not return
>KEY_UP but 'ESC [ C.'

You're correct in your analysis: this has to do with the timing of the
escape sequence as it arrives from the net. There is an environment
variable called ESCDELAY that can change the fudge factor used to decide
when an escape is just an escape. The default value is 500; boosting
this a bit should solve your problems.

Christopher Carlyle O'Callaghan has more comments
concerning extended curses:

1) The sample program in User Interface Programming Concepts, page 7-13
is WRONG. Here is the correct use of panes and panels.

#include
#include

main()
{
PANE *A, *B, *C, *D, *E, *F, *G, *H;
PANEL *P;

initscr();

A = ecbpns (24, 79, NULL, NULL, 0, 2500, Pdivszp, Pbordry, NULL, NULL);
D = ecbpns (24, 79, NULL, NULL, 0, 0, Pdivszf, Pbordry, NULL, NULL);
E = ecbpns (24, 79, D, NULL, 0, 0, Pdivszf, Pbordry, NULL, NULL);
B = ecbpns (24, 79, A, D, Pdivtyh, 3000, Pdivszp, Pbordry, NULL, NULL);
F = ecbpns (24, 79, NULL, NULL, 0, 0, Pdivszf, Pbordry, NULL, NULL);
G = ecbpns (24, 79, F, NULL, 0, 5000, Pdivszp, Pbordry, NULL, NULL);
H = ecbpns (24, 79, G, NULL, 0, 3000, Pdivszp, Pbordry, NULL, NULL);
C = ecbpns (24, 79, B, F, Pdivtyh, 0, Pdivszf, Pbordry, NULL, NULL);
P = ecbpls (24, 79, 0, 0, "MAIN PANEL", Pdivtyv, Pbordry, A);

ecdvpl (P);
ecdfpl (P, FALSE);
ecshpl (P);
ecrfpl (P);
endwin();
}

2) DO NOT include and any other file together.
You will get a bunch of redefined statements.

3) There is CURSES and EXTENDED CURSES. Use only one or the other. If the
manual says that they're backwards compatible or some other indication
that you can use CURSES routines with EXTENDED, don't believe it. To
use CURSES you need to include and you can't (see above).

4) If you use -lcur and -lcurses in the same link command, you will get
Memory fault (core dump) error. You CANNOT use both of them at the same
time. -lcur is for extended curses, -lcurses is for regular curses.

5) When creating PANEs, when you supply a value (other than 0) for the
'ds' parameter and use Pdivszf value for the 'du' parameter, the 'ds'
will be ignored (the sample program on page 7-13 in User Interface
Programming Concepts is wrong.) For reasons as yet undetermined,
Pdivszc doesn't seem to work (or at least I can't figure out how to
use it.)

6) If you're running into bugs and can't figure out what is happening,
try the following:
include -qextchk -g in your compile line
-qextchk will check to make sure you're passing the right number of
parameters to the functions
-g enables debug

7) Do not use 80 as the number of columns if you want to use the whole
screen. The lower right corner will get erased. Use 79 instead.

8) If you create a panel, you must create at least 1 pane, otherwise you
will get a Memory fault (core dump).

9) When creating a panel, if you don't have a border around it, any title
you want will not show up.

10) to make the screen scroll down:
wmove (win, 0, 0);
winsertln (win)

11) delwin(win) doesn't work in EXTENDED WINDOWS

To make it appear as if a window is deleted, you need to do the following:
for every window that you want to appear on the screen
touchwin(win)
wrefresh(win)

you must make sure that you do it in the exact same order as you put
them on the screen (i.e., if you called newwin with A, then C, then B,
then you must do the loop with A, then C, then B, otherwise you won't
get the same screen back). The best thing to do is to put them into
an array and keep track of the last window index.

12) mvwin(win, line, col) implies that it is only used for viewports and
subwindows. It can also be used for the actual windows themselves.

13) If you specify the attribute of a window using wcolorout(win), any
subsequent calls to chgat(numchars, mode) or any of its relatives
will not work. (or at least they get very picky.)



Home FAQ