libncurses: Import https://ftp.gnu.org/pub/gnu/ncurses/ncurses-6.5.tar.gz changes

Change-Id: I3433d30ca01359fd2e3623ede96b531f0b39cbfa
Signed-off-by: micky387 <mickaelsaibi@free.fr>
diff --git a/c++/Makefile.in b/c++/Makefile.in
index 4f5b960..99f21da 100644
--- a/c++/Makefile.in
+++ b/c++/Makefile.in
@@ -1,6 +1,7 @@
-# $Id: Makefile.in,v 1.111 2015/08/05 23:15:41 tom Exp $
+# $Id: Makefile.in,v 1.133 2021/07/03 18:53:57 tom Exp $
 ##############################################################################
-# Copyright (c) 1998-2014,2015 Free Software Foundation, Inc.                #
+# Copyright 2018-2020,2021 Thomas E. Dickey                                  #
+# Copyright 1998-2015,2016 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 "Software"), #
@@ -58,7 +59,7 @@
 PACKAGE		= @PACKAGE@
 
 LIBTOOL		= @LIBTOOL_CXX@
-LIBTOOL_OPTS	= @LIBTOOL_OPTS@
+LIBTOOL_OPTS	= @LIBTOOL_OPTS@ @LIBTOOL_OPTS_CXX@
 LIBTOOL_CLEAN	= @LIB_CLEAN@
 LIBTOOL_COMPILE	= @LIB_COMPILE@
 LIBTOOL_LINK	= @LIB_LINK@
@@ -68,8 +69,9 @@
 LT_UNDEF	= @LT_UNDEF@
 
 INSTALL		= @INSTALL@
-INSTALL_LIB	= @INSTALL@ @INSTALL_LIB@
+INSTALL_LIB	= $(INSTALL) @INSTALL_LIB@
 INSTALL_DATA	= @INSTALL_DATA@
+INSTALL_OPT_P	= @INSTALL_OPT_P@
 
 AR		= @AR@
 ARFLAGS		= @ARFLAGS@
@@ -87,7 +89,7 @@
 CXXLIBS		= @CXXLIBS@
 
 INCDIR		= ../include
-CPPFLAGS	= -DHAVE_CONFIG_H @CPPFLAGS@
+CPPFLAGS	= -DHAVE_CONFIG_H -DBUILDING_NCURSES_CXX -I../c++ @CPPFLAGS@
 
 CTAGS		= @CTAGS@
 ETAGS		= @ETAGS@
@@ -96,9 +98,9 @@
 CCFLAGS		= $(CPPFLAGS) $(CXXFLAGS)
 
 CFLAGS_LIBTOOL	= $(CCFLAGS)
-CFLAGS_NORMAL	= $(CCFLAGS)
-CFLAGS_DEBUG	= $(CCFLAGS) @CXX_G_OPT@ -DTRACE
-CFLAGS_PROFILE	= $(CCFLAGS) -pg
+CFLAGS_NORMAL	= $(CCFLAGS) -DNCURSES_STATIC
+CFLAGS_DEBUG	= $(CCFLAGS) -DNCURSES_STATIC @CXX_G_OPT@ -DTRACE
+CFLAGS_PROFILE	= $(CCFLAGS) -DNCURSES_STATIC -pg
 CFLAGS_SHARED	= $(CCFLAGS) @CC_SHARED_OPTS@
 
 CFLAGS_DEFAULT	= $(CFLAGS_@DFT_UPR_MODEL@)
@@ -112,7 +114,11 @@
 
 LINK		= @LINK_PROGS@ $(LIBTOOL_LINK) @CXXLDFLAGS@
 SHLIB_DIRS	= -L../lib
-SHLIB_LIST	= $(SHLIB_DIRS) -lform@USE_LIB_SUFFIX@ -lmenu@USE_LIB_SUFFIX@ -lpanel@USE_LIB_SUFFIX@ -lncurses@USE_LIB_SUFFIX@ @SHLIB_LIST@
+SHLIB_LIST	= $(SHLIB_DIRS) \
+		-l@FORM_NAME@@USE_LIB_SUFFIX@ \
+		-l@MENU_NAME@@USE_LIB_SUFFIX@ \
+		-l@PANEL_NAME@@USE_LIB_SUFFIX@ \
+		-lncurses@USE_LIB_SUFFIX@ @SHLIB_LIST@
 
 LIBROOT		= ncurses++
 
@@ -122,6 +128,10 @@
 
 LIBRARIES	= @Libs_To_Make@
 
+LINT		= @LINT@
+LINT_OPTS	= @LINT_OPTS@
+LINT_LIBS	= -lncurses @LIBS@
+
 LINK_FLAGS	= @EXTRA_LDFLAGS@ -L../lib -l$(LIBROOT)@USE_LIB_SUFFIX@
 RPATH_LIST	= @RPATH_LIST@
 MK_SHARED_LIB	= @MK_SHARED_LIB@
@@ -134,7 +144,7 @@
 
 # flags for test-programs
 TEST_LIBS	= @TEST_LIBS@
-TEST_ARGS	= @LDFLAGS_STATIC@ @TEST_ARGS@ @LDFLAGS_SHARED@ 
+TEST_ARGS	= @LDFLAGS_STATIC@ @TEST_ARGS@ @LDFLAGS_SHARED@
 TEST_LDFLAGS	= $(TEST_ARGS) @LDFLAGS@ \
 	@LD_MODEL@ $(TEST_LIBS) @LIBS@ @LOCAL_LDFLAGS@ $(CXXLIBS)
 
@@ -153,15 +163,31 @@
 AUTO_SRC	= \
 		etip.h
 
+################################################################################
+
+@MAKE_PHONY@.PHONY :	all
+@MAKE_PHONY@.PHONY :	check
+@MAKE_PHONY@.PHONY :	clean
+@MAKE_PHONY@.PHONY :	depend
+@MAKE_PHONY@.PHONY :	distclean
+@MAKE_PHONY@.PHONY :	install
+@MAKE_PHONY@.PHONY :	install.libs
+@MAKE_PHONY@.PHONY :	libs
+@MAKE_PHONY@.PHONY :	mostlyclean
+@MAKE_PHONY@.PHONY :	realclean
+@MAKE_PHONY@.PHONY :	sources
+@MAKE_PHONY@.PHONY :	uninstall
+@MAKE_PHONY@.PHONY :	uninstall.libs
+
 all \
 libs ::		$(AUTO_SRC) $(LIBRARIES)
 
 @MAKE_TESTS@all ::		demo$x
 
-sources :	$(AUTO_SRC)
-
 depend :
 
+sources :	$(AUTO_SRC)
+
 tags:
 	$(CTAGS) *.[h] *.cc
 
@@ -184,29 +210,34 @@
 
 ###############################################################################
 
-internal_h	= $(srcdir)/internal.h \
-		  $(INCDIR)/ncurses_cfg.h \
-		  $(INCDIR)/nc_mingw.h \
-		  $(INCDIR)/nc_string.h
-
-etip_h		= etip.h \
-		  $(INCDIR)/ncurses_dll.h
+HEADER_DEPS	= @INTERNALS_HDR@ \
+	etip.h \
+	../include/curses.h \
+	../include/eti.h \
+	../include/form.h \
+	../include/menu.h \
+	../include/ncurses_cfg.h \
+	../include/ncurses_def.h \
+	../include/ncurses_dll.h \
+	../include/panel.h \
+	../include/unctrl.h \
+	$(INCDIR)/nc_string.h \
+	$(srcdir)/cursesp.h \
+	$(srcdir)/cursesw.h \
+	$(srcdir)/cursslk.h \
+	$(srcdir)/internal.h
 
 cursesw_h	= $(srcdir)/cursesw.h \
-		  $(etip_h) \
-		  $(INCDIR)/curses.h
+		  $(HEADER_DEPS)
 
 cursesp_h	= $(srcdir)/cursesp.h \
-		  $(cursesw_h) \
-		  $(INCDIR)/panel.h
+		  $(cursesw_h)
 
 cursesf_h	= $(srcdir)/cursesf.h \
-		  $(cursesp_h) \
-		  $(INCDIR)/form.h
+		  $(cursesp_h)
 
 cursesm_h	= $(srcdir)/cursesm.h \
-		  $(cursesp_h) \
-		  $(INCDIR)/menu.h
+		  $(cursesp_h)
 
 cursslk_h	= $(srcdir)/cursslk.h \
 		  $(cursesw_h)
@@ -215,25 +246,25 @@
 		  $(cursslk_h)
 
 $(INCDIR)/form.h :
-	cd ../form && $(MAKE) $@
+	( cd ../form && $(MAKE) $@ )
 
 $(INCDIR)/menu.h :
-	cd ../menu && $(MAKE) $@
+	( cd ../menu && $(MAKE) $@ )
 
 $(INCDIR)/panel.h :
-	cd ../panel && $(MAKE) $@
+	( cd ../panel && $(MAKE) $@ )
 
 ###############################################################################
 
 OBJS_DEMO = $(MODEL)/demo$o
 
 $(MODEL)/demo$o : $(srcdir)/demo.cc \
-		$(internal_h) \
+		$(HEADER_DEPS) \
 		$(cursesf_h) \
 		$(cursesm_h) \
 		$(cursesapp_h)
 	@echo 'compiling demo (obj_s)'
-	@$(LIBTOOL_COMPILE) $(CXX) $(CFLAGS_DEFAULT) -c $(srcdir)/demo.cc -o $@
+	@( cd $(MODEL) && $(LIBTOOL_COMPILE) $(CXX) $(CFLAGS_DEFAULT) -c $(top_srcdir)/c++/demo.cc -o $@ )
 
 demo$x:	$(OBJS_DEMO) \
 	$(LIBRARIES)  \
@@ -244,6 +275,18 @@
 	cp $(srcdir)/etip.h.in $@
 	$(SHELL) $(srcdir)/edit_cfg.sh ../include/ncurses_cfg.h $@
 
