]> granicus.if.org Git - nethack/commitdiff
curses persistent inventory window tweak
authorPatR <rankin@nethack.org>
Tue, 9 Feb 2021 00:34:29 +0000 (16:34 -0800)
committerPatR <rankin@nethack.org>
Tue, 9 Feb 2021 00:34:29 +0000 (16:34 -0800)
Under curses interface, provide a way to get a little more space
for perm_invent without turning off windowborders entirely.

Possible 'windowborders' values:
 0 = no borders, max screen space available for useful info
 1 = full borders, two lines and two columns wasted for each window
 2 = contingent borders, show if screen is big enough, else hide
New:
 3 = as 1 except no borders for perm_invent window
 4 = as 2 except never borders for perm_invent window

3 and 4 let the map, message, and status windows have borders while
providing two extra lines and two extra columns on each line for
persistent inventory.  It's not much but better than nothing when
borders are enabled.

doc/Guidebook.mn
doc/Guidebook.tex
doc/fixes37.0
include/wincurs.h
src/options.c
win/curses/cursinit.c
win/curses/cursinvt.c
win/curses/cursmain.c

index 1d0baab22dc5ef3c7ef9e4ccbe88e7996289c77b..d83bf4fea64e23a9db9f85adbebf105719c33e36 100644 (file)
@@ -4472,18 +4472,29 @@ Acceptable values are
 .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)"
+.CC 2 "auto, on if display is at least (24+2)x(80+2) [default]"
+.CC 3 "on, except forced off for perm_invent"
+.CC 4 "auto, except forced off for perm_invent"
 .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
+A width of at least 110 columns (80+2+26+2) is needed to show borders if
 .op align_status
