author Ray Chason <ray.chason@protonmail.com> 1684372172 -0400
committer nhmall <nhmall@nethack.org> 1685414340 -0400

Add configuration to support Curses on WinGUI

and enable support for Unicode on Curses.

Allow NetHackW to select the Curses interface

Reorder drawing of extended command prompt

Curses on WinGUI needs this change. This may be a bug in PDCursesMod,
but it seems to be harmless to the other ports.

Avoid calling Curses after the windows are closed

Provide erase_char and kill_char for WinGUI Curses

Set Lua version to 5.4.6
This commit is contained in:
Ray Chason
2023-05-29 22:39:43 -04:00
committed by nhmall
parent 97edec62b5
commit 9037592ea1
6 changed files with 82 additions and 25 deletions
+1
View File
@@ -694,6 +694,7 @@ count_and_validate_winopts(void)
#ifdef WIN32 #ifdef WIN32
window_opts[i].valid = FALSE; window_opts[i].valid = FALSE;
if ((GUILaunched if ((GUILaunched
&& case_insensitive_comp(window_opts[i].id, "curses") != 0
&& case_insensitive_comp(window_opts[i].id, "mswin") != 0) && case_insensitive_comp(window_opts[i].id, "mswin") != 0)
|| (!GUILaunched || (!GUILaunched
&& case_insensitive_comp(window_opts[i].id, "mswin") == 0)) && case_insensitive_comp(window_opts[i].id, "mswin") == 0))
+64 -20
View File
@@ -111,6 +111,15 @@ INTERNET_AVAILABLE=Y
GIT_AVAILABLE=Y GIT_AVAILABLE=Y
endif endif
# if WANT_GUICURSES=1 is passed, use the Bill Gray pdcursesmod and enable
# curses in NetHackW
ifeq "$(WANT_GUICURSES)" "1"
PDCURSES=pdcursesmod
else
PDCURSES=pdcurses
endif
PDCURSESFLAGS = -DPDC_WIDE
# #
#============================================================================== #==============================================================================
# Sanity checks for prerequisite Lua and pdcurses # Sanity checks for prerequisite Lua and pdcurses
@@ -167,10 +176,10 @@ endif # LUA_MAY_PROCEED
# Now, pdcurses # Now, pdcurses
ifeq "$(INTERNET_AVAILABLE)" "Y" ifeq "$(INTERNET_AVAILABLE)" "Y"
ifeq "$(GIT_AVAILABLE)" "Y" ifeq "$(GIT_AVAILABLE)" "Y"
PDCURSES_TOP=../submodules/pdcurses PDCURSES_TOP=../submodules/$(PDCURSES)
ADD_CURSES=Y ADD_CURSES=Y
else # GIT_AVAILABLE else # GIT_AVAILABLE
PDCURSES_TOP=../lib/pdcurses PDCURSES_TOP=../lib/$(PDCURSES)
ADD_CURSES=Y ADD_CURSES=Y
endif # GIT_AVAILABLE endif # GIT_AVAILABLE
else # INTERNET_AVAILABLE is not Y below else # INTERNET_AVAILABLE is not Y below
@@ -179,11 +188,11 @@ else # INTERNET_AVAILABLE is not Y below
# the expected locations already, with precedence given to ../submodules, # the expected locations already, with precedence given to ../submodules,
# then ../lib. # then ../lib.
# #
ifneq ("$(wildcard ../submodules/pdcurses/curses.h)", "") ifneq ("$(wildcard ../submodules/$(PDCURSES)/curses.h)", "")
PDCURSES_TOP=../submodules/pdcurses PDCURSES_TOP=../submodules/$(PDCURSES)
ADD_CURSES=Y ADD_CURSES=Y
else ifneq ("$(wildcard ../lib/pdcurses/curses.h)", "") else ifneq ("$(wildcard ../lib/$(PDCURSES)/curses.h)", "")
PDCURSES_TOP=../lib/pdcurses PDCURSES_TOP=../lib/$(PDCURSES)
ADD_CURSES=Y ADD_CURSES=Y
endif # pdcurses sources available somewhere endif # pdcurses sources available somewhere
@@ -499,15 +508,17 @@ CLEAN_FILE += $(RTARGETS) $(ROBJS)
#========================================== #==========================================
ifeq "$(ADD_CURSES)" "Y" ifeq "$(ADD_CURSES)" "Y"
OP = $(O)pdcurses OP = $(O)pdcurses
PDCOBJS = $(addprefix $(OP)/, addch.o addchstr.o addstr.o attr.o beep.o bkgd.o border.o \ PDCCOMMONOBJS = $(addprefix $(OP)/, \
clear.o color.o debug.o delch.o deleteln.o getch.o getstr.o getyx.o \ addch.o addchstr.o addstr.o attr.o beep.o bkgd.o border.o clear.o \
inch.o inchstr.o initscr.o inopts.o insch.o insstr.o \ color.o debug.o delch.o deleteln.o getch.o getstr.o getyx.o inch.o \
kernel.o keyname.o mouse.o move.o outopts.o overlay.o \ inchstr.o initscr.o inopts.o insch.o insstr.o kernel.o keyname.o \
pad.o panel.o pdcclip.o pdcdisp.o pdcgetsc.o pdckbd.o pdcscrn.o pdcsetsc.o pdcutil.o printw.o \ mouse.o move.o outopts.o overlay.o pad.o panel.o printw.o refresh.o \
refresh.o scanw.o scr_dump.o scroll.o slk.o termattr.o touch.o util.o window.o) scanw.o scr_dump.o scroll.o slk.o termattr.o touch.o util.o window.o)
PDCOBJS = $(PDCCOMMONOBJS) $(addprefix $(OP)/, \
pdcclip.o pdcdisp.o pdcgetsc.o pdckbd.o pdcscrn.o pdcsetsc.o pdcutil.o)
PDCSRC = $(PDCURSES_TOP)/pdcurses PDCSRC = $(PDCURSES_TOP)/pdcurses
PDCWINCON = $(PDCURSES_TOP)/wincon PDCWINCON = $(PDCURSES_TOP)/wincon
PDCINCL = -I$(PDCURSES_TOP) -I$(PDCSRC) -I$(PDCWINCON) PDCINCL = -I$(PDCURSES_TOP) -I$(PDCSRC)
PDCLIB = $(O)pdcurses.a PDCLIB = $(O)pdcurses.a
PDCDEP = $(PDCURSES_TOP)/curses.h PDCDEP = $(PDCURSES_TOP)/curses.h
@@ -517,16 +528,40 @@ $(PDCLIB): $(PDCOBJS)
ar rcs $@ $^ ar rcs $@ $^
$(OP)/%.o: $(PDCSRC)/%.c | $(OP) $(OP)/%.o: $(PDCSRC)/%.c | $(OP)
$(cc) $(CFLAGS) $(PDCINCL) -D_LIB $< -o$@ $(cc) $(CFLAGS) $(PDCURSESFLAGS) $(PDCINCL) -D_LIB $< -o$@
$(OP)/%.o: $(PDCWINCON)/%.c | $(OP) $(OP)/%.o: $(PDCWINCON)/%.c | $(OP)
$(cc) $(CFLAGS) $(PDCINCL) -D_LIB $< -o$@ $(cc) $(CFLAGS) $(PDCURSESFLAGS) $(PDCINCL) -I$(PDCWINCON) -D_LIB $< -o$@
$(OP): $(OP):
@mkdir -p $@ @mkdir -p $@
CLEAN_DIR += $(OP) CLEAN_DIR += $(OP)
CLEAN_FILE += $(PDCLIB) $(PDCOBJS) CLEAN_FILE += $(PDCLIB) $(PDCOBJS)
ifneq ("$(wildcard $(PDCURSES_TOP)/wingui/pdcwin.h)", "")
# pdcursesmod in use; enable Curses graphics on NetHackW
OPW = $(O)pdcursesw
PDCWOBJS = $(PDCCOMMONOBJS) $(addprefix $(OPW)/, \
pdcclip.o pdcdisp.o pdcgetsc.o pdckbd.o pdcscrn.o pdcsetsc.o pdcutil.o)
PDCWINGUI = $(PDCURSES_TOP)/wingui
PDCWLIB = $(O)pdcursesw.a
pdcursesw: $(PDCWLIB)
$(PDCWLIB): $(PDCWOBJS)
ar rcs $@ $^
$(OPW)/%.o: $(PDCWINGUI)/%.c | $(OPW)
$(cc) $(CFLAGS) $(PDCURSESFLAGS) $(PDCINCL) -I$(PDCWINGUI) -D_LIB $< -o$@
$(OPW):
@mkdir -p $@
CLEAN_DIR += $(OPW)
CLEAN_FILE += $(PDCWLIB) $(PDCWOBJS)
endif
endif endif
#========================================== #==========================================
@@ -752,8 +787,8 @@ fetchlua:
git submodule update --remote ../submodules/lua ; fi git submodule update --remote ../submodules/lua ; fi
fetchpdcurses: fetchpdcurses:
@if [ ! -f $(PDCURSES_TOP)/curses.h ] ; then \ @if [ ! -f $(PDCURSES_TOP)/curses.h ] ; then \
git submodule init ../submodules/pdcurses && \ git submodule init ../submodules/$(PDCURSES) && \
git submodule update --remote ../submodules/pdcurses ; fi git submodule update --remote ../submodules/$(PDCURSES) ; fi
else # GIT_AVAILABLE no else # GIT_AVAILABLE no
CURLLUASRC=http://www.lua.org/ftp/lua-5.4.6.tar.gz CURLLUASRC=http://www.lua.org/ftp/lua-5.4.6.tar.gz
CURLLUADST=lua-5.4.6.tar.gz CURLLUADST=lua-5.4.6.tar.gz
@@ -945,9 +980,14 @@ BMPS = $(addprefix $(MSWIN)/, $(addsuffix .bmp, mnsel mnselcnt mnunsel petmark p
NHWRES = $(ONHW)/winres.o NHWRES = $(ONHW)/winres.o
NHWTARGETS = $(GAMEDIR)/NetHackW.exe NHWTARGETS = $(GAMEDIR)/NetHackW.exe
ifneq "$(PDCWINGUI)" ""
CFLAGSW += $(NHCURSESFLAGS)
NHWONLY += $(addsuffix .o, cursdial cursinit cursinvt cursmain cursmesg cursmisc cursstat curswins guitty)
endif
nethackw: $(NHWTARGETS) nethackw: $(NHWTARGETS)
$(GAMEDIR)/NetHackW.exe: $(NHWOBJS) $(NHWRES) $(DATEW_O) $(LUALIB) | $(GAMEDIR) $(GAMEDIR)/NetHackW.exe: $(NHWOBJS) $(NHWRES) $(DATEW_O) $(LUALIB) $(PDCWLIB) | $(GAMEDIR)
$(ld) $(LDFLAGS) -mwindows $^ $(LIBS) -static -lstdc++ $(SOUNDLIBLIBS) -o$@ $(ld) $(LDFLAGS) -mwindows $^ $(LIBS) -static -lstdc++ $(SOUNDLIBLIBS) -o$@
$(ONHW)/%.o: $(SRC)/%.c $(NHLUAH) | $(ONHW) $(ONHW)/%.o: $(SRC)/%.c $(NHLUAH) | $(ONHW)
@@ -989,6 +1029,9 @@ $(ONHW)/%.o: $(MSWIN)/%.c $(NHLUAH) | $(ONHW)
$(ONHW)/%.o: $(WSHR)/%.c $(NHLUAH) | $(ONHW) $(ONHW)/%.o: $(WSHR)/%.c $(NHLUAH) | $(ONHW)
$(cc) $(CFLAGSW) $< -o$@ $(cc) $(CFLAGSW) $< -o$@
$(ONHW)/%.o: $(WCURSES)/%.c $(NHLUAH) | $(ONH)
$(cc) $(CFLAGSW) $(PDCINCL) $< -o$@
$(NHWRES): $(MSWIN)/NetHackW.rc $(BMPS) $(WAV) $(MSWIN)/NetHack.ico | $(ONHW) $(NHWRES): $(MSWIN)/NetHackW.rc $(BMPS) $(WAV) $(MSWIN)/NetHack.ico | $(ONHW)
$(rc) --include-dir=$(MSWIN) $(RCFLAGS) --input=$< -o$@ $(rc) --include-dir=$(MSWIN) $(RCFLAGS) --input=$< -o$@
@@ -1019,7 +1062,8 @@ ONH = $(O)nethack
NHONLY = consoletty.o getline.o topl.o wintty.o NHONLY = consoletty.o getline.o topl.o wintty.o
ifeq "$(ADD_CURSES)" "Y" ifeq "$(ADD_CURSES)" "Y"
CFLAGSNH += -DCURSES_GRAPHICS -DCHTYPE_32 -DPDC_NCMOUSE NHCURSESFLAGS = -DCURSES_GRAPHICS -DCURSES_UNICODE $(PDCURSESFLAGS) -DPDC_NCMOUSE
CFLAGSNH += $(NHCURSESFLAGS)
NHONLY += $(addsuffix .o, cursdial cursinit cursinvt cursmain cursmesg cursmisc cursstat curswins) NHONLY += $(addsuffix .o, cursdial cursinit cursinvt cursmain cursmesg cursmisc cursstat curswins)
endif endif
DATE_O = $(addsuffix .o, $(addprefix $(ONH)/, date)) DATE_O = $(addsuffix .o, $(addprefix $(ONH)/, date))
@@ -1091,7 +1135,7 @@ CLEAN_FILE += $(NHTARGET) $(NHOBJS) $(NHRES)
#=============== TARGETS ================== #=============== TARGETS ==================
#========================================== #==========================================
.PHONY: all clean default install lua makedefs recover pdcurses \ .PHONY: all clean default install lua makedefs recover pdcurses pdcursesw \
tile2bmp tilemap uudecode dlb nethackw nethack tileutil \ tile2bmp tilemap uudecode dlb nethackw nethack tileutil \
fetchlua fetchpdcurses fetchlua fetchpdcurses
+4
View File
@@ -0,0 +1,4 @@
/* Provide erase_char and kill_char for Curses on Windows GUI */
char erase_char;
char kill_char;
+4 -2
View File
@@ -86,7 +86,7 @@ int windows_startup_state = 0; /* we flag whether to continue with this */
extern int redirect_stdout; /* from sys/share/pcsys.c */ extern int redirect_stdout; /* from sys/share/pcsys.c */
extern int GUILaunched; extern int GUILaunched;
HANDLE hStdOut; HANDLE hStdOut;
char default_window_sys[] = char default_window_sys[7] =
#if defined(MSWIN_GRAPHICS) #if defined(MSWIN_GRAPHICS)
"mswin"; "mswin";
#elif defined(TTY_GRAPHICS) #elif defined(TTY_GRAPHICS)
@@ -560,9 +560,11 @@ _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);*/
/* /*
* It seems you really want to play. * It seems you really want to play.
*/ */
#ifndef CURSES_GRAPHICS
if (argc >= 1 && !strcmpi(default_window_sys, "mswin") if (argc >= 1 && !strcmpi(default_window_sys, "mswin")
&& (strstri(argv[0], "nethackw.exe") || GUILaunched)) && (strstri(argv[0], "nethackw.exe") || GUILaunched))
iflags.windowtype_locked = TRUE; iflags.windowtype_locked = TRUE;
#endif
windowtype = default_window_sys; windowtype = default_window_sys;
#ifdef DLB #ifdef DLB
@@ -582,7 +584,7 @@ _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);*/
#if defined(TTY_GRAPHICS) #if defined(TTY_GRAPHICS)
Strcpy(default_window_sys, "tty"); Strcpy(default_window_sys, "tty");
#else #else
#if defined(CURSES_GRAPHICS) #if defined(CURSES_GRAPHICS) && !defined(MSWIN_GRAPHICS)
Strcpy(default_window_sys, "curses"); Strcpy(default_window_sys, "curses");
#endif /* CURSES */ #endif /* CURSES */
#endif /* TTY */ #endif /* TTY */
+1 -1
View File
@@ -417,11 +417,11 @@ curses_ext_cmd(void)
while (1) { while (1) {
wmove(extwin, starty, startx); wmove(extwin, starty, startx);
wclrtoeol(extwin);
waddstr(extwin, "# "); waddstr(extwin, "# ");
wmove(extwin, starty, startx + 2); wmove(extwin, starty, startx + 2);
waddstr(extwin, cur_choice); waddstr(extwin, cur_choice);
wmove(extwin, starty, (int) strlen(cur_choice) + startx + 2); wmove(extwin, starty, (int) strlen(cur_choice) + startx + 2);
wclrtoeol(extwin);
/* if we have an autocomplete command, AND it matches uniquely */ /* if we have an autocomplete command, AND it matches uniquely */
if (matches == 1 && ecmatches) { if (matches == 1 && ecmatches) {
+8 -2
View File
@@ -175,6 +175,10 @@ curses_refresh_nethack_windows(void)
map_window = curses_get_nhwin(MAP_WIN); map_window = curses_get_nhwin(MAP_WIN);
inv_window = curses_get_nhwin(INV_WIN); inv_window = curses_get_nhwin(INV_WIN);
if (!iflags.window_inited) {
return;
}
if ((gm.moves <= 1) && !gi.invent) { if ((gm.moves <= 1) && !gi.invent) {
/* Main windows not yet displayed; refresh base window instead */ /* Main windows not yet displayed; refresh base window instead */
touchwin(stdscr); touchwin(stdscr);
@@ -322,8 +326,10 @@ curses_del_nhwin(winid wid)
wid); wid);
return; return;
} }
delwin(nhwins[wid].curwin); if (nhwins[wid].curwin != NULL) {
nhwins[wid].curwin = NULL; delwin(nhwins[wid].curwin);
nhwins[wid].curwin = NULL;
}
nhwins[wid].nhwin = -1; nhwins[wid].nhwin = -1;
} }