]> granicus.if.org Git - nethack/commitdiff
curses options and status groundwork
authorPatR <rankin@nethack.org>
Thu, 21 Mar 2019 21:33:39 +0000 (14:33 -0700)
committerPatR <rankin@nethack.org>
Thu, 21 Mar 2019 21:33:39 +0000 (14:33 -0700)
More groundwork for overhauling the status display for curses, plus
a few functional changes.  It was doing a full status update for
every changed field (except conditions), instead of waiting for a
flush directive after gathering multiple changes at a time.  Since
it already does gather every change, the fix to wait is trivial.

This decouples 'hitpointbar' from 'statushilites'.  When highlighting
is off, it uses inverse video only.  When on, it behaves as before:
using inverse video plus the most recent color used to highlight HP
(which can vary if that has rules to highlight changes or percentage
thresholds) but ignoring any HP attribute(s).  This also enables the
latent 'statuslines' option and changes 'windowborders' option from
being settable at startup only to changeable during play.

'statuslines' can have a value of 2 (the default) or 3 and applies to
'align_status:bottom' or 'top'; it's ignored for 'left' and 'right'.
At the moment, setting it to 3 only allows status condition overflow
to wrap from the end of line to 2 to the beginning of line 3, and if
window borders are drawn they'll clobber the last character on line 2
and first one on line 3.  There's no point in trying to fix that
because it will go away when the main status overhaul changes go in.
Condition wrapping for vertical orientation (left or right placement)
was already subject to the same phenomenon and will be superseded too.

