The CursesWindow
class is a repackaging of standard
curses library features into a class. It relies on `curses.h'.
The supplied `curses.h' is a fairly conservative declaration of curses library features, and does not include features like "screen" or X-window support. It is, for the most part, an adaptation, rather than an improvement of C-based `curses.h' files. The only substantive changes are the declarations of many functions as inline functions rather than macros, which was done solely to allow overloading.
The CursesWindow
class encapsulates curses window functions
within a class. Only those functions that control windows are included:
Terminal control functions and macros like cbreak
are not part
of the class. All CursesWindows
member functions have names
identical to the corresponding curses library functions, except that the
"w" prefix is generally dropped. Descriptions of these functions may
be found in your local curses library documentation.
A CursesWindow
may be declared via
CursesWindow w(WINDOW* win)
CursesWindow w(stdscr)
CursesWindow w(int lines, int cols, int begin_y, int begin_x)
CursesWindow sub(CursesWindow& w,int l,int c,int by,int bx,char ar='a')
The class maintains a static counter that is used in order to
automatically call the curses library initscr
and endscr
functions at the proper times. These need not, and should not be
called "manually".
CursesWindow
s maintain a tree of their subwindows. Upon
destruction of a CursesWindow
, all of their subwindows are
also invalidated if they had not previously been destroyed.
It is possible to traverse trees of subwindows via the following member functions
CursesWindow* w.parent()
CursesWindow* w.child()
CursesWindow* w.sibling()
For example, to call some function visit
for all subwindows
of a window, you could write
void traverse(CursesWindow& w) { visit(w); if (w.child() != 0) traverse(*w.child); if (w.sibling() != 0) traverse(*w.sibling); }