]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - c++/cursesw.cc
ncurses 6.2 - patch 20200907
[ncurses.git] / c++ / cursesw.cc
index 527bb7c40e4c39af6c539b7a3e3b6aaea603b999..8ea265cb3e90081c1e911cd2abf130f589905a8d 100644 (file)
@@ -1,6 +1,7 @@
 // * this is for making emacs happy: -*-Mode: C++;-*-
 /****************************************************************************
- * Copyright (c) 2007 Free Software Foundation, Inc.                        *
+ * Copyright 2019,2020 Thomas E. Dickey                                     *
+ * Copyright 1998-2012,2014 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -42,7 +43,7 @@
 #include "internal.h"
 #include "cursesw.h"
 
-MODULE_ID("$Id: cursesw.cc,v 1.48 2007/03/24 19:00:58 tom Exp $")
+MODULE_ID("$Id: cursesw.cc,v 1.56 2020/02/02 23:34:34 tom Exp $")
 
 #define COLORS_NEED_INITIALIZATION  -1
 #define COLORS_NOT_INITIALIZED       0
@@ -84,6 +85,29 @@ NCursesWindow::scanw(int y, int x, const char* fmt, ...)
 }
 
 
+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, ...)
 {
@@ -109,6 +133,25 @@ NCursesWindow::printw(int y, int x, 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)
 {
@@ -150,7 +193,6 @@ NCursesWindow::NCursesWindow()
     constructing();
 
     w = static_cast<WINDOW *>(0);
-    set_keyboard();
 }
 
 NCursesWindow::NCursesWindow(int nlines, int ncols, int begin_y, int begin_x)
@@ -243,19 +285,19 @@ static RIPOFFINIT* prip = R_INIT;
 NCursesWindow::NCursesWindow(WINDOW *win, int ncols)
   : w(0), alloced(FALSE), par(0), subwins(0), sib(0)
 {
+    (void) ncols;
     initialize();
     w = win;
-    assert((w->_maxx +1 ) == ncols);
 }
 
 int _nc_xx_ripoff_init(WINDOW *w, int ncols)
 {
+    (void) ncols;
     int res = ERR;
 
     RIPOFFINIT init = *prip++;
     if (init) {
-       NCursesWindow* W = new NCursesWindow(w,ncols);
-       res = init(*W);
+       res = init(*(new NCursesWindow(w,ncols)));
     }
     return res;
 }
@@ -303,7 +345,7 @@ NCursesWindow::kill_subwindows()
 }
 
 
-NCursesWindow::~NCursesWindow()
+NCursesWindow::~NCursesWindow() THROWS(NCursesException)
 {
     kill_subwindows();
 
@@ -360,16 +402,16 @@ NCursesWindow::useColors(void)
     }
 }
 
-short
+NCURSES_PAIRS_T
 NCursesWindow::getPair() const
 {
-    return static_cast<short>(PAIR_NUMBER(getattrs(w)));
+    return static_cast<NCURSES_PAIRS_T>(PAIR_NUMBER(getattrs(w)));
 }
 
-short
+NCURSES_COLOR_T
 NCursesWindow::getcolor(int getback) const
 {
-    short fore, back;
+    NCURSES_COLOR_T fore, back;
 
     if (HaveColors()) {
        if (::pair_content(getPair(), &fore, &back) == ERR)
@@ -387,27 +429,27 @@ int NCursesWindow::NumberOfColors()
     return (HaveColors()) ? COLORS : 1;
 }
 
-short
+NCURSES_PAIRS_T
 NCursesWindow::getcolor() const
 {
     return (HaveColors()) ? getPair() : 0;
 }
 
 int
-NCursesWindow::setpalette(short fore, short back, short pair)
+NCursesWindow::setpalette(NCURSES_COLOR_T fore, NCURSES_COLOR_T back, NCURSES_PAIRS_T pair)
 {
     return (HaveColors()) ? ::init_pair(pair, fore, back) : OK;
 }
 
 int
-NCursesWindow::setpalette(short fore, short back)
+NCursesWindow::setpalette(NCURSES_COLOR_T fore, NCURSES_COLOR_T back)
 {
     return setpalette(fore, back, getPair());
 }
 
 
 int
-NCursesWindow::setcolor(short pair)
+NCursesWindow::setcolor(NCURSES_PAIRS_T pair)
 {
     if (HaveColors()) {
        if ((pair < 1) || (pair > COLOR_PAIRS))
@@ -422,7 +464,7 @@ NCursesWindow::setcolor(short pair)
 #if HAVE_HAS_KEY
 bool NCursesWindow::has_mouse() const
 {
-    return ((::has_key(KEY_MOUSE) || ::_nc_has_mouse())
+    return ((::has_key(KEY_MOUSE) || ::has_mouse())
             ? TRUE : FALSE);
 }
 #endif