#include "internal.h"
#include "cursesw.h"
-MODULE_ID("$Id: cursesw.cc,v 1.46 2007/01/27 22:31:12 tom Exp $")
+MODULE_ID("$Id: cursesw.cc,v 1.49 2007/12/15 23:01:57 tom Exp $")
#define COLORS_NEED_INITIALIZATION -1
#define COLORS_NOT_INITIALIZED 0
}
+int
+NCursesWindow::scanw(const char* fmt, va_list args)
+{
+ int result = ERR;
+
+ result = ::vw_scanw (w, const_cast<NCURSES_CONST char *>(fmt), args);
+
+ return result;
+}
+
+
+int
+NCursesWindow::scanw(int y, int x, const char* fmt, va_list args)
+{
+ int result = ERR;
+
+ if (::wmove(w, y, x) != ERR) {
+ result = ::vw_scanw (w, const_cast<NCURSES_CONST char *>(fmt), args);
+ }
+ return result;
+}
+
+
int
NCursesWindow::printw(const char * fmt, ...)
{
}
+int
+NCursesWindow::printw(const char * fmt, va_list args)
+{
+ int result = ::vw_printw(w, fmt, args);
+ return result;
+}
+
+
+int
+NCursesWindow::printw(int y, int x, const char * fmt, va_list args)
+{
+ int result = ::wmove(w, y, x);
+ if (result == OK) {
+ result = ::vw_printw(w, fmt, args);
+ }
+ return result;
+}
+
+
void
NCursesWindow::set_keyboard(void)
{
set_keyboard();
}
-NCursesWindow::NCursesWindow(WINDOW* &window)
+NCursesWindow::NCursesWindow(WINDOW* window)
: w(0), alloced(FALSE), par(0), subwins(0), sib(0)
{
constructing();
- w = window;
+ // We used to use a reference on the "window" parameter, but we cannot do
+ // that with an opaque pointer (see NCURSES_OPAQUE). If the parameter was
+ // "::stdscr", that is first set via the "constructing() call, and is null
+ // up to that point. So we allow a null pointer here as meaning the "same"
+ // as "::stdscr".
+ w = window ? window : ::stdscr;
set_keyboard();
}
}
}
+short
+NCursesWindow::getPair() const
+{
+ return static_cast<short>(PAIR_NUMBER(getattrs(w)));
+}
+
short
NCursesWindow::getcolor(int getback) const
{
short fore, back;
if (HaveColors()) {
- if (::pair_content(static_cast<short>(PAIR_NUMBER(w->_attrs)), &fore, &back) == ERR)
+ if (::pair_content(getPair(), &fore, &back) == ERR)
err_handler("Can't get color pair");
} else {
// Monochrome means white on black
short
NCursesWindow::getcolor() const
{
- return (HaveColors()) ? PAIR_NUMBER(w->_attrs) : 0;
+ return (HaveColors()) ? getPair() : 0;
}
int
int
NCursesWindow::setpalette(short fore, short back)
{
- return setpalette(fore, back, static_cast<short>(PAIR_NUMBER(w->_attrs)));
+ return setpalette(fore, back, getPair());
}