-set to \f(CRleft\fP or \f(CRright\fP.)
+is set to \f(CRleft\fP or \f(CRright\fP.)
+.lp ""
+The persistent inventory window, when enabled, can grow until it is
+too big to fit on most displays, resulting in truncation of its contents.
+If borders are forced on (1) or the display is big enough to show them (2),
+setting the value to 3 or 4 instead will keep borders for the map, message,
+and status windows but have room for two additional lines of inventory
+plus widen each inventory line by two columns.
 .lp windowcolors
 If NetHack can, it should display windows with the specified
-foreground/background colors. Windows GUI only. The format is
+foreground/background colors.
+Windows GUI only.
+The format is
 .si
 .lp "OPTION=windowcolors:wintype foreground/background"
 .ei
index a3a2a01f5fc0a0f94fc59323cd74dec4db7df591..c52322ceb650de3f8fa94803679c7a3530d57c00 100644 (file)
@@ -4888,20 +4888,32 @@ Acceptable values are
 {\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)\\
+(\verb&24+2&)x(\verb&80+2&) [default]\\
+{\tt 3} --- on, except forced off for perm\verb+_+invent\\
+{\tt 4} --- auto, except forced off for perm\verb+_+invent\\
 %.ei
 %.ed
 
-%.lp "
+%.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 ""
+The persistent inventory window, when enabled, can grow until it is
+too big to fit on most displays, resulting in truncation of its contents.
+If borders are forced on (1) or the display is big enough to show them (2),
+setting the value to 3 or 4 instead will keep borders for the map, message,
+and status windows but have room for two additional lines of inventory
+plus widen each inventory line by two columns.
 %.lp
 \item[\ib{windowcolors}]
 If {\it NetHack\/} can, it should display windows with the specified
-foreground/background colors. Windows GUI only. The format is
+foreground/background colors.
+Windows GUI only.
+The format is
 \begin{verbatim}
     OPTION=windowcolors:wintype foreground/background
 \end{verbatim}
index 3d7b4be45c8fad11d9b295827c7ccfdb048be9d5..a07e9eff44f3be7ba9974a50575d78f74d9b53e9 100644 (file)
@@ -791,6 +791,8 @@ user_sounds: provide an experimental mechanism for terminal-side sounds similar
        act on it)
 curses: implement 'selectsaved', restore via menu of saved games
 curses: implement selecting menu items via mouse
+curses: 'windowborders' can be set to 3 or 4 to suppress perm_invent borders
+       to provide slightly more room for actual inventory info
 Qt: the "paper doll" inventory subset can be controlled via the "Qt Settings"
        dialog box ("Preferences..." on OSX)
 Qt: draw a border around each tile in the paper doll inventory; when BUC is
index 6820c969e9725cf673fdd8fbb70df43a5dab64ca..38567e8237589d95f2f3c584210c56c431e79c99 100644 (file)
@@ -195,8 +195,7 @@ extern void curses_status_update(int, genericptr_t, int, int, int,
 /* cursinvt.c */
 
 extern void curses_update_inv(void);
-extern void curses_add_inv(int, const glyph_info *,
-                           char, attr_t, const char *);
+extern void curses_add_inv(int, char, attr_t, const char *);
 
 /* cursinit.c */
 
index 3698929b7d5e67183dc414c50ea89c7db8b1712a..cfd6ad21676e85cee86ba35de5473d744dade815 100644 (file)
@@ -3742,13 +3742,15 @@ optfn_windowborders(int optidx, int req, boolean negated, char *opts, char *op)
                 itmp = 0; /* Off */
             else if (op == empty_optstr)
                 itmp = 1; /* On */
-            else /* Value supplied; expect 0 (off), 1 (on), or 2 (auto) */
+            else /* Value supplied; expect 0 (off), 1 (on), 2 (auto)
+                  * or 3 (on for most windows, off for perm_invent)
+                  * or 4 (auto for most windows, off for perm_invent) */
                 itmp = atoi(op);
 
-            if (itmp < 0 || itmp > 2) {
-                config_error_add("Invalid %s (should be 0, 1, or 2): %s",
+            if (itmp < 0 || itmp > 4) {
+                config_error_add("Invalid %s (should be within 0 to 4): %s",
                                  allopt[optidx].name, opts);
-                retval = optn_err;
+                retval = optn_silenterr;
             } else {
                 iflags.wc2_windowborders = itmp;
             }
@@ -3762,7 +3764,11 @@ optfn_windowborders(int optidx, int req, boolean negated, char *opts, char *op)
                 (iflags.wc2_windowborders == 0) ? "0=off"
                 : (iflags.wc2_windowborders == 1) ? "1=on"
                   : (iflags.wc2_windowborders == 2) ? "2=auto"
-                    : defopt);
+                    : (iflags.wc2_windowborders == 3)
+                      ? "3=on, except off for perm_invent"
+                      : (iflags.wc2_windowborders == 4)
+                        ? "4=auto, except off for perm_invent"
+                        : defopt);
         return optn_ok;
     }
     return optn_ok;
index 621efd7dbeddae745536fad9ab7eab64b793712c..92f9773f94b0c2c8aadafb4b3ee5afcfae9b9b5d 100644 (file)
@@ -115,20 +115,27 @@ curses_create_main_windows(void)
     int status_orientation = 0;
     int border_space = 0;
     int hspace = term_cols - 80;
-    boolean borders = FALSE;
+    boolean borders = FALSE, noperminv_borders = FALSE;
 
     switch (iflags.wc2_windowborders) {
+    default:
     case 0:                     /* Off */
         borders = FALSE;
         break;
+
+    case 3:
+        noperminv_borders = TRUE;
+        /*FALLTHRU*/
     case 1:                     /* On */
         borders = TRUE;
         break;
+
+    case 4:
+        noperminv_borders = TRUE;
+        /*FALLTHRU*/
     case 2:                     /* Auto */
-        borders = (term_cols > 81 && term_rows > 25);
+        borders = (term_cols >= 80 + 2 && term_rows >= 24 + 2);
         break;
-    default:
-        borders = FALSE;
     }
 
     if (borders) {
@@ -228,6 +235,9 @@ curses_create_main_windows(void)
                                 ALIGN_RIGHT, &map_x, &map_y,
                                 &map_width, &map_height,
                                 border_space, -1, width);
+            /* suppress borders on perm_invent window, part I */
+            if (noperminv_borders)
+                inv_width += border_space, inv_height += border_space; /*+=2*/
         }
 
         if (msg_vertical)
@@ -276,7 +286,9 @@ curses_create_main_windows(void)
 
         if (iflags.perm_invent)
             curses_add_nhwin(INV_WIN, inv_height, inv_width, inv_y, inv_x,
-                             ALIGN_RIGHT, borders);
+                             ALIGN_RIGHT,
+                             /* suppress perm_invent borders, part II */
+                             borders && !noperminv_borders);
 
         curses_add_nhwin(MAP_WIN, map_height, map_width,
                          map_y, map_x, 0, borders);
index c60167e1df01b382cf877106ab212cd5cf75602a..05f9bc4b7a0699320602db628c09898999d054a4 100644 (file)
@@ -55,8 +55,7 @@ curses_update_inv(void)
 
 /* Adds an inventory item.  'y' is 1 rather than 0 for the first item. */
 void
