From 4a9a92a2e8c1fbcf319ffa657fd315604e7a2925 Mon Sep 17 00:00:00 2001 From: PatR Date: Sat, 16 Feb 2019 15:34:23 -0800 Subject: [PATCH 1/2] VMS curses Add untested support for building the curses interface instead of or in addtion to tty. While in there, update Makefile.src's isaac64.obj dependency. --- sys/vms/Makefile.src | 37 +++++++++++++++++++++++++++++++++++-- sys/vms/vmsbuild.com | 29 +++++++++++++++++++++++------ 2 files changed, 58 insertions(+), 8 deletions(-) diff --git a/sys/vms/Makefile.src b/sys/vms/Makefile.src index 86a419a44..659698301 100644 --- a/sys/vms/Makefile.src +++ b/sys/vms/Makefile.src @@ -1,5 +1,5 @@ # NetHack Makefile (VMS) - for building nethack itself. -# NetHack 3.6 Makefile.src $NHDT-Date: 1549835645 2019/02/10 21:54:05 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.33 $ +# NetHack 3.6 Makefile.src $NHDT-Date: 1550360058 2019/02/16 23:34:18 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.34 $ # Copyright (c) 2011 by Robert Patrick Rankin # NetHack may be freely redistributed. See license for details. @@ -23,6 +23,7 @@ INC = [-.include] SYSSHR = [-.sys.share] SRC = [-.src] TTY = [-.win.tty] +CURSES = [-.win.curses] UTL = [-.util] VMS = [-.sys.vms] WINSHR = [-.win.share] @@ -74,6 +75,13 @@ WINTTYSRC = $(TTY)getline.c $(TTY)termcap.c $(TTY)topl.c $(TTY)wintty.c \ $(TERMCAPSRC) WINTTYOBJ = getline.obj,termcap.obj,topl.obj,wintty.obj $(TERMCAPOBJ) # +# curses; doesn't use termcap; may or may not support TERMTABLE for non-DEC tty +WINCURSESSRC = $(CURSES)cursdial.c $(CURSES)cursmesg.c $(CURSES)cursinit.c \ + $(CURSES)cursmisc.c $(CURSES)cursinvt.c $(CURSES)cursstat.c \ + $(CURSES)cursmain.c $(CURSES)curswins.c +WINCURSESOBJ = cursdial.obj,cursmesg.obj,cursinit.obj,cursmisc.obj, \ + cursinvt.obj,cursstat.obj,cursmain.obj,curswins.obj +# # an X11 port (not supported under DECwindows) WINX11SRC = $(X11)Window.c $(X11)dialogs.c $(X11)winX.c $(X11)winmap.c \ $(X11)winmenu.c $(X11)winmesg.c $(X11)winmisc.c $(X11)winstat.c \ @@ -82,8 +90,33 @@ WINX11OBJ = Window.obj,dialogs.obj,winX.obj,winmap.obj,winmenu.obj,\ winmesg.obj,winmisc.obj,winstat.obj,wintext.obj,winval.obj,tile.obj # # +# make sure both WANT_WIN_TTY and WANT_WIN_CURSES have a value +.ifndef WANT_WIN_CURSES +WANT_WIN_CURSES=0 +.endif +.ifndef WANT_WIN_TTY +.if WANT_WIN_CURSES +WANT_WIN_TTY=0 +.else +WANT_WIN_TTY=1 +.endif +.endif + +.if WANT_WIN_TTY WINSRC = $(WINTTYSRC) WINOBJ = $(WINTTYOBJ) +.if WANT_WIN_CURSES +WINSRC +=,$(WINCURSESSRC) +WINOBJ += $(WINCURSESOBJ) +.endif +.else +.if WANT_WIN_CURSES +WINSRC = $(WINCURSESSRC) +WINOBJ = $(WINCURSESOBJ) +.else +# Neither WANT_WIN_TTY nor WANT_WIN_CURSES? +.endif +.endif # make NetHack for VMS SYSTEM = SysVMS.timestamp; @@ -344,7 +377,7 @@ vmsfiles.obj : $(VMS)vmsfiles.c $(CONFIG_H) vmsmail.obj : $(VMS)vmsmail.c $(CONFIG_H) $(INC)mail.h \ $(INC)wintype.h $(INC)winprocs.h # conditionally used code -- VMS always wants these -isaac64.obj : isaac64.c +isaac64.obj : isaac64.c $(CONFIG_H) $(INC)isaac64.h random.obj : random.c $(HACK_H) random.c : $(SYSSHR)random.c copy $(SYSSHR)random.c random.c diff --git a/sys/vms/vmsbuild.com b/sys/vms/vmsbuild.com index 3b6e82295..28b6dba1a 100755 --- a/sys/vms/vmsbuild.com +++ b/sys/vms/vmsbuild.com @@ -1,24 +1,30 @@ $ ! vms/vmsbuild.com -- compile and link NetHack 3.6.* [pr] $ version_number = "3.6.2" -$ ! $NHDT-Date: 1549835647 2019/02/10 21:54:07 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.21 $ +$ ! $NHDT-Date: 1550360057 2019/02/16 23:34:17 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.22 $ $ ! Copyright (c) 2018 by Robert Patrick Rankin $ ! NetHack may be freely redistributed. See license for details. $ ! $ ! usage: $ ! $ set default [.src] !or [-.-.src] if starting from [.sys.vms] -$ ! $ @[-.sys.vms]vmsbuild [compiler-option] [link-option] [cc-switches] +$ ! $ @[-.sys.vms]vmsbuild [compiler-option] [link-option] [cc-switches] - +$ ! [linker-switches] [interface] $ ! options: $ ! compiler-option : either "VAXC", "DECC" or "GNUC" or "" !default VAXC $ ! link-option : either "SHARE[able]" or "LIB[rary]" !default SHARE $ ! cc-switches : optional qualifiers for CC (such as "/noOpt/Debug") +$ ! linker-switches : optional qualifers for LINK (/Debug or /noTraceback) +$ ! interface : "TTY" or "CURSES" or "TTY+CURSES" or "CURSES+TTY" $ ! notes: -$ ! If the symbol "CC" is defined, compiler-option is not used. +$ ! If the symbol "CC" is defined, compiler-option is not used (unless it +$ ! is "LINK"). $ ! The link-option refers to VAXCRTL (C Run-Time Library) handling; $ ! to specify it while letting compiler-option default, use "" as $ ! the compiler-option. $ ! To re-link without compiling, use "LINK" as special 'compiler-option'; $ ! to re-link with GNUC library, 'CC' must begin with "G" (or "g"). -$ ! Default wizard definition moved to include/vmsconf.h. +$ ! All options are positional; to specify a later one without an earlier +$ ! one, use "" in the earlier one's position, such as +$ ! $ @[-.sys.vms]vmsbuild "" "" "" "" "TTY+CURSES" $ $ decc_dflt = f$trnlnm("DECC$CC_DEFAULT") $ j = (decc_dflt.nes."") .and. 1 @@ -233,6 +239,18 @@ $ if f$search("random.c").eqs."" then copy [-.sys.share]random.c []*.* $ if f$search("tclib.c") .eqs."" then copy [-.sys.share]tclib.c []*.* $ if f$search("[-.util]lev_yacc.c").eqs."" then @[-.sys.vms]spec_lev.com $! +$ p5 := 'p5' +$ ttysrc = "[-.win.tty]getline,[-.win.tty]termcap" - + + ",[-.win.tty]topl,[-.win.tty]wintty" +$ cursessrc = "[-.win.curses]cursdial,[-.win/curses]cursmesg" - + + ",[-.win.curses]cursinit,[-.win.curses]cursmisc" - + + ",[-.win.curses]cursinvt,[-.win.curses]cursstat" - + + ",[-.win.curses]cursmain,[-.win.curses]curswins" +$ interface = ttysrc !default +$ if p5.eqs."CURSES" then interface = cursessrc +$ if p5.eqs."TTY+CURSES" then interface = ttysrc + "," + cursessrc +$ if p5.eqs."CURSES+TTY" then interface = cursessrc + "," + ttysrc +$! $! create object library $! $ if c_opt.ne.o_SPCL .or. f$search(nethacklib).eqs."" then - @@ -265,8 +283,7 @@ $ c_list = "decl,version,[-.sys.vms]vmsmain,[-.sys.vms]vmsunix" - + ",[]isaac64" - !already in [.src] + ",[]random,[]tclib,[]pmatchregex" !copied from [-.sys.share] $ gosub compile_list -$ c_list = "[-.win.tty]getline,[-.win.tty]termcap" - - + ",[-.win.tty]topl,[-.win.tty]wintty" +$ c_list = interface !ttysrc or cursessrc or both $ gosub compile_list $ c_list = "allmain,apply,artifact,attrib,ball,bones,botl,cmd,dbridge,detect" - + ",dig,display,do,do_name,do_wear,dog,dogmove,dokick,dothrow,drawing" - From 6b54456c45ab70446e33f64f7a1e546cb7c2c787 Mon Sep 17 00:00:00 2001 From: PatR Date: Sun, 17 Feb 2019 15:00:43 -0800 Subject: [PATCH 2/2] extended #version windowing options When makedefs generates dat/options for #version, enhance the formatting of the 'supported windowing systems' section with more thorough word fill and also emphasize the actual window system names so that user can tell what value to give to OPTIONS=window_system:%s when picking one of them. Before and after Supported windowing systems: traditional tty-based graphics, terminal-based graphics using curses libraries, and X11 with a default of tty. Supported windowing systems: "tty" (traditional text with optional line-drawing), "curses" (terminal-based graphics), and "X11", with a default of "tty". --- util/makedefs.c | 118 +++++++++++++++++++++++++++++++----------------- 1 file changed, 77 insertions(+), 41 deletions(-) diff --git a/util/makedefs.c b/util/makedefs.c index 04519c8dc..8a1c47610 100644 --- a/util/makedefs.c +++ b/util/makedefs.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 makedefs.c $NHDT-Date: 1539804926 2018/10/17 19:35:26 $ $NHDT-Branch: keni-makedefsm $:$NHDT-Revision: 1.126 $ */ +/* NetHack 3.6 makedefs.c $NHDT-Date: 1550444428 2019/02/17 23:00:28 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.141 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Kenneth Lorber, Kensington, Maryland, 2015. */ /* Copyright (c) M. Stephenson, 1990, 1991. */ @@ -187,6 +187,7 @@ static boolean FDECL(d_filter, (char *)); static boolean FDECL(h_filter, (char *)); static void NDECL(build_savebones_compat_string); static void NDECL(windowing_sanity); +static void FDECL(opt_out_words, (char *, int *)); static boolean FDECL(qt_comment, (char *)); static boolean FDECL(qt_control, (char *)); @@ -1678,10 +1679,23 @@ struct win_info { }; static struct win_info window_opts[] = { #ifdef TTY_GRAPHICS - { "tty", "traditional tty-based graphics" }, + { "tty", + /* testing 'USE_TILES' here would bring confusion because it could + apply to another interface such as X11, so check MSDOS explicitly + instead; even checking TTY_TILES_ESCCODES would probably be + confusing to most users (and it will already be listed separately + in the compiled options section so users aware of it can find it) */ +#ifdef MSDOS + "traditional text with optional 'tiles' graphics" +#else + /* assume that one or more of IBMgraphics, DECgraphics, or MACgraphics + can be enabled; we can't tell from here whether that is accurate */ + "traditional text with optional line-drawing" +#endif + }, #endif #ifdef CURSES_GRAPHICS - { "curses", "terminal-based graphics using curses libraries" }, + { "curses", "terminal-based graphics" }, #endif #ifdef X11_GRAPHICS { "X11", "X11" }, @@ -1749,12 +1763,38 @@ windowing_sanity() #endif /*DEFAULT_WINDOW_SYS*/ } +static const char opt_indent[] = " "; + +static void +opt_out_words(str, length_p) +char *str; /* input, but modified during processing */ +int *length_p; /* in/out */ +{ + char *word; + + while (*str) { + word = index(str, ' '); +#if 0 + /* treat " (" as unbreakable space */ + if (word && *(word + 1) == '(') + word = index(word + 1, ' '); +#endif + if (word) + *word = '\0'; + if (*length_p + (int) strlen(str) > COLNO - 5) + Fprintf(ofp, "\n%s", opt_indent), + *length_p = (int) strlen(opt_indent); + else + Fprintf(ofp, " "), (*length_p)++; + Fprintf(ofp, "%s", str), *length_p += (int) strlen(str); + str += strlen(str) + (word ? 1 : 0); + } +} + void do_options() { - static const char indent[] = " "; - const char *str, *sep; - char *word, buf[BUFSZ]; + char buf[BUFSZ]; int i, length, winsyscnt; windowing_sanity(); @@ -1770,56 +1810,52 @@ do_options() } build_savebones_compat_string(); - Fprintf(ofp, + Fprintf(ofp, "\n%sNetHack version %d.%d.%d%s\n", + opt_indent, + VERSION_MAJOR, VERSION_MINOR, PATCHLEVEL, #ifdef BETA - "\n NetHack version %d.%d.%d [beta]\n", + " [beta]" #else - "\n NetHack version %d.%d.%d\n", + "" #endif - VERSION_MAJOR, VERSION_MINOR, PATCHLEVEL); + ); Fprintf(ofp, "\nOptions compiled into this edition:\n"); length = COLNO + 1; /* force 1st item onto new line */ for (i = 0; i < SIZE(build_opts); i++) { - str = strcat(strcpy(buf, build_opts[i]), - (i < SIZE(build_opts) - 1) ? "," : "."); - while (*str) { - word = index(str, ' '); - if (word) - *word = '\0'; - if (length + strlen(str) > COLNO - 5) - Fprintf(ofp, "\n%s", indent), length = strlen(indent); - else - Fprintf(ofp, " "), length++; - Fprintf(ofp, "%s", str), length += strlen(str); - str += strlen(str) + (word ? 1 : 0); - } + opt_out_words(strcat(strcpy(buf, build_opts[i]), + (i < SIZE(build_opts) - 1) ? "," : "."), + &length); } + Fprintf(ofp, "\n"); /* terminate last line of words */ winsyscnt = SIZE(window_opts) - 1; - Fprintf(ofp, "\n\nSupported windowing system%s:\n", + Fprintf(ofp, "\nSupported windowing system%s:\n", (winsyscnt > 1) ? "s" : ""); length = COLNO + 1; /* force 1st item onto new line */ for (i = 0; i < winsyscnt; i++) { - str = window_opts[i].name; - if (length + strlen(str) > COLNO - 5) - Fprintf(ofp, "\n%s", indent), length = strlen(indent); - else - Fprintf(ofp, " "), length++; - Fprintf(ofp, "%s", str), length += strlen(str); - sep = (winsyscnt == 1) - ? "." - : (winsyscnt == 2) - ? ((i == 0) ? " and" : "") - : (i < winsyscnt - 2) - ? "," - : ((i == winsyscnt - 2) ? ", and" : ""); - Fprintf(ofp, "%s", sep), length += strlen(sep); + Sprintf(buf, "\"%s\"", window_opts[i].id); + if (strcmp(window_opts[i].name, window_opts[i].id)) + Sprintf(eos(buf), " (%s)", window_opts[i].name); + /* + * 1 : foo. + * 2 : foo and bar (note no period; comes from 'with default' below) + * 3+: for, bar, and quux + */ + opt_out_words(strcat(buf, (winsyscnt == 1) ? "." /* no 'default' */ + : (winsyscnt == 2 && i == 0) ? " and" + : (i == winsyscnt - 2) ? ", and" + : ","), + &length); } - if (winsyscnt > 1) - Fprintf(ofp, "\n%swith a default of %s.", indent, DEFAULT_WINDOW_SYS); - Fprintf(ofp, "\n\n"); + if (winsyscnt > 1) { + Sprintf(buf, "with a default of \"%s\".", DEFAULT_WINDOW_SYS); + opt_out_words(buf, &length); + } + Fprintf(ofp, "\n"); /* terminate last line of words */ + /* end with a blank line */ + Fprintf(ofp, "\n"); Fclose(ofp); return; }