+# Verify that each header-file can be compiled without including another.
+check ::
+	@$(SHELL) -c "for header in *.h;\
+		do \
+			[ \$${header} = etip.h ] && continue; \
+			echo \"** testing \$${header}\" ; \
+			echo \"#include <\$${header}>\" >headers.cc; \
+			echo \"int main(int argc, char **argv) { (void) argc; (void) argv; return 0; }\" >>headers.cc; \
+			$(CXX) -c $(CXXFLAGS) $(CPPFLAGS) headers.cc; \
+		done"
+	-@rm -f headers.*
+
 ###############################################################################
 # The remainder of this file is automatically generated during configuration
 ###############################################################################
diff --git a/c++/NEWS b/c++/NEWS
index 17488a4..998e5ff 100644
--- a/c++/NEWS
+++ b/c++/NEWS
@@ -1,5 +1,6 @@
 -------------------------------------------------------------------------------
--- Copyright (c) 1998,2006 Free Software Foundation, Inc.                    --
+-- Copyright 2020,2021 Thomas E. Dickey                                      --
+-- Copyright 1998-1999,2006 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             --
@@ -25,7 +26,7 @@
 -- sale, use or other dealings in this Software without prior written        --
 -- authorization.                                                            --
 -------------------------------------------------------------------------------
--- $Id: NEWS,v 1.4 2006/04/22 22:19:37 tom Exp $
+-- $Id: NEWS,v 1.6 2021/06/17 21:20:30 tom Exp $
 -------------------------------------------------------------------------------
 This is a log of changes that the ncurses C++ binding has gone
 through starting with the integration of menu and forms integration
@@ -36,19 +37,19 @@
           to view the pad.
 
 970908	+ Improve NCursesWindow class: added additional methods to
-	  cover more ncurses functionality. Make refresh() and 
+	  cover more ncurses functionality. Make refresh() and
 	  noutrefresh() virtual members to allow different implementation
 	  in the NCursesPanel class.
 	+ CAUTION: changed order of parameters in vline() and hline() of
 	  NCursesWindow class.
 	+ Make refresh() in NCursesPanel non-static, it is now a
-	  reimplementation  of refresh() in the base class. Added 
+	  reimplementation  of refresh() in the base class. Added
 	  noutrefresh() to NCursesPanel.
 	+ Added NCursesForm and related classes to support libform
 	  functionality.
 	+ Moved most of configuration related stuff from cursesw.h to
 	  etip.h
-	+ Added NCursesApplication class to support easy configuration 
+	+ Added NCursesApplication class to support easy configuration
 	  of menu and forms related attributes as well as ripped of
 	  title lines and Soft-Label-Keys for an application.
 	+ Support of Auto-Cleanup for a menus fieldlist.
@@ -62,10 +63,10 @@
 	+ Added the NCursesMenu class to support libmenu functionality.
 	+ The inheritace relation between NCursesWindow and NCursesColorWindow
 	  was kind of brain damage. Monochrome is a special case of colored, so
-	  the relation should be just the opposite. This would allow all 
-	  derived classes like NCursesPanel, NCursesMenu or NCursesForm to 
+	  the relation should be just the opposite. This would allow all
+	  derived classes like NCursesPanel, NCursesMenu or NCursesForm to
 	  have colors.
-	  To resolve that design flaw I put the color functionality into the 
+	  To resolve that design flaw I put the color functionality into the
 	  NCursesWindow class and it can be switched on by the static member
 	  useColors(). NCursesColorWindow is still there for compatibility
 	  reasons.
diff --git a/c++/PROBLEMS b/c++/PROBLEMS
index 7f2a7df..daa3754 100644
--- a/c++/PROBLEMS
+++ b/c++/PROBLEMS
@@ -1,5 +1,6 @@
 -------------------------------------------------------------------------------
--- Copyright (c) 1998,2006 Free Software Foundation, Inc.                    --
+-- Copyright 2020 Thomas E. Dickey                                           --
+-- Copyright 1998,2006 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             --
@@ -25,7 +26,7 @@
 -- sale, use or other dealings in this Software without prior written        --
 -- authorization.                                                            --
 -------------------------------------------------------------------------------
--- $Id: PROBLEMS,v 1.3 2006/04/22 22:19:37 tom Exp $
+-- $Id: PROBLEMS,v 1.4 2020/02/02 23:34:34 tom Exp $
 -------------------------------------------------------------------------------
 This is a list of open problems. This mainly lists known missing pieces
 and design flaws.
diff --git a/c++/README-first b/c++/README-first
index 42487f5..313c1f8 100644
--- a/c++/README-first
+++ b/c++/README-first
@@ -1,5 +1,6 @@
 -------------------------------------------------------------------------------
--- Copyright (c) 1998-2006,2007 Free Software Foundation, Inc.               --
+-- Copyright 2020,2021 Thomas E. Dickey                                      --
+-- Copyright 1998-2006,2007 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             --
@@ -25,7 +26,7 @@
 -- sale, use or other dealings in this Software without prior written        --
 -- authorization.                                                            --
 -------------------------------------------------------------------------------
--- $Id: README-first,v 1.9 2007/01/27 18:27:09 tom Exp $
+-- $Id: README-first,v 1.11 2021/06/17 21:20:30 tom Exp $
 -------------------------------------------------------------------------------
                   C++ interface to ncurses routines
 -----------------------------------------------------------------------
@@ -44,7 +45,7 @@
 common identifiers are used.  Instead now all #defines are inline
 functions, which also allows strict type checking of arguments.
 
-The next enhancement is color support. It was originally provided by a 
+The next enhancement is color support. It was originally provided by a
 derived class.  This caused some trouble if you think about Panels or
 Menus and Forms with colors.  We decided to put color support into the
 base class so that any derived class may use color support also.
diff --git a/c++/cursesapp.cc b/c++/cursesapp.cc
index ddab6fd..81f6098 100644
--- a/c++/cursesapp.cc
+++ b/c++/cursesapp.cc
@@ -1,6 +1,7 @@
 // * this is for making emacs happy: -*-Mode: C++;-*-
 /****************************************************************************
- * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc.              *
+ * Copyright 2019,2020 Thomas E. Dickey                                     *
+ * Copyright 1998-2007,2008 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            *
@@ -35,7 +36,7 @@
 #include "internal.h"
 #include "cursesapp.h"
 
-MODULE_ID("$Id: cursesapp.cc,v 1.15 2008/08/16 17:15:35 tom Exp $")
+MODULE_ID("$Id: cursesapp.cc,v 1.18 2020/07/18 19:57:11 anonymous.maarten Exp $")
 
 void
 NCursesApplication::init(bool bColors)
@@ -68,7 +69,12 @@
 NCursesWindow* NCursesApplication::titleWindow = 0;
 NCursesApplication::SLK_Link* NCursesApplication::slk_stack = 0;
 
-NCursesApplication::~NCursesApplication()
+
+NCursesWindow *&NCursesApplication::getTitleWindow() {
+  return titleWindow;
+}
+
+NCursesApplication::~NCursesApplication() THROWS(NCursesException)
 {
   Soft_Label_Key_Set* S;
 
@@ -86,6 +92,10 @@
   ::endwin();
 }
 
+NCursesApplication* NCursesApplication::getApplication() {
+  return theApp;
+}
+
 int NCursesApplication::rinit(NCursesWindow& w)
 {
   titleWindow = &w;
diff --git a/c++/cursesapp.h b/c++/cursesapp.h
index e3cbc04..1296f37 100644
--- a/c++/cursesapp.h
+++ b/c++/cursesapp.h
@@ -1,6 +1,7 @@
 // * This makes emacs happy -*-Mode: C++;-*-
 /****************************************************************************
- * Copyright (c) 1998-2005,2011 Free Software Foundation, Inc.              *
+ * Copyright 2019-2020,2021 Thomas E. Dickey                                *
+ * Copyright 1998-2005,2011 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            *
@@ -31,14 +32,25 @@
  *   Author: Juergen Pfeifer, 1997                                          *
  ****************************************************************************/
 
-// $Id: cursesapp.h,v 1.12 2011/09/17 22:12:10 tom Exp $
+// $Id: cursesapp.h,v 1.18 2021/06/17 21:26:02 tom Exp $
 
 #ifndef NCURSES_CURSESAPP_H_incl
 #define NCURSES_CURSESAPP_H_incl
 
 #include <cursslk.h>
 