This also changes the meaning of the 'windowborders' value so could
impact players using source from git (or possibly beta binaries for
Windows, but not for OSX where curses interface wasn't included).
Old:
 0 = unspecified, 1 = On, 2 = Off, 3 = Auto (On if display is big
     enough, Off otherwise; reevaluated after dynamic resizing);
 Unspecified got changed to 3 during curses windowing initialization.
New:
 0 = Off, 1 = On, 2 = Auto;
 0 gets changed to 2 for default value at start of options processing.
So old value of 2 is changing meaning and explicit old value of 3 is
becoming invalid.  Implicit 3 changes to default 2.  Explicit 3 could
be the subject of a fixup but there isn't much point since 2 can't
have a similar fix.  Users who are using old 2 or explicit 3 will need
to update their run-time config files.

This adds 'statuslines' to the Guidebook and moves some other recently
added documentation of curses options from among the general options
(section 9.4) to "Window Port Customization options" (section 9.5).
None of them have been added to dat/opthelp which seems to be missing
all the wincap options.

Originally I made a lot of changes (mostly moving C99 declarations to
start of their blocks) to the old '#if 0' code at end of cursstat.c,
but have tossed those, except for one subtle bug that assumed 'int'
and 'long' are the same size.

doc/Guidebook.mn
doc/Guidebook.tex
doc/fixes36.2
include/flag.h
include/winprocs.h
src/options.c
win/curses/cursinit.c
win/curses/cursmain.c
win/curses/cursmesg.c
win/curses/cursstat.c

index ec00bf74ba7dd87cc32c561502805d922e587f3e..0f67c2b0d1ed9b7b68f4a2c3719d6894300aee2e 100644 (file)
@@ -1,4 +1,4 @@
-.\" $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.299 $ $NHDT-Date: 1551488947 2019/03/02 01:09:07 $
+.\" $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.300 $ $NHDT-Date: 1553204011 2019/03/21 21:33:31 $
 .\"
 .\" This is an excerpt from the 'roff' man page from the 'groff' package.
 .\" NetHack's Guidebook.mn currently does *not* adhere to these guidelines.
@@ -24,7 +24,7 @@
 .ds vr "NetHack 3.6
 .ds f0 "\*(vr
 .ds f1
-.ds f2 "February 27, 2019
+.ds f2 "March 19, 2019
 .
 .\" A note on some special characters:
 .\" \(lq = left double quote
@@ -3010,10 +3010,6 @@ Gold is never blessed or cursed, but it is not described as \(lquncursed\(rq
 even when the
 .op implicit_uncursed
 option is \(lqoff\(rq.
-.lp guicolor
-Use color text and/or highlighting attributes when displaying some
-non-map data (such as menu selector letters).
-Curses interface only; default is on.
 .lp "help    "
 If more information is available for an object looked at
 with the \(oq/\(cq command, ask if you want to see it (default on).
@@ -3281,6 +3277,7 @@ such as \(lqparanoid_confirmation:attack pray Remove\(rq.
 .lp perm_invent
 If true, always display your current inventory in a window.  This only
 makes sense for windowing system interfaces that implement this feature.
+.\" petattr is a wincap option but we'll document it here...
 .lp petattr
 Specifies one or more text highlighting attributes to use when showing
 pets on the map.
@@ -3308,7 +3305,7 @@ Currently multiple highlight-style letters can be combined by simply
 stringing them together (for example, \(lqbk\(rq), but in the future
 they might require being separated by plus signs (such as \(lqb+k\(rq,
 which works already).
-When using the \(oqN\(cq choice, it should be specified on its own,
+When using the \(oqn\(cq choice, it should be specified on its own,
 not in combination with any of the other letters.
 .lp pettype
 Specify the type of your initial pet, if you are playing a character class
@@ -3473,13 +3470,6 @@ and prior versions (for example \(lqsuppress_alert:3.3.1\(rq).
 This option may be used to select one of the named symbol sets found within
 \(lqsymbols\(rq to alter the symbols displayed on the screen.
 Use \(lqsymset:default\(rq to explicitly select the default symbols.
-.lp "term_cols\ \ \fIand\fP"
-.lp term_rows
-Curses interface only.
-Number of columns and rows to use for the display.
-Curses will attempt to resize to the values specified but will settle
-for smaller sizes if they are too big.
-Default is the current window size.
 .lp "time    "
 Show the elapsed game time in turns on bottom line (default off).
 Persistent.
@@ -3554,26 +3544,20 @@ When getting a location on the map, and using shifted movement keys or
 meta-digit keys to fast-move, instead of moving 8 units at a time,
 move by skipping the same glyphs.
 (default off)
-.lp windowborders
-Whether to draw boxes around the map, status area, message area, and
-persistent inventory window if enabled.
-Curses interface only.
-Acceptable values are
-.sd
-.si
-.CC 1 "on, always show borders"
-.CC 2 "off, never show borders"
-.CC 3 "auto, on if terminal or window is at least (24+2)x(80+2)\ \ (default)"
-.ei
-.ed
-.lp ""
-(The 26x82 size threshold for \(oq3\(cq refers to number of rows and
-columns of the display.)
 .lp windowtype
 When the program has been built to support multiple interfaces,
 select which one to use, such as \(lqtty\(rq or \(lqX11\(rq
 (default depends on build-time settings; use \(lq#version\(rq to check).
 Cannot be set with the \(oqO\(cq command.
+.lp ""
+When used, it should be the first option set since its value might
+enable or disable the availability of various other options.
+For multiple lines in a configuration file, that would be the first
+non-comment line.
+For a comma-separated list in NETHACKOPTIONS or an OPTIONS line in a
+configuration file,
+that would
+be the \fIrightmost\fP option in the list.
 .lp wizweight
 Augment object descriptions with their objects' weight (default off).
 Debug mode only.
@@ -3634,6 +3618,10 @@ If NetHack can, it should use this size font for text windows.
 .lp fullscreen
 If NetHack can, it should try and display on the entire screen rather than
 in a window.
+.lp guicolor
+Use color text and/or highlighting attributes when displaying some
+non-map data (such as menu selector letters).
+Curses interface only; default is on.
 .lp large_font
 If NetHack can, it should use a large font.
 .lp map_mode
@@ -3665,6 +3653,17 @@ Handhelds are most likely to support this option.
 .lp splash_screen
 If NetHack can, it should display an opening splash screen when it starts
 up (default yes).
+.lp statuslines
+Number of lines for traditional below-the-map status display.
+Acceptable values are 2 and 3 (default is 2).
+Curses interface only.
+.lp "term_cols\ \ \fIand\fP"
+.lp term_rows
+Curses interface only.
+Number of columns and rows to use for the display.
+Curses will attempt to resize to the values specified but will settle
+for smaller sizes if they are too big.
+Default is the current window size.
 .lp tiled_map
 If NetHack can, it should display a tiled map if it can.
 .lp tile_file
@@ -3680,6 +3679,24 @@ If NetHack can, it should display inverse when the game specifies it.
 .lp vary_msgcount
 If NetHack can, it should display this number of messages at a time in
 the message window.
+.lp windowborders
+Whether to draw boxes around the map, status area, message area, and
+persistent inventory window if enabled.
+Curses interface only.
+Acceptable values are
+.sd
+.si
+.CC 0 "off, never show borders"
+.CC 1 "on, always show borders"
+.CC 2 "auto, on if display is at least (24+2)x(80+2)\ \ (default)"
+.ei
+.ed
+.lp ""
+(The 26x82 size threshold for \(oq2\(cq refers to number of rows and
+columns of the display.
+A width of at least 110 columns (80+2+26+2) is needed for
+.op align_status
+set to \f(CRleft\fP or \f(CRright\fP.)
 .lp windowcolors
 If NetHack can, it should display windows with the specified
 foreground/background colors. Windows GUI only. The format is
index 497fb660a5e10ba4aa4063b40352536fcb6b4d8a..ad3fa1ce72d4f20b9f1b3aac3401cbe9e9484cea 100644 (file)
@@ -45,7 +45,7 @@
 %.au
 \author{Original version - Eric S. Raymond\\
 (Edited and expanded for 3.6 by Mike Stephenson and others)}
-\date{February 27, 2019}
+\date{March 19, 2019}
 
 \maketitle
 
@@ -3305,11 +3305,6 @@ or {\tt U} (known to be uncursed, when `off', the default).
 Gold is never blessed or cursed, but it is not described as ``uncursed''
 even when the {\it implicit\verb+_+uncursed\/} option is `off'.
 %.lp
-\item[\ib{guicolor}]
-Use color text and/or highlighting attributes when displaying some
-non-map data (such as menu selector letters).
-Curses interface only; default is on.
-%.lp
 \item[\ib{help}]
 If more information is available for an object looked at
 with the `{\tt /}' command, ask if you want to see it (default on).
@@ -3614,6 +3609,7 @@ such as ``{\it par\-a\-noid\verb+_+con\-fir\-ma\-tion:attack~pray~Remove}''.
 If true, always display your current inventory in a window.  This only
 makes sense for windowing system interfaces that implement this feature.
 %.lp
+%.\" petattr is a wincap option but we'll document it here...
 \item[\ib{petattr}]
 Specifies one or more text highlighting attributes to use when showing
 pets on the map.
@@ -3642,7 +3638,7 @@ Currently multiple highlight-style letters can be combined by simply
 stringing them together (for example, ``bk''), but in the future
 they might require being separated by plus signs (such as ``b\verb&+&k'',
 which works already).
-When using the `N' choice, it should be specified on its own,
+When using the `n' choice, it should be specified on its own,
 not in combination with any of the other letters.
 
 %.lp
@@ -3754,8 +3750,8 @@ depend upon the window port used or on the type of terminal.  Persistent.
 Prevent you from (knowingly) attacking your pets (default on).  Persistent.
 %+.lp
 \item[\ib{sanity\verb+_+check}]
-+Evaluate monsters, objects, and map prior to each turn (default off).
-+Debug mode only.
+Evaluate monsters, objects, and map prior to each turn (default off).
+Debug mode only.
 %.lp
 \item[\ib{scores}]
 Control what parts of the score list you are shown at the end (for example,
@@ -3823,15 +3819,6 @@ This option may be used to select one of the named symbol sets found within
 {\tt symbols} to alter the symbols displayed on the screen.
 Use ``{\tt symset:default}'' to explicitly select the default symbols.
 %.lp
-\item[\ib{term\verb+_+cols}\ \ {\it and}]"
-%.lp
-\item[\ib{term\verb+_+rows}]
-Curses interface only.
-Number of columns and rows to use for the display.
-Curses will attempt to resize to the values specified but will settle
-for smaller sizes if they are too big.
-Default is the current window size.
-%.lp
 \item[\ib{time}]
 Show the elapsed game time in turns on bottom line (default off).  Persistent.
 %.lp
@@ -3923,30 +3910,19 @@ meta-digit keys to fast-move, instead of moving 8 units at a time,
 move by skipping the same glyphs.
 (default off)
 %.lp
-\item[\ib{windowborders}]
-Whether to draw boxes around the map, status area, message area, and
-persistent inventory window if enabled.
-Curses interface only.
-Acceptable values are
-
-%.sd
-%.si
-{\tt 1} --- on, always show borders\\
-{\tt 2} --- off, never show borders\\
-{\tt 3} --- auto, on if terminal or window is at least
-(24\verb&+&2)x(80\verb&+&2)\ \ (default)\\
-%.ei
-%.ed
-
-%.lp ""
-(The 26x82 size threshold for `3' refers to number of rows and
-columns of the display.)
-%.lp
 \item[\ib{windowtype}]
 When the program has been built to support multiple interfaces,
 select whichone to use, such as ``{\tt tty}'' or ``{\tt X11}''
 (default depends on build-time settings; use ``{\tt \#version}'' to check).
 Cannot be set with the `{\tt O}' command.
+
+%.lp ""
+When used, it should be the first option set since its value might
+enable or disable the availability of various other options.
+For multiple lines in a configuration file, that would be the first
+non-comment line.
+For a comma-separated list in NETHACKOPTIONS or an OPTIONS line in a
+configuration file, that would be the {\it rightmost\/} option in the list.
 %.lp
 \item[\ib{wizweight}]
 Augment object descriptions with their objects' weight (default off).
@@ -4031,6 +4007,11 @@ If {\it NetHack\/} can, it should use this size font for text windows.
 \item[\ib{fullscreen}]
 If {\it NetHack\/} can, it should try and display on the entire screen rather than in a window.
 %.lp
+\item[\ib{guicolor}]
+Use color text and/or highlighting attributes when displaying some
+non-map data (such as menu selector letters).
+Curses interface only; default is on.
+%.lp
 \item[\ib{large\verb+_+font}]
 If {\it NetHack\/} can, it should use a large font.
 %.lp
@@ -4063,10 +4044,26 @@ If {\it NetHack\/} can, it should display a menu of existing saved games for the
 choose from at game startup, if it can. Not all ports support this option.
 %.lp
 \item[\ib{softkeyboard}]
-If {\it NetHack\/} can, it should display an onscreen keyboard.  Handhelds are most likely to support this option.
+If {\it NetHack\/} can, it should display an onscreen keyboard.
+Handhelds are most likely to support this option.
 %.lp
 \item[\ib{splash\verb+_+screen}]
-If {\it NetHack\/} can, it should display an opening splash screen when it starts up (default yes).
+If {\it NetHack\/} can, it should display an opening splash screen when
+it starts up (default yes).
+%.lp
+\item[\ib{statuslines}]
+Number of lines for traditional below-the-map status display.
+Acceptable values are 2 and 3 (default is 2).
+Curses interface only.
+%.lp
+\item[\ib{term\verb+_+cols}\ \ {\it and}]"
+%.lp
+\item[\ib{term\verb+_+rows}]
+Curses interface only.
+Number of columns and rows to use for the display.
+Curses will attempt to resize to the values specified but will settle
+for smaller sizes if they are too big.
+Default is the current window size.
 %.lp
 \item[\ib{tiled\verb+_+map}]
 If {\it NetHack\/} can, it should display a tiled map if it can.
@@ -4090,6 +4087,28 @@ If {\it NetHack\/} can, it should display inverse when the game specifies it.
 If {\it NetHack\/} can, it should display this number of messages at a time
 in the message window.
 %.lp
+\item[\ib{windowborders}]
+Whether to draw boxes around the map, status area, message area, and
+persistent inventory window if enabled.
+Curses interface only.
+Acceptable values are
+
+%.sd
+%.si
+{\tt 0} --- off, never show borders\\
+{\tt 1} --- on, always show borders\\
+{\tt 2} --- auto, on display is at least
+(\verb&24+2&)x(\verb&80+2&)\ \ (default)\\
+%.ei
+%.ed
+
+%.lp "
+(The 26x82 size threshold for `2' refers to number of rows and
+columns of the display.
+A width of at least 110 columns (\verb&80+2+26+2&) is needed for
+{\it align_status\/}
+set to {tt left} or {\tt right}.)
+%.lp
 \item[\ib{windowcolors}]
 If {\it NetHack\/} can, it should display windows with the specified
 foreground/background colors. Windows GUI only. The format is
index a0297e8a5ee1add4b3059a0405b43e39528db892..e76a86e04f36481aea4a031b2b0aa9e7de6bc976 100644 (file)
@@ -1,4 +1,4 @@
-$NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.276 $ $NHDT-Date: 1552697495 2019/03/16 00:51:35 $
+$NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.277 $ $NHDT-Date: 1553204013 2019/03/21 21:33:33 $
 
 This fixes36.2 file is here to capture information about updates in the 3.6.x
 lineage following the release of 3.6.1 in April 2018. Please note, however,
@@ -474,8 +474,8 @@ X11: rollback disabling of keystroke input for PICK_NONE menus (for scrolling)
 curses: catch up with tty to not put dolook/whatis autodescribe feedback into
        ^P message recall (multi-digit count feedback was already handled)
 curses: if the interface code ran out of memory, it would crash rather than
-       attempt a controlled panic (which is fairly likely crash anyway if
-       done when there's no memory available)
+       attempt a controlled panic (though that's fairly likely to crash anyway
+       if done when there's no more memory available)
 curses: when getting multi-character responses from player, support <delete>
        as well as <backspace> to remove last character entered; also, return
        <escape> to core if ESC is typed when there is no input entered
@@ -483,7 +483,14 @@ curses: extend preceding <delete> support to typing of extended command names
 curses: support hilite_pet and hilite_pile even when color is disabled
 curses: support color hilite_status rules even if 'guicolor' is off
 curses: update status if 'O' is used to add/change/remove hilite_status rules
+curses: was doing a full status update for every changed field even when more
+       than one field was being changed at the same time
+curses: 'hitpointbar' now works even when status highlighting is disabled
+curses: add 'statuslines' option (value is 2 or 3)
+curses: change 'windowborders' option's value (0=Off, 1=On, or 2=Auto instead
+       of 1=On, 2=Off, 3=Auto; can now be changed via 'O' during play)
 vms: add compile of isaac64.c to Makefile.src and vmsbuild.com
+vms+curses: add compile support but it is known to fail to build
 
 
 Platform- and/or Interface-Specific Fixes or Features
index 1306356c4c5d5c126c23b2cf0e818ba8122fd573..cf545edbb6bbbc3b71dc6209692e708c6cf26610 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6 flag.h  $NHDT-Date: 1514071158 2017/12/23 23:19:18 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.132 $ */
+/* NetHack 3.6 flag.h  $NHDT-Date: 1553204011 2019/03/21 21:33:31 $  $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.148 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Michael Allison, 2006. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -367,7 +367,6 @@ struct instance_flags {
     boolean wizweight;       /* display weight of everything in wizard mode */
     boolean cmdassist;       /* provide detailed assistance for some commands */
     boolean clicklook;          /* allow right-clicking for look */
-    int statuslines;         /* default = 2, code support for alternative 3 */
     /*
      * Window capability support.
      */
@@ -387,10 +386,8 @@ struct instance_flags {
     char *wc_backgrnd_menu; /* points to backgrnd color name for menu win   */
     char *wc_foregrnd_message; /* points to foregrnd color name for msg win */
     char *wc_backgrnd_message; /* points to backgrnd color name for msg win */
-    char *
-        wc_foregrnd_status; /* points to foregrnd color name for status win */
-    char *
-        wc_backgrnd_status; /* points to backgrnd color name for status win */
+    char *wc_foregrnd_status; /* points to foregrnd color name for status   */
+    char *wc_backgrnd_status; /* points to backgrnd color name for status   */
     char *wc_foregrnd_text; /* points to foregrnd color name for text win   */
     char *wc_backgrnd_text; /* points to backgrnd color name for text win   */
     char *wc_font_map;      /* points to font name for the map win */
@@ -418,13 +415,13 @@ struct instance_flags {
     boolean wc2_selectsaved;    /* display a menu of user's saved games */
     boolean wc2_darkgray;    /* try to use dark-gray color for black glyphs */
     boolean wc2_hitpointbar;  /* show graphical bar representing hit points */
+    boolean wc2_guicolor;       /* allow colours in gui (outside map) */
     int wc_mouse_support;       /* allow mouse support */
     int wc2_term_cols;         /* terminal width, in characters */
     int wc2_term_rows;         /* terminal height, in characters */
+    int wc2_statuslines;        /* default = 2, curses can handle 3 */
     int wc2_windowborders;     /* display borders on NetHack windows */
     int wc2_petattr;            /* text attributes for pet */
-    boolean wc2_guicolor;   /* allow colours in gui (outside map) */
-    boolean obsolete;  /* obsolete options can point at this, it isn't used */
     struct autopickup_exception *autopickup_exceptions[2];
 #define AP_LEAVE 0
 #define AP_GRAB 1
@@ -448,6 +445,7 @@ struct instance_flags {
     boolean windowtype_deferred; /* pick a windowport and store it in
                                     chosen_windowport[], but do not switch to
                                     it in the midst of options processing */
+    boolean obsolete;  /* obsolete options can point at this, it isn't used */
 };
 
 /*
index 26512c8ce6230914d3059a6219ac661fff193a5e..36962750eec27c0e7eb7cfde6006752d449772d6 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6 winprocs.h      $NHDT-Date: 1549327479 2019/02/05 00:44:39 $  $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.46 $ */
+/* NetHack 3.6 winprocs.h      $NHDT-Date: 1553204011 2019/03/21 21:33:31 $  $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.47 $ */
 /* Copyright (c) David Cohrs, 1992                               */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -217,16 +217,17 @@ extern
 #define WC2_RESET_STATUS  0x0100L /* 09 call status_update(BL_RESET) to
                                    *    indicate 'draw everything'      */
 #define WC2_TERM_SIZE     0x0200L /* 10 support setting terminal size   */
-#define WC2_WINDOWBORDERS 0x0400L /* 11 display borders on nh windows   */
-#define WC2_PETATTR       0x0800L /* 12 attributes for hilite_pet       */
-#define WC2_GUICOLOR      0x1000L /* 13 display colours outside map win */
+#define WC2_STATUSLINES   0x0400L /* 16 switch between 2 or 3 lines of status */
+#define WC2_WINDOWBORDERS 0x0800L /* 11 display borders on nh windows   */
+#define WC2_PETATTR       0x1000L /* 12 attributes for hilite_pet       */
+#define WC2_GUICOLOR      0x2000L /* 13 display colours outside map win */
 /* pline() can overload the display attributes argument passed to putstr()
    with one or more flags and at most one of bold/blink/inverse/&c */
-#define WC2_URGENT_MESG   0x2000L /* 14 putstr(WIN_MESSAGE) supports urgency
+#define WC2_URGENT_MESG   0x4000L /* 14 putstr(WIN_MESSAGE) supports urgency
                                    *    via non-display attribute flag  */
-#define WC2_SUPPRESS_HIST 0x4000L /* 15 putstr(WIN_MESSAGE) supports history
+#define WC2_SUPPRESS_HIST 0x8000L /* 15 putstr(WIN_MESSAGE) supports history
                                    *    suppression via non-disp attr   */
-                                  /* 17 free bits */
+                                  /* 16 free bits */
 
 #define ALIGN_LEFT   1
 #define ALIGN_RIGHT  2
index e1ffd0e0b450153a332a4e182add332a36dc432a..7bdde27a9bd47a1bef7a6cd2cedfbc6308f8e899 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6 options.c       $NHDT-Date: 1552521022 2019/03/13 23:50:22 $  $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.357 $ */
+/* NetHack 3.6 options.c       $NHDT-Date: 1553204012 2019/03/21 21:33:32 $  $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.358 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Michael Allison, 2008. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -394,10 +394,10 @@ static struct Comp_Opt {
 #endif
 #ifdef CURSES_GRAPHICS
     { "statuslines",
-      "0,1,2 = classic behavior, 3 = alternative behavior",
-      20, DISP_IN_GAME },
+      "2 or 3 lines for horizonal (bottom or top) status display",
+      20, SET_IN_GAME }, /*WC2*/
 #else
-    { "statuslines", "# of status lines", 20, SET_IN_FILE },
+    { "statuslines", "2 or 3 lines for status display", 20, SET_IN_FILE },
 #endif
     { "symset", "load a set of display symbols from the symbols file", 70,
       SET_IN_GAME },
@@ -433,7 +433,7 @@ static struct Comp_Opt {
     { "whatis_filter",
       "filter coordinate locations when targeting next or previous",
       1, SET_IN_GAME },
-    { "windowborders", "1 (on), 2 (off), 3 (auto)", 9, DISP_IN_GAME }, /*WC2*/
+    { "windowborders", "0 (off), 1 (on), 2 (auto)", 9, SET_IN_GAME }, /*WC2*/
     { "windowcolors", "the foreground/background colors of windows", /*WC*/
       80, DISP_IN_GAME },
     { "windowtype", "windowing system to use", WINTYPELEN, DISP_IN_GAME },
@@ -817,6 +817,12 @@ initoptions_init()
 #endif /* MAC_GRAPHICS_ENV */
     flags.menu_style = MENU_FULL;
 
+    iflags.wc_align_message = ALIGN_TOP;
+    iflags.wc_align_status = ALIGN_BOTTOM;
+    /* these are currently only used by curses */
+    iflags.wc2_statuslines = 2;
+    iflags.wc2_windowborders = 2; /* 'Auto' */
+
     /* since this is done before init_objects(), do partial init here */
     objects[SLIME_MOLD].oc_name_idx = SLIME_MOLD;
     nmcpy(pl_fruit, OBJ_NAME(objects[SLIME_MOLD]), PL_FSIZ);
@@ -1370,7 +1376,8 @@ static const struct {
     { "inverse", ATR_INVERSE },
     { NULL, ATR_NONE }, /* everything after this is an alias */
     { "normal", ATR_NONE },
-    { "uline", ATR_ULINE }
+    { "uline", ATR_ULINE },
+    { "reverse", ATR_INVERSE },
 };
 
 const char *
@@ -3676,14 +3683,15 @@ boolean tinitial, tfrom_file;
             int itmp;
 
             if (negated)
-                itmp = 2; /* Off */
+                itmp = 0; /* Off */
             else if (!op)
                 itmp = 1; /* On */
-            else    /* Value supplied; expect 1 (on), 2 (off), or 3 (auto) */
+            else    /* Value supplied; expect 0 (off), 1 (on), or 2 (auto) */
                 itmp = atoi(op);
 
-            if (itmp < 1 || itmp > 3) {
-                config_error_add("Invalid %s: %s.", fullname, opts);
+            if (itmp < 0 || itmp > 2) {
+                config_error_add("Invalid %s (should be 0, 1, or 2): %s",
+                                 fullname, opts);
                 retval = FALSE;
             } else {
                 iflags.wc2_windowborders = itmp;
@@ -3691,6 +3699,31 @@ boolean tinitial, tfrom_file;
         }
         return retval;
     }
+
+    /* WINCAP2
+     * statuslines:n */
+    fullname = "statuslines";
+    if (match_optname(opts, fullname, 11, TRUE)) {
+        int itmp = 0;
+
+        op = string_for_opt(opts, negated);
+        if (negated) {
+            bad_negation(fullname, TRUE);
+            itmp = 2;
+            retval = FALSE;
+        } else if (op) {
+            itmp = atoi(op);
+        }
+        if (itmp < 2 || itmp > 3) {
+            config_error_add("'%s' requires a value of 2 and 3", fullname);
+            retval = FALSE;
+        } else {
+            iflags.wc2_statuslines = itmp;
+            if (!initial)
+                need_redraw = TRUE;
+        }
+        return retval;
+    }
 #endif /* CURSES_GRAPHICS */
 
     /* menustyle:traditional or combination or full or partial */
@@ -5424,29 +5457,17 @@ char *buf;
     int i;
 
     buf[0] = '\0';
-    if (!strcmp(optname, "align_message"))
-        Sprintf(buf, "%s",
-                iflags.wc_align_message == ALIGN_TOP
-                    ? "top"
-                    : iflags.wc_align_message == ALIGN_LEFT
-                          ? "left"
-                          : iflags.wc_align_message == ALIGN_BOTTOM
-                                ? "bottom"
-                                : iflags.wc_align_message == ALIGN_RIGHT
-                                      ? "right"
-                                      : defopt);
-    else if (!strcmp(optname, "align_status"))
+    if (!strcmp(optname, "align_message")
+        || !strcmp(optname, "align_status")) {
+        int which = !strcmp(optname, "align_status") ? iflags.wc_align_status
+                                                     : iflags.wc_align_message;
         Sprintf(buf, "%s",
-                iflags.wc_align_status == ALIGN_TOP
-                    ? "top"
-                    : iflags.wc_align_status == ALIGN_LEFT
-                          ? "left"
-                          : iflags.wc_align_status == ALIGN_BOTTOM
-                                ? "bottom"
-                                : iflags.wc_align_status == ALIGN_RIGHT
-                                      ? "right"
-                                      : defopt);
-    else if (!strcmp(optname, "align"))
+                (which == ALIGN_TOP) ? "top"
+                : (which == ALIGN_LEFT) ? "left"
+                  : (which == ALIGN_BOTTOM) ? "bottom"
+                    : (which == ALIGN_RIGHT) ? "right"
+                      : defopt);
+    } else if (!strcmp(optname, "align"))
         Sprintf(buf, "%s", rolestring(flags.initalign, aligns, adj));
 #ifdef WIN32
     else if (!strcmp(optname, "altkeyhandler"))
@@ -5707,6 +5728,9 @@ char *buf;
             Sprintf(buf, "%ld (on: highlight status for %ld turns)",
                     iflags.hilite_delta, iflags.hilite_delta);
 #endif
+    } else if (!strcmp(optname,"statuslines")) {
+        Strcpy(buf, (WINDOWPORT("curses")
+                     && iflags.wc2_statuslines < 3) ? "2" : "3");
     } else if (!strcmp(optname, "suppress_alert")) {
         if (flags.suppress_alert == 0L)
             Strcpy(buf, none);
@@ -5764,14 +5788,12 @@ char *buf;
                 ttycolors[CLR_YELLOW], ttycolors[CLR_BRIGHT_BLUE],
                 ttycolors[CLR_BRIGHT_MAGENTA], ttycolors[CLR_BRIGHT_CYAN]);
 #endif /* VIDEOSHADES */
-#ifdef CURSES_GRAPHICS
     } else if (!strcmp(optname,"windowborders")) {
         Sprintf(buf, "%s",
-                (iflags.wc2_windowborders == 1) ? "1=on"
-                : (iflags.wc2_windowborders == 2) ? "2=off"
-                  : (iflags.wc2_windowborders == 3) ? "3=auto"
+                (iflags.wc2_windowborders == 0) ? "0=off"
+                : (iflags.wc2_windowborders == 1) ? "1=on"
+                  : (iflags.wc2_windowborders == 2) ? "2=auto"
                     : defopt);
-#endif
     } else if (!strcmp(optname, "windowtype")) {
         Sprintf(buf, "%s", windowprocs.name);
     } else if (!strcmp(optname, "windowcolors")) {
@@ -6479,6 +6501,7 @@ static struct wc_Opt wc2_options[] = {
     { "term_rows", WC2_TERM_SIZE },
     { "petattr", WC2_PETATTR },
     { "guicolor", WC2_GUICOLOR },
+    { "statuslines", WC2_STATUSLINES },
     { "windowborders", WC2_WINDOWBORDERS },
     { (char *) 0, 0L }
 };
index 2e7e17a70db8191e0b9f1aeb214ba0d7c8ae503a..2434f676b9e37e39cc1d09a083ea89e005fe71f5 100644 (file)
@@ -119,16 +119,14 @@ curses_create_main_windows()
     boolean borders = FALSE;
 
     switch (iflags.wc2_windowborders) {
+    case 0:                     /* Off */
+        borders = FALSE;
+        break;
     case 1:                     /* On */
         borders = TRUE;
         break;
-    case 2:                     /* Off */
-        borders = FALSE;
-        break;
-    case 3:                     /* Auto */
-        if ((term_cols > 81) && (term_rows > 25)) {
-            borders = TRUE;
-        }
+    case 2:                     /* Auto */
+        borders = (term_cols > 81 && term_rows > 25);
         break;
     default:
         borders = FALSE;
@@ -208,7 +206,7 @@ curses_create_main_windows()
         int inv_width = 0;
         int map_height = (term_rows - border_space);
         int map_width = (term_cols - border_space);
-        int statusheight = (iflags.statuslines < 3) ? 2 : 3;
+        int statusheight = (iflags.wc2_statuslines < 3) ? 2 : 3;
         boolean status_vertical = (status_orientation == ALIGN_LEFT
                                    || status_orientation == ALIGN_RIGHT);
         boolean msg_vertical = (message_orientation == ALIGN_LEFT
@@ -221,7 +219,7 @@ curses_create_main_windows()
                                 &status_width, &status_height,
                                 status_orientation,
                                 &map_x, &map_y, &map_width, &map_height,
-                                border_space, statusheight, 26);
+                                border_space, 20, 26);
 
         if (iflags.perm_invent) {
             /* Take up all width unless msgbar is also vertical. */
@@ -246,7 +244,7 @@ curses_create_main_windows()
                                 &status_width, &status_height,
                                 status_orientation,
                                 &map_x, &map_y, &map_width, &map_height,
-                                border_space, statusheight, 26);
+                                border_space, statusheight, 0);
 
         if (!msg_vertical)
             set_window_position(&message_x, &message_y,
@@ -777,18 +775,13 @@ curses_character_dialog(const char **choices, const char *prompt)
 void
 curses_init_options()
 {
-    set_wc_option_mod_status(WC_ALIGN_MESSAGE | WC_ALIGN_STATUS | WC_COLOR
-                             | WC_HILITE_PET | WC_POPUP_DIALOG, SET_IN_GAME);
-
-    set_wc2_option_mod_status(WC2_GUICOLOR, SET_IN_GAME);
+    /* change these from DISP_IN_GAME to SET_IN_GAME */
+    set_wc_option_mod_status(WC_ALIGN_MESSAGE | WC_ALIGN_STATUS, SET_IN_GAME);
 
     /* Remove a few options that are irrelevant to this windowport */
     /*set_option_mod_status("DECgraphics", SET_IN_FILE); */
     set_option_mod_status("eight_bit_tty", SET_IN_FILE);
 
-    /* Add those that are */
-    set_option_mod_status("statuslines", SET_IN_GAME);
-
     /* Make sure that DECgraphics is not set to true via the config
        file, as this will cause display issues.  We can't disable it in
        options.c in case the game is compiled with both tty and curses. */
@@ -800,15 +793,12 @@ curses_init_options()
 #ifdef PDCURSES
     /* PDCurses for SDL, win32 and OS/2 has the ability to set the
        terminal size programatically.  If the user does not specify a
-       size in the config file, we will set it to a nice big 110x32 to
+       size in the config file, we will set it to a nice big 32x110 to
        take advantage of some of the nice features of this windowport. */
-    if (iflags.wc2_term_cols == 0) {
+    if (iflags.wc2_term_cols == 0)
         iflags.wc2_term_cols = 110;
-    }
-
-    if (iflags.wc2_term_rows == 0) {
+    if (iflags.wc2_term_rows == 0)
         iflags.wc2_term_rows = 32;
-    }
 
     resize_term(iflags.wc2_term_rows, iflags.wc2_term_cols);
     getmaxyx(base_term, term_rows, term_cols);
@@ -825,9 +815,6 @@ curses_init_options()
     }
 */
 #endif /* PDCURSES */
-    if (!iflags.wc2_windowborders) {
-        iflags.wc2_windowborders = 3;   /* Set to auto if not specified */
-    }
 
     /* fix up pet highlighting */
     if (iflags.wc2_petattr == -1) /* shouldn't happen */
index ab472414d9733fe0bb6b7ff05c03444b5fb975fa..5cc30c1268d31f1fa87bf8ddc5e8cb5d6574a504 100644 (file)
@@ -20,8 +20,8 @@ struct window_procs curses_procs = {
 #if defined(STATUS_HILITES)
      | WC2_HILITE_STATUS
 #endif
-     | WC2_HITPOINTBAR | WC2_FLUSH_STATUS
-     | WC2_TERM_SIZE | WC2_WINDOWBORDERS | WC2_PETATTR | WC2_GUICOLOR
+     | WC2_HITPOINTBAR | WC2_FLUSH_STATUS | WC2_TERM_SIZE
+     | WC2_STATUSLINES | WC2_WINDOWBORDERS | WC2_PETATTR | WC2_GUICOLOR
      | WC2_SUPPRESS_HIST),
     curses_init_nhwindows,
     curses_player_selection,
index 49567bafd3a05d34dbc2904a8425ad044c38d239..55cb157f9da91d7ed9ee5e28b2f535dbe7d82eca 100644 (file)
@@ -380,6 +380,7 @@ curses_message_win_getline(const char *prompt, char *answer, int buffer)
 
     curses_get_window_size(MESSAGE_WIN, &height, &width);
     if (border) {
+        height -= 2, width -= 2;
         border_space = 1;
         if (mx < 1)
             mx = 1;
index 67287ea8871a8991f25db7083db87128efef0293..12153aa34a3ccd1c37c4fcbccbea19f13035520b 100644 (file)
@@ -3,7 +3,6 @@
 /* Copyright (c) Andy Thomson, 2018. */
 /* NetHack may be freely redistributed.  See license for details. */
 
-#include <ctype.h> /* toupper() */
 #include "curses.h"
 #include "hack.h"
 #include "wincurs.h"
@@ -28,9 +27,11 @@ static char *status_vals_long[MAXBLSTATS];
 #ifdef STATUS_HILITES
 static long curses_condition_bits;
 static int curses_status_colors[MAXBLSTATS];
-int hpbar_percent, hpbar_color;
+static int hpbar_percent, hpbar_color;
 
+#ifdef TEXTCOLOR
 static int FDECL(condcolor, (long, unsigned long *));
+#endif
 static int FDECL(condattr, (long, unsigned long *));
 #endif /* STATUS_HILITES */
 static void FDECL(draw_status, (unsigned long *));
@@ -45,8 +46,8 @@ curses_status_init()
     int i;
 
     for (i = 0; i < MAXBLSTATS; ++i) {
-       curses_status_colors[i] = NO_COLOR; /* no color */
-       status_vals_long[i] = (char *) alloc(MAXCO);
+        curses_status_colors[i] = NO_COLOR; /* no color and no attributes */
+        status_vals_long[i] = (char *) alloc(MAXCO);
         *status_vals_long[i] = '\0';
     }
     curses_condition_bits = 0L;
@@ -189,18 +190,19 @@ curses_status_finish()
 #endif
 
 void
-curses_status_update(fldidx, ptr, chg, percent, color, colormasks)
-int fldidx, chg UNUSED, percent, color;
+curses_status_update(fldidx, ptr, chg, percent, color_and_attr, colormasks)
+int fldidx, chg UNUSED,
+    percent, color_and_attr;
 genericptr_t ptr;
 unsigned long *colormasks;
 {
     long *condptr = (long *) ptr;
     char *text = (char *) ptr;
     char *goldnum = NULL;
-    static boolean oncearound = FALSE; /* prevent premature partial display */
     boolean use_name = TRUE;
 
     if (fldidx != BL_FLUSH) {
+        *status_vals[fldidx] = '\0';
         if (!status_activefields[fldidx])
             return;
         if (fldidx == BL_GOLD)
@@ -208,7 +210,6 @@ unsigned long *colormasks;
         switch (fldidx) {
         case BL_CONDITION:
             curses_condition_bits = *condptr;
-            oncearound = TRUE;
             break;
         case BL_TITLE:
         case BL_HPMAX:
@@ -219,6 +220,15 @@ unsigned long *colormasks;
             use_name = FALSE;
             /* FALLTHROUGH */
         default:
+#ifndef TEXTCOLOR
+            color_and_attr = (color_and_attr & ~0x00FF) | NO_COLOR;
+#endif
+            /*
+             * status_vals[] are used for horizontal orientation
+             *  (wide lines of multiple short values).
+             * status_vals_long[] are used for vertical orientation
+             *  (narrow-ish lines of one long value each).
+             */
             Sprintf(status_vals[fldidx],
                     (fldidx == BL_TITLE && iflags.wc2_hitpointbar) ? "%-30s" :
                     status_fieldfmt[fldidx] ? status_fieldfmt[fldidx] : "%s",
@@ -226,51 +236,36 @@ unsigned long *colormasks;
             if (use_name) {
                 Sprintf(status_vals_long[fldidx], "%-16s: %s",
                         status_fieldnm[fldidx], goldnum ? goldnum : text);
-                *(status_vals_long[fldidx]) = toupper((*status_vals_long[fldidx]));
+                *(status_vals_long[fldidx]) = highc(*status_vals_long[fldidx]);
             } else
                 Strcpy(status_vals_long[fldidx], status_vals[fldidx]);
-#ifdef TEXTCOLOR
-            curses_status_colors[fldidx] = color;
-#else
-            curses_status_colors[fldidx] = NO_COLOR;
-#endif
+
+            curses_status_colors[fldidx] = color_and_attr;
             if (iflags.wc2_hitpointbar && fldidx == BL_HP) {
-                       hpbar_percent = percent;
-#ifdef TEXTCOLOR
-                hpbar_color = color;
-#else
-                hpbar_color = NO_COLOR;
-#endif
+                hpbar_percent = percent;
+                hpbar_color = color_and_attr;
             }
             break;
         }
+    } else { /* BL_FLUSH */
+        draw_status(colormasks);
     }
-
-    if (!oncearound) return;
-    draw_status(colormasks);
 }
 
 void
 draw_status(colormasks)
 unsigned long *colormasks;
 {
-    boolean horiz = FALSE;
     WINDOW *win = curses_get_nhwin(STATUS_WIN);
     int orient = curses_get_window_orientation(STATUS_WIN);
+    boolean horiz = (orient != ALIGN_RIGHT && orient != ALIGN_LEFT);
     boolean border = curses_window_has_border(STATUS_WIN);
 
-    if ((orient != ALIGN_RIGHT) && (orient != ALIGN_LEFT))
-        horiz = TRUE;
-
-    /* Figure out if we have proper window dimensions for horizontal statusbar. */
+    /* Figure out if we have proper window dimensions for horizontal
+       statusbar. */
     if (horiz) {
-        int ax = 0;
-        int ay = 0;
-
-        /* correct y */
-        int cy = 3;
-        if (iflags.statuslines < 3)
-            cy = 2;
+        int ax = 0, ay = 0;
+        int cy = (iflags.wc2_statuslines < 3) ? 2 : 3;
 
         /* actual y (and x) */
         getmaxyx(win, ay, ax);
@@ -278,16 +273,14 @@ unsigned long *colormasks;
             ay -= 2;
 
         if (cy != ay) { /* something changed. Redo everything */
-            curses_create_main_windows();
-            curses_last_messages();
-            doredraw();
+            curs_reset_windows(TRUE, TRUE);
             win = curses_get_nhwin(STATUS_WIN);
         }
     }
 
     werase(win);
     if (horiz) {
-        if (iflags.statuslines < 3)
+        if (iflags.wc2_statuslines < 3)
             draw_classic(border, colormasks);
         else
             draw_horizontal(border, colormasks);
@@ -305,7 +298,7 @@ draw_classic(border, colormasks)
 boolean border;
 unsigned long *colormasks;
 {
-    enum statusfields fieldorder[2][15] = {
+    static const enum statusfields fieldorder[2][15] = {
         { BL_TITLE, BL_STR, BL_DX, BL_CO, BL_IN, BL_WI, BL_CH, BL_ALIGN,
           BL_SCORE, BL_FLUSH, BL_FLUSH, BL_FLUSH, BL_FLUSH, BL_FLUSH,
           BL_FLUSH },
@@ -313,33 +306,32 @@ unsigned long *colormasks;
           BL_AC, BL_XP, BL_EXP, BL_HD, BL_TIME, BL_HUNGER,
           BL_CAP, BL_CONDITION, BL_FLUSH }
     };
-#ifdef TEXTCOLOR
-    int coloridx = NO_COLOR;
-#endif
-    int i, attrmask = 0;
+    int i, coloridx = NO_COLOR, attrmask = 0;
     char *text;
     int attridx = 0;
 
     WINDOW *win = curses_get_nhwin(STATUS_WIN);
-    if (border) wmove(win, 1, 1);
-    else wmove(win, 0, 0);
+    if (border)
+        wmove(win, 1, 1);
+    else
+        wmove(win, 0, 0);
     for (i = 0; fieldorder[0][i] != BL_FLUSH; ++i) {
         int fldidx1 = fieldorder[0][i];
+
         if (status_activefields[fldidx1]) {
             if (fldidx1 != BL_TITLE || !iflags.wc2_hitpointbar) {
-#ifdef TEXTCOLOR
-                coloridx = curses_status_colors[fldidx1] & 0x00FF;
-#endif
-                attridx = (curses_status_colors[fldidx1] & 0xFF00) >> 8;
                 text = status_vals[fldidx1];
-                if (iflags.hilite_delta) {
+                coloridx = curses_status_colors[fldidx1]; /* plus attributes */
+                if (iflags.hilite_delta && coloridx != NO_COLOR) {
                     if (*text == ' ') {
                         putstr(STATUS_WIN, 0, " ");
                         text++;
                     }
                     /* multiple attributes can be in effect concurrently */
+                    attridx = (coloridx >> 8) & 0x00FF;
                     Begin_Attr(attridx);
 #ifdef TEXTCOLOR
+                    coloridx &= 0x00FF;
                     if (coloridx != NO_COLOR && coloridx != CLR_MAX)
                         curses_toggle_color_attr(win, coloridx, NONE, ON);
 #endif
@@ -350,7 +342,7 @@ unsigned long *colormasks;
                 if (iflags.hilite_delta) {
 #ifdef TEXTCOLOR
                     if (coloridx != NO_COLOR)
-                        curses_toggle_color_attr(win, coloridx,NONE,OFF);
+                        curses_toggle_color_attr(win, coloridx, NONE, OFF);
 #endif
                     End_Attr(attridx);
                 }
@@ -377,54 +369,56 @@ unsigned long *colormasks;
                         *bar2 = '\0';
                     }
                 }
-                if (iflags.hilite_delta && iflags.wc2_hitpointbar) {
-                    putstr(STATUS_WIN, 0, "[");
+
+                putstr(STATUS_WIN, 0, "[");
+                /* fixed attribute, not ((hpbar_color >> 8) & 0x00FF) */
+                wattron(win, A_REVERSE);
 #ifdef TEXTCOLOR
+                if (iflags.hilite_delta) {
                     coloridx = hpbar_color & 0x00FF;
-                    /* attridx = (hpbar_color & 0xFF00) >> 8; */
                     if (coloridx != NO_COLOR)
-                        curses_toggle_color_attr(win,coloridx,NONE,ON);
+                        curses_toggle_color_attr(win, coloridx, NONE, ON);
+                }
 #endif
-                    wattron(win,A_REVERSE);
-                    putstr(STATUS_WIN, 0, bar);
-                    wattroff(win,A_REVERSE);
+                putstr(STATUS_WIN, 0, bar);
 #ifdef TEXTCOLOR
-                    if (coloridx != NO_COLOR)
-                        curses_toggle_color_attr(win,coloridx,NONE,OFF);
+                if (iflags.hilite_delta && coloridx != NO_COLOR)
+                    curses_toggle_color_attr(win, coloridx, NONE, OFF);
 #endif
-                    if (twoparts) {
-                        *bar2 = savedch;
-                        putstr(STATUS_WIN, 0, bar2);
-                    }
-                    putstr(STATUS_WIN, 0, "]");
-                } else
-                    putstr(STATUS_WIN, 0, text);
+                wattroff(win, A_REVERSE);
+                if (twoparts) {
+                    *bar2 = savedch;
+                    putstr(STATUS_WIN, 0, bar2);
+                }
+                putstr(STATUS_WIN, 0, "]");
             }
         }
     }
     wclrtoeol(win);
-    if (border) wmove(win, 2, 1);
-    else wmove (win, 1, 0);
+    if (border)
+        wmove(win, 2, 1);
+    else
+        wmove (win, 1, 0);
     for (i = 0; fieldorder[1][i] != BL_FLUSH; ++i) {
         int fldidx2 = fieldorder[1][i];
 
         if (status_activefields[fldidx2]) {
             if (fldidx2 != BL_CONDITION) {
-#ifdef TEXTCOLOR
-                coloridx = curses_status_colors[fldidx2] & 0x00FF;
-#endif
-                attridx = (curses_status_colors[fldidx2] & 0xFF00) >> 8;
+                /* regular field, including title if no hitpointbar */
                 text = status_vals[fldidx2];
-                if (iflags.hilite_delta) {
+                coloridx = curses_status_colors[fldidx2]; /* plus attribute */
+                if (iflags.hilite_delta && coloridx != NO_COLOR) {
                     if (*text == ' ') {
                         putstr(STATUS_WIN, 0, " ");
                         text++;
                     }
+                    attridx = (coloridx >> 8) & 0x00FF;
                     /* multiple attributes can be in effect concurrently */
                     Begin_Attr(attridx);
 #ifdef TEXTCOLOR
+                    coloridx &= 0x00FF;
                     if (coloridx != NO_COLOR && coloridx != CLR_MAX)
-                        curses_toggle_color_attr(win,coloridx,NONE,ON);
+                        curses_toggle_color_attr(win, coloridx, NONE, ON);
 #endif
                 }
 
@@ -438,11 +432,11 @@ unsigned long *colormasks;
                 if (iflags.hilite_delta) {
 #ifdef TEXTCOLOR
                     if (coloridx != NO_COLOR)
-                        curses_toggle_color_attr(win,coloridx,NONE,OFF);
+                        curses_toggle_color_attr(win, coloridx, NONE, OFF);
 #endif
                     End_Attr(attridx);
                 }
-            } else {
+            } else if (curses_condition_bits) {
                 MaybeDisplayCond(BL_MASK_STONE, "Stone");
                 MaybeDisplayCond(BL_MASK_SLIME, "Slime");
                 MaybeDisplayCond(BL_MASK_STRNGL, "Strngl");
@@ -480,7 +474,7 @@ draw_vertical(border, colormasks)
 boolean border;
 unsigned long *colormasks;
 {
-    enum statusfields fieldorder[24] = {
+    static const enum statusfields fieldorder[24] = {
          BL_TITLE, BL_STR, BL_DX, BL_CO, BL_IN, BL_WI, BL_CH, BL_ALIGN,
          BL_SCORE, BL_LEVELDESC, BL_GOLD, BL_HP, BL_HPMAX, BL_ENE, BL_ENEMAX,
          BL_AC, BL_XP, BL_EXP, BL_HD, BL_TIME, BL_HUNGER,
@@ -493,28 +487,29 @@ unsigned long *colormasks;
     char *text;
     int attridx = 0;
     int x = 0, y = 0;
-
     WINDOW *win = curses_get_nhwin(STATUS_WIN);
-    if (border) x++,y++;
+
+    if (border)
+        x++, y++;
     for (i = 0; fieldorder[i] != BL_FLUSH; ++i) {
         int fldidx1 = fieldorder[i];
+
         if (status_activefields[fldidx1]) {
             if (fldidx1 != BL_TITLE || !iflags.wc2_hitpointbar) {
 
                 if (fldidx1 != BL_CONDITION) {
-#ifdef TEXTCOLOR
-                    coloridx = curses_status_colors[fldidx1] & 0x00FF;
-#endif
-                    attridx = (curses_status_colors[fldidx1] & 0xFF00) >> 8;
                     text = status_vals_long[fldidx1];
-                    if (iflags.hilite_delta) {
+                    coloridx = curses_status_colors[fldidx1]; /* plus attr */
+                    if (iflags.hilite_delta && coloridx != NO_COLOR) {
                         if (*text == ' ') {
                             putstr(STATUS_WIN, 0, " ");
                             text++;
                         }
                         /* multiple attributes can be in effect concurrently */
+                        attridx = (coloridx >> 8) & 0x00FF;
                         Begin_Attr(attridx);
 #ifdef TEXTCOLOR
+                        coloridx &= 0x00FF;
                         if (coloridx != NO_COLOR && coloridx != CLR_MAX)
                             curses_toggle_color_attr(win, coloridx, NONE, ON);
 #endif
@@ -523,20 +518,21 @@ unsigned long *colormasks;
                     if (fldidx1 != BL_HPMAX
                         && fldidx1 != BL_ENEMAX
                         && fldidx1 != BL_EXP)
-                        wmove(win, y++, x); /* everything on a new line except the above */
+                        wmove(win, y++, x); /* on next line unless the above */
 
                     putstr(STATUS_WIN, 0, text);
 
-                    if (fldidx1 == BL_TITLE) y++;
+                    if (fldidx1 == BL_TITLE)
+                        y++;
 
                     if (iflags.hilite_delta) {
 #ifdef TEXTCOLOR
                         if (coloridx != NO_COLOR)
-                            curses_toggle_color_attr(win, coloridx,NONE,OFF);
+                            curses_toggle_color_attr(win, coloridx, NONE, OFF);
 #endif
                         End_Attr(attridx);
                     }
-                } else { /* condition */
+                } else if (curses_condition_bits) { /* BL_CONDITION */
                     MaybeDisplayCond(BL_MASK_STONE, "Stone");
                     MaybeDisplayCond(BL_MASK_SLIME, "Slime");
                     MaybeDisplayCond(BL_MASK_STRNGL, "Strngl");
@@ -561,7 +557,7 @@ unsigned long *colormasks;
 
                 text = status_vals[fldidx1];
                 getmaxyx(win, height, width);
-                bar_len = min(strlen(text), (size_t)width - (border ? 4 : 2));
+                bar_len = min((int) strlen(text), width - (border ? 4 : 2));
                 text[bar_len] = '\0';
                 if (bar_len < MAXCO-1) {
                     Strcpy(bar, text);
@@ -578,28 +574,29 @@ unsigned long *colormasks;
                     }
                 }
                 wmove(win, y++, x);
-                if (iflags.hilite_delta && iflags.wc2_hitpointbar) {
-                    putstr(STATUS_WIN, 0, "[");
+                putstr(STATUS_WIN, 0, "[");
+                wattron(win, A_REVERSE); /* not (hpbar_color >> 8) & 0x00FF) */
 #ifdef TEXTCOLOR
-                    coloridx = hpbar_color & 0x00FF;
+                coloridx = hpbar_color & 0x00FF;
+                if (iflags.hilite_delta) {
                     /* attridx = (hpbar_color & 0xFF00) >> 8; */
                     if (coloridx != NO_COLOR)
-                        curses_toggle_color_attr(win,coloridx,NONE,ON);
+                        curses_toggle_color_attr(win, coloridx, NONE, ON);
 #endif
-                    wattron(win,A_REVERSE);
-                    putstr(STATUS_WIN, 0, bar);
-                    wattroff(win,A_REVERSE);
+                }
+                putstr(STATUS_WIN, 0, bar);
 #ifdef TEXTCOLOR
+                if (iflags.hilite_delta) {
                     if (coloridx != NO_COLOR)
-                        curses_toggle_color_attr(win,coloridx,NONE,OFF);
+                        curses_toggle_color_attr(win, coloridx, NONE, OFF);
+                }
 #endif
-                    if (twoparts) {
-                        *bar2 = savedch;
-                        putstr(STATUS_WIN, 0, bar2);
-                    }
-                    putstr(STATUS_WIN, 0, "]");
-                } else
-                    putstr(STATUS_WIN, 0, text);
+                wattroff(win,A_REVERSE);
+                if (twoparts) {
+                     *bar2 = savedch;
+                     putstr(STATUS_WIN, 0, bar2);
+                }
+                putstr(STATUS_WIN, 0, "]");
                 y++; /* blank line after title */
             }
         }
@@ -612,7 +609,8 @@ unsigned long *colormasks;
  * Return what color this condition should
  * be displayed in based on user settings.
  */
-int condcolor(bm, bmarray)
+static int
+condcolor(bm, bmarray)
 long bm;
 unsigned long *bmarray;
 {
@@ -620,39 +618,41 @@ unsigned long *bmarray;
 
     if (bm && bmarray)
         for (i = 0; i < CLR_MAX; ++i) {
-            if (bmarray[i] && (bm & bmarray[i]))
+            if ((bmarray[i] & bm) != 0)
                 return i;
         }
     return NO_COLOR;
 }
 #endif /* TEXTCOLOR */
 
-int condattr(bm, bmarray)
+static int
+condattr(bm, bmarray)
 long bm;
 unsigned long *bmarray;
 {
-    int attr = 0;
-    int i;
+    int i, attr = 0;
 
     if (bm && bmarray) {
         for (i = HL_ATTCLR_DIM; i < BL_ATTCLR_MAX; ++i) {
-            if (bmarray[i] && (bm & bmarray[i])) {
-                switch(i) {
-                    case HL_ATTCLR_DIM:
-                        attr |= HL_DIM;
-                        break;
-                    case HL_ATTCLR_BLINK:
-                        attr |= HL_BLINK;
-                        break;
-                    case HL_ATTCLR_ULINE:
-                        attr |= HL_ULINE;
-                        break;
-                    case HL_ATTCLR_INVERSE:
-                        attr |= HL_INVERSE;
-                        break;
-                    case HL_ATTCLR_BOLD:
-                        attr |= HL_BOLD;
-                        break;
+            if ((bmarray[i] & bm) != 0) {
+                switch (i) {
+                case HL_ATTCLR_DIM:
+                    attr |= HL_DIM;
+                    break;
+                case HL_ATTCLR_BLINK:
+                    attr |= HL_BLINK;
+                    break;
+                case HL_ATTCLR_ULINE:
+                    attr |= HL_ULINE;
+                    break;
+                case HL_ATTCLR_INVERSE:
+                    attr |= HL_INVERSE;
+                    break;
+                case HL_ATTCLR_BOLD:
+                    attr |= HL_BOLD;
+                    break;
+                default:
+                    break;
                 }
             }
         }
@@ -661,7 +661,8 @@ unsigned long *bmarray;
 }
 #endif /* STATUS_HILITES */
 
-#if 0 /* old stuff to be re-incorporated */
+
+#if 0 /* old stuff; some may be re-incorporated, most should be discarded */
 /* Private declarations */
 
 /* Used to track previous value of things, to highlight changes. */
@@ -673,7 +674,7 @@ typedef struct nhs {
 
 static attr_t get_trouble_color(const char *);
 static void draw_trouble_str(const char *);
-static void print_statdiff(const char *append, nhstat *, int, int);
+static void print_statdiff(const char *append, nhstat *, long, int);
 static void get_playerrank(char *);
 static int hpen_color(boolean, int, int);
 static void draw_bar(boolean, int, int, const char *);
@@ -812,7 +813,7 @@ get_playerrank(char *rank)
    type is generally STAT_OTHER (generic "do nothing special"),
    but is used if the stat needs to be handled in a special way. */
 static void
-print_statdiff(const char *append, nhstat *stat, int new, int type)
+print_statdiff(const char *append, nhstat *stat, long new, int type)
 {
     char buf[BUFSZ];
     WINDOW *win = curses_get_nhwin(STATUS_WIN);