tty perm_invent fixes

Modify the error message delivery when too-small so that it works for
both NETHACKOPTIONS or .nethackrc and for 'O'.  "Early failure" isn't
very early; using pline() instead of raw_print() ends up writing to
the base window but also works normally when used for failed attempt
to set perm_invent with 'O'.

Fix the off by one error in height which required an extra line that
ended up going unused.

Fix an off by one error in the middle divider.  Forcing the same item
from the left column to the right column, I was seeing
 "f - an uncursed +0 pair of leather glove" ["s (being worn)" truncated]
 "F - an uncursed +0 pair of leather gl"
After the fix I get
 "f - an uncursed +0 pair of leather glov"
 "F - an uncursed +0 pair of leather glo"
(When terminal width is even, the left side is one character wider
than the right.)

Split the invent window creation code out of tty_create_nhwwindow() to
new routine tty_create_invent().  I came across
  if (r == 0 || (newwin->maxrow - 1)
in the process (note lack of 'r ==' in the second part).  I'm not sure
what the initialization code is intended to accomplish but missing
that init for the bottom (boundary box) row didn't seem to be causing
any problem.

This forces the required size to be big enough to handle statuslines:3
regardless of what the setting for that is at the time the perm_invent
window is created.  When the value is 2, there will be a blank line
between status and the boundary box of perm_invent.  When it is 3, the
third line will use that line and the only separator will be the top
boundary box line.  Toggling back and forth with 'O' works as expected.
This commit is contained in:
PatR
2022-06-22 14:21:57 -07:00
parent 5caae51234
commit 295a8523f5
2 changed files with 124 additions and 125 deletions

View File

@@ -1,4 +1,4 @@
/* NetHack 3.7 options.c $NHDT-Date: 1651887695 2022/05/07 01:41:35 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.555 $ */
/* NetHack 3.7 options.c $NHDT-Date: 1655932898 2022/06/22 21:21:38 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.569 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Michael Allison, 2008. */
/* NetHack may be freely redistributed. See license for details. */
@@ -4413,15 +4413,12 @@ optfn_boolean(int optidx, int req, boolean negated, char *opts, char *op)
hasn't been executed yet */
if (WINDOWPORT("tty") && !g.opt_initial && !negated) {
tty_perm_invent_toggled(FALSE);
if (g.tty_invent_win == WIN_ERR) {
/* FIXME: there is some confusion between this and
tty_create_nhwindow(NHW_TTYINVENT) over when this
should be done */
set_option_mod_status("perm_invent", set_gameview);
config_error_add("Enabling perm_invent failed");
/* tty_perm_invent_toggled()
-> tty_create_nhwindow(WIN_TTYINVENT)
-> tty_create_invent()
gives feedback for failure (terminal too small) */
if (g.tty_invent_win == WIN_ERR)
return optn_silenterr;
}
}
#endif
break; /* from opt_perm_invent */