-class NCURSES_IMPEXP NCursesApplication {
+#if (defined(_WIN32) || defined(_WIN64))
+# define NCURSES_CXX_MAIN_NAME cursespp_main
+# define NCURSES_CXX_MAIN \
+  int main(int argc, char *argv[]) { \
+  	return NCURSES_CXX_MAIN_NAME(argc, argv); \
+  }
+#else
+# define NCURSES_CXX_MAIN_NAME main
+#endif
+NCURSES_CXX_IMPEXP int NCURSES_CXX_MAIN_NAME(int argc, char *argv[]);
+
+class NCURSES_CXX_IMPEXP NCursesApplication {
 public:
   typedef struct _slk_link {          // This structure is used to maintain
     struct _slk_link* prev;           // a stack of SLKs
@@ -105,13 +117,13 @@
   {
   }
 
+  static NCursesWindow *&getTitleWindow();
+
 public:
-  virtual ~NCursesApplication();
+  virtual ~NCursesApplication() THROWS(NCursesException);
 
   // Get a pointer to the current application object
-  static NCursesApplication* getApplication() {
-    return theApp;
-  }
+  static NCursesApplication* getApplication();
 
   // This method runs the application and returns its exit value
   int operator()(void);
@@ -175,5 +187,5 @@
   }
 
 };
- 
+
 #endif /* NCURSES_CURSESAPP_H_incl */
diff --git a/c++/cursesf.cc b/c++/cursesf.cc
index 7956054..5d31648 100644
--- a/c++/cursesf.cc
+++ b/c++/cursesf.cc
@@ -1,6 +1,7 @@
 // * this is for making emacs happy: -*-Mode: C++;-*-
 /****************************************************************************
- * Copyright (c) 1998-2005,2011 Free Software Foundation, Inc.              *
+ * Copyright 2019-2020,2021 Thomas E. Dickey                                *
+ * Copyright 1998-2005,2011 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            *
@@ -35,9 +36,9 @@
 #include "cursesf.h"
 #include "cursesapp.h"
 
-MODULE_ID("$Id: cursesf.cc,v 1.22 2011/09/17 22:12:10 tom Exp $")
+MODULE_ID("$Id: cursesf.cc,v 1.26 2021/04/17 18:11:08 tom Exp $")
 
-NCursesFormField::~NCursesFormField ()
+NCursesFormField::~NCursesFormField () THROWS(NCursesException)
 {
   if (field)
     OnError(::free_field (field));
@@ -149,7 +150,7 @@
   setDefaultAttributes();
 }
 
-NCursesForm::~NCursesForm()
+NCursesForm::~NCursesForm() THROWS(NCursesException)
 {
   UserHook* hook = reinterpret_cast<UserHook*>(::form_userptr(form));
   delete hook;
@@ -284,15 +285,15 @@
 NCursesForm::operator()(void)
 {
   int drvCmnd;
-  int err;
   int c;
 
   post();
   show();
   refresh();
 
-  while (((drvCmnd = virtualize((c=getKey()))) != CMD_QUIT)) {
-    switch((err=driver(drvCmnd))) {
+  while (((drvCmnd = virtualize((c = getKey()))) != CMD_QUIT)) {
+    int err;
+    switch((err = driver(drvCmnd))) {
     case E_REQUEST_DENIED:
       On_Request_Denied(c);
       break;
@@ -405,10 +406,19 @@
   ::new_fieldtype(_nc_xx_fld_fcheck,
 		  _nc_xx_fld_ccheck);
 
+
+UserDefinedFieldType::UserDefinedFieldType() : NCursesFieldType(generic_fieldtype) {
+}
+
 FIELDTYPE* UserDefinedFieldType_With_Choice::generic_fieldtype_with_choice =
   ::new_fieldtype(_nc_xx_fld_fcheck,
 		  _nc_xx_fld_ccheck);
 
+
+UserDefinedFieldType_With_Choice::UserDefinedFieldType_With_Choice() {
+  fieldtype = generic_fieldtype_with_choice;
+}
+
 bool _nc_xx_next_choice(FIELD *f, const void *u)
 {
   (void) f;
@@ -460,3 +470,5 @@
 };
 
 UDF_Init* UDF_Init::I = new UDF_Init();
+
+
diff --git a/c++/cursesf.h b/c++/cursesf.h
index fe1f1aa..e29e7ad 100644
--- a/c++/cursesf.h
+++ b/c++/cursesf.h
@@ -1,6 +1,8 @@
 // * This makes emacs happy -*-Mode: C++;-*-
+// vile:cppmode
 /****************************************************************************
- * Copyright (c) 1998-2012,2014 Free Software Foundation, Inc.              *
+ * Copyright 2019-2021,2022 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            *
@@ -31,7 +33,7 @@
  *   Author: Juergen Pfeifer, 1997                                          *
  ****************************************************************************/
 
-// $Id: cursesf.h,v 1.32 2014/08/09 22:06:11 Adam.Jiang Exp $
+// $Id: cursesf.h,v 1.39 2022/08/20 20:52:15 tom Exp $
 
 #ifndef NCURSES_CURSESF_H_incl
 #define NCURSES_CURSESF_H_incl 1
@@ -47,14 +49,14 @@
 }
 //
 // -------------------------------------------------------------------------
-// The abstract base class for buitin and user defined Fieldtypes.
+// The abstract base class for builtin and user defined Fieldtypes.
 // -------------------------------------------------------------------------
 //
-class NCURSES_IMPEXP NCursesFormField; // forward declaration
+class NCURSES_CXX_IMPEXP NCursesFormField; // forward declaration
 
 // Class to represent builtin field types as well as C++ written new
 // fieldtypes (see classes UserDefineFieldType...
