From: nhmall Date: Fri, 30 Nov 2018 21:00:24 +0000 (-0500) Subject: curses follow-up bits X-Git-Tag: nmake-explicit-path~108 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8a9f98f179789c6455efb67fcbe8a603af5dbeae;p=nethack curses follow-up bits Move the curses global variable defininitions to cursmain.c. Make the references to those global variables extern in include/wincurs.h Get rid of a warning: ../win/curses/cursmesg.c:379:9: warning: declaration shadows a variable in the global scope [-Wshadow] int orig_cursor = curs_set(0); Kludge for Visual Studio compiler: Add a stub- file for use in Windows curses port builds to ensure that a needed #pragma is invoked prior to compiling the file pdcscrn.c in the PDCurses source distribution. All command line options and compile of the file. It is unreasonable to expect a NetHack builder to have to tinker with the PDCurses source files in order to build NetHack. This kludge means the NetHack builder doesn't have to. The file stub-pdcscrn.c contains only two lines: #pragma warning(disable : 4996) #include "pdcscrn.c" Some day, if the PDCurses sources corrects the issue, this can go away. --- diff --git a/include/wincurs.h b/include/wincurs.h index eb07879f4..55e7f1d22 100644 --- a/include/wincurs.h +++ b/include/wincurs.h @@ -7,16 +7,11 @@ /* Global declarations for curses interface */ -int term_rows, term_cols; /* size of underlying terminal */ - -WINDOW *base_term; /* underlying terminal window */ - -WINDOW *mapwin, *statuswin, *messagewin; /* Main windows */ - -int orig_cursor; /* Preserve initial cursor state */ - -boolean counting; /* Count window is active */ - +extern int term_rows, term_cols; /* size of underlying terminal */ +extern int orig_cursor; /* Preserve initial cursor state */ +extern WINDOW *base_term; /* underlying terminal window */ +extern boolean counting; /* Count window is active */ +extern WINDOW *mapwin, *statuswin, *messagewin; /* Main windows */ #define TEXTCOLOR /* Allow color */ #define NHW_END 19 diff --git a/sys/winnt/Makefile.msc b/sys/winnt/Makefile.msc index 926eed8ad..4db6936ff 100644 --- a/sys/winnt/Makefile.msc +++ b/sys/winnt/Makefile.msc @@ -73,8 +73,8 @@ DEBUGINFO = Y # PDCurses header (.h) files and PDCURSES_C to the location # of your PDCurses C files. # -#ADD_CURSES=Y -#PDCURSES_TOP=..\..\pdcurses +ADD_CURSES=Y +PDCURSES_TOP=..\..\pdcurses # #============================================================================== # This marks the end of the BUILD DECISIONS section. @@ -399,7 +399,7 @@ PDCLIBOBJS = $(O)addch.o $(O)addchstr.o $(O)addstr.o $(O)attr.o $(O)beep.o PDCOBJS = $(O)pdcclip.o $(O)pdcdisp.o $(O)pdcgetsc.o $(O)pdckbd.o $(O)pdcscrn.o \ $(O)pdcsetsc.o $(O)pdcutil.o -PDCLIB = $(O)\pdcurses.lib +PDCLIB = $(O)pdcurses.lib PDCINCL = /I$(PDCURSES_TOP) /I$(PDCSRC) /I$(PDCWINCON) @@ -1257,16 +1257,19 @@ $(O)tile2bmp.o: $(WSHR)\tile2bmp.c $(HACK_H) $(TILE_H) $(MSWSYS)\win32api.h $(O)til2bm32.o: $(WSHR)\tile2bmp.c $(HACK_H) $(TILE_H) $(MSWSYS)\win32api.h @$(cc) $(cflagsBuild) -I$(WSHR) /DPACKED_FILE /DTILE_X=32 /DTILE_Y=32 /Fo$@ $(WSHR)\tile2bmp.c -#========================================== +#=============================================================================== # PDCurses -#========================================== +#=============================================================================== -$(O)\pdcurses.lib : $(PDCLIBOBJS) $(PDCOBJS) +$(O)pdcurses.lib : $(PDCLIBOBJS) $(PDCOBJS) lib -nologo /out:$@ $(PDCLIBOBJS) $(PDCOBJS) -#========================================== +$(O)pdcscrn.o : $(PDCURSES_HEADERS) $(PDCWINCON)\pdcscrn.c $(MSWSYS)\stub-pdcscrn.c + $(cc) $(PDCINCL) $(cflagsBuild) -Fo$@ $(MSWSYS)\stub-pdcscrn.c + +#=============================================================================== # Housekeeping -#========================================== +#=============================================================================== spotless: clean ! IF ("$(OBJ)"!="") diff --git a/sys/winnt/stub-pdcscrn.c b/sys/winnt/stub-pdcscrn.c new file mode 100644 index 000000000..7588a782b --- /dev/null +++ b/sys/winnt/stub-pdcscrn.c @@ -0,0 +1,15 @@ +/* + * Use this stub to insert a needed pragma prior + * to compiling $(PDCWINCON)\pdcscrn.c in the + * PDCurses distribution. + * + * We don't want to ask NetHack builders to + * modify the PDCurses distribution in any way, + * we only ask that they have the original intact + * PDCurses source tree available during the build. + * + */ + +#pragma warning(disable : 4996) +#include "pdcscrn.c" + diff --git a/win/curses/cursmain.c b/win/curses/cursmain.c index 8e20a31f8..2412def4b 100644 --- a/win/curses/cursmain.c +++ b/win/curses/cursmain.c @@ -80,6 +80,16 @@ struct window_procs curses_procs = { genl_can_suspend_yes, }; +/* + * Global variables for curses interface + */ + +int term_rows, term_cols; /* size of underlying terminal */ +int orig_cursor; /* Preserve initial cursor state */ +WINDOW *base_term; /* underlying terminal window */ +boolean counting; /* Count window is active */ +WINDOW *mapwin, *statuswin, *messagewin; /* Main windows */ + /* Track if we're performing an update to the permanent window. Needed since we aren't using the normal menu functions to handle the inventory window. */ diff --git a/win/curses/cursmesg.c b/win/curses/cursmesg.c index 69215871a..df45d07b8 100644 --- a/win/curses/cursmesg.c +++ b/win/curses/cursmesg.c @@ -371,12 +371,12 @@ curses_message_win_getline(const char *prompt, char *answer, int buffer) char *tmpstr; /* for free() */ int maxy, maxx; /* linewrap / scroll */ int ch; - WINDOW *win = curses_get_nhwin(MESSAGE_WIN); int border_space = 0; int len = 0; /* of answer string */ boolean border = curses_window_has_border(MESSAGE_WIN); - int orig_cursor = curs_set(0); + + orig_cursor = curs_set(0); curses_get_window_size(MESSAGE_WIN, &height, &width); if (border) {