-curses_add_inv(int y, const glyph_info *glyphinfo UNUSED, char accelerator,
-               attr_t attr, const char *str)
+curses_add_inv(int y, char accelerator, attr_t attr, const char *str)
 {
     WINDOW *win = curses_get_nhwin(INV_WIN);
     int color = NO_COLOR;
@@ -70,12 +69,8 @@ curses_add_inv(int y, const glyph_info *glyphinfo UNUSED, char accelerator,
     curses_get_window_size(INV_WIN, &height, &width);
     /*
      * TODO:
-     *  If border is On and 'y' is too big, turn border Off in order to
-     *  get two more lines of perm_invent.
-     *
-     *  And/or implement a way to switch focus from map to inventory
-     *  so that the latter can be scrolled.  Must not require use of a
-     *  mouse.
+     *  Implement a way to switch focus from map to inventory so that
+     *  the latter can be scrolled.  Must not require use of a mouse.
      *
      *  Also, when entries are omitted due to lack of space, mark the
      *  last line to indicate "there's more that you can't see" (like
@@ -88,28 +83,22 @@ curses_add_inv(int y, const glyph_info *glyphinfo UNUSED, char accelerator,
 
     wmove(win, y, x);
     if (accelerator) {
-#if 0
-        attr_t bold = A_BOLD;
-
-        wattron(win, bold);
-        waddch(win, accelerator);
-        wattroff(win, bold);
-        wprintw(win, ") ");
-#else
         /* despite being shown as a menu, nothing is selectable from the
-           persistent inventory window so don't highlight inventory letters */
+           persistent inventory window so avoid the usual highlighting of
+           inventory letters */
         wprintw(win, "%c) ", accelerator);
-#endif
         available_width -= 3; /* letter+parenthesis+space */
-
-        /* narrow the entries to fit more of the interesting text; do so
-           unconditionally rather than trying to figure whether it's needed;
-           when 'sortpack' is enabled we could also strip out "<class> of"
-           from "<prefix><class> of <item><suffix> but if that's to be done,
-           core ought to do it;
-           'stroffset': defer skipping the article prefix until after menu
-           color pattern matching has taken place so that the persistent
-           inventory window always gets same coloring as regular inventory */
+        /*
+         * Narrow the entries to fit more of the interesting text.  Do so
+         * unconditionally rather than trying to figure whether it's needed.
+         * When 'sortpack' is enabled we could also strip out "<class> of"
+         * from "<prefix><class> of <item><suffix> but if that's to be done,
+         * the core ought to do it.
+         *
+         * 'stroffset': defer skipping the article prefix until after menu
+         * color pattern matching has taken place so that the persistent
+         * inventory window always gets same coloring as regular inventory.
+         */
         if (!strncmpi(str, "a ", 2))
             stroffset = 2;
         else if (!strncmpi(str, "an ", 3))
@@ -117,24 +106,8 @@ curses_add_inv(int y, const glyph_info *glyphinfo UNUSED, char accelerator,
         else if (!strncmpi(str, "the ", 4))
             stroffset = 4;
     }
-#if 0 /* FIXME: MENU GLYPHS */
-    if (accelerator && iflags.use_menu_glyphs
-            && glyphinfo->glyph != NO_GLYPH ) {
-        int symbol;
-        attr_t glyphclr;
-
-        symbol = glyphinfo->ttychar;
-        color = glyphinfo->color;
-
-        glyphclr = curses_color_attr(color, 0);
-        wattron(win, glyphclr);
-        wprintw(win, "%c ", symbol);
-        wattroff(win, glyphclr);
-        available_width -= 2;
-    }
-#endif
-    if (accelerator /* Don't colorize categories */
-        && iflags.use_menu_color) {
+    /* only perform menu coloring on item entries, not subtitles */
+    if (accelerator && iflags.use_menu_color) {
         attr = 0;
         get_menu_coloring(str, &color, (int *) &attr);
         attr = curses_convert_attr(attr);
index 1096a63717e1b70a55291a956abb57d7c3c25083..5024bddd58bb11edda0f1dd469ca2f7d5d4f3e4e 100644 (file)
@@ -543,7 +543,7 @@ add_menu(winid wid, const glyph_info *glyphinfo,
 */
 void
 curses_add_menu(winid wid, const glyph_info *glyphinfo,
-                const ANY_P * identifier,
+                const ANY_P *identifier,
                 char accelerator, char group_accel, int attr,
                 const char *str, unsigned itemflags)
 {
@@ -553,12 +553,16 @@ curses_add_menu(winid wid, const glyph_info *glyphinfo,
     curses_attr = curses_convert_attr(attr);
 
     if (inv_update) {
-        curses_add_inv(inv_update, glyphinfo, accelerator, curses_attr, str);
+        /* persistent inventory window; nothing is selectable;
+           omit glyphinfo because perm_invent is to the side of
+           the map so usually cramped for space */
+        curses_add_inv(inv_update, accelerator, curses_attr, str);
         inv_update++;
         return;
     }
 
-    curses_add_nhmenu_item(wid, glyphinfo, identifier, accelerator, group_accel,
+    curses_add_nhmenu_item(wid, glyphinfo, identifier,
+                           accelerator, group_accel,
                            curses_attr, str, itemflags);
 }