From 191745016a1a4299137fe8a96c62edcfa2e29977 Mon Sep 17 00:00:00 2001 From: Simon Sobisch Date: Wed, 1 Jan 2025 12:23:42 +0000 Subject: [PATCH] make panel_hidden portable fixing #325 while being a breaking change returning TRUE (1) and FALSE (0) instead of OK (0) and ERR (-1) version constants increased, now at 4.5.0 --- curses.h | 4 ++-- demos/test_pan.c | 4 ---- docs/HISTORY.md | 8 +++++++- pdcurses/panel.c | 21 +++++++++++++-------- 4 files changed, 22 insertions(+), 15 deletions(-) diff --git a/curses.h b/curses.h index 51ac8e35..0f46d1f9 100644 --- a/curses.h +++ b/curses.h @@ -38,11 +38,11 @@ Defined by this header: /* NOTE : For version changes that are not backward compatible, */ /* the 'endwin_*' #defines below should be updated. */ #define PDC_VER_MAJOR 4 -#define PDC_VER_MINOR 4 +#define PDC_VER_MINOR 5 #define PDC_VER_CHANGE 0 #define PDC_VER_YEAR 2024 #define PDC_VER_MONTH 12 -#define PDC_VER_DAY 11 +#define PDC_VER_DAY 31 #define PDC_STRINGIZE( x) #x #define PDC_stringize( x) PDC_STRINGIZE( x) diff --git a/demos/test_pan.c b/demos/test_pan.c index 4e9f1a85..c5d79288 100644 --- a/demos/test_pan.c +++ b/demos/test_pan.c @@ -279,11 +279,7 @@ int main( const int argc, const char **argv) case 9: if( curr_top) { -#ifdef __PDCURSES__ - if( panel_hidden( curr_top) == OK) -#else if( panel_hidden( curr_top) == TRUE) -#endif show_panel( curr_top); else hide_panel( curr_top); diff --git a/docs/HISTORY.md b/docs/HISTORY.md index 9bb94f11..b674fe5c 100644 --- a/docs/HISTORY.md +++ b/docs/HISTORY.md @@ -1,7 +1,7 @@ Generally speaking, this history mentions only the more significant changes. See the git log for full details. -Current PDCursesMod - 2024 Oct 28 +Current PDCursesMod - 2024 Dec 31 ================================= Major new features @@ -54,6 +54,8 @@ Minor new features arbitrarily long strings via recursion. Added some code to test this in 'show_col.c'. 3f8dfa9e06 18ef78de69 +- PDC_wcwidth( ) updated from Unicode 14.0.0 to 16.0.0 93e32ef a5f13c2 + Bug fixes --------- @@ -119,6 +121,10 @@ Bug fixes - Fixes for Borland Turbo C compilation. a59f452e78 26128c29aa d6b7e998eb +- panel_hidden() is now portable, returning TRUE (1) and FALSE (0) instead + of OK (0) and ERR (-1) This may break existing applications, so you possibly + want to check for the PDCurses version number / date. + PDCursesMod 4.4.0 - 2023 November 30 =================================== diff --git a/pdcurses/panel.c b/pdcurses/panel.c index 60fb6d1a..4284d75c 100644 --- a/pdcurses/panel.c +++ b/pdcurses/panel.c @@ -1,8 +1,5 @@ /* PDCurses */ -#include -#include - /*man-start************************************************************** panel @@ -71,7 +68,8 @@ panel ceiling_panel() returns a pointer to the top panel in the deck. - panel_hidden() returns OK if pan is hidden and ERR if it is not. + panel_hidden() returns TRUE if pan is hidden, FALSE if not and + ERR if pan is NULL. panel_userptr() - Each panel has a user pointer available for maintaining relevant information. This function returns a pointer to @@ -100,7 +98,8 @@ panel Each routine that returns a pointer to an object returns NULL if an error occurs. Each panel routine that returns an integer, returns OK - if it executes successfully and ERR if it does not. + if it executes successfully and ERR if it does not, with the exception + of panel_hidden returning TRUE/FALSE/ERR. ### Portability X/Open ncurses NetBSD @@ -122,14 +121,21 @@ panel top_panel - Y Y update_panels - Y Y + Note: Before PDC_BUILD 4500 panel_hidden did not return the expected + values TRUE (1) and FALSE (0), but OK (0) and ERR (-1). + Credits: Original Author - Warren Tucker **man-end****************************************************************/ -#include #include +#include + +#include "curspriv.h" +#include + struct panel { WINDOW *win; @@ -430,11 +436,10 @@ PANEL *ground_panel( SCREEN *sp) int panel_hidden(const PANEL *pan) { - assert( pan); if (!pan) return ERR; - return _panel_is_linked(pan) ? ERR : OK; + return _panel_is_linked(pan) ? FALSE : TRUE; } const void *panel_userptr(const PANEL *pan)