@@ -38,6 +38,14 @@ module deimos.curses;
3838
3939extern (C ):
4040
41+ /*
42+ * NCURSES_REENTRANT implies NCURSES_OPAQUE (as in the C configure script).
43+ * See ncurses configure.in lines 1377-1388.
44+ */
45+ version (NCURSES_REENTRANT) {
46+ version = NCURSES_OPAQUE ;
47+ }
48+
4149/*
4250 The symbols beginning NCURSES_ or USE_ are configuration choices.
4351 A few of the former can be overridden by applications at compile-time.
@@ -124,10 +132,26 @@ alias NCURSES_PAIRS_T = short;
124132 * Definitions used to make WINDOW and similar structs opaque.
125133 */
126134version (NCURSES_INTERNALS) {} else {
127- enum NCURSES_OPAQUE = 0 ;
128- enum NCURSES_OPAQUE_FORM = 0 ;
129- enum NCURSES_OPAQUE_MENU = 0 ;
130- enum NCURSES_OPAQUE_PANEL = 0 ;
135+ version (NCURSES_OPAQUE) {
136+ enum NCURSES_OPAQUE = 1 ;
137+ } else {
138+ enum NCURSES_OPAQUE = 0 ;
139+ }
140+ version (NCURSES_OPAQUE_FORM) {
141+ enum NCURSES_OPAQUE_FORM = 1 ;
142+ } else {
143+ enum NCURSES_OPAQUE_FORM = 0 ;
144+ }
145+ version (NCURSES_OPAQUE_MENU) {
146+ enum NCURSES_OPAQUE_MENU = 1 ;
147+ } else {
148+ enum NCURSES_OPAQUE_MENU = 0 ;
149+ }
150+ version (NCURSES_OPAQUE_PANEL) {
151+ enum NCURSES_OPAQUE_PANEL = 1 ;
152+ } else {
153+ enum NCURSES_OPAQUE_PANEL = 0 ;
154+ }
131155}
132156
133157/*
@@ -460,6 +484,9 @@ version (all) {
460484}
461485}
462486}
487+ } else { /* NCURSES_OPAQUE */
488+ /* Opaque struct - only WINDOW* pointers can be used */
489+ struct _win_st ;
463490} /* NCURSES_OPAQUE */
464491
465492/*
@@ -772,15 +799,21 @@ extern nothrow @nogc char * tiparm (const(char) *, ...); /* specia
772799/*
773800 * These functions are not in X/Open, but we use them in macro definitions:
774801 */
775- // extern nothrow @nogc int getattrs (const(WINDOW) *); /* generated */
776- // extern nothrow @nogc int getcurx (const(WINDOW) *); /* generated */
777- // extern nothrow @nogc int getcury (const(WINDOW) *); /* generated */
778- // extern nothrow @nogc int getbegx (const(WINDOW) *); /* generated */
779- // extern nothrow @nogc int getbegy (const(WINDOW) *); /* generated */
780- // extern nothrow @nogc int getmaxx (const(WINDOW) *); /* generated */
781- // extern nothrow @nogc int getmaxy (const(WINDOW) *); /* generated */
782- // extern nothrow @nogc int getparx (const(WINDOW) *); /* generated */
783- // extern nothrow @nogc int getpary (const(WINDOW) *); /* generated */
802+ // The functions in the block below are overridden in C
803+ // by macros (see `if (!NCURSES_OPAQUE)` lower in this file).
804+ // D does not have an equivalent to macros which override previously
805+ // defined functions, so we make these conditional instead.
806+ static if (NCURSES_OPAQUE ) {
807+ extern nothrow @nogc int getattrs (const (WINDOW ) * ); /* generated */
808+ extern nothrow @nogc int getcurx (const (WINDOW ) * ); /* generated */
809+ extern nothrow @nogc int getcury (const (WINDOW ) * ); /* generated */
810+ extern nothrow @nogc int getbegx (const (WINDOW ) * ); /* generated */
811+ extern nothrow @nogc int getbegy (const (WINDOW ) * ); /* generated */
812+ extern nothrow @nogc int getmaxx (const (WINDOW ) * ); /* generated */
813+ extern nothrow @nogc int getmaxy (const (WINDOW ) * ); /* generated */
814+ extern nothrow @nogc int getparx (const (WINDOW ) * ); /* generated */
815+ extern nothrow @nogc int getpary (const (WINDOW ) * ); /* generated */
816+ }
784817
785818/*
786819 * vid_attr() was implemented originally based on a draft of X/Open curses.
0 commit comments