\#perminv, 2 of 2: implementation

Add new '|' command, aka #perminv, which allows the player to
send menu scrolling keystrokes to the persistent inventory window.

Implemented for X11, where its usefulness is limited, and for
curses, where it is more needed and also more fully functional.
The interface can either prompt for one keystroke, act upon it,
and return to normal play, or it can loop for multiple keystrokes
until player types <return> or <escape>.  X11 does the former if
the 'slow' application resource is False so that prompting uses
popups, and the latter when 'slow' is True where prompting is in
a fixed spot and doesn't end up causing the persistent inventory
window to be stacked behind the map window.  curses always does
the loop-until-done approach.  It also accepts up and down arrow
keys to scroll one line at a time.

Also adds two new menu scrolling commands, menu_shift_right (key
'}' by default) and menu_shift_left ('{') if wincap2 flags contain
WC2_MENU_SHIFT.  Shifting allows different substrings of too-long
lines to be seen.

For X11, neither works because their handling requires a horizontal
scrollbar and for some reason that escapes me our menus don't have
one of those.  If they did, shifts could work for all menus but a
shifted window would hide the selection letters.  So shifting would
be most usefully done as:  pan right, read more of any long lines,
immediately pan back to the left.

For curses, they only apply to the persistent inventory window.
Shift right redraws it with class headers and inventory letters
shown normally but the item descriptions omit their leftmost
portion, showing more text towards the end.  Shift left reverses
that and does nothing if the beginning is already in view.  Forward
and backward scrolling while shifted leave the shift in place.
This commit is contained in:
PatR
2021-03-13 18:18:53 -08:00
parent dd49431296
commit 946df19ea2
21 changed files with 784 additions and 110 deletions

View File

@@ -110,12 +110,15 @@ typedef struct mi {
/* invalid winid */
#define WIN_ERR ((winid) -1)
/* menu window keyboard commands (may be mapped) */
/* menu window keyboard commands (may be mapped); menu_shift_right and
menu_shift_left are for interacting with persistent inventory window */
/* clang-format off */
#define MENU_FIRST_PAGE '^'
#define MENU_LAST_PAGE '|'
#define MENU_NEXT_PAGE '>'
#define MENU_PREVIOUS_PAGE '<'
#define MENU_SHIFT_RIGHT '}'
#define MENU_SHIFT_LEFT '{'
#define MENU_SELECT_ALL '.'
#define MENU_UNSELECT_ALL '-'
#define MENU_INVERT_ALL '@'