]> granicus.if.org Git - nethack/commitdiff
version feedback (trunk only)
authornethack.rankin <nethack.rankin>
Fri, 23 Sep 2011 07:33:18 +0000 (07:33 +0000)
committernethack.rankin <nethack.rankin>
Fri, 23 Sep 2011 07:33:18 +0000 (07:33 +0000)
     Show the 'v' output (full version number plus build date-time) as
the first line of '#version' output (build time configuration settings).
It isn't simple to do that when generating dat/options (there's some
port-specific tweaking going), so do it at run-time by processing that
file one line at a time instead of passing it through a pager routine.

     This also inserts an "About NetHack" entry as the first choice in
the menu for '?', the way that most Windows programs have interactive
help organized.  Picking that gives the same output as using #version.

'make depend' manually updated for Unix and VMS (add dlb.h to version.*).

doc/fixes35.0
src/pager.c
src/version.c
sys/unix/Makefile.src
sys/vms/Makefile.src

index f55f7780bd419d5bc6e9f48c0617a4ad036b4b78..ebd664bd884dc60650db64c7c063f690c3a377aa 100644 (file)
@@ -523,6 +523,7 @@ flexibility for specifying "detect <foo>" vs "<foo> detection" when wishing
 when a sokoban puzzle has been completed (last pit or hole filled in),
        stop assessing luck penalties and lift most movement restrictions
 '`' command to show discoveries for one class of objects
+add "about nethack" to '?' menu as an alternate way to view 'v'+'#version'
 
 
 Platform- and/or Interface-Specific New Features
index 22cc5accc1186ba6be9f8fe349502c6b1f5d591d..446168f36dbe18c503b400539e3289e7647a35c3 100644 (file)
@@ -774,18 +774,21 @@ do_look(mode, click_cc)
     return 0;
 }
 
+/* the '/' command */
 int
 dowhatis()
 {
        return do_look(0,(coord *)0);
 }
 
+/* the ';' command */
 int
 doquickwhatis()
 {
        return do_look(1,(coord *)0);
 }
 
+/* the '^' command */
 int
 doidtrap()
 {
@@ -903,7 +906,7 @@ docontact()
        }
        putstr(cwin, 0, "To contact the NetHack development team directly,");
 /*XXX overflow possibilities*/
