Skip to content

Commit

Permalink
The ncurses 'menu' library can now be built and used with PDCursesMod…
Browse files Browse the repository at this point in the history
…, and the ncurses program 'demo_menus' built and used to test it out.
  • Loading branch information
Bill-Gray committed Jul 29, 2024
1 parent 21b4154 commit 07bc4ac
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 26 deletions.
4 changes: 2 additions & 2 deletions curses.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ Defined by this header:
#define PDC_VER_MINOR 4
#define PDC_VER_CHANGE 0
#define PDC_VER_YEAR 2024
#define PDC_VER_MONTH 06
#define PDC_VER_DAY 19
#define PDC_VER_MONTH 07
#define PDC_VER_DAY 29

#define PDC_STRINGIZE( x) #x
#define PDC_stringize( x) PDC_STRINGIZE( x)
Expand Down
25 changes: 25 additions & 0 deletions demos/curses.priv.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include <curses.h>

#define NCURSES_SP_NAME(name) name
#define NCURSES_API
#define T(a)
#define returnAttr(code) return code
#define returnBool(code) return code
#define returnCode(code) return code
#define returnCPtr(code) return code
#define returnPtr(code) return code
#define returnVoidPtr(code) return code
#define returnWin(code) return code
#define CURRENT_SCREEN SP
#define NCURSES_INLINE inline
#define Min(a,b) ((a) > (b) ? (b) : (a))
#define TR_FUNC_BFR(max)
#define NCURSES_SP_DCLx

#define StdScreen(sp) stdscr
#define UChar(c) ((unsigned char)(c))
#define ChCharOf(c) ((chtype)(c) & (chtype)A_CHARTEXT)
#define CharOf(c) ChCharOf(c)
#define BLANK ' '
#define ZEROS '\0'

53 changes: 45 additions & 8 deletions demos/nctests.mif
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# This provides for compiling and linking the ncurses test programs.

ncurses_testdir = $(HOME)/ncurses-6.5/test
menudir = $(HOME)/ncurses-6.5/menu
formdir = $(HOME)/ncurses-6.5/form

NCURSES_TESTS = back_ground$(E) background$(E) blue$(E) \
bs$(E) cardfile$(E) chgat$(E) clip_printw$(E) color_content$(E) \
Expand All @@ -13,14 +15,49 @@ filter$(E) firstlast$(E) foldkeys$(E) form_driver_w$(E) gdc$(E) \
hanoi$(E) hashtest$(E) inchs$(E) inch_wide$(E) insdelln$(E) \
inserts$(E) ins_wide$(E) key_names$(E) keynames$(E) knight$(E) \
list_keys$(E) lrtest$(E) move_field$(E) \
movewindow$(E) ncurses$(E) newdemo$(E) padview$(E) pair_content$(E) \
movewindow$(E) newdemo$(E) padview$(E) pair_content$(E) \
picsmap$(E) railroad$(E) redraw$(E) savescreen$(E) sp_tinfo$(E) \
tclock$(E) testaddch$(E) test_addchstr$(E) test_addstr$(E) \
test_add_wchstr$(E) test_addwstr$(E) test_arrays$(E) \
test_delwin$(E) test_getstr$(E) test_get_wstr$(E) test_instr$(E) \
test_opaque$(E) testscanw$(E) test_setupterm$(E) test_sgr$(E) test_termattrs$(E) \
test_tparm$(E) test_vid_puts$(E) test_vidputs$(E) view$(E)

MENUOBJS = m_attribs.$(O) m_cursor.$(O) m_driver.$(O) m_format.$(O) \
m_global.$(O) m_hook.$(O) m_item_cur.$(O) m_item_nam.$(O) m_item_new.$(O) \
m_item_opt.$(O) m_items.$(O) m_item_top.$(O) m_item_use.$(O) m_item_val.$(O) \
m_item_vis.$(O) m_new.$(O) m_opts.$(O) m_pad.$(O) m_pattern.$(O) m_post.$(O) \
m_req_name.$(O) m_scale.$(O) m_spacing.$(O) m_sub.$(O) m_trace.$(O) \
m_userptr.$(O) m_win.$(O)

