summaryrefslogtreecommitdiff
path: root/c++
diff options
context:
space:
mode:
Diffstat (limited to 'c++')
-rw-r--r--c++/Makefile.in28
-rw-r--r--c++/cursesapp.cc22
-rw-r--r--c++/cursesf.cc137
-rw-r--r--c++/cursesf.h44
-rw-r--r--c++/cursesm.cc120
-rw-r--r--c++/cursesm.h44
-rw-r--r--c++/cursesp.cc10
-rw-r--r--c++/cursesp.h16
-rw-r--r--c++/cursespad.cc24
-rw-r--r--c++/cursesw.cc42
-rw-r--r--c++/cursesw.h10
-rw-r--r--c++/cursslk.cc15
-rw-r--r--c++/cursslk.h6
-rw-r--r--c++/demo.cc20
-rwxr-xr-xc++/edit_cfg.sh6
-rw-r--r--c++/etip.h.in41
-rw-r--r--c++/internal.h8
-rw-r--r--c++/modules20
18 files changed, 327 insertions, 286 deletions
diff --git a/c++/Makefile.in b/c++/Makefile.in
index 99f21da480fa..f03468bb519b 100644
--- a/c++/Makefile.in
+++ b/c++/Makefile.in
@@ -1,6 +1,6 @@
-# $Id: Makefile.in,v 1.133 2021/07/03 18:53:57 tom Exp $
+# $Id: Makefile.in,v 1.139 2025/10/18 13:33:46 tom Exp $
##############################################################################
-# Copyright 2018-2020,2021 Thomas E. Dickey #
+# Copyright 2018-2024,2025 Thomas E. Dickey #
# Copyright 1998-2015,2016 Free Software Foundation, Inc. #
# #
# Permission is hereby granted, free of charge, to any person obtaining a #
@@ -38,13 +38,13 @@
SHELL = @SHELL@
VPATH = @srcdir@
-CF_MFLAGS = @cf_cv_makeflags@
@SET_MAKE@
+@SET_DESTDIR@
+
x = @EXEEXT@
o = .@OBJEXT@
MODEL = ../@DFT_OBJ_SUBDIR@
-DESTDIR = @DESTDIR@
top_srcdir = @top_srcdir@
srcdir = @srcdir@
prefix = @prefix@
@@ -54,7 +54,9 @@ libdir = @libdir@
includedir = @includedir@
includesubdir = @includesubdir@
-INCLUDEDIR = $(DESTDIR)$(includedir)$(includesubdir)
+INCLUDEDIR = $(DESTDIR)$(includedir@MERGE_PREFIX@)$(includesubdir)
+BINDIR = $(DESTDIR)$(bindir@MERGE_PREFIX@)
+LIBDIR = $(DESTDIR)$(libdir@MERGE_PREFIX@)
PACKAGE = @PACKAGE@
@@ -115,15 +117,15 @@ LOCAL_LIBDIR = @top_builddir@/lib
LINK = @LINK_PROGS@ $(LIBTOOL_LINK) @CXXLDFLAGS@
SHLIB_DIRS = -L../lib
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@
+ -l@FORM_NAME@@ABI_SUFFIX@ \
+ -l@MENU_NAME@@ABI_SUFFIX@ \
+ -l@PANEL_NAME@@ABI_SUFFIX@ \
+ -lncurses@ABI_SUFFIX@ @SHLIB_LIST@
LIBROOT = ncurses++
-LIBNAME_LIBTOOL = @LIB_PREFIX@$(LIBROOT)@USE_LIB_SUFFIX@.la
-LIBNAME_NORMAL = @LIB_PREFIX@$(LIBROOT)@USE_LIB_SUFFIX@.a
+LIBNAME_LIBTOOL = @LIB_PREFIX@$(LIBROOT)@ABI_SUFFIX@.la
+LIBNAME_NORMAL = @LIB_PREFIX@$(LIBROOT)@ABI_SUFFIX@.a
LIBNAME = @LIB_PREFIX@$(LIBROOT)@CXX_LIB_SUFFIX@
LIBRARIES = @Libs_To_Make@
@@ -132,7 +134,7 @@ LINT = @LINT@
LINT_OPTS = @LINT_OPTS@
LINT_LIBS = -lncurses @LIBS@
-LINK_FLAGS = @EXTRA_LDFLAGS@ -L../lib -l$(LIBROOT)@USE_LIB_SUFFIX@
+LINK_FLAGS = @EXTRA_LDFLAGS@ -L../lib -l$(LIBROOT)@ABI_SUFFIX@
RPATH_LIST = @RPATH_LIST@
MK_SHARED_LIB = @MK_SHARED_LIB@
@@ -191,7 +193,7 @@ sources : $(AUTO_SRC)
tags:
$(CTAGS) *.[h] *.cc
-$(DESTDIR)$(libdir) :
+$(LIBDIR) :
mkdir -p $@
mostlyclean ::
diff --git a/c++/cursesapp.cc b/c++/cursesapp.cc
index 81f60983ab62..5cfc105aec01 100644
--- a/c++/cursesapp.cc
+++ b/c++/cursesapp.cc
@@ -1,6 +1,6 @@
// * this is for making emacs happy: -*-Mode: C++;-*-
/****************************************************************************
- * Copyright 2019,2020 Thomas E. Dickey *
+ * Copyright 2019-2020,2025 Thomas E. Dickey *
* Copyright 1998-2007,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -36,7 +36,7 @@
#include "internal.h"
#include "cursesapp.h"
-MODULE_ID("$Id: cursesapp.cc,v 1.18 2020/07/18 19:57:11 anonymous.maarten Exp $")
+MODULE_ID("$Id: cursesapp.cc,v 1.19 2025/01/25 21:20:17 tom Exp $")
void
NCursesApplication::init(bool bColors)
@@ -65,9 +65,9 @@ NCursesApplication::init(bool bColors)
Root_Window->bkgd(' '|window_backgrounds());
}
-NCursesApplication* NCursesApplication::theApp = 0;
-NCursesWindow* NCursesApplication::titleWindow = 0;
-NCursesApplication::SLK_Link* NCursesApplication::slk_stack = 0;
+NCursesApplication* NCursesApplication::theApp = NULL;
+NCursesWindow* NCursesApplication::titleWindow = NULL;
+NCursesApplication::SLK_Link* NCursesApplication::slk_stack = NULL;
NCursesWindow *&NCursesApplication::getTitleWindow() {
@@ -79,7 +79,7 @@ NCursesApplication::~NCursesApplication() THROWS(NCursesException)
Soft_Label_Key_Set* S;
delete titleWindow;
- titleWindow = 0;
+ titleWindow = NULL;
while( (S=top()) ) {
pop();
@@ -87,7 +87,7 @@ NCursesApplication::~NCursesApplication() THROWS(NCursesException)
}
delete Root_Window;
- Root_Window = 0;
+ Root_Window = NULL;
::endwin();
}
@@ -105,7 +105,7 @@ int NCursesApplication::rinit(NCursesWindow& w)
void NCursesApplication::push(Soft_Label_Key_Set& S)
{
SLK_Link* L = new SLK_Link;
- assert(L != 0);
+ assert(L != NULL);
L->prev = slk_stack;
L->SLKs = &S;
slk_stack = L;
@@ -121,7 +121,7 @@ bool NCursesApplication::pop()
delete L;
if (Root_Window) {
Soft_Label_Key_Set* xx = top();
- if (xx != 0)
+ if (xx != NULL)
xx->show();
}
}
@@ -139,7 +139,7 @@ Soft_Label_Key_Set* NCursesApplication::top() const
int NCursesApplication::operator()(void)
{
bool bColors = b_Colors;
- Soft_Label_Key_Set* S = 0;
+ Soft_Label_Key_Set* S = NULL;
int ts = titlesize();
if (ts>0)
@@ -147,7 +147,7 @@ int NCursesApplication::operator()(void)
Soft_Label_Key_Set::Label_Layout fmt = useSLKs();
if (fmt!=Soft_Label_Key_Set::None) {
S = new Soft_Label_Key_Set(fmt);
- assert(S != 0);
+ assert(S != NULL);
init_labels(*S);
}
diff --git a/c++/cursesf.cc b/c++/cursesf.cc
index 5d316489ea00..747564daa153 100644
--- a/c++/cursesf.cc
+++ b/c++/cursesf.cc
@@ -1,6 +1,6 @@
// * this is for making emacs happy: -*-Mode: C++;-*-
/****************************************************************************
- * Copyright 2019-2020,2021 Thomas E. Dickey *
+ * Copyright 2019-2024,2025 Thomas E. Dickey *
* Copyright 1998-2005,2011 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -36,7 +36,7 @@
#include "cursesf.h"
#include "cursesapp.h"
-MODULE_ID("$Id: cursesf.cc,v 1.26 2021/04/17 18:11:08 tom Exp $")
+MODULE_ID("$Id: cursesf.cc,v 1.28 2025/01/25 21:20:17 tom Exp $")
NCursesFormField::~NCursesFormField () THROWS(NCursesException)
{
@@ -50,33 +50,39 @@ NCursesFormField::~NCursesFormField () THROWS(NCursesException)
FIELD**
NCursesForm::mapFields(NCursesFormField* nfields[])
{
- int fieldCount = 0,lcv;
+ int fieldCount = 0, lcv;
FIELD** old_fields;
- assert(nfields != 0);
+ assert(nfields != NULL);
for (lcv=0; nfields[lcv]->field; ++lcv)
++fieldCount;
- FIELD** fields = new FIELD*[fieldCount + 1];
+ try {
+ FIELD** fields = new FIELD*[fieldCount + 1];
- for (lcv=0;nfields[lcv]->field;++lcv) {
- fields[lcv] = nfields[lcv]->field;
- }
- fields[lcv] = NULL;
+ for (lcv=0;nfields[lcv]->field;++lcv) {
+ fields[lcv] = nfields[lcv]->field;
+ }
+ fields[lcv] = NULL;
- my_fields = nfields;
+ my_fields = nfields;
- if (form && (old_fields = ::form_fields(form))) {
- ::set_form_fields(form, static_cast<FIELD**>(0));
- delete[] old_fields;
+ if (form && (old_fields = ::form_fields(form))) {
+ ::set_form_fields(form, static_cast<FIELD**>(0));
+ delete[] old_fields;
+ }
+ return fields;
}
- return fields;
+ catch (std::bad_alloc const&) {
+ OnError (E_SYSTEM_ERROR);
+ }
+ return NULL;
}
void NCursesForm::setDefaultAttributes()
{
- NCursesApplication* S = NCursesApplication::getApplication();
+ const NCursesApplication* S = NCursesApplication::getApplication();
int n = count();
if (n > 0) {
@@ -108,46 +114,51 @@ NCursesForm::InitForm(NCursesFormField* nfields[],
bool with_frame,
bool autoDelete_Fields)
{
- int mrows, mcols;
-
- keypad(TRUE);
- meta(TRUE);
-
- b_framed = with_frame;
- b_autoDelete = autoDelete_Fields;
-
- form = static_cast<FORM*>(0);
- form = ::new_form(mapFields(nfields));
- if (!form)
- OnError (E_SYSTEM_ERROR);
-
- UserHook* hook = new UserHook;
- hook->m_user = NULL;
- hook->m_back = this;
- hook->m_owner = form;
- ::set_form_userptr(form, reinterpret_cast<void*>(hook));
-
- ::set_form_init (form, _nc_xx_frm_init);
- ::set_form_term (form, _nc_xx_frm_term);
- ::set_field_init (form, _nc_xx_fld_init);
- ::set_field_term (form, _nc_xx_fld_term);
-
- scale(mrows, mcols);
- ::set_form_win(form, w);
-
- if (with_frame) {
- if ((mrows > height()-2) || (mcols > width()-2))
- OnError(E_NO_ROOM);
- sub = new NCursesWindow(*this,mrows,mcols,1,1,'r');
- ::set_form_sub(form, sub->w);
- b_sub_owner = TRUE;
+ try {
+ int mrows, mcols;
+
+ keypad(TRUE);
+ meta(TRUE);
+
+ b_framed = with_frame;
+ b_autoDelete = autoDelete_Fields;
+
+ form = static_cast<FORM*>(0);
+ form = ::new_form(mapFields(nfields));
+ if (!form)
+ OnError (E_SYSTEM_ERROR);
+
+ UserHook* hook = new UserHook;
+ hook->m_user = NULL;
+ hook->m_back = this;
+ hook->m_owner = form;
+ ::set_form_userptr(form, reinterpret_cast<void*>(hook));
+
+ ::set_form_init (form, _nc_xx_frm_init);
+ ::set_form_term (form, _nc_xx_frm_term);
+ ::set_field_init (form, _nc_xx_fld_init);
+ ::set_field_term (form, _nc_xx_fld_term);
+
+ scale(mrows, mcols);
+ ::set_form_win(form, w);
+
+ if (with_frame) {
+ if ((mrows > height()-2) || (mcols > width()-2))
+ OnError(E_NO_ROOM);
+ sub = new NCursesWindow(*this,mrows,mcols,1,1,'r');
+ ::set_form_sub(form, sub->w);
+ b_sub_owner = TRUE;
+ }
+ else {
+ sub = static_cast<NCursesWindow*>(NULL);
+ b_sub_owner = FALSE;
+ }
+ options_on(O_NL_OVERLOAD);
+ setDefaultAttributes();
}
- else {
- sub = static_cast<NCursesWindow*>(0);
- b_sub_owner = FALSE;
+ catch (std::bad_alloc const&) {
+ OnError (E_SYSTEM_ERROR);
}
- options_on(O_NL_OVERLOAD);
- setDefaultAttributes();
}
NCursesForm::~NCursesForm() THROWS(NCursesException)
@@ -156,13 +167,13 @@ NCursesForm::~NCursesForm() THROWS(NCursesException)
delete hook;
if (b_sub_owner) {
delete sub;
- ::set_form_sub(form, static_cast<WINDOW *>(0));
+ ::set_form_sub(form, static_cast<WINDOW *>(NULL));
}
if (form) {
FIELD** fields = ::form_fields(form);
int cnt = count();
- OnError(::set_form_fields(form, static_cast<FIELD**>(0)));
+ OnError(::set_form_fields(form, static_cast<FIELD**>(NULL)));
if (b_autoDelete) {
if (cnt>0) {
@@ -381,19 +392,19 @@ bool _nc_xx_fld_fcheck(FIELD *f, const void *u)
{
(void) f;
NCursesFormField* F = reinterpret_cast<NCursesFormField*>(const_cast<void *>(u));
- assert(F != 0);
+ assert(F != NULL);
UserDefinedFieldType* udf = reinterpret_cast<UserDefinedFieldType*>(F->fieldtype());
- assert(udf != 0);
+ assert(udf != NULL);
return udf->field_check(*F);
}
bool _nc_xx_fld_ccheck(int c, const void *u)
{
NCursesFormField* F = reinterpret_cast<NCursesFormField*>(const_cast<void *>(u));
- assert(F != 0);
+ assert(F != NULL);
UserDefinedFieldType* udf =
reinterpret_cast<UserDefinedFieldType*>(F->fieldtype());
- assert(udf != 0);
+ assert(udf != NULL);
return udf->char_check(c);
}
@@ -423,10 +434,10 @@ bool _nc_xx_next_choice(FIELD *f, const void *u)
{
(void) f;
NCursesFormField* F = reinterpret_cast<NCursesFormField*>(const_cast<void *>(u));
- assert(F != 0);
+ assert(F != NULL);
UserDefinedFieldType_With_Choice* udf =
reinterpret_cast<UserDefinedFieldType_With_Choice*>(F->fieldtype());
- assert(udf != 0);
+ assert(udf != NULL);
return udf->next(*F);
}
@@ -434,10 +445,10 @@ bool _nc_xx_prev_choice(FIELD *f, const void *u)
{
(void) f;
NCursesFormField* F = reinterpret_cast<NCursesFormField*>(const_cast<void *>(u));
- assert(F != 0);
+ assert(F != NULL);
UserDefinedFieldType_With_Choice* udf =
reinterpret_cast<UserDefinedFieldType_With_Choice*>(F->fieldtype());
- assert(udf != 0);
+ assert(udf != NULL);
return udf->previous(*F);
}
diff --git a/c++/cursesf.h b/c++/cursesf.h
index e29e7adbf6f0..7d6c2b717395 100644
--- a/c++/cursesf.h
+++ b/c++/cursesf.h
@@ -1,7 +1,7 @@
// * This makes emacs happy -*-Mode: C++;-*-
// vile:cppmode
/****************************************************************************
- * Copyright 2019-2021,2022 Thomas E. Dickey *
+ * Copyright 2019-2024,2025 Thomas E. Dickey *
* Copyright 1998-2012,2014 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -33,7 +33,7 @@
* Author: Juergen Pfeifer, 1997 *
****************************************************************************/
-// $Id: cursesf.h,v 1.39 2022/08/20 20:52:15 tom Exp $
+// $Id: cursesf.h,v 1.41 2025/01/25 21:20:17 tom Exp $
#ifndef NCURSES_CURSESF_H_incl
#define NCURSES_CURSESF_H_incl 1
@@ -78,7 +78,7 @@ protected:
public:
NCursesFieldType()
- : fieldtype(STATIC_CAST(FIELDTYPE*)(0))
+ : fieldtype(STATIC_CAST(FIELDTYPE*)(NULL))
{
}
@@ -119,8 +119,8 @@ protected:
public:
// Create a 'Null' field. Can be used to delimit a field list
NCursesFormField()
- : field(STATIC_CAST(FIELD*)(0)),
- ftype(STATIC_CAST(NCursesFieldType*)(0))
+ : field(STATIC_CAST(FIELD*)(NULL)),
+ ftype(STATIC_CAST(NCursesFieldType*)(NULL))
{
}
@@ -131,8 +131,8 @@ public:
int first_col = 0,
int offscreen_rows = 0,
int additional_buffers = 0)
- : field(0),
- ftype(STATIC_CAST(NCursesFieldType*)(0))
+ : field(NULL),
+ ftype(STATIC_CAST(NCursesFieldType*)(NULL))
{
field = ::new_field(rows, ncols, first_row, first_col,
offscreen_rows, additional_buffers);
@@ -363,7 +363,7 @@ private:
// Get the backward pointer to the C++ object from a FORM
static inline NCursesForm* getHook(const FORM *f) {
UserHook* hook = reinterpret_cast<UserHook*>(::form_userptr(f));
- assert(hook != 0 && hook->m_owner==f);
+ assert(hook != NULL && hook->m_owner==f);
return const_cast<NCursesForm*>(hook->m_back);
}
@@ -379,13 +379,13 @@ protected:
// internal routines
inline void set_user(void *user) {
UserHook* uptr = reinterpret_cast<UserHook*>(::form_userptr (form));
- assert (uptr != 0 && uptr->m_back==this && uptr->m_owner==form);
+ assert (uptr != NULL && uptr->m_back==this && uptr->m_owner==form);
uptr->m_user = user;
}
inline void *get_user() {
- UserHook* uptr = reinterpret_cast<UserHook*>(::form_userptr (form));
- assert (uptr != 0 && uptr->m_back==this && uptr->m_owner==form);
+ const UserHook* uptr = reinterpret_cast<UserHook*>(::form_userptr (form));
+ assert (uptr != NULL && uptr->m_back==this && uptr->m_owner==form);
return uptr->m_user;
}
@@ -408,12 +408,12 @@ protected:
int begin_y = 0,
int begin_x = 0)
: NCursesPanel(nlines, ncols, begin_y, begin_x),
- form (STATIC_CAST(FORM*)(0)),
- sub(0),
+ form (STATIC_CAST(FORM*)(NULL)),
+ sub(NULL),
b_sub_owner(0),
b_framed(0),
b_autoDelete(0),
- my_fields(0)
+ my_fields(NULL)
{
}
@@ -423,12 +423,12 @@ public:
bool with_frame=FALSE, // reserve space for a frame?
bool autoDelete_Fields=FALSE) // do automatic cleanup?
: NCursesPanel(),
- form(0),
- sub(0),
+ form(NULL),
+ sub(NULL),
b_sub_owner(0),
b_framed(0),
b_autoDelete(0),
- my_fields(0)
+ my_fields(NULL)
{
InitForm(Fields, with_frame, autoDelete_Fields);
}
@@ -442,12 +442,12 @@ public:
bool with_frame=FALSE, // reserve space for a frame?
bool autoDelete_Fields=FALSE) // do automatic cleanup?
: NCursesPanel(nlines, ncols, begin_y, begin_x),
- form(0),
- sub(0),
+ form(NULL),
+ sub(NULL),
b_sub_owner(0),
b_framed(0),
b_autoDelete(0),
- my_fields(0)
+ my_fields(NULL)
{
InitForm(Fields, with_frame, autoDelete_Fields);
}
@@ -681,7 +681,7 @@ protected:
public:
NCursesUserForm (NCursesFormField* Fields[],
- const T* p_UserData = STATIC_CAST(T*)(0),
+ const T* p_UserData = STATIC_CAST(T*)(NULL),
bool with_frame=FALSE,
bool autoDelete_Fields=FALSE)
: NCursesForm (Fields, with_frame, autoDelete_Fields) {
@@ -694,7 +694,7 @@ public:
int ncols,
int begin_y = 0,
int begin_x = 0,
- const T* p_UserData = STATIC_CAST(T*)(0),
+ const T* p_UserData = STATIC_CAST(T*)(NULL),
bool with_frame=FALSE,
bool autoDelete_Fields=FALSE)
: NCursesForm (Fields, nlines, ncols, begin_y, begin_x,
diff --git a/c++/cursesm.cc b/c++/cursesm.cc
index 64f36358cd99..e75539173cea 100644
--- a/c++/cursesm.cc
+++ b/c++/cursesm.cc
@@ -1,6 +1,6 @@
// * this is for making emacs happy: -*-Mode: C++;-*-
/****************************************************************************
- * Copyright 2019-2020,2021 Thomas E. Dickey *
+ * Copyright 2019-2024,2025 Thomas E. Dickey *
* Copyright 1998-2011,2017 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -36,7 +36,7 @@
#include "cursesm.h"
#include "cursesapp.h"
-MODULE_ID("$Id: cursesm.cc,v 1.27 2021/04/17 18:11:08 tom Exp $")
+MODULE_ID("$Id: cursesm.cc,v 1.29 2025/01/25 21:20:17 tom Exp $")
NCursesMenuItem::~NCursesMenuItem() THROWS(NCursesException)
{
@@ -100,23 +100,28 @@ _nc_xx_itm_term(MENU *m)
ITEM**
NCursesMenu::mapItems(NCursesMenuItem* nitems[])
{
- int itemCount = 0,lcv;
+ try {
+ int itemCount = 0,lcv;
- for (lcv=0; nitems[lcv]->item; ++lcv)
- ++itemCount;
+ for (lcv=0; nitems[lcv]->item; ++lcv)
+ ++itemCount;
- ITEM** itemArray = new ITEM*[itemCount + 1];
+ ITEM** itemArray = new ITEM*[itemCount + 1];
- for (lcv=0;nitems[lcv]->item;++lcv) {
- itemArray[lcv] = nitems[lcv]->item;
- }
- itemArray[lcv] = NULL;
+ for (lcv=0;nitems[lcv]->item;++lcv) {
+ itemArray[lcv] = nitems[lcv]->item;
+ }
+ itemArray[lcv] = NULL;
- my_items = nitems;
+ my_items = nitems;
- if (menu)
- delete[] ::menu_items(menu);
- return itemArray;
+ if (menu)
+ delete[] ::menu_items(menu);
+ return itemArray;
+ }
+ catch (std::bad_alloc const&) {
+ }
+ return NULL;
}
void
@@ -124,51 +129,56 @@ NCursesMenu::InitMenu(NCursesMenuItem* nitems[],
bool with_frame,
bool autoDelete_Items)
{
- int mrows, mcols;
-
- keypad(TRUE);
- meta(TRUE);
-
- b_framed = with_frame;
- b_autoDelete = autoDelete_Items;
-
- menu = static_cast<MENU*>(0);
- menu = ::new_menu(mapItems(nitems));
- if (!menu)
- OnError (E_SYSTEM_ERROR);
-
- UserHook* hook = new UserHook;
- hook->m_user = NULL;
- hook->m_back = this;
- hook->m_owner = menu;
- ::set_menu_userptr(menu, static_cast<void*>(hook));
-
- ::set_menu_init (menu, _nc_xx_mnu_init);
- ::set_menu_term (menu, _nc_xx_mnu_term);
- ::set_item_init (menu, _nc_xx_itm_init);
- ::set_item_term (menu, _nc_xx_itm_term);
-
- scale(mrows, mcols);
- ::set_menu_win(menu, w);
-
- if (with_frame) {
- if ((mrows > height()-2) || (mcols > width()-2))
- OnError(E_NO_ROOM);
- sub = new NCursesWindow(*this,mrows,mcols,1,1,'r');
- ::set_menu_sub(menu, sub->w);
- b_sub_owner = TRUE;
+ try {
+ int mrows, mcols;
+
+ keypad(TRUE);
+ meta(TRUE);
+
+ b_framed = with_frame;
+ b_autoDelete = autoDelete_Items;
+
+ menu = static_cast<MENU*>(NULL);
+ menu = ::new_menu(mapItems(nitems));
+ if (!menu)
+ OnError (E_SYSTEM_ERROR);
+
+ UserHook* hook = new UserHook;
+ hook->m_user = NULL;
+ hook->m_back = this;
+ hook->m_owner = menu;
+ ::set_menu_userptr(menu, static_cast<void*>(hook));
+
+ ::set_menu_init (menu, _nc_xx_mnu_init);
+ ::set_menu_term (menu, _nc_xx_mnu_term);
+ ::set_item_init (menu, _nc_xx_itm_init);
+ ::set_item_term (menu, _nc_xx_itm_term);
+
+ scale(mrows, mcols);
+ ::set_menu_win(menu, w);
+
+ if (with_frame) {
+ if ((mrows > height()-2) || (mcols > width()-2))
+ OnError(E_NO_ROOM);
+ sub = new NCursesWindow(*this,mrows,mcols,1,1,'r');
+ ::set_menu_sub(menu, sub->w);
+ b_sub_owner = TRUE;
+ }
+ else {
+ sub = static_cast<NCursesWindow*>(NULL);
+ b_sub_owner = FALSE;
+ }
+ setDefaultAttributes();
}
- else {
- sub = static_cast<NCursesWindow*>(0);
- b_sub_owner = FALSE;
+ catch (std::bad_alloc const&) {
+ OnError (E_SYSTEM_ERROR);
}
- setDefaultAttributes();
}
void
NCursesMenu::setDefaultAttributes()
{
- NCursesApplication* S = NCursesApplication::getApplication();
+ const NCursesApplication* S = NCursesApplication::getApplication();
if (S) {
::set_menu_fore(menu, S->foregrounds());
::set_menu_back(menu, S->backgrounds());
@@ -181,14 +191,14 @@ NCursesMenu::~NCursesMenu() THROWS(NCursesException)
UserHook* hook = reinterpret_cast<UserHook*>(::menu_userptr(menu));
delete hook;
if (b_sub_owner) {
- ::set_menu_sub(menu, static_cast<WINDOW *>(0));
+ ::set_menu_sub(menu, static_cast<WINDOW *>(NULL));
delete sub;
}
if (menu) {
ITEM** itms = ::menu_items(menu);
int cnt = count();
- OnError(::set_menu_items(menu, static_cast<ITEM**>(0)));
+ OnError(::set_menu_items(menu, static_cast<ITEM**>(NULL)));
if (b_autoDelete) {
if (cnt>0) {
@@ -322,7 +332,7 @@ NCursesMenu::operator()(void)
if (drvCmnd == CMD_ACTION) {
if (options() & O_ONEVALUE) {
NCursesMenuItem* itm = current_item();
- assert(itm != 0);
+ assert(itm != NULL);
if (itm->options() & O_SELECTABLE)
{
b_action = itm->action();
diff --git a/c++/cursesm.h b/c++/cursesm.h
index 9651195fd9d2..6e4a184ce882 100644
--- a/c++/cursesm.h
+++ b/c++/cursesm.h
@@ -1,6 +1,6 @@
// * This makes emacs happy -*-Mode: C++;-*-
/****************************************************************************
- * Copyright 2019-2020,2022 Thomas E. Dickey *
+ * Copyright 2019-2024,2025 Thomas E. Dickey *
* Copyright 1998-2012,2014 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -32,7 +32,7 @@
* Author: Juergen Pfeifer, 1997 *
****************************************************************************/
-// $Id: cursesm.h,v 1.35 2022/08/20 20:52:15 tom Exp $
+// $Id: cursesm.h,v 1.37 2025/01/25 21:20:17 tom Exp $
#ifndef NCURSES_CURSESM_H_incl
#define NCURSES_CURSESM_H_incl 1
@@ -62,9 +62,9 @@ protected:
public:
NCursesMenuItem (const char* p_name = NULL,
const char* p_descript = NULL)
- : item(0)
+ : item(NULL)
{
- item = p_name ? ::new_item (p_name, p_descript) : STATIC_CAST(ITEM*)(0);
+ item = p_name ? ::new_item (p_name, p_descript) : STATIC_CAST(ITEM*)(NULL);
if (p_name && !item)
OnError (E_SYSTEM_ERROR);
}
@@ -81,7 +81,7 @@ public:
}
NCursesMenuItem(const NCursesMenuItem& rhs)
- : item(0)
+ : item(NULL)
{
(void) rhs;
}
@@ -176,7 +176,7 @@ public:
NCursesMenuCallbackItem(const NCursesMenuCallbackItem& rhs)
: NCursesMenuItem(rhs),
- p_fct(0)
+ p_fct(NULL)
{
}
@@ -224,7 +224,7 @@ private:
// Get the backward pointer to the C++ object from a MENU
static inline NCursesMenu* getHook(const MENU *m) {
UserHook* hook = STATIC_CAST(UserHook*)(::menu_userptr(m));
- assert(hook != 0 && hook->m_owner==m);
+ assert(hook != NULL && hook->m_owner==m);
return const_cast<NCursesMenu*>(hook->m_back);
}
@@ -240,13 +240,13 @@ protected:
// internal routines
inline void set_user(void *user) {
UserHook* uptr = STATIC_CAST(UserHook*)(::menu_userptr (menu));
- assert (uptr != 0 && uptr->m_back==this && uptr->m_owner==menu);
+ assert (uptr != NULL && uptr->m_back==this && uptr->m_owner==menu);
uptr->m_user = user;
}
inline void *get_user() {
- UserHook* uptr = STATIC_CAST(UserHook*)(::menu_userptr (menu));
- assert (uptr != 0 && uptr->m_back==this && uptr->m_owner==menu);
+ const UserHook* uptr = STATIC_CAST(UserHook*)(::menu_userptr (menu));
+ assert (uptr != NULL && uptr->m_back==this && uptr->m_owner==menu);
return uptr->m_user;
}
@@ -270,11 +270,11 @@ protected:
int begin_x = 0)
: NCursesPanel(nlines,ncols,begin_y,begin_x),
menu (STATIC_CAST(MENU*)(0)),
- sub(0),
+ sub(NULL),
b_sub_owner(0),
b_framed(0),
b_autoDelete(0),
- my_items(0)
+ my_items(NULL)
{
}
@@ -284,12 +284,12 @@ public:
bool with_frame=FALSE, // Reserve space for a frame?
bool autoDelete_Items=FALSE) // Autocleanup of Items?
: NCursesPanel(),
- menu(0),
- sub(0),
+ menu(NULL),
+ sub(NULL),
b_sub_owner(0),
b_framed(0),
b_autoDelete(0),
- my_items(0)
+ my_items(NULL)
{
InitMenu(Items, with_frame, autoDelete_Items);
}
@@ -303,12 +303,12 @@ public:
bool with_frame=FALSE, // Reserve space for a frame?
bool autoDelete_Items=FALSE) // Autocleanup of Items?
: NCursesPanel(nlines, ncols, begin_y, begin_x),
- menu(0),
- sub(0),
+ menu(NULL),
+ sub(NULL),
b_sub_owner(0),
b_framed(0),
b_autoDelete(0),
- my_items(0)
+ my_items(NULL)
{
InitMenu(Items, with_frame, autoDelete_Items);
}
@@ -601,7 +601,7 @@ template<class T> class NCURSES_CXX_IMPEXP NCursesUserItem : public NCursesMenuI
public:
NCursesUserItem (const char* p_name,
const char* p_descript = NULL,
- const T* p_UserData = STATIC_CAST(T*)(0))
+ const T* p_UserData = STATIC_CAST(T*)(NULL))
: NCursesMenuItem (p_name, p_descript) {
if (item)
OnError (::set_item_userptr (item, const_cast<void *>(reinterpret_cast<const void*>(p_UserData))));
@@ -630,7 +630,7 @@ protected:
int ncols,
int begin_y = 0,
int begin_x = 0,
- const T* p_UserData = STATIC_CAST(T*)(0))
+ const T* p_UserData = STATIC_CAST(T*)(NULL))
: NCursesMenu(nlines,ncols,begin_y,begin_x) {
if (menu)
set_user (const_cast<void *>(reinterpret_cast<const void*>(p_UserData)));
@@ -638,7 +638,7 @@ protected:
public:
NCursesUserMenu (NCursesMenuItem* Items[],
- const T* p_UserData = STATIC_CAST(T*)(0),
+ const T* p_UserData = STATIC_CAST(T*)(NULL),
bool with_frame=FALSE,
bool autoDelete_Items=FALSE)
: NCursesMenu (Items, with_frame, autoDelete_Items) {
@@ -651,7 +651,7 @@ public:
int ncols,
int begin_y = 0,
int begin_x = 0,
- const T* p_UserData = STATIC_CAST(T*)(0),
+ const T* p_UserData = STATIC_CAST(T*)(NULL),
bool with_frame=FALSE)
: NCursesMenu (Items, nlines, ncols, begin_y, begin_x, with_frame) {
if (menu)
diff --git a/c++/cursesp.cc b/c++/cursesp.cc
index 58b2a8fa4e9a..65497030dc29 100644
--- a/c++/cursesp.cc
+++ b/c++/cursesp.cc
@@ -1,6 +1,6 @@
// * this is for making emacs happy: -*-Mode: C++;-*-
/****************************************************************************
- * Copyright 2019,2020 Thomas E. Dickey *
+ * Copyright 2019-2024,2025 Thomas E. Dickey *
* Copyright 1998-2003,2005 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -35,9 +35,9 @@
#include "internal.h"
#include "cursesp.h"
-MODULE_ID("$Id: cursesp.cc,v 1.27 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: cursesp.cc,v 1.29 2025/01/25 21:20:17 tom Exp $")
-NCursesPanel* NCursesPanel::dummy = static_cast<NCursesPanel*>(0);
+NCursesPanel* NCursesPanel::dummy = static_cast<NCursesPanel*>(NULL);
void NCursesPanel::init()
{
@@ -55,7 +55,7 @@ void NCursesPanel::init()
NCursesPanel::~NCursesPanel() THROWS(NCursesException)
{
UserHook* hook = UserPointer();
- assert(hook != 0 && hook->m_back==this && hook->m_owner==p);
+ assert(hook != NULL && hook->m_back==this && hook->m_owner==p);
delete hook;
::del_panel(p);
::update_panels();
@@ -64,7 +64,7 @@ NCursesPanel::~NCursesPanel() THROWS(NCursesException)
void
NCursesPanel::redraw()
{
- PANEL *pan;
+ const PANEL *pan;
pan = ::panel_above(NULL);
while (pan) {
diff --git a/c++/cursesp.h b/c++/cursesp.h
index f0bd5c9cdfff..e0bc550acc8e 100644
--- a/c++/cursesp.h
+++ b/c++/cursesp.h
@@ -1,7 +1,7 @@
// * This makes emacs happy -*-Mode: C++;-*-
// vile:cppmode
/****************************************************************************
- * Copyright 2019-2021,2022 Thomas E. Dickey *
+ * Copyright 2019-2022,2025 Thomas E. Dickey *
* Copyright 1998-2012,2014 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -36,7 +36,7 @@
#ifndef NCURSES_CURSESP_H_incl
#define NCURSES_CURSESP_H_incl 1
-// $Id: cursesp.h,v 1.36 2022/08/20 20:52:15 tom Exp $
+// $Id: cursesp.h,v 1.37 2025/01/25 21:20:17 tom Exp $
#include <cursesw.h>
@@ -73,7 +73,7 @@ protected:
void set_user(void *user)
{
UserHook* uptr = UserPointer();
- if (uptr != 0 && uptr->m_back==this && uptr->m_owner==p) {
+ if (uptr != NULL && uptr->m_back==this && uptr->m_owner==p) {
uptr->m_user = user;
}
}
@@ -82,8 +82,8 @@ protected:
void *get_user()
{
UserHook* uptr = UserPointer();
- void *result = 0;
- if (uptr != 0 && uptr->m_back==this && uptr->m_owner==p)
+ void *result = NULL;
+ if (uptr != NULL && uptr->m_back==this && uptr->m_owner==p)
result = uptr->m_user;
return result;
}
@@ -104,14 +104,14 @@ public:
int ncols,
int begin_y = 0,
int begin_x = 0)
- : NCursesWindow(nlines,ncols,begin_y,begin_x), p(0)
+ : NCursesWindow(nlines,ncols,begin_y,begin_x), p(NULL)
{
init();
}
// Create a panel with this size starting at the requested position.
NCursesPanel()
- : NCursesWindow(::stdscr), p(0)
+ : NCursesWindow(::stdscr), p(NULL)
{
init();
}
@@ -244,7 +244,7 @@ public:
// This creates an user panel of the requested size with associated
// user data pointed to by p_UserData.
- explicit NCursesUserPanel(const T* p_UserData = STATIC_CAST(T*)(0)) : NCursesPanel()
+ explicit NCursesUserPanel(const T* p_UserData = STATIC_CAST(T*)(NULL)) : NCursesPanel()
{
if (p)
set_user(const_cast<void *>(reinterpret_cast<const void*>(p_UserData)));
diff --git a/c++/cursespad.cc b/c++/cursespad.cc
index 6065923bdf8c..010e51a16a5e 100644
--- a/c++/cursespad.cc
+++ b/c++/cursespad.cc
@@ -1,6 +1,6 @@
// * this is for making emacs happy: -*-Mode: C++;-*-
/****************************************************************************
- * Copyright 2020 Thomas E. Dickey *
+ * Copyright 2020-2024,2025 Thomas E. Dickey *
* Copyright 1999-2012,2013 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -36,17 +36,17 @@
#include <cursesw.h>
-MODULE_ID("$Id: cursespad.cc,v 1.18 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: cursespad.cc,v 1.20 2025/01/25 21:21:05 tom Exp $")
NCursesPad::NCursesPad(int nlines, int ncols)
: NCursesWindow(),
- viewWin(static_cast<NCursesWindow*>(0)),
- viewSub(static_cast<NCursesWindow*>(0)),
+ viewWin(static_cast<NCursesWindow*>(NULL)),
+ viewSub(static_cast<NCursesWindow*>(NULL)),
h_gridsize(0), v_gridsize(0),
min_row(0), min_col(0)
{
w = ::newpad(nlines, ncols);
- if (static_cast<WINDOW*>(0) == w) {
+ if (static_cast<WINDOW*>(NULL) == w) {
count--;
err_handler("Cannot construct window");
}
@@ -85,7 +85,7 @@ void NCursesPad::operator()(void)
{
NCursesWindow* W = Win();
- if (static_cast<NCursesWindow*>(0) != W) {
+ if (static_cast<NCursesWindow*>(NULL) != W) {
int Width = W->width();
int Height = W->height();
@@ -170,7 +170,7 @@ void NCursesPad::operator()(void)
int NCursesPad::refresh()
{
int res = noutrefresh();
- if (res==OK && (static_cast<NCursesWindow*>(0) != viewWin)) {
+ if (res==OK && (static_cast<NCursesWindow*>(NULL) != viewWin)) {
res = (viewWin->refresh());
}
return(res);
@@ -180,7 +180,7 @@ int NCursesPad::noutrefresh()
{
int res = OK;
NCursesWindow* W = Win();
- if (static_cast<NCursesWindow*>(0) != W) {
+ if (static_cast<NCursesWindow*>(NULL) != W) {
int high = W->maxy();
int wide = W->maxx();
res = copywin(*W, min_row, min_col,
@@ -210,9 +210,9 @@ void NCursesPad::setWindow(NCursesWindow& view,
void NCursesPad::setSubWindow(NCursesWindow& sub)
{
- if (static_cast<NCursesWindow*>(0) == viewWin)
+ if (static_cast<NCursesWindow*>(NULL) == viewWin)
err_handler("Pad has no viewport");
- assert(viewWin != 0);
+ assert(viewWin != NULL);
if (!viewWin->isDescendant(sub))
THROW(new NCursesException("NCursesFramePad", E_SYSTEM_ERROR));
viewSub = &sub;
@@ -221,10 +221,10 @@ void NCursesPad::setSubWindow(NCursesWindow& sub)
void NCursesFramedPad::OnOperation(int pad_req)
{
(void) pad_req;
- NCursesWindow* W = Win();
+ const NCursesWindow* W = Win();
NCursesWindow* W2 = getWindow();
- if ((static_cast<NCursesWindow*>(0) != W) && (static_cast<NCursesWindow*>(0) != W2)) {
+ if ((static_cast<NCursesWindow*>(NULL) != W) && (static_cast<NCursesWindow*>(NULL) != W2)) {
int Width = W->width();
int Height = W->height();
int i, row, col, h_len, v_len;
diff --git a/c++/cursesw.cc b/c++/cursesw.cc
index 8ea265cb3e90..835e90957ccf 100644
--- a/c++/cursesw.cc
+++ b/c++/cursesw.cc
@@ -1,6 +1,6 @@
// * this is for making emacs happy: -*-Mode: C++;-*-
/****************************************************************************
- * Copyright 2019,2020 Thomas E. Dickey *
+ * Copyright 2019-2020,2025 Thomas E. Dickey *
* Copyright 1998-2012,2014 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -43,7 +43,7 @@
#include "internal.h"
#include "cursesw.h"
-MODULE_ID("$Id: cursesw.cc,v 1.56 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: cursesw.cc,v 1.57 2025/01/25 21:21:05 tom Exp $")
#define COLORS_NEED_INITIALIZATION -1
#define COLORS_NOT_INITIALIZED 0
@@ -188,27 +188,27 @@ NCursesWindow::constructing()
}
NCursesWindow::NCursesWindow()
- : w(0), alloced(FALSE), par(0), subwins(0), sib(0)
+ : w(NULL), alloced(FALSE), par(NULL), subwins(NULL), sib(NULL)
{
constructing();
- w = static_cast<WINDOW *>(0);
+ w = static_cast<WINDOW *>(NULL);
}
NCursesWindow::NCursesWindow(int nlines, int ncols, int begin_y, int begin_x)
- : w(0), alloced(TRUE), par(0), subwins(0), sib(0)
+ : w(NULL), alloced(TRUE), par(NULL), subwins(NULL), sib(NULL)
{
constructing();
w = ::newwin(nlines, ncols, begin_y, begin_x);
- if (w == 0) {
+ if (w == NULL) {
err_handler("Cannot construct window");
}
set_keyboard();
}
NCursesWindow::NCursesWindow(WINDOW* window)
- : w(0), alloced(FALSE), par(0), subwins(0), sib(0)
+ : w(NULL), alloced(FALSE), par(NULL), subwins(NULL), sib(NULL)
{
constructing();
@@ -223,7 +223,7 @@ NCursesWindow::NCursesWindow(WINDOW* window)
NCursesWindow::NCursesWindow(NCursesWindow& win, int ny, int nx,
int begin_y, int begin_x, char absrel)
- : w(0), alloced(TRUE), par(0), subwins(0), sib(0)
+ : w(NULL), alloced(TRUE), par(NULL), subwins(NULL), sib(NULL)
{
constructing();
if (absrel == 'a') { // absolute origin
@@ -234,7 +234,7 @@ NCursesWindow::NCursesWindow(NCursesWindow& win, int ny, int nx,
// Link this window into its parent's list of subwindows.
// We use derwin(), since this also works for pads.
w = ::derwin(win.w, ny, nx, begin_y, begin_x);
- if (w == 0) {
+ if (w == NULL) {
err_handler("Cannot construct subwindow");
}
@@ -245,20 +245,20 @@ NCursesWindow::NCursesWindow(NCursesWindow& win, int ny, int nx,
NCursesWindow::NCursesWindow(NCursesWindow& win,
bool do_box NCURSES_PARAM_INIT(TRUE))
- : w(0), alloced(TRUE), par(0), subwins(0), sib(0)
+ : w(NULL), alloced(TRUE), par(NULL), subwins(NULL), sib(NULL)
{
constructing();
int myHeight = win.height();
int myWidth = win.width();
w = :: derwin(win.w, myHeight - 2, myWidth - 2, 1, 1);
- if (w == 0) {
+ if (w == NULL) {
err_handler("Cannot construct subwindow");
}
par = &win;
sib = win.subwins;
win.subwins = this;
- subwins = 0;
+ subwins = NULL;
if (do_box) {
win.box();
@@ -283,7 +283,7 @@ static int r_init_idx = 0;
static RIPOFFINIT* prip = R_INIT;
NCursesWindow::NCursesWindow(WINDOW *win, int ncols)
- : w(0), alloced(FALSE), par(0), subwins(0), sib(0)
+ : w(NULL), alloced(FALSE), par(NULL), subwins(NULL), sib(NULL)
{
(void) ncols;
initialize();
@@ -331,12 +331,12 @@ NCursesWindow::kill_subwindows()
{
NCursesWindow* p = subwins;
- subwins = 0;
- while (p != 0) {
+ subwins = NULL;
+ while (p != NULL) {
NCursesWindow* q = p->sib;
p->kill_subwindows();
if (p->alloced) {
- if (p->w != 0)
+ if (p->w != NULL)
::delwin(p->w);
}
delete p;
@@ -349,13 +349,13 @@ NCursesWindow::~NCursesWindow() THROWS(NCursesException)
{
kill_subwindows();
- if (par != 0) {
+ if (par != NULL) {
// Remove this window from the parent's list of subwindows.
NCursesWindow * next = par->subwins;
- NCursesWindow * prev = 0;
- while (next != 0) {
+ NCursesWindow * prev = NULL;
+ while (next != NULL) {
if (next == this) {
- if (prev != 0) {
+ if (prev != NULL) {
prev->sib = next->sib;
} else {
par->subwins = next->sib;
@@ -367,7 +367,7 @@ NCursesWindow::~NCursesWindow() THROWS(NCursesException)
}
}
- if (alloced && w != 0)
+ if (alloced && w != NULL)
::delwin(w);
if (alloced) {
diff --git a/c++/cursesw.h b/c++/cursesw.h
index eef5a631c995..10481a2224b5 100644
--- a/c++/cursesw.h
+++ b/c++/cursesw.h
@@ -1,7 +1,7 @@
// * This makes emacs happy -*-Mode: C++;-*-
// vile:cppmode
/****************************************************************************
- * Copyright 2019-2021,2022 Thomas E. Dickey *
+ * Copyright 2019-2024,2025 Thomas E. Dickey *
* Copyright 1998-2014,2017 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -32,11 +32,9 @@
#ifndef NCURSES_CURSESW_H_incl
#define NCURSES_CURSESW_H_incl 1
-// $Id: cursesw.h,v 1.59 2022/08/20 20:52:15 tom Exp $
+// $Id: cursesw.h,v 1.62 2025/01/25 21:21:05 tom Exp $
-extern "C" {
-# include <curses.h>
-}
+#include <curses.h>
#if defined(BUILDING_NCURSES_CXX)
# define NCURSES_CXX_IMPEXP NCURSES_EXPORT_GENERAL_EXPORT
@@ -1441,7 +1439,7 @@ protected:
NCursesWindow* Win(void) const {
// Get the window into which the pad should be copied (if any)
- return (viewSub?viewSub:(viewWin?viewWin:0));
+ return (viewSub?viewSub:(viewWin?viewWin:NULL));
}
NCursesWindow* getWindow(void) const {
diff --git a/c++/cursslk.cc b/c++/cursslk.cc
index 7b898cefff7d..5ff7dd9dda77 100644
--- a/c++/cursslk.cc
+++ b/c++/cursslk.cc
@@ -1,6 +1,6 @@
// * this is for making emacs happy: -*-Mode: C++;-*-
/****************************************************************************
- * Copyright 2019-2022,2023 Thomas E. Dickey *
+ * Copyright 2019-2023,2024 Thomas E. Dickey *
* Copyright 1998-2005,2012 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -33,13 +33,12 @@
****************************************************************************/
#include "internal.h"
-#include "cursslk.h"
#include "cursesapp.h"
-MODULE_ID("$Id: cursslk.cc,v 1.21 2023/02/25 23:36:06 tom Exp $")
+MODULE_ID("$Id: cursslk.cc,v 1.23 2024/10/05 19:36:22 tom Exp $")
Soft_Label_Key_Set::Soft_Label_Key&
- Soft_Label_Key_Set::Soft_Label_Key::operator=(char *text)
+ Soft_Label_Key_Set::Soft_Label_Key::operator=(const char *text)
{
delete[] label;
size_t need = 1 + ::strlen(text);
@@ -112,11 +111,11 @@ int Soft_Label_Key_Set::labels() const {
void Soft_Label_Key_Set::activate_label(int i, bool bf) {
if (!b_attrInit) {
- NCursesApplication* A = NCursesApplication::getApplication();
+ const NCursesApplication* A = NCursesApplication::getApplication();
if (A) attrset(A->labels());
b_attrInit = TRUE;
}
- Soft_Label_Key& K = (*this)[i];
+ const Soft_Label_Key& K = (*this)[i];
if (ERR==::slk_set(K.num,bf?K.label:"",K.format))
Error("slk_set");
noutrefresh();
@@ -125,12 +124,12 @@ void Soft_Label_Key_Set::activate_label(int i, bool bf) {
void Soft_Label_Key_Set::activate_labels(bool bf)
{
if (!b_attrInit) {
- NCursesApplication* A = NCursesApplication::getApplication();
+ const NCursesApplication* A = NCursesApplication::getApplication();
if (A) attrset(A->labels());
b_attrInit = TRUE;
}
for(int i=1; i <= num_labels; i++) {
- Soft_Label_Key& K = (*this)[i];
+ const Soft_Label_Key& K = (*this)[i];
if (ERR==::slk_set(K.num,bf?K.label:"",K.format))
Error("slk_set");
}
diff --git a/c++/cursslk.h b/c++/cursslk.h
index 66564fe3a479..7b02ed446622 100644
--- a/c++/cursslk.h
+++ b/c++/cursslk.h
@@ -1,7 +1,7 @@
// * this is for making emacs happy: -*-Mode: C++;-*-
// vile:cppmode
/****************************************************************************
- * Copyright 2019-2020,2021 Thomas E. Dickey *
+ * Copyright 2019-2021,2024 Thomas E. Dickey *
* Copyright 1998-2003,2005 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -33,7 +33,7 @@
* Author: Juergen Pfeifer, 1997 *
****************************************************************************/
-// $Id: cursslk.h,v 1.19 2021/04/17 18:11:08 tom Exp $
+// $Id: cursslk.h,v 1.20 2024/10/05 22:47:12 tom Exp $
#ifndef NCURSES_CURSSLK_H_incl
#define NCURSES_CURSSLK_H_incl
@@ -62,7 +62,7 @@ public:
public:
// Set the text of the Label
- Soft_Label_Key& operator=(char *text);
+ Soft_Label_Key& operator=(const char *text);
// Set the Justification of the Label
Soft_Label_Key& operator=(Justification just) {
diff --git a/c++/demo.cc b/c++/demo.cc
index 7d300ff38b4e..182784513474 100644
--- a/c++/demo.cc
+++ b/c++/demo.cc
@@ -1,6 +1,6 @@
// * This makes emacs happy -*-Mode: C++;-*-
/****************************************************************************
- * Copyright 2018-2021,2023 Thomas E. Dickey *
+ * Copyright 2018-2023,2025 Thomas E. Dickey *
* Copyright 1998-2012,2017 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -36,7 +36,7 @@
* Demo code for NCursesMenu and NCursesForm written by
* Juergen Pfeifer
*
- * $Id: demo.cc,v 1.52 2023/08/26 19:14:14 tom Exp $
+ * $Id: demo.cc,v 1.53 2025/01/25 21:21:05 tom Exp $
*/
#include "internal.h"
@@ -174,7 +174,7 @@ template<class T> class NCURSES_CXX_IMPEXP MyAction : public NCursesUserItem<Use
public:
MyAction (const char* p_name,
const T* p_UserData)
- : NCursesUserItem<T>(p_name, static_cast<const char*>(0), p_UserData)
+ : NCursesUserItem<T>(p_name, static_cast<const char*>(NULL), p_UserData)
{}
virtual ~MyAction() THROWS(NCursesException) {}
@@ -244,10 +244,10 @@ private:
public:
TestForm()
: NCursesForm(13, 51, (lines() - 15)/2, (cols() - 53)/2),
- F(0),
- mft(0),
- ift(0),
- eft(0)
+ F(NULL),
+ mft(NULL),
+ ift(NULL),
+ eft(NULL)
{
F = new NCursesFormField*[10];
@@ -289,7 +289,7 @@ public:
}
TestForm(const TestForm& rhs)
- : NCursesForm(rhs), F(0), mft(0), ift(0), eft(0)
+ : NCursesForm(rhs), F(NULL), mft(NULL), ift(NULL), eft(NULL)
{
}
@@ -438,7 +438,7 @@ private:
public:
MyMenu ()
: NCursesMenu (n_items+2, 8, (lines()-10)/2, (cols()-10)/2),
- P(0), I(0), u(0)
+ P(NULL), I(NULL), u(NULL)
{
u = new UserData(1);
I = new NCursesMenuItem*[1+n_items];
@@ -467,7 +467,7 @@ public:
}
MyMenu(const MyMenu& rhs)
- : NCursesMenu(rhs), P(0), I(0), u(0)
+ : NCursesMenu(rhs), P(NULL), I(NULL), u(NULL)
{
}
diff --git a/c++/edit_cfg.sh b/c++/edit_cfg.sh
index 928f7fdfb7dd..0a3b710dd1d7 100755
--- a/c++/edit_cfg.sh
+++ b/c++/edit_cfg.sh
@@ -1,7 +1,7 @@
#!/bin/sh
-# $Id: edit_cfg.sh,v 1.19 2022/07/16 18:00:59 tom Exp $
+# $Id: edit_cfg.sh,v 1.20 2025/02/02 00:38:39 tom Exp $
##############################################################################
-# Copyright 2020,2022 Thomas E. Dickey #
+# Copyright 2020-2022,2025 Thomas E. Dickey #
# Copyright 1998-2007,2008 Free Software Foundation, Inc. #
# #
# Permission is hereby granted, free of charge, to any person obtaining a #
@@ -46,7 +46,9 @@ for name in \
HAVE_BUILTIN_H \
HAVE_GPP_BUILTIN_H \
HAVE_GXX_BUILTIN_H \
+ HAVE_EXCEPTION \
HAVE_IOSTREAM \
+ HAVE_NEW \
HAVE_TYPEINFO \
HAVE_VALUES_H \
IOSTREAM_NAMESPACE
diff --git a/c++/etip.h.in b/c++/etip.h.in
index 70842ef6b4c6..193c298750e2 100644
--- a/c++/etip.h.in
+++ b/c++/etip.h.in
@@ -1,6 +1,6 @@
// * This makes emacs happy -*-Mode: C++;-*-
/****************************************************************************
- * Copyright 2018-2021,2022 Thomas E. Dickey *
+ * Copyright 2018-2024,2025 Thomas E. Dickey *
* Copyright 1998-2012,2017 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -32,7 +32,7 @@
* Author: Juergen Pfeifer, 1997 *
****************************************************************************/
-// $Id: etip.h.in,v 1.50 2022/08/20 20:50:00 tom Exp $
+// $Id: etip.h.in,v 1.55 2025/02/08 23:39:52 tom Exp $
#ifndef NCURSES_ETIP_H_incl
#define NCURSES_ETIP_H_incl 1
@@ -42,6 +42,10 @@
#define HAVE_BUILTIN_H 0
#endif
+#ifndef HAVE_EXCEPTION
+#define HAVE_EXCEPTION 0
+#endif
+
#ifndef HAVE_GXX_BUILTIN_H
#define HAVE_GXX_BUILTIN_H 0
#endif
@@ -54,6 +58,10 @@
#define HAVE_IOSTREAM 0
#endif
+#ifndef HAVE_NEW
+#define HAVE_NEW 0
+#endif
+
#ifndef HAVE_TYPEINFO
#define HAVE_TYPEINFO 0
#endif
@@ -94,6 +102,8 @@
# endif
#endif
+#include <exception>
+
#if defined(__GNUG__)
# if HAVE_BUILTIN_H || HAVE_GXX_BUILTIN_H || HAVE_GPP_BUILTIN_H
# if ETIP_NEEDS_MATH_H
@@ -118,7 +128,16 @@
# include <generic.h>
#endif
-#include <curses.h>
+#if HAVE_EXCEPTION
+# include <exception>
+#endif
+#if HAVE_NEW
+# include <new>
+#endif
+
+// This used to include <curses.h>, but Apple's configuration as of 2024
+// provides only a broken version of ncurses's header, which interferes
+// with the configure script.
extern "C" {
#if HAVE_VALUES_H
@@ -128,6 +147,10 @@ extern "C" {
#include <assert.h>
#include <eti.h>
#include <errno.h>
+
+#ifndef HAVE_CONFIG_H
+int endwin(void); // needed for the configure check
+#endif
}
// Language features
@@ -200,7 +223,7 @@ public:
NCursesPanelException (const char *msg, int err) :
NCursesException (msg, err),
- p (0)
+ p (NULL)
{};
NCursesPanelException (const NCursesPanel* panel,
@@ -212,7 +235,7 @@ public:
explicit NCursesPanelException (int err) :
NCursesException ("panel library error", err),
- p (0)
+ p (NULL)
{};
NCursesPanelException (const NCursesPanel* panel,
@@ -251,7 +274,7 @@ public:
NCursesMenuException (const char *msg, int err) :
NCursesException (msg, err),
- m (0)
+ m (NULL)
{};
NCursesMenuException (const NCursesMenu* menu,
@@ -263,7 +286,7 @@ public:
explicit NCursesMenuException (int err) :
NCursesException ("menu library error", err),
- m (0)
+ m (NULL)
{};
NCursesMenuException (const NCursesMenu* menu,
@@ -302,7 +325,7 @@ public:
NCursesFormException (const char *msg, int err) :
NCursesException (msg, err),
- f (0)
+ f (NULL)
{};
NCursesFormException (const NCursesForm* form,
@@ -314,7 +337,7 @@ public:
explicit NCursesFormException (int err) :
NCursesException ("form library error", err),
- f (0)
+ f (NULL)
{};
NCursesFormException (const NCursesForm* form,
diff --git a/c++/internal.h b/c++/internal.h
index f67aaec3d99f..8777d8ea808d 100644
--- a/c++/internal.h
+++ b/c++/internal.h
@@ -1,6 +1,6 @@
// * This makes emacs happy -*-Mode: C++;-*-
/****************************************************************************
- * Copyright 2018,2020 Thomas E. Dickey *
+ * Copyright 2018-2020,2025 Thomas E. Dickey *
* Copyright 1998-2008,2012 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -32,7 +32,7 @@
* Author: Juergen Pfeifer, 1997 *
****************************************************************************/
-// $Id: internal.h,v 1.22 2020/08/29 23:06:41 tom Exp $
+// $Id: internal.h,v 1.23 2025/08/09 10:43:32 tom Exp $
#ifndef NCURSES_CPLUS_INTERNAL_H
#define NCURSES_CPLUS_INTERNAL_H 1
@@ -46,11 +46,7 @@
#endif
#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 f82b487fdfc5..0cd80573a6a2 100644
--- a/c++/modules
+++ b/c++/modules
@@ -1,7 +1,7 @@
# Program modules
-# $Id: modules,v 1.12 2020/02/02 23:34:34 tom Exp $
+# $Id: modules,v 1.13 2024/06/15 21:07:41 tom Exp $
##############################################################################
-# Copyright 2020 Thomas E. Dickey #
+# Copyright 2020,2024 Thomas E. Dickey #
# Copyright 1998-2006,2013 Free Software Foundation, Inc. #
# #
# Permission is hereby granted, free of charge, to any person obtaining a #
@@ -33,13 +33,13 @@
#
@ base
-cursesf c++ $(srcdir) $(internal_h) $(cursesf_h) $(cursesapp_h)
-cursesm c++ $(srcdir) $(internal_h) $(cursesm_h) $(cursesapp_h)
-cursesw c++ $(srcdir) $(internal_h) $(cursesw_h)
-cursespad c++ $(srcdir) $(internal_h) $(cursesw_h)
-cursesp c++ $(srcdir) $(internal_h) $(cursesp_h)
-cursslk c++ $(srcdir) $(internal_h) $(cursesapp_h)
-cursesapp c++ $(srcdir) $(internal_h) $(cursesapp_h)
-cursesmain c++ $(srcdir) $(internal_h) $(cursesapp_h) $(INCDIR)/nc_alloc.h
+cursesf c++ $(srcdir) $(HEADER_DEPS) $(internal_h) $(cursesf_h) $(cursesapp_h)
+cursesm c++ $(srcdir) $(HEADER_DEPS) $(internal_h) $(cursesm_h) $(cursesapp_h)
+cursesw c++ $(srcdir) $(HEADER_DEPS) $(internal_h) $(cursesw_h)
+cursespad c++ $(srcdir) $(HEADER_DEPS) $(internal_h) $(cursesw_h)
+cursesp c++ $(srcdir) $(HEADER_DEPS) $(internal_h) $(cursesp_h)
+cursslk c++ $(srcdir) $(HEADER_DEPS) $(internal_h) $(cursesapp_h)
+cursesapp c++ $(srcdir) $(HEADER_DEPS) $(internal_h) $(cursesapp_h)
+cursesmain c++ $(srcdir) $(HEADER_DEPS) $(internal_h) $(cursesapp_h) $(INCDIR)/nc_alloc.h
# vile:makemode