rework TTY_PERM_INVENT; update window port interface

Change the inner workings of the experimental TTY_PERM_INVENT.

Switch to delivering the content to tty for the experimental perm_invent
via the existing window port interface (start_menu(), add_menu(), end_menu).

This also adds a new window port interface call ctrl_nhwindow() for
delivering information to the window port, and/or obtaining specific
information from the window port. The information and requests can
be extended as required. To be documented later once the changes settle
down.

Due to the intrusive nature of these changes and the possibility of
some bugs in the new code, I'm going to leave TTY_PERM_INVENT commented
out in the repository for a day or two.  Anyone wishing to test it out
can do so by uncommenting TTY_PERM_INVENT in config.h.
This commit is contained in:
nhmall
2022-07-03 00:34:08 -04:00
parent 67e80cc329
commit c84e0ba6e1
28 changed files with 602 additions and 616 deletions

View File

@@ -562,7 +562,7 @@ typedef unsigned char uchar;
/* An experimental minimalist inventory list capability under tty if you have
* at least 28 additional rows beneath the status window on your terminal */
#define TTY_PERM_INVENT
/* #define TTY_PERM_INVENT */
/* NetHack will execute an external program whenever a new message-window
* message is shown. The program to execute is given in environment variable

View File

@@ -972,8 +972,10 @@ struct instance_globals {
persistent one doesn't get shrunk during filtering for item selection
then regrown to full inventory, possibly being resized in the process */
winid cached_pickinv_win;
winid perm_invent_win;
int core_invent_state;
int in_sync_perminvent;
int perm_invent_toggling_direction;
long glyph_reset_timestamp;
/* query objlist callback: return TRUE if obj type matches "this_type" */
int this_type;

View File

@@ -1176,6 +1176,7 @@ extern const char *currency(long);
extern void silly_thing(const char *, struct obj *);
extern void sync_perminvent(void);
extern void perm_invent_toggled(boolean negated);
extern void prepare_perminvent(winid window);
/* ### ioctl.c ### */

View File

@@ -487,6 +487,6 @@ extern void genl_outrip(winid, int, time_t);
extern void X11_preference_update(const char *);
extern void X11_update_inventory(int);
extern perminvent_info *X11_update_invent_slot(winid, int, perminvent_info *);
extern win_request_info *X11_ctrl_nhwindow(winid, int, win_request_info *);
#endif /* WINX_H */

View File

@@ -113,7 +113,7 @@ extern void genl_outrip(winid tmpwin, int how, time_t when);
extern void curses_preference_update(const char *pref);
extern void curs_reset_windows(boolean, boolean);
extern void curses_update_inventory(int);
extern perminvent_info *curses_update_invent_slot(winid, int, perminvent_info *);
extern win_request_info *curses_ctrl_nhwindow(winid, int, win_request_info *);
/* curswins.c */

View File

@@ -92,7 +92,7 @@ struct window_procs {
unsigned long *);
boolean (*win_can_suspend)(void);
void (*win_update_inventory)(int);
perminvent_info *(*win_update_invent_slot)(winid, int, perminvent_info *);
win_request_info *(*win_ctrl_nhwindow)(winid, int, win_request_info *);
};
extern
@@ -174,7 +174,7 @@ extern
*/
#define status_enablefield (*windowprocs.win_status_enablefield)
#define status_update (*windowprocs.win_status_update)
#define update_invent_slot (*windowprocs.win_update_invent_slot)
#define ctrl_nhwindow (*windowprocs.win_ctrl_nhwindow)
/*
*
@@ -491,7 +491,7 @@ extern void stdio_nonl_raw_print(const char *);
extern void stdio_raw_print_bold(const char *);
extern void stdio_wait_synch(void);
extern void safe_update_inventory(int);
extern perminvent_info *safe_update_invent_slot(winid, int, perminvent_info *);
extern win_request_info *safe_ctrl_nhwindow(winid, int, win_request_info *);
extern int stdio_nhgetch(void);
#endif /* SAFEPROCS */
#endif /* WINPROCS_H */

View File

@@ -12,7 +12,7 @@
#ifdef TTY_PERM_INVENT
enum { tty_pi_minrow = 28, tty_pi_mincol = 79 };
enum { tty_perminv_minrow = 28, tty_perminv_mincol = 79 };
/* for static init of zerottycell, put pointer first */
union ttycellcontent {
glyph_info *gi;
@@ -283,7 +283,7 @@ E void genl_outrip(winid, int, time_t);
E char *tty_getmsghistory(boolean);
E void tty_putmsghistory(const char *, boolean);
E void tty_update_inventory(int);
E perminvent_info *tty_update_invent_slot(winid, int, perminvent_info *);
E win_request_info *tty_ctrl_nhwindow(winid, int, win_request_info *);
#ifdef TTY_PERM_INVENT
E void tty_refresh_inventory(int start, int stop, int y);

View File

@@ -169,6 +169,9 @@ typedef struct gi {
*/
#define MENU_BEHAVE_STANDARD 0x0000000U
#define MENU_BEHAVE_PERMINV 0x0000001U
enum perm_invent_toggles {toggling_off = -1, toggling_not = 0, toggling_on = 1 };
/* inventory modes */
enum inv_modes { InvNormal = 0, InvShowGold = 1, InvSparse = 2, InvInUse = 4 };
@@ -180,9 +183,8 @@ enum to_core_flags {
};
enum from_core_requests {
request_settings = 1,
update_slot = 2,
render = 3
set_mode = 1,
request_settings = 2,
};
struct to_core {
@@ -197,24 +199,16 @@ struct to_core {
struct from_core {
enum from_core_requests core_request;
enum inv_modes invmode;
boolean force_redraw;
int slot; /* which inventory slot + 1; 0 indicates request */
int invlet;
char text[BUFSZ];
int32_t clr; /* adjusted color 0 = ignore
* 1-16 = NetHack color + 1
* 17..16,777,233 = 24-bit color + 17
*/
};
struct perminvent_info_t {
struct win_request_info_t {
struct to_core tocore;
struct from_core fromcore;
};
typedef struct perminvent_info_t perminvent_info;
typedef struct win_request_info_t win_request_info;
#define CORE_INVENT
/* #define CORE_INVENT */
/* clang-format on */