FORMOBJS = fld_arg.$(O) fld_link.$(O) fld_user.$(O) frm_req_name.$(O) \
fty_generic.$(O) fld_attr.$(O) fld_max.$(O) frm_cursor.$(O) frm_scale.$(O) \
fty_int.$(O) fld_current.$(O) fld_move.$(O) frm_data.$(O) frm_sub.$(O) \
fty_ipv4.$(O) fld_def.$(O) fld_newftyp.$(O) frm_def.$(O) frm_user.$(O) \
fty_num.$(O) fld_dup.$(O) fld_opts.$(O) frm_driver.$(O) frm_win.$(O) \
fty_regex.$(O) fld_ftchoice.$(O) fld_pad.$(O) frm_hook.$(O) f_trace.$(O) \
fld_ftlink.$(O) fld_page.$(O) frm_opts.$(O) fty_alnum.$(O) \
fld_info.$(O) fld_stat.$(O) frm_page.$(O) fty_alpha.$(O) \
fld_just.$(O) fld_type.$(O) frm_post.$(O) fty_enum.$(O) \

LIBMENUNAME=libmenu
LIBMENU = $(LIBMENUNAME).a

$(LIBMENU) : $(MENUOBJS)
$(LIBEXE) $(LIBFLAGS) $@ $?

$(MENUOBJS) : %.o: $(menudir)/%.c
$(BUILD) $(SFLAGS) -DBUILDING_MENU -I $(demodir) -c $<

LIBFORMNAME=libform
LIBFORM = $(LIBFORMNAME).a

$(LIBFORM) : $(FORMOBJS)
$(LIBEXE) $(LIBFLAGS) $@ $?

$(FORMOBJS) : %.o: $(formdir)/%.c
$(BUILD) $(SFLAGS) -DBUILDING_FORM -I $(demodir) -I $(menudir) -c $<

ncurses_tests: $(NCURSES_TESTS)

ncurses_clean:
Expand Down Expand Up @@ -67,8 +104,8 @@ demo_forms$(E): $(ncurses_testdir)/demo_forms.c
demo_keyok$(E): $(ncurses_testdir)/demo_keyok.c
$(BUILD) $(NCFLAGS) -o $@ $< $(LDFLAGS)

demo_menus$(E): $(ncurses_testdir)/demo_menus.c
$(BUILD) $(NCFLAGS) -o $@ $< $(LDFLAGS)
demo_menus$(E): $(ncurses_testdir)/demo_menus.c libmenu.a
$(BUILD) $(NCFLAGS) -o $@ $< $(LDFLAGS) libmenu.a

demo_new_pair$(E): $(ncurses_testdir)/demo_new_pair.c $(ncurses_testdir)/popup_msg.c $(srcdir)/terminfo.c
$(BUILD) $(NCFLAGS) -o $@ $^ $(LDFLAGS)
Expand Down Expand Up @@ -139,8 +176,8 @@ inchs$(E): $(ncurses_testdir)/inchs.c $(ncurses_testdir)/popup_msg.c
inch_wide$(E): $(ncurses_testdir)/inch_wide.c $(ncurses_testdir)/popup_msg.c
$(BUILD) $(NCFLAGS) -o $@ $^ $(LDFLAGS)

insdelln$(E): $(ncurses_testdir)/insdelln.c
$(BUILD) $(NCFLAGS) -o $@ $< $(LDFLAGS)
insdelln$(E): $(ncurses_testdir)/insdelln.c $(ncurses_testdir)/popup_msg.c
$(BUILD) $(NCFLAGS) -o $@ $^ $(LDFLAGS)

inserts$(E): $(ncurses_testdir)/inserts.c
$(BUILD) $(NCFLAGS) -o $@ $< $(LDFLAGS)
Expand Down Expand Up @@ -169,8 +206,8 @@ move_field$(E): $(ncurses_testdir)/move_field.c
movewindow$(E): $(ncurses_testdir)/movewindow.c
$(BUILD) $(NCFLAGS) -o $@ $< $(LDFLAGS)

ncurses$(E): $(ncurses_testdir)/ncurses.c
$(BUILD) $(NCFLAGS) -o $@ $< $(LDFLAGS)
ncurses$(E): $(ncurses_testdir)/ncurses.c $(ncurses_testdir)/popup_msg.c $(LIBFORM) $(LIBMENU)
$(BUILD) $(NCFLAGS) -o $@ $^ $(LDFLAGS) $(LIBFORM) $(LIBMENU)

newdemo$(E): $(ncurses_testdir)/newdemo.c
$(BUILD) $(NCFLAGS) -o $@ $< $(LDFLAGS)
Expand All @@ -191,7 +228,7 @@ redraw$(E): $(ncurses_testdir)/redraw.c $(ncurses_testdir)/popup_msg.c
$(BUILD) $(NCFLAGS) -o $@ $^ $(LDFLAGS)

