modified by Ulrich Drepper (drepper@karlsruhe.gmd.de)
and Anatoly Ivasyuk (anatoly@nick.csh.rit.edu)
- modified by Juergen Pfeifer (Juergen.Pfeifer@T-Online.de)
+ modified by Juergen Pfeifer (juergen.pfeifer@gmx.net)
*/
#include "cursesw.h"
#include "internal.h"
-MODULE_ID("$Id: cursesw.cc,v 1.10 1997/10/20 21:26:35 juergen Exp $")
+MODULE_ID("$Id: cursesw.cc,v 1.15 1999/09/11 23:26:29 tom Exp $")
#define COLORS_NEED_INITIALIZATION -1
#define COLORS_NOT_INITIALIZED 0
long NCursesWindow::count = 0L;
bool NCursesWindow::b_initialized = FALSE;
+#if defined(__GNUG__)
+# ifndef _IO_va_list
+# define _IO_va_list char *
+# endif
+#endif
+
int
NCursesWindow::scanw(const char* fmt, ...)
{
char buf[BUFSIZ];
int result = wgetstr(w, buf);
if (result == OK) {
- strstreambuf ss(buf, BUFSIZ);
- result = ss.vscan(fmt, args);
+ strstreambuf ss(buf, sizeof(buf));
+ result = ss.vscan(fmt, (_IO_va_list)args);
}
va_end(args);
return result;
if (result == OK) {
result = wgetstr(w, buf);
if (result == OK) {
- strstreambuf ss(buf, BUFSIZ);
- result = ss.vscan(fmt, args);
+ strstreambuf ss(buf, sizeof(buf));
+ result = ss.vscan(fmt, (_IO_va_list)args);
}
}
va_end(args);
NCursesWindow::NCursesWindow() {
if (!b_initialized)
initialize();
-
+
w = (WINDOW *)0;
init();
alloced = FALSE;
{
if (!b_initialized)
initialize();
-
+
w = window;
init();
alloced = FALSE;
NCursesWindow::NCursesWindow(NCursesWindow& win, int l, int c,
int begin_y, int begin_x, char absrel)
{
- if (absrel == 'a') { // absolute origin
+ if (absrel == 'a') { // absolute origin
begin_y -= win.begy();
begin_x -= win.begx();
}
alloced = TRUE;
count++;
}
-
+
+NCursesWindow::NCursesWindow(NCursesWindow& win,
+ bool do_box NCURSES_PARAM_INIT(TRUE))
+{
+ w = :: derwin(win.w,win.height()-2,win.width()-2,1,1);
+ if (w == 0) {
+ err_handler("Cannot construct subwindow");
+ }
+
+ par = &win;
+ sib = win.subwins;
+ win.subwins = this;
+ subwins = 0;
+ alloced = TRUE;
+ count++;
+
+ if (do_box) {
+ win.box();
+ win.touchwin();
+ }
+}
+
NCursesWindow NCursesWindow::Clone() {
WINDOW *d = ::dupwin(w);
NCursesWindow W(d);
void
NCursesWindow::useColors(void)
{
- if (colorInitialized == COLORS_NOT_INITIALIZED) {
+ if (colorInitialized == COLORS_NOT_INITIALIZED) {
if (b_initialized) {
if (::has_colors()) {
::start_color();
}
short
-NCursesWindow::getcolor(int getback) const
+NCursesWindow::getcolor(int getback) const
{
short fore, back;
if (colorInitialized==COLORS_ARE_REALLY_THERE) {
- if (pair_content(PAIR_NUMBER(w->_attrs), &fore, &back))
+ if (pair_content((short)PAIR_NUMBER(w->_attrs), &fore, &back))
err_handler("Can't get color pair");
}
else {
}
short
-NCursesWindow::getcolor() const
+NCursesWindow::getcolor() const
{
if (colorInitialized==COLORS_ARE_REALLY_THERE)
return PAIR_NUMBER(w->_attrs);
NCursesWindow::setpalette(short fore, short back)
{
if (colorInitialized==COLORS_ARE_REALLY_THERE)
- return setpalette(fore, back, PAIR_NUMBER(w->_attrs));
+ return setpalette(fore, back, (short)PAIR_NUMBER(w->_attrs));
else
return OK;
}
if (colorInitialized==COLORS_ARE_REALLY_THERE) {
if ((pair < 1) || (pair > COLOR_PAIRS))
err_handler("Can't set color pair");
-
+
attroff(A_COLOR);
attrset(COLOR_PAIR(pair));
}
extern "C" int _nc_has_mouse(void);
bool NCursesWindow::has_mouse() const {
- return ((::has_key(KEY_MOUSE) || ::_nc_has_mouse())
+ return ((::has_key(KEY_MOUSE) || ::_nc_has_mouse())
? TRUE : FALSE);
}
-
-NCursesPad::NCursesPad(int lines, int cols) : NCursesWindow() {
- w = ::newpad(lines,cols);
- if (w==(WINDOW*)0) {
- count--;
- err_handler("Cannot construct window");
- }
- alloced = TRUE;
-}