Prevent a small inventory menu as the first one shown from forcing
all subsequent ones from being the same short height by forcing it
to have room for at least 15 lines. Temporary hack until someone
figures out why resizing the reused WIN_INVEN isn't working.
Does not affect non-inventory menus which get created on demand and
destroyed when done so don't need to change size to fit different
contents.
Don't allow the user to construct a count value when operating on
a pick-none menu where counts aren't meaningful. Unfortunately
that can still be done on pick-one or pick-any menus which don't
happen to have any entries where a count is applicable.
Allow a count to be optionally started with '#'. Note that if
there is an entry using '#' for the selector letter (probably
inventory that has something in the overflow slot), typing '#'
will select the entry instead of initiating a count.
Flail about a bit trying to get menu size correct--failed on this
front.
Remove a 'TODO' for once. Have the popup that's used to accept the
target string--after clicking on [search] or typing ':' to initiate
menu search+select operation--force keyboard focus to itself. Menu
searching worked without this, but only if you manually clicked on
the search popup prior to typing the target string. Failure to do
so resulted in typed characters being used to select menu entries.
The #enhance menu revealed a couple of menu problems for Qt.
Items flagged with "*" or "#" were showing tiny "..." instead of
the flag character. An existing problem rather than something
caused by yesterday's overhaul patch.
The "(Skills flagged by "*" may be enhanced when you're more
experienced.)" legend line was causing the regular entries to be
formatted strangely (their skill name column was much too wide).
That was caused by me dropping something (special case for header
lines during tab-separation handling) in yesterday's patch that
I mistakenly thought wasn't needed.
handle preselected item in pick-one menu; picking it returns that
item rather than toggling it off and returning nothing, picking
something else only returns the other thing (was returning first
of the chosen item or the preselected item, foiling core's attempt
to deal with both and giving wrong result whenever the preselected
one came first--like pick-an-attribute for menu colors);
when handling typed input, check selector letters before menu
command keys so that special "letters" '-' (fingers, hands, self)
and ':' (look inside container) that are specified by a few menus
can be chosen by keyboard;
menus were using default line heights which are excessively tall,
effectively making them be double spaced and using more screen
space than should have been needed; reduce height to 60% of what
it was, still a bit taller than regular spacing; look at ^X--which
is rendered via menu--before and after to see the difference;
start with count column empty instead of 6 spaces; grow it as counts
get entered; reset to empty if [all], [none], or [invert] is used;
treat intermediate counts as long rather than int; right justify
formatted count values;
simplify creating menu return data (pick-one doesn't need separate
handling);
for pick-one menus,
enable [ok] button if there is one preselected item,
enable [all] button if there is only one item (may never happen),
enable [none] if there is a preselected item (menu remains active
if [none] is used to clear the preselection);
enable [invert] if there is one item (may never happen; should
allow two items if one of them is preselected--definitely does
happen--but that wouldn't work as intended without code changes);
honor pending count if an item is selected by clicking its checkbox
(already done for typing its letter or for clicking another part
of item's menu line);
accept <delete>/<rubout> in addition to <backspace> when backing out
a digit as a count is being typed;
accept ^[ as well as ESC key for cancelling count or entire menu;
honor 'menucolors'=false to ignore any defined menu color patterns.
Menus have [ok], [cancel], [all], [none], [invert], and [search]
buttons across their top but the [all], [none], and [invert] choices
didn't redraw the menu after making changes to the pending selections
so it seemed as if they weren't doing anything. Subsequently picking
[ok] revealed otherwise.
[search] is broken (instead of accepting a search string, the letters
I type are being used to toggle individual entries as I type). This
doesn't attempt to address that.
Infrastructure bits: Qt tombstone uses a short buffer; make sure that
the plname value fits instead of relying on snprintf() to truncate it.
A warning about gold, if any, was iffy but this should guarantee no
reason for future complaint. Year was safe but a compiler sensitive
to buffer overflows wouldn't know that.
Actual bugs: Qt used money in inventory for gold amount on tombstone;
that overlooks gold in containers and will be 0 by tombstone stage if
bones get saved. Year was recalculated from current date+time instead
of using the value that gets passed in--blindly flagging that variable
as UNUSED was a mistake.
Move the nine #undef's common to all qt_*.cpp sources into qt_pre.h.
Make "hack.h" usage consistent; always enclose withing 'extern "C {'
and '}' even though only some of the sources care.
An earlier tweak worked to prevent unnecessary line wrapping
for ^X output in a menu, but #enhance and '+' both had problems
with their last column. This seems to work better but is still
based on thrashing about rather than knowledge of how things are
supposed to operate.
The change to use fixed-width fonts for menus wasn't working
optimally because the font got changed after menu construction
had measured the necessary width and height amounts. ^X output,
which uses a menu instead of a text window for tty's benefit
(probably curses too; I don't remember), had a couple of lines
which were wrapping unnecessarily.
This fix avoids that, but the extra '+20' shouldn't be needed.
Unfortunately lines in menus are effectively double-spaced, which
looks bad, and I've no idea how to fix that.
Qt menus have [ok][cancel][all][none][other stuff] buttons across
the top but it was disabling [cancel] for inventory viewing and
other pick-none menus. Enable that so that [cancel] is a viable
alternative to typing ESC or clicking on [ok] for dismissing the
menu without picking anything.
This greatly improves the '?' choice when using the '#' prefix
to select an extended command. It isn't perfect, because the
<text><spaces><more text> layout (using spaces to pad the first
column so that the second one lines up) produces at least one
line where <more text> is so long that it wraps, and instead of
| <text><spaces><start of more text>
| <blank><spaces><rest of more text>
that selectable menu entries have, the continuation is
| <text><spaces><start of more text>
|<rest of more text>
(made slightly worse by the fact that <text> is indented a little
and <rest...> isn't.
This affects the aesthetics of all NHW_MENU windows, not just the
one that desparately needed help. Maybe the core should send some
hint on a menu or text window by menu or text window basis about
whether or not fixed-width font is preferable to variable one.
In file included from ../win/Qt/qt_bind.cpp:20:
In file included from /usr/local/Cellar/qt/5.15.0/lib/QtGui.framework/Headers/QtGui:3:
In file included from /usr/local/Cellar/qt/5.15.0/lib/QtGui.framework/Headers/QtGuiDepends:3:
In file included from /usr/local/Cellar/qt/5.15.0/lib/QtCore.framework/Headers/QtCore:4:
In file included from /usr/local/Cellar/qt/5.15.0/lib/QtCore.framework/Headers/qglobal.h:1302:
/usr/local/Cellar/qt/5.15.0/lib/QtCore.framework/Headers/qflags.h:121:41: warning: declaration shadows a
variable in the global namespace [-Wshadow]
Q_DECL_CONSTEXPR inline QFlags(Enum flags) noexcept : i(Int(flags)) {}
^
[…]
../include/flag.h:390:29: note: previous declaration is here
extern NEARDATA struct flag flags;
^
In file included from ../win/Qt/qt_click.cpp:18:
In file included from /usr/local/Cellar/qt/5.15.0/lib/QtGui.framework/Headers/QtGui:3:
In file included from /usr/local/Cellar/qt/5.15.0/lib/QtGui.framework/Headers/QtGuiDepends:3:
In file included from /usr/local/Cellar/qt/5.15.0/lib/QtCore.framework/Headers/QtCore:36:
/usr/local/Cellar/qt/5.15.0/lib/QtCore.framework/Headers/qcache.h:191:15: warning: declaration shadows a
variable in the global namespace [-Wshadow]
Node *u = n;
^
../include/decl.h:219:23: note: previous declaration is here
E NEARDATA struct you u;
^
[…]
In file included from ../win/Qt/qt_click.cpp:18:
In file included from /usr/local/Cellar/qt/5.15.0/lib/QtGui.framework/Headers/QtGui:5:
In file included from /usr/local/Cellar/qt/5.15.0/lib/QtGui.framework/Headers/qabstracttextdocumentlayout.h:45:
In file included from /usr/local/Cellar/qt/5.15.0/lib/QtGui.framework/Headers/qtextlayout.h:47:
In file included from /usr/local/Cellar/qt/5.15.0/lib/QtGui.framework/Headers/qcolor.h:44:
/usr/local/Cellar/qt/5.15.0/lib/QtGui.framework/Headers/qrgb.h:66:46: warning: declaration shadows a
variable in the global namespace [-Wshadow]
inline Q_DECL_CONSTEXPR QRgb qRgb(int r, int g, int b)// set RGB value
^
../include/decl.h:1208:27: note: previous declaration is here
E struct instance_globals g;
^
[…]
In file included from ../win/Qt/qt_glyph.cpp:21:
In file included from /usr/local/Cellar/qt/5.15.0/lib/QtGui.framework/Headers/QtGui:5:
In file included from /usr/local/Cellar/qt/5.15.0/lib/QtGui.framework/Headers/qabstracttextdocumentlayout.h:48:
/usr/local/Cellar/qt/5.15.0/lib/QtGui.framework/Headers/qpalette.h:107:49: warning: declaration shadows a
variable in the global namespace [-Wshadow]
inline void setCurrentColorGroup(ColorGroup cg) { data.current_group = cg; }
^
../include/decl.h:1216:30: note: previous declaration is here
E const struct const_globals cg;
^