-class NCURSES_IMPEXP NCursesFieldType
+class NCURSES_CXX_IMPEXP NCursesFieldType
 {
   friend class NCursesFormField;
 
@@ -100,7 +102,7 @@
 // The class representing a forms field, wrapping the lowlevel FIELD struct
 // -------------------------------------------------------------------------
 //
-class NCURSES_IMPEXP NCursesFormField
+class NCURSES_CXX_IMPEXP NCursesFormField
 {
   friend class NCursesForm;
 
@@ -151,7 +153,7 @@
   {
   }
 
-  virtual ~NCursesFormField ();
+  virtual ~NCursesFormField () THROWS(NCursesException);
 
   // Duplicate the field at a new position
   inline NCursesFormField* dup(int first_row, int first_col)
@@ -337,7 +339,7 @@
 // The class representing a form, wrapping the lowlevel FORM struct
 // -------------------------------------------------------------------------
 //
-class NCURSES_IMPEXP NCursesForm : public NCursesPanel
+class NCURSES_CXX_IMPEXP NCursesForm : public NCursesPanel
 {
 protected:
   FORM* form;  // the lowlevel structure
@@ -470,7 +472,7 @@
   {
   }
 
-  virtual ~NCursesForm();
+  virtual ~NCursesForm() THROWS(NCursesException);
 
   // Set the default attributes for the form
   virtual void setDefaultAttributes();
@@ -499,21 +501,21 @@
   }
 
   // Decorations
-  inline void frame(const char *title=NULL, const char* btitle=NULL) {
+  inline void frame(const char *title=NULL, const char* btitle=NULL) NCURSES_OVERRIDE {
     if (b_framed)
       NCursesPanel::frame(title,btitle);
     else
       OnError(E_SYSTEM_ERROR);
   }
 
-  inline void boldframe(const char *title=NULL, const char* btitle=NULL) {
+  inline void boldframe(const char *title=NULL, const char* btitle=NULL) NCURSES_OVERRIDE {
     if (b_framed)
       NCursesPanel::boldframe(title,btitle);
     else
       OnError(E_SYSTEM_ERROR);
   }
 
-  inline void label(const char *topLabel, const char *bottomLabel) {
+  inline void label(const char *topLabel, const char *bottomLabel) NCURSES_OVERRIDE {
     if (b_framed)
       NCursesPanel::label(topLabel,bottomLabel);
     else
@@ -628,7 +630,7 @@
 // data belongs to some class T. Use T as template argument
 // to create a UserField.
 // -------------------------------------------------------------------------
-template<class T> class NCURSES_IMPEXP NCursesUserField : public NCursesFormField
+template<class T> class NCURSES_CXX_IMPEXP NCursesUserField : public NCursesFormField
 {
 public:
   NCursesUserField (int rows,
@@ -645,7 +647,7 @@
 	OnError(::set_field_userptr(field, STATIC_CAST(void *)(p_UserData)));
   }
 
-  virtual ~NCursesUserField() {};
+  virtual ~NCursesUserField() THROWS(NCursesException) {};
 
   inline const T* UserData (void) const {
     return reinterpret_cast<const T*>(::field_userptr (field));
@@ -661,7 +663,7 @@
 // The same mechanism is used to attach user data to a form
 // -------------------------------------------------------------------------
 //
-template<class T> class NCURSES_IMPEXP NCursesUserForm : public NCursesForm
+template<class T> class NCURSES_CXX_IMPEXP NCursesUserForm : public NCursesForm
 {
 protected:
   // 'Internal' constructor, builds an object without association to a
@@ -702,7 +704,7 @@
 				     (p_UserData)));
   };
 
-  virtual ~NCursesUserForm() {
+  virtual ~NCursesUserForm() THROWS(NCursesException) {
   };
 
   inline T* UserData (void) {
@@ -720,45 +722,45 @@
 // Builtin Fieldtypes
 // -------------------------------------------------------------------------
 //
-class NCURSES_IMPEXP Alpha_Field : public NCursesFieldType
+class NCURSES_CXX_IMPEXP Alpha_Field : public NCursesFieldType
 {
 private:
   int min_field_width;
 
-  void set(NCursesFormField& f) {
+  void set(NCursesFormField& f) NCURSES_OVERRIDE {
     OnError(::set_field_type(f.get_field(),fieldtype,min_field_width));
   }
 
 public:
-  Alpha_Field(int width)
+  explicit Alpha_Field(int width)
     : NCursesFieldType(TYPE_ALPHA),
       min_field_width(width) {
   }
 };
 
-class NCURSES_IMPEXP Alphanumeric_Field : public NCursesFieldType
+class NCURSES_CXX_IMPEXP Alphanumeric_Field : public NCursesFieldType
 {
 private:
   int min_field_width;
 
-  void set(NCursesFormField& f) {
+  void set(NCursesFormField& f) NCURSES_OVERRIDE {
     OnError(::set_field_type(f.get_field(),fieldtype,min_field_width));
   }
 
 public:
-  Alphanumeric_Field(int width)
+  explicit Alphanumeric_Field(int width)
     : NCursesFieldType(TYPE_ALNUM),
       min_field_width(width) {
   }
 };
 
-class NCURSES_IMPEXP Integer_Field : public NCursesFieldType
+class NCURSES_CXX_IMPEXP Integer_Field : public NCursesFieldType
 {
 private:
   int precision;
   long lower_limit, upper_limit;
 
-  void set(NCursesFormField& f) {
+  void set(NCursesFormField& f) NCURSES_OVERRIDE {
     OnError(::set_field_type(f.get_field(),fieldtype,
 			     precision,lower_limit,upper_limit));
   }
@@ -770,13 +772,13 @@
   }
 };
 
-class NCURSES_IMPEXP Numeric_Field : public NCursesFieldType
+class NCURSES_CXX_IMPEXP Numeric_Field : public NCursesFieldType
 {
 private:
   int precision;
   double lower_limit, upper_limit;
 
-  void set(NCursesFormField& f) {
+  void set(NCursesFormField& f) NCURSES_OVERRIDE {
     OnError(::set_field_type(f.get_field(),fieldtype,
 			     precision,lower_limit,upper_limit));
   }
@@ -788,12 +790,12 @@
   }
 };
 
-class NCURSES_IMPEXP Regular_Expression_Field : public NCursesFieldType
+class NCURSES_CXX_IMPEXP Regular_Expression_Field : public NCursesFieldType
 {
 private:
   char* regex;
 
-  void set(NCursesFormField& f) {
+  void set(NCursesFormField& f) NCURSES_OVERRIDE {
     OnError(::set_field_type(f.get_field(),fieldtype,regex));
   }
 
@@ -804,7 +806,7 @@
   }
 
 public:
-  Regular_Expression_Field(const char *expr)
+  explicit Regular_Expression_Field(const char *expr)
     : NCursesFieldType(TYPE_REGEXP),
       regex(NULL)
   {
@@ -833,14 +835,14 @@
   }
 };
 
-class NCURSES_IMPEXP Enumeration_Field : public NCursesFieldType
+class NCURSES_CXX_IMPEXP Enumeration_Field : public NCursesFieldType
 {
 private:
   const char** list;
   int case_sensitive;
   int non_unique_matches;
 
-  void set(NCursesFormField& f) {
+  void set(NCursesFormField& f) NCURSES_OVERRIDE {
     OnError(::set_field_type(f.get_field(),fieldtype,
 			     list,case_sensitive,non_unique_matches));
   }
@@ -872,10 +874,10 @@
   }
 };
 
-class NCURSES_IMPEXP IPV4_Address_Field : public NCursesFieldType
+class NCURSES_CXX_IMPEXP IPV4_Address_Field : public NCursesFieldType
 {
 private:
-  void set(NCursesFormField& f) {
+  void set(NCursesFormField& f) NCURSES_OVERRIDE {
     OnError(::set_field_type(f.get_field(),fieldtype));
   }
 
@@ -895,7 +897,7 @@
 // Abstract base class for User-Defined Fieldtypes
 // -------------------------------------------------------------------------
 //
-class NCURSES_IMPEXP UserDefinedFieldType : public NCursesFieldType
+class NCURSES_CXX_IMPEXP UserDefinedFieldType : public NCursesFieldType
 {
   friend class UDF_Init; // Internal helper to set up statics
 private:
@@ -910,7 +912,7 @@
   friend bool _nc_xx_fld_ccheck(int c, const void *);
   friend void* _nc_xx_fld_makearg(va_list*);
 
-  void set(NCursesFormField& f) {
+  void set(NCursesFormField& f) NCURSES_OVERRIDE {
     OnError(::set_field_type(f.get_field(),fieldtype,&f));
   }
 
@@ -924,8 +926,7 @@
   virtual bool char_check (int c) = 0;
 
 public:
-  UserDefinedFieldType() : NCursesFieldType(generic_fieldtype) {
-  }
+  UserDefinedFieldType();
 };
 
 extern "C" {
@@ -938,7 +939,7 @@
 // Abstract base class for User-Defined Fieldtypes with Choice functions
 // -------------------------------------------------------------------------
 //
-class NCURSES_IMPEXP UserDefinedFieldType_With_Choice : public UserDefinedFieldType
+class NCURSES_CXX_IMPEXP UserDefinedFieldType_With_Choice : public UserDefinedFieldType
 {
   friend class UDF_Init; // Internal helper to set up statics
 private:
@@ -961,9 +962,7 @@
   virtual bool previous(NCursesFormField& f) = 0;
 
 public:
-  UserDefinedFieldType_With_Choice() {
-    fieldtype = generic_fieldtype_with_choice;
-  }
+  UserDefinedFieldType_With_Choice();
 };
 
 #endif /* NCURSES_CURSESF_H_incl */
diff --git a/c++/cursesm.cc b/c++/cursesm.cc
index 222de46..64f3635 100644
--- a/c++/cursesm.cc
+++ b/c++/cursesm.cc
@@ -1,6 +1,7 @@
 // * this is for making emacs happy: -*-Mode: C++;-*-
 /****************************************************************************
- * Copyright (c) 1998-2005,2011 Free Software Foundation, Inc.              *
+ * Copyright 2019-2020,2021 Thomas E. Dickey                                *
+ * Copyright 1998-2011,2017 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            *
@@ -35,9 +36,9 @@
 #include "cursesm.h"
 #include "cursesapp.h"
 
-MODULE_ID("$Id: cursesm.cc,v 1.23 2011/09/17 22:11:32 tom Exp $")
+MODULE_ID("$Id: cursesm.cc,v 1.27 2021/04/17 18:11:08 tom Exp $")
 
-NCursesMenuItem::~NCursesMenuItem()
+NCursesMenuItem::~NCursesMenuItem() THROWS(NCursesException)
 {
   if (item)
     OnError(::free_item(item));
@@ -49,7 +50,7 @@
   return FALSE;
 }
 
-NCursesMenuCallbackItem::~NCursesMenuCallbackItem()
+NCursesMenuCallbackItem::~NCursesMenuCallbackItem() THROWS(NCursesException)
 {
 }
 
@@ -175,13 +176,13 @@
   }
 }
 
-NCursesMenu::~NCursesMenu()
+NCursesMenu::~NCursesMenu() THROWS(NCursesException)
 {
   UserHook* hook = reinterpret_cast<UserHook*>(::menu_userptr(menu));
   delete hook;
   if (b_sub_owner) {
-    delete sub;
     ::set_menu_sub(menu, static_cast<WINDOW *>(0));
+    delete sub;
   }
   if (menu) {
     ITEM** itms = ::menu_items(menu);
@@ -300,7 +301,6 @@
 NCursesMenu::operator()(void)
 {
   int drvCmnd;
-  int err;
   int c;
   bool b_action = FALSE;
 
@@ -308,9 +308,10 @@
   show();
   refresh();
 
-  while (!b_action && ((drvCmnd = virtualize((c=getKey()))) != CMD_QUIT)) {
+  while (!b_action && ((drvCmnd = virtualize((c = getKey()))) != CMD_QUIT)) {
+    int err;
 
-    switch((err=driver(drvCmnd))) {
+    switch((err = driver(drvCmnd))) {
     case E_REQUEST_DENIED:
       On_Request_Denied(c);
       break;
diff --git a/c++/cursesm.h b/c++/cursesm.h
index f8f9665..9651195 100644
--- a/c++/cursesm.h
+++ b/c++/cursesm.h
@@ -1,6 +1,7 @@
 // * This makes emacs happy -*-Mode: C++;-*-
 /****************************************************************************
- * Copyright (c) 1998-2012,2014 Free Software Foundation, Inc.              *
+ * Copyright 2019-2020,2022 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            *
@@ -31,7 +32,7 @@
  *   Author: Juergen Pfeifer, 1997                                          *
  ****************************************************************************/
 
-// $Id: cursesm.h,v 1.30 2014/08/09 22:06:18 Adam.Jiang Exp $
+// $Id: cursesm.h,v 1.35 2022/08/20 20:52:15 tom Exp $
 
 #ifndef NCURSES_CURSESM_H_incl
 #define NCURSES_CURSESM_H_incl 1
@@ -46,7 +47,7 @@
 // This wraps the ITEM type of <menu.h>
 // -------------------------------------------------------------------------
 //
-class NCURSES_IMPEXP NCursesMenuItem
+class NCURSES_CXX_IMPEXP NCursesMenuItem
 {
   friend class NCursesMenu;
 
@@ -85,7 +86,7 @@
     (void) rhs;
   }
 
-  virtual ~NCursesMenuItem ();
+  virtual ~NCursesMenuItem () THROWS(NCursesException);
   // Release the items memory
 
   inline const char* name () const {
@@ -152,7 +153,7 @@
 // If you don't like to create a child class for individual items to
 // overload action(), you may use this class and provide a callback
 // function pointer for items.
-class NCURSES_IMPEXP NCursesMenuCallbackItem : public NCursesMenuItem
+class NCURSES_CXX_IMPEXP NCursesMenuCallbackItem : public NCursesMenuItem
 {
 private:
   ITEMCALLBACK* p_fct;
@@ -179,9 +180,9 @@
   {
   }
 
-  virtual ~NCursesMenuCallbackItem();
+  virtual ~NCursesMenuCallbackItem() THROWS(NCursesException);
 
-  bool action();
+  bool action() NCURSES_OVERRIDE;
 };
 
   // This are the built-in hook functions in this C++ binding. In C++ we use
@@ -199,7 +200,7 @@
 // This wraps the MENU type of <menu.h>
 // -------------------------------------------------------------------------
 //
-class NCURSES_IMPEXP NCursesMenu : public NCursesPanel
+class NCURSES_CXX_IMPEXP NCursesMenu : public NCursesPanel
 {
 protected:
   MENU *menu;
@@ -332,7 +333,7 @@
   {
   }
 
-  virtual ~NCursesMenu ();
+  virtual ~NCursesMenu () THROWS(NCursesException);
 
   // Retrieve the menus subwindow
   inline NCursesWindow& subWindow() const {
@@ -358,7 +359,7 @@
     flag ? OnError (::post_menu(menu)) : OnError (::unpost_menu (menu));
   }
 
-  // Get the numer of rows and columns for this menu
+  // Get the number of rows and columns for this menu
   inline void scale (int& mrows, int& mcols) const  {
     OnError (::scale_menu (menu, &mrows, &mcols));
   }
@@ -511,21 +512,21 @@
   }
 
   // Decorations
-  inline void frame(const char *title=NULL, const char* btitle=NULL) {
+  inline void frame(const char *title=NULL, const char* btitle=NULL) NCURSES_OVERRIDE {
     if (b_framed)
       NCursesPanel::frame(title,btitle);
     else
       OnError(E_SYSTEM_ERROR);
   }
 
-  inline void boldframe(const char *title=NULL, const char* btitle=NULL) {
+  inline void boldframe(const char *title=NULL, const char* btitle=NULL) NCURSES_OVERRIDE {
     if (b_framed)
       NCursesPanel::boldframe(title,btitle);
     else
       OnError(E_SYSTEM_ERROR);
   }
 
-  inline void label(const char *topLabel, const char *bottomLabel) {
+  inline void label(const char *topLabel, const char *bottomLabel) NCURSES_OVERRIDE {
     if (b_framed)
       NCursesPanel::label(topLabel,bottomLabel);
     else
@@ -595,7 +596,7 @@
 // to create a UserItem.
 // -------------------------------------------------------------------------
 //
-template<class T> class NCURSES_IMPEXP NCursesUserItem : public NCursesMenuItem
+template<class T> class NCURSES_CXX_IMPEXP NCursesUserItem : public NCursesMenuItem
 {
 public:
   NCursesUserItem (const char* p_name,
@@ -606,7 +607,7 @@
 	OnError (::set_item_userptr (item, const_cast<void *>(reinterpret_cast<const void*>(p_UserData))));
   }
 
-  virtual ~NCursesUserItem() {}
+  virtual ~NCursesUserItem() THROWS(NCursesException) {}
 
   inline const T* UserData (void) const {
     return reinterpret_cast<const T*>(::item_userptr (item));
@@ -622,7 +623,7 @@
 // The same mechanism is used to attach user data to a menu
 // -------------------------------------------------------------------------
 //
-template<class T> class NCURSES_IMPEXP NCursesUserMenu : public NCursesMenu
+template<class T> class NCURSES_CXX_IMPEXP NCursesUserMenu : public NCursesMenu
 {
 protected:
   NCursesUserMenu( int  nlines,
@@ -657,7 +658,7 @@
 	set_user (const_cast<void *>(reinterpret_cast<const void*>(p_UserData)));
   };
 
-  virtual ~NCursesUserMenu() {
+  virtual ~NCursesUserMenu() THROWS(NCursesException) {
   };
 
   inline T* UserData (void) {
diff --git a/c++/cursesmain.cc b/c++/cursesmain.cc
index e870995..cc41b50 100644
--- a/c++/cursesmain.cc
+++ b/c++/cursesmain.cc
@@ -1,6 +1,7 @@
 // * this is for making emacs happy: -*-Mode: C++;-*-
 /****************************************************************************
- * Copyright (c) 1998-2007,2013 Free Software Foundation, Inc.              *
+ * Copyright 2019,2020 Thomas E. Dickey                                     *
+ * Copyright 1998-2007,2013 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            *
@@ -43,7 +44,7 @@
 #define CPP_HAS_TRY_CATCH 0
 #endif
 
-MODULE_ID("$Id: cursesmain.cc,v 1.15 2013/09/28 20:56:47 tom Exp $")
+MODULE_ID("$Id: cursesmain.cc,v 1.20 2020/07/18 19:57:11 anonymous.maarten Exp $")
 
 #if HAVE_LOCALE_H
 #include <locale.h>
@@ -59,7 +60,7 @@
  * You only have to instantiate a static NCursesApplication object in your
  * main application source file and link this module with your application.
  */
-int main(int argc, char* argv[])
+int NCURSES_CXX_MAIN_NAME(int argc, char* argv[])
 {
   setlocale(LC_ALL, "");
 
@@ -87,7 +88,7 @@
 #endif
 #if NO_LEAKS
     delete A;
-    _nc_free_and_exit(res);
+    exit_curses(res);
 #else
     return(res);
 #endif
diff --git a/c++/cursesp.cc b/c++/cursesp.cc
index 9c4eab6..58b2a8f 100644
--- a/c++/cursesp.cc
+++ b/c++/cursesp.cc
@@ -1,6 +1,7 @@
 // * this is for making emacs happy: -*-Mode: C++;-*-
 /****************************************************************************
- * Copyright (c) 1998-2003,2005 Free Software Foundation, Inc.              *
+ * Copyright 2019,2020 Thomas E. Dickey                                     *
+ * Copyright 1998-2003,2005 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            *
@@ -34,7 +35,7 @@
 #include "internal.h"
 #include "cursesp.h"
 
-MODULE_ID("$Id: cursesp.cc,v 1.25 2005/08/06 22:12:36 tom Exp $")
+MODULE_ID("$Id: cursesp.cc,v 1.27 2020/02/02 23:34:34 tom Exp $")
 
 NCursesPanel* NCursesPanel::dummy = static_cast<NCursesPanel*>(0);
 
@@ -51,7 +52,7 @@
   ::set_panel_userptr(p, reinterpret_cast<void *>(hook));
 }
 
-NCursesPanel::~NCursesPanel()
+NCursesPanel::~NCursesPanel() THROWS(NCursesException)
 {
   UserHook* hook = UserPointer();
   assert(hook != 0 && hook->m_back==this && hook->m_owner==p);
diff --git a/c++/cursesp.h b/c++/cursesp.h
index 54b0d58..f0bd5c9 100644
--- a/c++/cursesp.h
+++ b/c++/cursesp.h
@@ -1,6 +1,8 @@
 // * This makes emacs happy -*-Mode: C++;-*-
+// vile:cppmode
 /****************************************************************************
- * Copyright (c) 1998-2012,2014 Free Software Foundation, Inc.              *
+ * Copyright 2019-2021,2022 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            *
@@ -34,7 +36,7 @@
 #ifndef NCURSES_CURSESP_H_incl
 #define NCURSES_CURSESP_H_incl 1
 
-// $Id: cursesp.h,v 1.31 2014/08/09 22:06:26 Adam.Jiang Exp $
+// $Id: cursesp.h,v 1.36 2022/08/20 20:52:15 tom Exp $
 
 #include <cursesw.h>
 
@@ -42,7 +44,7 @@
 #  include <panel.h>
 }
 
-class NCURSES_IMPEXP NCursesPanel
+class NCURSES_CXX_IMPEXP NCursesPanel
   : public NCursesWindow
 {
 protected:
@@ -131,7 +133,7 @@
   {
   }
 
-  virtual ~NCursesPanel();
+  virtual ~NCursesPanel() THROWS(NCursesException);
 
   // basic manipulation
   inline void hide()
@@ -160,7 +162,7 @@
   // N.B.: The panel associated with ::stdscr is always on the bottom. So
   // actually bottom() makes the panel the first above ::stdscr.
 
-  virtual int mvwin(int y, int x)
+  virtual int mvwin(int y, int x) NCURSES_OVERRIDE
   {
     OnError(::move_panel(p, y, x));
     return OK;
@@ -193,11 +195,11 @@
 
   // Those two are rewrites of the corresponding virtual members of
   // NCursesWindow
-  virtual int refresh();
+  virtual int refresh() NCURSES_OVERRIDE;
   // Propagate all panel changes to the virtual screen and update the
   // physical screen.
 
-  virtual int noutrefresh();
+  virtual int noutrefresh() NCURSES_OVERRIDE;
   // Propagate all panel changes to the virtual screen.
 
   static void redraw();
@@ -242,7 +244,7 @@
   // This creates an user panel of the requested size with associated
   // user data pointed to by p_UserData.
 
-  NCursesUserPanel(const T* p_UserData = STATIC_CAST(T*)(0)) : NCursesPanel()
+  explicit NCursesUserPanel(const T* p_UserData = STATIC_CAST(T*)(0)) : NCursesPanel()
   {
     if (p)
       set_user(const_cast<void *>(reinterpret_cast<const void*>(p_UserData)));
@@ -250,7 +252,7 @@
   // This creates an user panel associated with the ::stdscr and user data
   // pointed to by p_UserData.
 
-  virtual ~NCursesUserPanel() {};
+  virtual ~NCursesUserPanel() THROWS(NCursesException) {};
 
   T* UserData (void)
   {
diff --git a/c++/cursespad.cc b/c++/cursespad.cc
index a534713..6065923 100644
--- a/c++/cursespad.cc
+++ b/c++/cursespad.cc
@@ -1,6 +1,7 @@
 // * this is for making emacs happy: -*-Mode: C++;-*-
 /****************************************************************************
- * Copyright (c) 1998-2012,2013 Free Software Foundation, Inc.              *
+ * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 1999-2012,2013 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            *
@@ -35,7 +36,7 @@
 
 #include <cursesw.h>
 
-MODULE_ID("$Id: cursespad.cc,v 1.17 2013/03/30 19:45:36 tom Exp $")
+MODULE_ID("$Id: cursespad.cc,v 1.18 2020/02/02 23:34:34 tom Exp $")
 
 NCursesPad::NCursesPad(int nlines, int ncols)
   : NCursesWindow(),
diff --git a/c++/cursesw.cc b/c++/cursesw.cc
index 1643877..8ea265c 100644
--- a/c++/cursesw.cc
+++ b/c++/cursesw.cc
@@ -1,6 +1,7 @@
 // * this is for making emacs happy: -*-Mode: C++;-*-
 /****************************************************************************
- * Copyright (c) 2007-2012,2014 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.54 2014/02/01 22:10:42 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
@@ -344,7 +345,7 @@
 }
 
 
-NCursesWindow::~NCursesWindow()
+NCursesWindow::~NCursesWindow() THROWS(NCursesException)
 {
     kill_subwindows();
 
diff --git a/c++/cursesw.h b/c++/cursesw.h
index ca07b04..eef5a63 100644
--- a/c++/cursesw.h
+++ b/c++/cursesw.h
@@ -1,7 +1,8 @@
 // * This makes emacs happy -*-Mode: C++;-*-
 // vile:cppmode
 /****************************************************************************
- * Copyright (c) 1998-2011,2014 Free Software Foundation, Inc.              *
+ * Copyright 2019-2021,2022 Thomas E. Dickey                                *
+ * Copyright 1998-2014,2017 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            *
@@ -31,14 +32,25 @@
 #ifndef NCURSES_CURSESW_H_incl
 #define NCURSES_CURSESW_H_incl 1
 
-// $Id: cursesw.h,v 1.50 2014/02/01 22:17:37 tom Exp $
-
-#include <etip.h>
+// $Id: cursesw.h,v 1.59 2022/08/20 20:52:15 tom Exp $
 
 extern "C" {
 #  include   <curses.h>
 }
 
+#if defined(BUILDING_NCURSES_CXX)
+# define NCURSES_CXX_IMPEXP NCURSES_EXPORT_GENERAL_EXPORT
+#else
+# define NCURSES_CXX_IMPEXP NCURSES_EXPORT_GENERAL_IMPORT
+#endif
+
+#define NCURSES_CXX_WRAPPED_VAR(type,name) extern NCURSES_CXX_IMPEXP type NCURSES_PUBLIC_VAR(name)(void)
+
+#define NCURSES_CXX_EXPORT(type) NCURSES_CXX_IMPEXP type NCURSES_API
+#define NCURSES_CXX_EXPORT_VAR(type) NCURSES_CXX_IMPEXP type
+
+#include <etip.h>
+
 /* SCO 3.2v4 curses.h includes term.h, which defines lines as a macro.
    Undefine it here, because NCursesWindow uses lines as a method.  */
 #undef lines
@@ -324,6 +336,12 @@
 #define intrflush UNDEF(intrflush)
 #endif
 
+#ifdef is_linetouched
+inline int UNDEF(is_linetouched)(WINDOW *w, int l)  { return is_linetouched(w,l); }
+#undef is_linetouched
+#define is_linetouched UNDEF(is_linetouched)
+#endif
+
 #ifdef leaveok
 inline int UNDEF(leaveok)(WINDOW* win, bool bf)  { return leaveok(win, bf); }
 #undef leaveok
@@ -750,7 +768,7 @@
 extern "C" int     _nc_xx_ripoff_init(WINDOW *, int);
 extern "C" int     _nc_has_mouse(void);
 
-class NCURSES_IMPEXP NCursesWindow
+class NCURSES_CXX_IMPEXP NCursesWindow
 {
   friend class NCursesMenu;
   friend class NCursesForm;
@@ -798,7 +816,7 @@
   NCursesWindow();
 
 public:
-  NCursesWindow(WINDOW* window);   // useful only for stdscr
+  explicit NCursesWindow(WINDOW* window);   // useful only for stdscr
 
   NCursesWindow(int nlines,        // number of lines
 		int ncols,         // number of columns
@@ -831,7 +849,7 @@
   {
   }
 
-  virtual ~NCursesWindow();
+  virtual ~NCursesWindow() THROWS(NCursesException);
 
   NCursesWindow Clone();
   // Make an exact copy of the window.
@@ -1241,7 +1259,7 @@
   // on the value of the changed flag.
 
   bool           is_linetouched(int line) const {
-    return (::is_linetouched(w, line) ? TRUE:FALSE); }
+    return (::is_linetouched(w, line) == TRUE ? TRUE:FALSE); }
   // Return TRUE if line is marked as changed, FALSE otherwise
 
   bool           is_wintouched() const {
@@ -1249,7 +1267,7 @@
   // Return TRUE if window is marked as changed, FALSE otherwise
 
   int            leaveok(bool bf) { return ::leaveok(w, bf); }
-  // If bf is TRUE, curses will leave the cursor after an update whereever
+  // If bf is TRUE, curses will leave the cursor after an update wherever
   // it is after the update.
 
   int            redrawln(int from, int n) { return ::wredrawln(w, from, n); }
@@ -1364,10 +1382,10 @@
 // -------------------------------------------------------------------------
 // We leave this here for compatibility reasons.
 // -------------------------------------------------------------------------
-class NCURSES_IMPEXP NCursesColorWindow : public NCursesWindow
+class NCURSES_CXX_IMPEXP NCursesColorWindow : public NCursesWindow
 {
 public:
-  NCursesColorWindow(WINDOW* &window)   // useful only for stdscr
+  explicit NCursesColorWindow(WINDOW* &window)   // useful only for stdscr
     : NCursesWindow(window) {
       useColors(); }
 
@@ -1410,7 +1428,7 @@
 // Pad Support. We allow an association of a pad with a "real" window
 // through which the pad may be viewed.
 // -------------------------------------------------------------------------
-class NCURSES_IMPEXP NCursesPad : public NCursesWindow
+class NCURSES_CXX_IMPEXP NCursesPad : public NCursesWindow
 {
 private:
   NCursesWindow* viewWin;       // the "viewport" window
@@ -1479,13 +1497,13 @@
   {
   }
 
-  virtual ~NCursesPad() {}
+  virtual ~NCursesPad() THROWS(NCursesException) {}
 
   int echochar(const chtype ch) { return ::pechochar(w, ch); }
   // Put the attributed character onto the pad and immediately do a
   // prefresh().
 
-  int refresh();
+  int refresh() NCURSES_OVERRIDE;
   // If a viewport is defined the pad is displayed in this window, otherwise
   // this is a noop.
 
@@ -1499,7 +1517,7 @@
   // on the screen. <b>refresh</b> copies a rectangle of this size beginning
   // with top left corner pminrow,pmincol onto the screen and calls doupdate().
 
-  int noutrefresh();
+  int noutrefresh() NCURSES_OVERRIDE;
   // If a viewport is defined the pad is displayed in this window, otherwise
   // this is a noop.
 
@@ -1526,10 +1544,10 @@
 // A FramedPad is constructed always with a viewport window. This viewport
 // will be framed (by a box() command) and the interior of the box is the
 // viewport subwindow. On the frame we display scrollbar sliders.
-class NCURSES_IMPEXP NCursesFramedPad : public NCursesPad
+class NCURSES_CXX_IMPEXP NCursesFramedPad : public NCursesPad
 {
 protected:
-  virtual void OnOperation(int pad_req);
+  virtual void OnOperation(int pad_req) NCURSES_OVERRIDE;
 
 public:
   NCursesFramedPad(NCursesWindow& win, int nlines, int ncols,
@@ -1540,11 +1558,11 @@
   }
   // Construct the FramedPad with the given Window win as viewport.
 
-  virtual ~NCursesFramedPad() {
+  virtual ~NCursesFramedPad() THROWS(NCursesException) {
     delete getSubWindow();
   }
 
-  void setWindow(NCursesWindow& view, int v_grid = 1, int h_grid = 1) {
+  void setWindow(NCursesWindow& view, int v_grid = 1, int h_grid = 1) NCURSES_OVERRIDE {
     (void) view;
     (void) v_grid;
     (void) h_grid;
@@ -1552,7 +1570,7 @@
   }
   // Disable this call; the viewport is already defined
 
-  void setSubWindow(NCursesWindow& sub) {
+  void setSubWindow(NCursesWindow& sub) NCURSES_OVERRIDE {
     (void) sub;
     err_handler("Operation not allowed");
   }
diff --git a/c++/cursslk.cc b/c++/cursslk.cc
index 23785df..7b898ce 100644
--- a/c++/cursslk.cc
+++ b/c++/cursslk.cc
@@ -1,6 +1,7 @@
 // * this is for making emacs happy: -*-Mode: C++;-*-
 /****************************************************************************
- * Copyright (c) 1998-2005,2012 Free Software Foundation, Inc.              *
+ * Copyright 2019-2022,2023 Thomas E. Dickey                                *
+ * Copyright 1998-2005,2012 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            *
@@ -35,7 +36,7 @@
 #include "cursslk.h"
 #include "cursesapp.h"
 
-MODULE_ID("$Id: cursslk.cc,v 1.16 2012/02/23 10:41:56 tom Exp $")
+MODULE_ID("$Id: cursslk.cc,v 1.21 2023/02/25 23:36:06 tom Exp $")
 
 Soft_Label_Key_Set::Soft_Label_Key&
   Soft_Label_Key_Set::Soft_Label_Key::operator=(char *text)
@@ -55,7 +56,11 @@
 
 void Soft_Label_Key_Set::init()
 {
-  slk_array = new Soft_Label_Key[num_labels];
+  if (num_labels > 12)
+      num_labels = 12;
+  if (num_labels < 0)
+      num_labels = 0;
+  slk_array = new Soft_Label_Key[num_labels + 1];
   for(int i=0; i < num_labels; i++) {
     slk_array[i].num = i+1;
   }
@@ -88,7 +93,7 @@
   init();
 }
 
-Soft_Label_Key_Set::~Soft_Label_Key_Set() {
+Soft_Label_Key_Set::~Soft_Label_Key_Set() THROWS(NCursesException) {
   if (!::isendwin())
     clear();
   delete[] slk_array;
@@ -101,6 +106,10 @@
   return slk_array[i-1];
 }
 
+int Soft_Label_Key_Set::labels() const {
+  return num_labels;
+}
+
 void Soft_Label_Key_Set::activate_label(int i, bool bf) {
   if (!b_attrInit) {
     NCursesApplication* A = NCursesApplication::getApplication();
diff --git a/c++/cursslk.h b/c++/cursslk.h
index 091695e..66564fe 100644
--- a/c++/cursslk.h
+++ b/c++/cursslk.h
@@ -1,6 +1,8 @@
 // * this is for making emacs happy: -*-Mode: C++;-*-
+// vile:cppmode
 /****************************************************************************
- * Copyright (c) 1998-2003,2005 Free Software Foundation, Inc.              *
+ * Copyright 2019-2020,2021 Thomas E. Dickey                                *
+ * Copyright 1998-2003,2005 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            *
@@ -31,17 +33,17 @@
  *   Author: Juergen Pfeifer, 1997                                          *
  ****************************************************************************/
 
-// $Id: cursslk.h,v 1.13 2005/05/28 21:58:18 tom Exp $
+// $Id: cursslk.h,v 1.19 2021/04/17 18:11:08 tom Exp $
 
 #ifndef NCURSES_CURSSLK_H_incl
 #define NCURSES_CURSSLK_H_incl
 
 #include <cursesw.h>
 
-class NCURSES_IMPEXP Soft_Label_Key_Set {
+class NCURSES_CXX_IMPEXP Soft_Label_Key_Set {
 public:
   // This inner class represents the attributes of a Soft Label Key (SLK)
-  class NCURSES_IMPEXP Soft_Label_Key {
+  class NCURSES_CXX_IMPEXP Soft_Label_Key {
     friend class Soft_Label_Key_Set;
   public:
     typedef enum { Left=0, Center=1, Right=2 } Justification;
@@ -100,10 +102,10 @@
   } Label_Layout;
 
 private:
-  static long NCURSES_IMPEXP count;               // Number of Key Sets
-  static Label_Layout NCURSES_IMPEXP  format;     // Layout of the Key Sets
-  static int  NCURSES_IMPEXP num_labels;          // Number Of Labels in Key Sets
-  bool NCURSES_IMPEXP b_attrInit;                 // Are attributes initialized
+  static long count;               // Number of Key Sets
+  static Label_Layout  format;     // Layout of the Key Sets
+  static int  num_labels;          // Number Of Labels in Key Sets
+  bool b_attrInit;                 // Are attributes initialized
 
   Soft_Label_Key *slk_array;       // The array of SLK's
 
@@ -139,11 +141,11 @@
   // You must create a Soft_Label_Key_Set before you create any object of
   // the NCursesWindow, NCursesPanel or derived classes. (Actually before
   // ::initscr() is called).
-  Soft_Label_Key_Set(Label_Layout fmt);
+  explicit Soft_Label_Key_Set(Label_Layout fmt);
 
   // This constructor assumes, that you already constructed a Key Set
   // with a layout by the constructor above. This layout will be reused.
-  NCURSES_IMPEXP Soft_Label_Key_Set();
+  Soft_Label_Key_Set();
 
   Soft_Label_Key_Set& operator=(const Soft_Label_Key_Set& rhs)
   {
@@ -161,13 +163,13 @@
     init();		// allocate a new slk_array[]
   }
 
-  virtual ~Soft_Label_Key_Set();
+  virtual ~Soft_Label_Key_Set() THROWS(NCursesException);
 
   // Get Label# i. Label counting starts with 1!
-  NCURSES_IMPEXP Soft_Label_Key& operator[](int i);
+  Soft_Label_Key& operator[](int i);
 
   // Retrieve number of Labels
-  inline int labels() const { return num_labels; }
+  int labels() const;
 
   // Refresh the SLK portion of the screen
   inline void refresh() {
diff --git a/c++/demo.cc b/c++/demo.cc
index 8bcfb14..7d300ff 100644
--- a/c++/demo.cc
+++ b/c++/demo.cc
@@ -1,6 +1,7 @@
 // * This makes emacs happy -*-Mode: C++;-*-
 /****************************************************************************
- * Copyright (c) 1998-2011,2012 Free Software Foundation, Inc.              *
+ * Copyright 2018-2021,2023 Thomas E. Dickey                                *
+ * Copyright 1998-2012,2017 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            *
@@ -35,7 +36,7 @@
  *   Demo code for NCursesMenu and NCursesForm written by
  *   Juergen Pfeifer
  *
- * $Id: demo.cc,v 1.41 2012/02/23 10:41:56 tom Exp $
+ * $Id: demo.cc,v 1.52 2023/08/26 19:14:14 tom Exp $
  */
 
 #include "internal.h"
@@ -43,11 +44,11 @@
 #include "cursesm.h"
 #include "cursesf.h"
 
-#ifdef __MINGW32__
+#if (defined(_WIN32) || defined(_WIN64))
 #undef KEY_EVENT
-#endif
-
-#ifndef __MINGW32__
+#undef sleep
+#define sleep(n) Sleep(n)
+#else
 extern "C" unsigned int sleep(unsigned int);
 #endif
 
@@ -104,7 +105,7 @@
     }
 
     //  A refresh to any valid panel updates all panels and refreshes
-    //  the screen.  Using mystd is just convenient - We know it's always
+    //  the screen.  Using mystd is just convenient - We know it is always
     //  valid until the end of the program.
 
     mystd->refresh();
@@ -168,7 +169,7 @@
 //
 // -------------------------------------------------------------------------
 //
-template<class T> class MyAction : public NCursesUserItem<T>
+template<class T> class NCURSES_CXX_IMPEXP MyAction : public NCursesUserItem<UserData>
 {
 public:
   MyAction (const char* p_name,
@@ -176,7 +177,7 @@
     : NCursesUserItem<T>(p_name, static_cast<const char*>(0), p_UserData)
   {}
 
-  virtual ~MyAction() {}
+  virtual ~MyAction() THROWS(NCursesException) {}
 
   bool action() {
     SillyDemo a;
@@ -185,9 +186,6 @@
   }
 };
 
-template class MyAction<UserData>;
-template class NCURSES_IMPEXP NCursesUserItem<UserData>;
-
 class QuitItem : public NCursesMenuItem
 {
 public:
@@ -295,7 +293,7 @@
   {
   }
 
-  ~TestForm() {
+  ~TestForm() THROWS(NCursesException) {
     delete mft;
     delete ift;
     delete eft;
@@ -320,7 +318,7 @@
     for(int i=1; i <= S->labels(); i++) {
       char buf[8];
       assert(i < 100);
-      ::_nc_SPRINTF(buf, _nc_SLIMIT(sizeof(buf)) "Frm%02d", i);
+      ::_nc_SPRINTF(buf, _nc_SLIMIT(sizeof(buf)) "Frm%02d", i % 100);
       (*S)[i] = buf;                                      // Text
       (*S)[i] = Soft_Label_Key_Set::Soft_Label_Key::Left; // Justification
     }
@@ -473,7 +471,7 @@
   {
   }
 
-  ~MyMenu()
+  ~MyMenu() THROWS(NCursesException)
   {
     P->hide();
     delete P;
@@ -540,7 +538,7 @@
   for(int i=1; i <= S.labels(); i++) {
     char buf[8];
     assert(i < 100);
-    ::_nc_SPRINTF(buf, _nc_SLIMIT(sizeof(buf)) "Key%02d", i);
+    ::_nc_SPRINTF(buf, _nc_SLIMIT(sizeof(buf)) "Key%02d", i % 100);
     S[i] = buf;                                      // Text
     S[i] = Soft_Label_Key_Set::Soft_Label_Key::Left; // Justification
   }
@@ -551,9 +549,9 @@
   const char * const titleText = "Simple C++ Binding Demo";
   const int len = ::strlen(titleText);
 
-  titleWindow->bkgd(screen_titles());
-  titleWindow->addstr(0, (titleWindow->cols() - len)/2, titleText);
-  titleWindow->noutrefresh();
+  getTitleWindow()->bkgd(screen_titles());
+  getTitleWindow()->addstr(0, (getTitleWindow()->cols() - len)/2, titleText);
+  getTitleWindow()->noutrefresh();
 }
 
 
@@ -568,3 +566,8 @@
 // -------------------------------------------------------------------------
 //
 static TestApplication *Demo = new TestApplication();
+
+#if (defined(_WIN32) || defined(_WIN64))
+// This is actually only needed when ncurses is a dll
+NCURSES_CXX_MAIN
+#endif
diff --git a/c++/edit_cfg.sh b/c++/edit_cfg.sh
index 73c31b2..928f7fd 100755
--- a/c++/edit_cfg.sh
+++ b/c++/edit_cfg.sh
@@ -1,7 +1,8 @@
 #!/bin/sh
-# $Id: edit_cfg.sh,v 1.17 2008/08/30 19:44:25 tom Exp $
+# $Id: edit_cfg.sh,v 1.19 2022/07/16 18:00:59 tom Exp $
 ##############################################################################
-# Copyright (c) 1998-2007,2008 Free Software Foundation, Inc.                #
+# Copyright 2020,2022 Thomas E. Dickey                                       #
+# Copyright 1998-2007,2008 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 "Software"), #
@@ -50,22 +51,22 @@
 	HAVE_VALUES_H \
 	IOSTREAM_NAMESPACE
 do
-	rm -f $2.bak
-	mv $2 $2.bak
-	if ( grep "[ 	]$name[ 	]1" $1 2>&1 >/dev/null)
+	rm -f "$2".bak
+	mv "$2" "$2".bak
+	if ( grep "[ 	]${name}[ 	]1" "$1" >/dev/null 2>&1)
 	then
 		value=1
-		sed -e 's/define '$name'.*$/define '$name' 1/' $2.bak >$2
+		sed -e 's/define '"$name"'.*$/define '"$name"' 1/' "$2".bak >"$2"
 	else
 		value=0
-		sed -e 's/define '$name'.*$/define '$name' 0/' $2.bak >$2
+		sed -e 's/define '"$name"'.*$/define '"$name"' 0/' "$2".bak >"$2"
 	fi
-	if (cmp -s $2 $2.bak)
+	if (cmp -s "$2" "$2".bak)
 	then
 		echo '... '$name $value
-		mv $2.bak $2
+		mv "$2".bak "$2"
 	else
 		echo '... '$name $value
-		rm -f $2.bak
+		rm -f "$2".bak
 	fi
 done
diff --git a/c++/etip.h.in b/c++/etip.h.in
index 9f642ee..70842ef 100644
--- a/c++/etip.h.in
+++ b/c++/etip.h.in
@@ -1,6 +1,7 @@
 // * This makes emacs happy -*-Mode: C++;-*-
 /****************************************************************************
- * Copyright (c) 1998-2011,2012 Free Software Foundation, Inc.              *
+ * Copyright 2018-2021,2022 Thomas E. Dickey                                *
+ * Copyright 1998-2012,2017 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            *
@@ -31,7 +32,7 @@
  *   Author: Juergen Pfeifer, 1997                                          *
  ****************************************************************************/
 
-// $Id: etip.h.in,v 1.39 2012/12/29 21:50:44 tom Exp $
+// $Id: etip.h.in,v 1.50 2022/08/20 20:50:00 tom Exp $
 
 #ifndef NCURSES_ETIP_H_incl
 #define NCURSES_ETIP_H_incl 1
@@ -69,6 +70,10 @@
 #define ETIP_NEEDS_MATH_EXCEPTION 0
 #endif
 
+#ifndef CPP_HAS_OVERRIDE
+#define CPP_HAS_OVERRIDE 0
+#endif
+
 #ifndef CPP_HAS_PARAM_INIT
 #define CPP_HAS_PARAM_INIT 0
 #endif
@@ -113,7 +118,7 @@
 #  include <generic.h>
 #endif
 
-#include <ncurses_dll.h>
+#include <curses.h>
 
 extern "C" {
 #if HAVE_VALUES_H
@@ -126,6 +131,12 @@
 }
 
 // Language features
+#if CPP_HAS_OVERRIDE
+#define NCURSES_OVERRIDE override
+#else
+#define NCURSES_OVERRIDE /*nothing*/
+#endif
+
 #if CPP_HAS_PARAM_INIT
 #define NCURSES_PARAM_INIT(value) = value
 #else
@@ -138,12 +149,16 @@
 #define STATIC_CAST(s) (s)
 #endif
 
-// Forward Declarations
-class NCURSES_IMPEXP NCursesPanel;
-class NCURSES_IMPEXP NCursesMenu;
-class NCURSES_IMPEXP NCursesForm;
+#ifndef NCURSES_CXX_IMPEXP
+#define NCURSES_CXX_IMPEXP  /* nothing */
+#endif
 
-class NCURSES_IMPEXP NCursesException
+// Forward Declarations
+class NCURSES_CXX_IMPEXP NCursesPanel;
+class NCURSES_CXX_IMPEXP NCursesMenu;
+class NCURSES_CXX_IMPEXP NCursesForm;
+
+class NCURSES_CXX_IMPEXP NCursesException
 {
 public:
   const char *message;
@@ -153,12 +168,13 @@
     : message(msg), errorno (err)
     {};
 
-  NCursesException (const char* msg)
+  explicit NCursesException (const char* msg)
     : message(msg), errorno (E_SYSTEM_ERROR)
     {};
 
   NCursesException& operator=(const NCursesException& rhs)
   {
+    message = rhs.message;
     errorno = rhs.errorno;
     return *this;
   }
@@ -177,7 +193,7 @@
   }
 };
 
-class NCURSES_IMPEXP NCursesPanelException : public NCursesException
+class NCURSES_CXX_IMPEXP NCursesPanelException : public NCursesException
 {
 public:
   const NCursesPanel* p;
@@ -194,7 +210,7 @@
     p (panel)
     {};
 
-  NCursesPanelException (int err) :
+  explicit NCursesPanelException (int err) :
     NCursesException ("panel library error", err),
     p (0)
     {};
@@ -219,7 +235,7 @@
   {
   }
 
-  virtual const char *classname() const {
+  virtual const char *classname() const NCURSES_OVERRIDE {
     return "NCursesPanel";
   }
 
@@ -228,7 +244,7 @@
   }
 };
 
-class NCURSES_IMPEXP NCursesMenuException : public NCursesException
+class NCURSES_CXX_IMPEXP NCursesMenuException : public NCursesException
 {
 public:
   const NCursesMenu* m;
@@ -245,7 +261,7 @@
     m (menu)
     {};
 
-  NCursesMenuException (int err) :
+  explicit NCursesMenuException (int err) :
     NCursesException ("menu library error", err),
     m (0)
     {};
@@ -270,7 +286,7 @@
   {
   }
 
-  virtual const char *classname() const {
+  virtual const char *classname() const NCURSES_OVERRIDE {
     return "NCursesMenu";
   }
 
@@ -279,7 +295,7 @@
   }
 };
 
-class NCURSES_IMPEXP NCursesFormException : public NCursesException
+class NCURSES_CXX_IMPEXP NCursesFormException : public NCursesException
 {
 public:
   const NCursesForm* f;
@@ -296,7 +312,7 @@
     f (form)
     {};
 
-  NCursesFormException (int err) :
+  explicit NCursesFormException (int err) :
     NCursesException ("form library error", err),
     f (0)
     {};
@@ -321,7 +337,7 @@
   {
   }
 
-  virtual const char *classname() const {
+  virtual const char *classname() const NCURSES_OVERRIDE {
     return "NCursesForm";
   }
 
@@ -330,7 +346,7 @@
   }
 };
 
-#if !((defined(__GNUG__) && defined(__EXCEPTIONS)) || defined(__SUNPRO_CC))
+#if !((defined(__GNUG__) && defined(__EXCEPTIONS) && (__GNUG__ < 7)) || defined(__SUNPRO_CC))
 #  if HAVE_IOSTREAM
 #     include <iostream>
 #     if IOSTREAM_NAMESPACE
@@ -340,22 +356,26 @@
 #  else
 #     include <iostream.h>
 #  endif
-   extern "C" void exit(int);
 #endif
 
 inline void THROW(const NCursesException *e) {
 #if defined(__GNUG__) && defined(__EXCEPTIONS)
 #  if ((__GNUG__ <= 2) && (__GNUC_MINOR__ < 8))
       (*lib_error_handler)(e ? e->classname() : "", e ? e->message : "");
-#else
-#define CPP_HAS_TRY_CATCH 1
-#endif
+#  elif (__GNUG__ >= 7)
+     // g++ 7.0 warns about deprecation, but lacks the predefined symbols
+      ::endwin();
+      std::cerr << "Found a problem - goodbye" << std::endl;
+      exit(EXIT_FAILURE);
+#  else
+#    define CPP_HAS_TRY_CATCH 1
+#  endif
 #elif defined(__SUNPRO_CC)
 #  if !defined(__SUNPRO_CC_COMPAT) || (__SUNPRO_CC_COMPAT < 5)
   genericerror(1, ((e != 0) ? (char *)(e->message) : ""));
-#else
-#define CPP_HAS_TRY_CATCH 1
-#endif
+#  else
+#    define CPP_HAS_TRY_CATCH 1
+#  endif
 #else
   if (e)
     cerr << e->message << endl;
@@ -372,9 +392,15 @@
   throw *e;
 #define NCURSES_CPP_TRY		try
 #define NCURSES_CPP_CATCH(e)	catch(e)
+#if defined(__cpp_noexcept_function_type) && (__cpp_noexcept_function_type >= 201510)
+// C++17 deprecates the usage of throw().
+#define THROWS(s)		/* nothing */
+#define THROW2(s,t)		/* nothing */
+#else
 #define THROWS(s)		throw(s)
 #define THROW2(s,t)		throw(s,t)
 #endif
+#endif
 }
 
 #endif /* NCURSES_ETIP_H_incl */
diff --git a/c++/headers b/c++/headers
index 0be0311..9a6a7f5 100644
--- a/c++/headers
+++ b/c++/headers
@@ -1,7 +1,8 @@
 # C++ headers
-# $Id: headers,v 1.3 2006/12/24 16:25:45 tom Exp $
+# $Id: headers,v 1.4 2020/02/02 23:34:34 tom Exp $
 ##############################################################################
-# Copyright (c) 1998,2006 Free Software Foundation, Inc.                     #
+# Copyright 2020 Thomas E. Dickey                                            #
+# Copyright 1998,2006 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 "Software"), #
diff --git a/c++/internal.h b/c++/internal.h
index 1f6b4a6..f67aaec 100644
--- a/c++/internal.h
+++ b/c++/internal.h
@@ -1,6 +1,7 @@
 // * This makes emacs happy -*-Mode: C++;-*-
 /****************************************************************************
- * Copyright (c) 1998-2008,2012 Free Software Foundation, Inc.              *
+ * Copyright 2018,2020 Thomas E. Dickey                                     *
+ * Copyright 1998-2008,2012 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            *
@@ -31,7 +32,7 @@
  *   Author: Juergen Pfeifer, 1997                                          *
  ****************************************************************************/
 
-// $Id: internal.h,v 1.18 2012/02/23 10:41:56 tom Exp $
+// $Id: internal.h,v 1.22 2020/08/29 23:06:41 tom Exp $
 
 #ifndef NCURSES_CPLUS_INTERNAL_H
 #define NCURSES_CPLUS_INTERNAL_H 1
@@ -41,11 +42,15 @@
 #if USE_RCS_IDS
 #define MODULE_ID(id) static const char Ident[] = id;
 #else
-#define MODULE_ID(id) /*nothing*/
+#define MODULE_ID(id)		/*nothing */
 #endif
 
-#ifdef __MINGW32__
+#if (defined(_WIN32) || defined(_WIN64))
+#if defined(EXP_WIN32_DRIVER)
+#include <nc_win32.h>
+#else
 #include <nc_mingw.h>
+#endif
 #undef KEY_EVENT
 #endif
 
diff --git a/c++/modules b/c++/modules
index 56ddad5..f82b487 100644
--- a/c++/modules
+++ b/c++/modules
@@ -1,7 +1,8 @@
 # Program modules
-# $Id: modules,v 1.11 2013/03/30 19:41:11 tom Exp $
+# $Id: modules,v 1.12 2020/02/02 23:34:34 tom Exp $
 ##############################################################################
-# Copyright (c) 1998-2006,2013 Free Software Foundation, Inc.                #
+# Copyright 2020 Thomas E. Dickey                                            #
+# Copyright 1998-2006,2013 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 "Software"), #