-       Sprintf(buf, " see the Contact form on our website or email %s",
+       Sprintf(buf, "see the Contact form on our website or email %s",
                DEVTEAM_EMAIL);
        putstr(cwin, 0, buf);
        putstr(cwin, 0, "");
@@ -916,22 +919,23 @@ docontact()
 
 /* data for help_menu() */
 static const char *help_menu_items[] = {
-/* 0*/ "Long description of the game and commands.",
-/* 1*/ "List of game commands.",
-/* 2*/ "Concise history of NetHack.",
-/* 3*/ "Info on a character in the game display.",
-/* 4*/ "Info on what a given key does.",
-/* 5*/ "List of game options.",
-/* 6*/ "Longer explanation of game options.",
-/* 7*/ "List of extended commands.",
-/* 8*/ "The NetHack license.",
-/* 9*/ "Support information.",
+/*  0*/        "About NetHack (version information).",
+/*  1*/        "Long description of the game and commands.",
+/*  2*/        "List of game commands.",
+/*  3*/        "Concise history of NetHack.",
+/*  4*/        "Info on a character in the game display.",
+/*  5*/        "Info on what a given key does.",
+/*  6*/        "List of game options.",
+/*  7*/        "Longer explanation of game options.",
+/*  8*/        "List of extended commands.",
+/*  9*/        "The NetHack license.",
+/* 10*/        "Support information.",
 #ifdef PORT_HELP
        "%s-specific help and commands.",
 #define PORT_HELP_ID 100
-#define WIZHLP_SLOT 11
+#define WIZHLP_SLOT 12
 #else
-#define WIZHLP_SLOT 10
+#define WIZHLP_SLOT 11
 #endif
 #ifdef WIZARD
        "List of wizard-mode commands.",
@@ -984,6 +988,7 @@ help_menu(sel)
        return FALSE;
 }
 
+/* the '?' command */
 int
 dohelp()
 {
@@ -991,22 +996,23 @@ dohelp()
 
        if (help_menu(&sel)) {
                switch (sel) {
-                       case  0:  display_file(HELP, TRUE);  break;
-                       case  1:  display_file(SHELP, TRUE);  break;
-                       case  2:  (void) dohistory();  break;
-                       case  3:  (void) dowhatis();  break;
-                       case  4:  (void) dowhatdoes();  break;
-                       case  5:  option_help();  break;
-                       case  6:  display_file(OPTIONFILE, TRUE);  break;
-                       case  7:  (void) doextlist();  break;
-                       case  8:  display_file(LICENSE, TRUE);  break;
-                       case  9:  (void) docontact(); break;
+                       case  0:  (void) doextversion();  break;
+                       case  1:  display_file(HELP, TRUE);  break;
+                       case  2:  display_file(SHELP, TRUE);  break;
+                       case  3:  (void) dohistory();  break;
+                       case  4:  (void) dowhatis();  break;
+                       case  5:  (void) dowhatdoes();  break;
+                       case  6:  option_help();  break;
+                       case  7:  display_file(OPTIONFILE, TRUE);  break;
+                       case  8:  (void) doextlist();  break;
+                       case  9:  display_file(LICENSE, TRUE);  break;
+                       case 10:  (void) docontact(); break;
 #ifdef PORT_HELP
                        case PORT_HELP_ID:  port_help();  break;
 #endif
                        default:
 #ifdef WIZARD
-                       /* handle slot 10 or 11 */
+                       /* handle slot 11 or 12 */
                                display_file(DEBUGHELP, TRUE);
 #endif
                                break;
@@ -1015,6 +1021,7 @@ dohelp()
        return 0;
 }
 
+/* the 'V' command; also a choice for '?' */
 int
 dohistory()
 {
index 2919759a5a4e894c2465acd5959cf4bff123f9c3..fa2c45bb50738d385edafb879589d9cda4620d07 100644 (file)
@@ -1,9 +1,9 @@
 /* NetHack 3.5 version.c       $Date$  $Revision$ */
-/*     SCCS Id: @(#)version.c  3.5     2006/12/11      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
 #include "hack.h"
+#include "dlb.h"
 #include "date.h"
 /*
  * All the references to the contents of patchlevel.h have been moved
@@ -40,6 +40,7 @@ char *buf;
        return buf;
 }
 
+/* the 'v' command */
 int
 doversion()
 {
@@ -49,10 +50,65 @@ doversion()
        return 0;
 }
 
+/* the '#version' command; also a choice for '?' */
 int
 doextversion()
 {
-       display_file(OPTIONS_USED, TRUE);
+       dlb *f;
+       char *cr, buf[BUFSZ];
+       winid win = create_nhwindow(NHW_TEXT);
+
+       /* instead of using ``display_file(OPTIONS_USED,TRUE)'' we handle
+          the file manually so we can include dynamic version info */
+       putstr(win, 0, getversionstring(buf));
+
+       f = dlb_fopen(OPTIONS_USED, "r");
+       if (!f) {
+           putstr(win, 0, "");
+           Sprintf(buf, "[Configuration '%s' not available?]", OPTIONS_USED);
+           putstr(win, 0, buf);
+       } else {
+    /*
+     * already inserted above:
+     * + outdented program name and version plus build date and time
+     * dat/options; display the contents with lines prefixed by '-' deleted:
+     * - blank-line
+     * -     indented program name and version
+     *   blank-line
+     *   outdented feature header
+     * - blank-line
+     *       indented feature list
+     *       spread over multiple lines
+     *   blank-line
+     *   outdented windowing header
+     * - blank-line
+     *       indented windowing choices with
+     *       optional second line for default
+     * - blank-line
+     * - EOF
+     */
+           boolean prolog = TRUE; /* to skip indented program name */
+
+           while (dlb_fgets(buf, BUFSZ, f)) {
+               if ((cr = index(buf, '\n')) != 0) *cr = 0;
+               if ((cr = index(buf, '\r')) != 0) *cr = 0;
+               if (index(buf, '\t') != 0) (void) tabexpand(buf);
+
+               if (*buf && *buf != ' ') {
+                   /* found outdented header; insert a separator since we'll
+                      have skipped corresponding blank line inside the file */
+                   putstr(win, 0, "");
+                   prolog = FALSE;
+               }
+               /* skip blank lines and prolog (progame name plus version) */
+               if (prolog || !*buf) continue;
+
+               putstr(win, 0, buf);
+           }
+           (void) dlb_fclose(f);
+           display_nhwindow(win, FALSE);
+           destroy_nhwindow(win);
+       }
        return 0;
 }
 
index 25725e6f11323220d3b33bb85b5cfa123a37356d..0c923c116339bea854d6d3efdd3d9e73614f9ece 100644 (file)
@@ -1,6 +1,5 @@
 #      NetHack Makefile.
 # NetHack 3.5  Makefile.src    $Date$  $Revision$
-#      SCCS Id: @(#)Makefile.src       3.5     2008/01/30
 
 # Root of source tree:
 NHSROOT=..
@@ -805,7 +804,8 @@ trap.o: trap.c $(HACK_H)
 u_init.o: u_init.c $(HACK_H)
 uhitm.o: uhitm.c $(HACK_H)
 vault.o: vault.c $(HACK_H)
-version.o: version.c $(HACK_H) ../include/date.h ../include/patchlevel.h
+version.o: version.c $(HACK_H) ../include/dlb.h ../include/date.h \
+               ../include/patchlevel.h
 vision.o: vision.c $(HACK_H) ../include/vis_tab.h
 weapon.o: weapon.c $(HACK_H)
 were.o: were.c $(HACK_H)
index 7e6728f6f483ef7fc79d1cf776d88c9f6a4dbcc8..69e23db37c2bd76daa9e7e17ff7a8c91aa068b3f 100644 (file)
@@ -469,7 +469,7 @@ trap.obj :  trap.c $(HACK_H)
 u_init.obj :   u_init.c $(HACK_H)
 uhitm.obj :    uhitm.c $(HACK_H)
 vault.obj :    vault.c $(HACK_H)
-version.obj :  version.c $(HACK_H) $(INC)date.h $(INC)patchlevel.h
+version.obj :  version.c $(HACK_H) $(INC)dlb.h $(INC)date.h $(INC)patchlevel.h
 vision.obj :   vision.c $(HACK_H) $(INC)vis_tab.h
 weapon.obj :   weapon.c $(HACK_H)
 were.obj :     were.c $(HACK_H)