savescreen$(E): $(ncurses_testdir)/savescreen.c $(ncurses_testdir)/popup_msg.c
$(BUILD) $(NCFLAGS) -o $@ $< $(LDFLAGS)
$(BUILD) $(NCFLAGS) -o $@ $^ $(LDFLAGS)

sp_tinfo$(E): $(ncurses_testdir)/sp_tinfo.c
$(BUILD) $(NCFLAGS) -o $@ $< $(LDFLAGS)
Expand Down
40 changes: 24 additions & 16 deletions demos/ncurses_cfg.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,30 @@
* "make ncurses_tests" to start.
* "make ncurses_clean" when you're done.
*
* Builds: bs gdc hanoi knight tclock ncurses (many others)
* Builds: bs gdc hanoi knight tclock ncurses (many others, see
* nctests.mif for the full list... many tests are still not built;
* many are not really relevant to PDCurses.)
*/

#define PDC_NCMOUSE
#define DATA_DIR "."
#define NCURSES_CONST
#define NCURSES_EXPORT(foo) foo

#define RETSIGTYPE void
// #define RETSIGTYPE void
#define TIME_WITH_SYS_TIME 1
#define HAVE_SYS_TIME_H 1
#define HAVE_SYS_TIME_SELECT 1
#define HAVE_UNISTD_H 1
#define HAVE_TERMATTRS 1

#include <curspriv.h>

#define ExitProgram exit
#include <curses.h>

#define HAVE_ALLOC_PAIR 1
#define HAVE_ASSUME_DEFAULT_COLORS 1
#define HAVE_CHGAT 1
#define HAVE_COLOR_CONTENT 1
#define HAVE_COPYWIN 1
#define HAVE_CURSES_VERSION 1
#define HAVE_DELSCREEN 1
#define HAVE_GETBEGX 1
#define HAVE_GETCURX 1
#define HAVE_GETMAXX 1
Expand All @@ -46,24 +45,34 @@
#define HAVE_LOCALE_H 1
#define HAVE_MATH_H 1
#define HAVE_MATH_FUNCS 1
#define HAVE_MENU_H 1
#define HAVE_NAPMS 1
#define HAVE_NEWPAD 1
#define HAVE_PANEL_H 1
#define HAVE_PUTWIN 1
#define HAVE_RIPOFFLINE 1
#define HAVE_SCR_DUMP 1
#define HAVE_SLK_COLOR 1
#define HAVE_SLK_INIT 1
#define HAVE_STRSTR 1
#define HAVE_USE_DEFAULT_COLORS 1
#define HAVE_WINSDELLN 1
#define HAVE_WRESIZE 1
#define USE_STRING_HACKS 1
#define USE_LIBMENU 1

#ifdef PDC_WIDE
# define USE_WIDEC_SUPPORT 1
# define HAVE_WCSRTOMBS 1
# define HAVE_MBSRTOWCS 1
# define HAVE_MBRTOWC 1
# define HAVE_MBRLEN 1
# define USE_WIDEC_SUPPORT 1
# define HAVE_WCSRTOMBS 1
# define HAVE_WCTYPE_H 1
# define HAVE_MBSRTOWCS 1
# define HAVE_MBRTOWC 1
# define HAVE_MBRLEN 1
# define wcwidth PDC_wcwidth
PDCEX int PDC_wcwidth( const int32_t ucs);
# define NCURSES_CH_T cchar_t
#else
# define NCURSES_CH_T chtype
#endif

/* Fool ncurses.c so it gives us all the tests, and doesn't redefine
Expand All @@ -72,16 +81,15 @@
#ifdef __GNUC__
#define GCC_UNUSED __attribute__((unused))
#define GCC_NORETURN __attribute__((noreturn))
#define GCC_DEPRECATED(msg) __attribute__((deprecated))
#else
#define GCC_UNUSED
#define GCC_NORETURN
#define GCC_DEPRECATED(msg)
#endif

#define NCURSES_VERSION PDCURSES

#ifdef PDC_WIDE
#define wcwidth PDC_wcwidth
PDCEX int PDC_wcwidth( const int32_t ucs);
#endif
#include <ncurses_dll.h>

char *tigetstr( const char *capname);

0 comments on commit 07bc4ac

Please sign in to comment.