[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Portable menu and forms libraries
From: |
Bill Gray |
Subject: |
Re: Portable menu and forms libraries |
Date: |
Thu, 25 Jul 2024 22:16:28 -0400 |
User-agent: |
Mozilla Thunderbird |
Hi Thomas, all,
Turns out it's indeed possible (with modest effort) to use the menu
library with PDCurses or PDCursesMod. I had to add a rudimentary
curses.priv.h and nc_alloc.h, and modify the PDCursesMod makefiles and
(existing) ncurses_cfg.h slightly. (Haven't pushed this to GitHub yet.)
I also had to change exactly one line in the ncurses menu library
code, at line 69 of menu/menu.priv.h :
#define Get_Menu_UserWin(menu) ((menu)->userwin ? \
(menu)->userwin : CURRENT_SCREEN->_stdscr)
This relies on access to SCREEN internals, which (a) are apt to
differ among curses implementations and (b) are opaque in PDCursesMod
anyway.
I've worked around this by changing the above to use the StdScreen
macro :
#define Get_Menu_UserWin(menu) ((menu)->userwin ? \
(menu)->userwin : StdScreen( CURRENT_SCREEN))
In the PDCursesMod version of curses.priv.h, I have
#define StdScreen(sp) stdscr
(compared to the definition (sp)->_stdscr in the ncurses version of
that file.)
It'd be nice if the ncurses version of menu.priv.h could have a
similar change. PDCurses* users could then use the ncurses menu library
source without altering anything at all.
With that, I was able to modify PDCursesMod to build the menu
library, then compile demo_menus.c and link it to the resulting library
and the PDCursesMod library, and run it without problems. (I did have
to use 32-bit chtypes; the default PDCursesMod 64-bit chtypes got their
upper half stripped, resulting in default-color menus. Haven't puzzled
that one out yet...)
The forms library, on the other hand, makes extensive use of
ncurses internals and will take much more effort. I've put use of that
with PDCurses* on hold.
Thanks! -- Bill