\#perminv, 1 of 2: groundwork

Give the window-port side of *_update_inventory() an argument.
Calls in the core still omit that; invent.c's update_inventory()
is the only place that cares.
This commit is contained in:
PatR
2021-03-13 18:17:00 -08:00
parent 160344feaa
commit dd49431296
21 changed files with 235 additions and 179 deletions
+14 -14
View File
@@ -103,8 +103,7 @@ timed_delay on unix and VMS, use a timer instead of sending [True]
display effect. on MSDOS without the termcap display effect. on MSDOS without the termcap
lib, whether or not to pause for visual effect. lib, whether or not to pause for visual effect.
Boolean option for Amiga, or for others if ALTMETA was set at compile time: Boolean option if ALTMETA was set at compile time:
altmeta For Amiga, treat Alt+key as Meta+key. [True]
altmeta For unix and VMS, treat two character sequence altmeta For unix and VMS, treat two character sequence
"ESC c" as M-c (Meta+c, 8th bit set) when nethack [False] "ESC c" as M-c (Meta+c, 8th bit set) when nethack [False]
obtains a command from player's keyboard. obtains a command from player's keyboard.
@@ -286,18 +285,19 @@ horsename name of your starting pet if it is a pony [none]
menu_* specify single character accelerators for menu commands. menu_* specify single character accelerators for menu commands.
Here is a list of all commands with their default keystroke Here is a list of all commands with their default keystroke
followed by a list of window-ports that implement them: followed by a list of window-ports that implement them:
'x' is X11, 't' is tty, 'g' is Gem, 'a' is Amiga. (t is tty, c is curses, w is Windows GUI, x is X11, q is Qt)
menu_deselect_all deselect all items in a menu [-](xtga) menu_first_page jump to the first page in a menu [^](tcwxq)
menu_deselect_page deselect all items on this menu page [\](tga) menu_last_page jump to the last page in a menu [|](tcwxq)
menu_first_page jump to the first page in a menu [^](tga) menu_next_page advance to the next menu page [>](tcwxq)
menu_invert_all invert all items in a menu [@](xtga) menu_previous_page back up to the previous menu page [<](tcwxq)
menu_invert_page invert all items on this menu page [~](tga) menu_select_all select all items in a menu [.](tcwxq)
menu_last_page jump to the last page in a menu [|](tga) menu_select_page select all items on this menu page [,](tcwq)
menu_next_page goto the next menu page [>](tga) menu_deselect_all deselect all items in a menu [-](tcwxq)
menu_previous_page goto the previous menu page [<](tga) menu_deselect_page deselect all items on this menu page [\](tcwq)
menu_search search for a menu item [:](xtga) menu_invert_all invert all items in a menu [@](tcwxq)
menu_select_all select all items in a menu [.](xtga) menu_invert_page invert all items on this menu page [~](tcwq)
menu_select_page select all items on this menu page [,](tga) menu_search prompt for target text and invert [:](tcwxq)
items which match that
msghistory number of top line messages to save [20] msghistory number of top line messages to save [20]
name the name of your character [defaults to username on multi- name the name of your character [defaults to username on multi-
user systems, asks "who are you?" on single-user systems or if user systems, asks "who are you?" on single-user systems or if
+2 -1
View File
@@ -258,11 +258,12 @@ player_selection()
display_file(str, boolean complain) display_file(str, boolean complain)
-- Display the file named str. Complain about missing files -- Display the file named str. Complain about missing files
iff complain is TRUE. iff complain is TRUE.
update_inventory() update_inventory(arg)
-- Indicate to the window port that the inventory has been -- Indicate to the window port that the inventory has been
changed. changed.
-- Merely calls display_inventory() for window-ports that -- Merely calls display_inventory() for window-ports that
leave the window up, otherwise empty. leave the window up, otherwise empty.
-- 'arg' is not used yet
doprev_message() doprev_message()
-- Display previous messages. Used by the ^P command. -- Display previous messages. Used by the ^P command.
-- On the tty-port this scrolls WIN_MESSAGE back one line. -- On the tty-port this scrolls WIN_MESSAGE back one line.
+7 -1
View File
@@ -253,6 +253,11 @@ struct xwindow {
#define DEFAULT_LINES_DISPLAYED 12 /* # of lines displayed message window */ #define DEFAULT_LINES_DISPLAYED 12 /* # of lines displayed message window */
#define MAX_HISTORY 60 /* max history saved on message window */ #define MAX_HISTORY 60 /* max history saved on message window */
/* flags for X11_yn_function_core() */
#define YN_NORMAL 0U /* no flags */
#define YN_NO_LOGMESG 1U /* suppress echo of prompt+response to message window
* and dumplog message history */
/* Window variables (winX.c). */ /* Window variables (winX.c). */
extern struct xwindow window_list[MAX_WINDOWS]; extern struct xwindow window_list[MAX_WINDOWS];
extern XtAppContext app_context; /* context of application */ extern XtAppContext app_context; /* context of application */
@@ -442,7 +447,7 @@ extern void X11_add_menu(winid, const glyph_info *, const ANY_P *, char,
char, int, const char *, unsigned int); char, int, const char *, unsigned int);
extern void X11_end_menu(winid, const char *); extern void X11_end_menu(winid, const char *);
extern int X11_select_menu(winid, int, MENU_ITEM_P **); extern int X11_select_menu(winid, int, MENU_ITEM_P **);
extern void X11_update_inventory(void); extern void X11_update_inventory(int);
extern void X11_mark_synch(void); extern void X11_mark_synch(void);
extern void X11_wait_synch(void); extern void X11_wait_synch(void);
#ifdef CLIPPING #ifdef CLIPPING
@@ -456,6 +461,7 @@ extern int X11_nhgetch(void);
extern int X11_nh_poskey(int *, int *, int *); extern int X11_nh_poskey(int *, int *, int *);
extern void X11_nhbell(void); extern void X11_nhbell(void);
extern int X11_doprev_message(void); extern int X11_doprev_message(void);
extern char X11_yn_function_core(const char *, const char *, char, unsigned);
extern char X11_yn_function(const char *, const char *, char); extern char X11_yn_function(const char *, const char *, char);
extern void X11_getlin(const char *, char *); extern void X11_getlin(const char *, char *);
extern int X11_get_ext_cmd(void); extern int X11_get_ext_cmd(void);
+1 -1
View File
@@ -87,7 +87,7 @@ extern void curses_add_menu(winid wid, const glyph_info *,
const char *str, unsigned int itemflags); const char *str, unsigned int itemflags);
extern void curses_end_menu(winid wid, const char *prompt); extern void curses_end_menu(winid wid, const char *prompt);
extern int curses_select_menu(winid wid, int how, MENU_ITEM_P **selected); extern int curses_select_menu(winid wid, int how, MENU_ITEM_P **selected);
extern void curses_update_inventory(void); extern void curses_update_inventory(int);
extern void curses_mark_synch(void); extern void curses_mark_synch(void);
extern void curses_wait_synch(void); extern void curses_wait_synch(void);
extern void curses_cliparound(int x, int y); extern void curses_cliparound(int x, int y);
+2 -2
View File
@@ -37,7 +37,7 @@ struct window_procs {
void (*win_end_menu)(winid, const char *); void (*win_end_menu)(winid, const char *);
int (*win_select_menu)(winid, int, MENU_ITEM_P **); int (*win_select_menu)(winid, int, MENU_ITEM_P **);
char (*win_message_menu)(char, int, const char *); char (*win_message_menu)(char, int, const char *);
void (*win_update_inventory)(void); void (*win_update_inventory)(int);
void (*win_mark_synch)(void); void (*win_mark_synch)(void);
void (*win_wait_synch)(void); void (*win_wait_synch)(void);
#ifdef CLIPPING #ifdef CLIPPING
@@ -417,7 +417,7 @@ extern void safe_add_menu(winid, const glyph_info *, const ANY_P *,
extern void safe_end_menu(winid, const char *); extern void safe_end_menu(winid, const char *);
extern int safe_select_menu(winid, int, MENU_ITEM_P **); extern int safe_select_menu(winid, int, MENU_ITEM_P **);
extern char safe_message_menu(char, int, const char *); extern char safe_message_menu(char, int, const char *);
extern void safe_update_inventory(void); extern void safe_update_inventory(int);
extern void safe_mark_synch(void); extern void safe_mark_synch(void);
extern void safe_wait_synch(void); extern void safe_wait_synch(void);
#ifdef CLIPPING #ifdef CLIPPING
+1 -1
View File
@@ -202,7 +202,7 @@ E void tty_add_menu(winid, const glyph_info *, const ANY_P *, char, char,
E void tty_end_menu(winid, const char *); E void tty_end_menu(winid, const char *);
E int tty_select_menu(winid, int, MENU_ITEM_P **); E int tty_select_menu(winid, int, MENU_ITEM_P **);
E char tty_message_menu(char, int, const char *); E char tty_message_menu(char, int, const char *);
E void tty_update_inventory(void); E void tty_update_inventory(int);
E void tty_mark_synch(void); E void tty_mark_synch(void);
E void tty_wait_synch(void); E void tty_wait_synch(void);
#ifdef CLIPPING #ifdef CLIPPING
+2 -2
View File
@@ -2282,13 +2282,13 @@ update_inventory(void)
return; return;
/* /*
* Ought to check (windowprocs.wincap2 & WC2_PERM_INVENT) here.... * Ought to check (windowprocs.wincap & WC_PERM_INVENT) here....
* *
* We currently don't skip this call when iflags.perm_invent is False * We currently don't skip this call when iflags.perm_invent is False
* because curses uses that to disable a previous perm_invent window * because curses uses that to disable a previous perm_invent window
* (after toggle via 'O'; perhaps the options code should handle that). * (after toggle via 'O'; perhaps the options code should handle that).
*/ */
(*windowprocs.win_update_inventory)(); (*windowprocs.win_update_inventory)(0);
} }
/* should of course only be called for things in invent */ /* should of course only be called for things in invent */
+2 -3
View File
@@ -551,15 +551,14 @@ static struct window_procs hup_procs = {
hup_curs, hup_putstr, hup_putstr, /* putmixed */ hup_curs, hup_putstr, hup_putstr, /* putmixed */
hup_display_file, hup_void_fdecl_winid_ulong, /* start_menu */ hup_display_file, hup_void_fdecl_winid_ulong, /* start_menu */
hup_add_menu, hup_end_menu, hup_select_menu, genl_message_menu, hup_add_menu, hup_end_menu, hup_select_menu, genl_message_menu,
hup_void_ndecl, /* update_inventory */ hup_void_fdecl_int, /* update_inventory */
hup_void_ndecl, /* mark_synch */ hup_void_ndecl, /* mark_synch */
hup_void_ndecl, /* wait_synch */ hup_void_ndecl, /* wait_synch */
#ifdef CLIPPING #ifdef CLIPPING
hup_cliparound, hup_cliparound,
#endif #endif
#ifdef POSITIONBAR #ifdef POSITIONBAR
(void (*)(char *)) hup_void_fdecl_constchar_p, (void (*)(char *)) hup_void_fdecl_constchar_p, /* update_positionbar */
/* update_positionbar */
#endif #endif
hup_print_glyph, hup_print_glyph,
hup_void_fdecl_constchar_p, /* raw_print */ hup_void_fdecl_constchar_p, /* raw_print */
+2 -1
View File
@@ -450,10 +450,11 @@ int NetHackQtBind::qt_select_menu(winid wid, int how, MENU_ITEM_P **menu_list)
return window->SelectMenu(how,menu_list); return window->SelectMenu(how,menu_list);
} }
void NetHackQtBind::qt_update_inventory() void NetHackQtBind::qt_update_inventory(int arg UNUSED)
{ {
if (main) if (main)
main->updateInventory(); // update the paper doll inventory subset main->updateInventory(); // update the paper doll inventory subset
/* doesn't work yet /* doesn't work yet
if (g.program_state.something_worth_saving && iflags.perm_invent) if (g.program_state.something_worth_saving && iflags.perm_invent)
display_inventory(NULL, false); display_inventory(NULL, false);
+1 -1
View File
@@ -57,7 +57,7 @@ public:
const char *str, unsigned int itemflags); const char *str, unsigned int itemflags);
static void qt_end_menu(winid wid, const char *prompt); static void qt_end_menu(winid wid, const char *prompt);
static int qt_select_menu(winid wid, int how, MENU_ITEM_P **menu_list); static int qt_select_menu(winid wid, int how, MENU_ITEM_P **menu_list);
static void qt_update_inventory(); static void qt_update_inventory(int);
static void qt_mark_synch(); static void qt_mark_synch();
static void qt_wait_synch(); static void qt_wait_synch();
+30 -8
View File
@@ -84,7 +84,7 @@ AppResources appResources;
void (*input_func)(Widget, XEvent *, String *, Cardinal *); void (*input_func)(Widget, XEvent *, String *, Cardinal *);
int click_x, click_y, click_button; /* Click position on a map window */ int click_x, click_y, click_button; /* Click position on a map window */
/* (filled by set_button_values()). */ /* (filled by set_button_values()). */
int updated_inventory; int updated_inventory; /* used to indicate perm_invent updating */
static int (*old_error_handler) (Display *, XErrorEvent *); static int (*old_error_handler) (Display *, XErrorEvent *);
@@ -1239,8 +1239,9 @@ X11_destroy_nhwindow(winid window)
} }
} }
/* display persistent inventory in its own window */
void void
X11_update_inventory(void) X11_update_inventory(int arg UNUSED)
{ {
struct xwindow *wp = 0; struct xwindow *wp = 0;
@@ -1259,6 +1260,7 @@ X11_update_inventory(void)
/* persistent inventory is up but perm_invent is off, take it down */ /* persistent inventory is up but perm_invent is off, take it down */
x11_no_perminv(wp); x11_no_perminv(wp);
} }
return;
} }
/* The current implementation has all of the saved lines on the screen. */ /* The current implementation has all of the saved lines on the screen. */
@@ -2150,19 +2152,21 @@ release_yn_widgets(void)
XtDestroyWidget(yn_popup), yn_popup = (Widget) 0; XtDestroyWidget(yn_popup), yn_popup = (Widget) 0;
} }
/* X11-specific edition of yn_function(), the routine called by the core /* guts of the X11_yn_function(), not to be confused with core code;
to show a prompt and get a single keystroke answer, often 'y' vs 'n' */ requires an extra argument: ynflags */
char char
X11_yn_function( X11_yn_function_core(
const char *ques, /* prompt text */ const char *ques, /* prompt text */
const char *choices, /* allowed response chars; any char if Null */ const char *choices, /* allowed response chars; any char if Null */
char def) /* default if user hits <space> or <return> */ char def, /* default if user hits <space> or <return> */
unsigned ynflags) /* flags; currently just log-it or not */
{ {
static XFontStruct *yn_font = 0; static XFontStruct *yn_font = 0;
static Dimension yn_minwidth = 0; static Dimension yn_minwidth = 0;
char buf[BUFSZ], buf2[BUFSZ]; char buf[BUFSZ], buf2[BUFSZ];
Arg args[4]; Arg args[4];
Cardinal num_args; Cardinal num_args;
boolean suppress_logging = (ynflags & YN_NO_LOGMESG) != 0U;
yn_choices = choices; /* set up globals for callback to use */ yn_choices = choices; /* set up globals for callback to use */
yn_def = def; yn_def = def;
@@ -2341,12 +2345,28 @@ X11_yn_function(
nh_XtPopdown(yn_popup); /* this removes the event grab */ nh_XtPopdown(yn_popup); /* this removes the event grab */
} }
char *p = trimspaces(buf); /* remove !slow's extra whitespace */ if (!suppress_logging) {
pline("%s %s", p, (yn_return == '\033') ? "ESC" : visctrl(yn_return)); char *p = trimspaces(buf); /* remove !slow's extra whitespace */
pline("%s %s", p, (yn_return == '\033') ? "ESC" : visctrl(yn_return));
}
return yn_return; return yn_return;
} }
/* X11-specific edition of yn_function(), the routine called by the core
to show a prompt and get a single key answer, often 'y' vs 'n' */
char
X11_yn_function(
const char *ques, /* prompt text */
const char *choices, /* allowed response chars; any char if Null */
char def) /* default if user hits <space> or <return> */
{
char res = X11_yn_function_core(ques, choices, def, YN_NORMAL);
return res;
}
/* used when processing window-capability-specific run-time options; /* used when processing window-capability-specific run-time options;
we support toggling tiles on and off via iflags.wc_tiled_map */ we support toggling tiles on and off via iflags.wc_tiled_map */
void void
@@ -2355,6 +2375,8 @@ X11_preference_update(const char *pref)
if (!strcmp(pref, "tiled_map")) { if (!strcmp(pref, "tiled_map")) {
if (WIN_MAP != WIN_ERR) if (WIN_MAP != WIN_ERR)
display_map_window(&window_list[WIN_MAP]); display_map_window(&window_list[WIN_MAP]);
} else if (!strcmp(pref, "perm_invent")) {
; /* TODO... */
} }
} }
+2 -2
View File
@@ -234,9 +234,9 @@ const char *mesg;
} }
void void
chainin_update_inventory() chainin_update_inventory(int arg)
{ {
(*cibase->nprocs->win_update_inventory)(cibase->ndata); (*cibase->nprocs->win_update_inventory)(cibase->ndata, arg);
} }
void void
+2 -3
View File
@@ -284,12 +284,11 @@ const char *mesg;
} }
void void
chainout_update_inventory(vp) chainout_update_inventory(void *vp, int arg)
void *vp;
{ {
struct chainout_data *tdp = vp; struct chainout_data *tdp = vp;
(*tdp->nprocs->win_update_inventory)(); (*tdp->nprocs->win_update_inventory)(arg);
} }
void void
+3 -4
View File
@@ -500,15 +500,14 @@ const char *mesg;
} }
void void
trace_update_inventory(vp) trace_update_inventory(void *vp, int arg)
void *vp;
{ {
struct trace_data *tdp = vp; struct trace_data *tdp = vp;
fprintf(wc_tracelogf, "%supdate_inventory()\n", INDENT); fprintf(wc_tracelogf, "%supdate_inventory(%d)\n", INDENT, arg);
PRE; PRE;
(*tdp->nprocs->win_update_inventory)(tdp->ndata); (*tdp->nprocs->win_update_inventory)(tdp->ndata, arg);
POST; POST;
} }
+139 -120
View File
@@ -50,14 +50,14 @@ typedef struct nhm {
const char *prompt; /* Menu prompt text */ const char *prompt; /* Menu prompt text */
nhmenu_item *entries; /* Menu entries */ nhmenu_item *entries; /* Menu entries */
int num_entries; /* Number of menu entries */ int num_entries; /* Number of menu entries */
int num_pages; /* Number of display pages for entry */ int num_pages; /* Number of display pages for menu */
int height; /* Window height of menu */ int height; /* Window height of menu */
int width; /* Window width of menu */ int width; /* Window width of menu */
unsigned long mbehavior; /* menu flags */ unsigned long mbehavior; /* menu flags */
boolean reuse_accels; /* Non-unique accelerators per page */ boolean reuse_accels; /* Non-unique accelerators per page */
boolean bottom_heavy; /* display multi-page menu starting at end */ boolean bottom_heavy; /* display multi-page menu starting at end */
struct nhm *prev_menu; /* Pointer to previous entry */ struct nhm *prev_menu; /* Pointer to previous menu */
struct nhm *next_menu; /* Pointer to next entry */ struct nhm *next_menu; /* Pointer to next menu */
} nhmenu; } nhmenu;
typedef enum menu_op_type { typedef enum menu_op_type {
@@ -877,7 +877,6 @@ get_menu(winid wid)
return NULL; /* Not found */ return NULL; /* Not found */
} }
static char static char
menu_get_accel(boolean first) menu_get_accel(boolean first)
{ {
@@ -1301,9 +1300,138 @@ menu_display_page(nhmenu *menu, WINDOW * win, int page_num, char *selectors)
wrefresh(win); wrefresh(win);
} }
/* split out from menu_get_selections() so that perm_invent scrolling
can be controlled from outside the normal menu activity */
boolean
curs_nonselect_menu_action(WINDOW *win, void *menu_v, int how,
int curletter, int *curpage_p,
char selectors[256], int *num_selected_p)
{
nhmenu_item *menu_item_ptr;
nhmenu *menu = (nhmenu *) menu_v;
boolean dismiss = FALSE;
int menucmd = (curletter <= 0 || curletter >= 255) ? curletter
: (int) (uchar) map_menu_cmd(curletter);
switch (menucmd) {
case KEY_ESC:
*num_selected_p = -1;
dismiss = TRUE;
break;
case '\n':
case '\r':
dismiss = TRUE;
break;
#ifdef NCURSES_MOUSE_VERSION
case KEY_MOUSE: {
MEVENT mev;
if (getmouse(&mev) == OK && how != PICK_NONE) {
if (wmouse_trafo(win, &mev.y, &mev.x, FALSE)) {
int y = mev.y;
menu_item_ptr = get_menuitem_y(menu, win, *curpage_p, y);
if (menu_item_ptr) {
if (how == PICK_ONE) {
menu_clear_selections(menu);
menu_select_deselect(win, menu_item_ptr,
SELECT, *curpage_p);
*num_selected_p = 1;
dismiss = TRUE;
} else {
menu_select_deselect(win, menu_item_ptr,
INVERT, *curpage_p);
}
}
}
}
break;
} /* case KEY_MOUSE */
#endif /*NCURSES_MOUSE_VERSION*/
case KEY_RIGHT:
case KEY_NPAGE:
case MENU_NEXT_PAGE:
case ' ':
if (*curpage_p < menu->num_pages) {
++(*curpage_p);
menu_display_page(menu, win, *curpage_p, selectors);
} else if (menucmd == ' ') {
dismiss = TRUE;
break;
}
break;
case KEY_LEFT:
case KEY_PPAGE:
case MENU_PREVIOUS_PAGE:
if (*curpage_p > 1) {
--(*curpage_p);
menu_display_page(menu, win, *curpage_p, selectors);
}
break;
case KEY_END:
case MENU_LAST_PAGE:
if (*curpage_p != menu->num_pages) {
*curpage_p = menu->num_pages;
menu_display_page(menu, win, *curpage_p, selectors);
}
break;
case KEY_HOME:
case MENU_FIRST_PAGE:
if (*curpage_p != 1) {
*curpage_p = 1;
menu_display_page(menu, win, *curpage_p, selectors);
}
break;
case MENU_SEARCH: {
char search_key[BUFSZ];
search_key[0] = '\0';
curses_line_input_dialog("Search for:", search_key, BUFSZ);
refresh();
touchwin(win);
wrefresh(win);
if (!*search_key)
break;
menu_item_ptr = menu->entries;
while (menu_item_ptr != NULL) {
if (menu_item_ptr->identifier.a_void != NULL
&& strstri(menu_item_ptr->str, search_key)) {
if (how == PICK_ONE) {
menu_clear_selections(menu);
menu_select_deselect(win, menu_item_ptr,
SELECT, *curpage_p);
*num_selected_p = 1;
dismiss = TRUE;
break;
} else {
menu_select_deselect(win, menu_item_ptr,
INVERT, *curpage_p);
}
}
menu_item_ptr = menu_item_ptr->next_item;
}
menu_item_ptr = menu->entries;
break;
} /* case MENU_SEARCH */
default:
if (how == PICK_NONE) {
*num_selected_p = 0;
dismiss = TRUE;
break;
}
}
return dismiss;
}
static int static int
menu_get_selections(WINDOW * win, nhmenu *menu, int how) menu_get_selections(WINDOW *win, nhmenu *menu, int how)
{ {
int curletter, menucmd; int curletter, menucmd;
int count = -1; int count = -1;
@@ -1311,7 +1439,7 @@ menu_get_selections(WINDOW * win, nhmenu *menu, int how)
int curpage = !menu->bottom_heavy ? 1 : menu->num_pages; int curpage = !menu->bottom_heavy ? 1 : menu->num_pages;
int num_selected = 0; int num_selected = 0;
boolean dismiss = FALSE; boolean dismiss = FALSE;
char search_key[BUFSZ], selectors[256]; char selectors[256];
nhmenu_item *menu_item_ptr = menu->entries; nhmenu_item *menu_item_ptr = menu->entries;
menu_display_page(menu, win, curpage, selectors); menu_display_page(menu, win, curpage, selectors);
@@ -1379,119 +1507,11 @@ menu_get_selections(WINDOW * win, nhmenu *menu, int how)
} }
if (curletter <= 0 || curletter >= 256 || !selectors[curletter]) { if (curletter <= 0 || curletter >= 256 || !selectors[curletter]) {
menucmd = (curletter <= 0 || curletter >= 255) ? curletter dismiss = curs_nonselect_menu_action(win, (void *) menu, how,
: (int) (uchar) map_menu_cmd(curletter); curletter, &curpage,
switch (menucmd) { selectors, &num_selected);
case KEY_ESC: if (num_selected == -1)
num_selected = -1; return -1;
dismiss = TRUE;
break;
case '\n':
case '\r':
dismiss = TRUE;
break;
#ifdef NCURSES_MOUSE_VERSION
case KEY_MOUSE: {
MEVENT mev;
if (getmouse(&mev) == OK && how != PICK_NONE) {
if (wmouse_trafo(win, &mev.y, &mev.x, FALSE)) {
int y = mev.y;
menu_item_ptr = get_menuitem_y(menu, win, curpage, y);
if (menu_item_ptr) {
if (how == PICK_ONE) {
menu_clear_selections(menu);
menu_select_deselect(win, menu_item_ptr,
SELECT, curpage);
num_selected = 1;
dismiss = TRUE;
} else {
menu_select_deselect(win, menu_item_ptr,
INVERT, curpage);
}
}
}
}
}
break;
#endif /*NCURSES_MOUSE_VERSION*/
case KEY_RIGHT:
case KEY_NPAGE:
case MENU_NEXT_PAGE:
case ' ':
if (curpage < menu->num_pages) {
curpage++;
menu_display_page(menu, win, curpage, selectors);
} else if (curletter == ' ') {
dismiss = TRUE;
break;
}
break;
case KEY_LEFT:
case KEY_PPAGE:
case MENU_PREVIOUS_PAGE:
if (curpage > 1) {
curpage--;
menu_display_page(menu, win, curpage, selectors);
}
break;
case KEY_END:
case MENU_LAST_PAGE:
if (curpage != menu->num_pages) {
curpage = menu->num_pages;
menu_display_page(menu, win, curpage, selectors);
}
break;
case KEY_HOME:
case MENU_FIRST_PAGE:
if (curpage != 1) {
curpage = 1;
menu_display_page(menu, win, curpage, selectors);
}
break;
case MENU_SEARCH:
search_key[0] = '\0';
curses_line_input_dialog("Search for:", search_key, BUFSZ);
refresh();
touchwin(win);
wrefresh(win);
if (!*search_key)
break;
menu_item_ptr = menu->entries;
while (menu_item_ptr != NULL) {
if (menu_item_ptr->identifier.a_void != NULL
&& strstri(menu_item_ptr->str, search_key)) {
if (how == PICK_ONE) {
menu_clear_selections(menu);
menu_select_deselect(win, menu_item_ptr,
SELECT, curpage);
num_selected = 1;
dismiss = TRUE;
break;
} else {
menu_select_deselect(win, menu_item_ptr,
INVERT, curpage);
}
}
menu_item_ptr = menu_item_ptr->next_item;
}
menu_item_ptr = menu->entries;
break;
default:
if (how == PICK_NONE) {
num_selected = 0;
dismiss = TRUE;
break;
}
}
} }
menu_item_ptr = menu->entries; menu_item_ptr = menu->entries;
@@ -1549,7 +1569,6 @@ menu_get_selections(WINDOW * win, nhmenu *menu, int how)
return num_selected; return num_selected;
} }
/* Select, deselect, or toggle selected for the given menu entry. /* Select, deselect, or toggle selected for the given menu entry.
For search operations, the toggled entry might be on a different For search operations, the toggled entry might be on a different
page than the one currently shown. */ page than the one currently shown. */
+3
View File
@@ -22,5 +22,8 @@ void curses_finalize_nhmenu(winid wid, const char *prompt);
int curses_display_nhmenu(winid wid, int how, MENU_ITEM_P **_selected); int curses_display_nhmenu(winid wid, int how, MENU_ITEM_P **_selected);
boolean curses_menu_exists(winid wid); boolean curses_menu_exists(winid wid);
void curses_del_menu(winid, boolean); void curses_del_menu(winid, boolean);
boolean curs_nonselect_menu_action(WINDOW *win, void *menu, int how,
int curletter, int *curpage_p,
char selectors[256], int *num_selected_p);
#endif /* CURSDIAL_H */ #endif /* CURSDIAL_H */
+3 -3
View File
@@ -631,10 +631,10 @@ curses_select_menu(winid wid, int how, MENU_ITEM_P ** selected)
} }
void void
curses_update_inventory(void) curses_update_inventory(int arg UNUSED)
{ {
/* Don't do anything if perm_invent is off unless we /* Don't do anything if perm_invent is off unless it was on and
changed the option. */ player just changed the option. */
if (!iflags.perm_invent) { if (!iflags.perm_invent) {
if (curses_get_nhwin(INV_WIN)) { if (curses_get_nhwin(INV_WIN)) {
curs_reset_windows(TRUE, FALSE); curs_reset_windows(TRUE, FALSE);
+6 -4
View File
@@ -67,13 +67,15 @@
struct window_procs safe_procs = { struct window_procs safe_procs = {
"safe-startup", 0L, 0L, "safe-startup", 0L, 0L,
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, /* color availability */ {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, /* color availability */
safe_init_nhwindows, safe_player_selection, safe_askname, safe_get_nh_event, safe_init_nhwindows, safe_player_selection, safe_askname,
safe_get_nh_event,
safe_exit_nhwindows, safe_suspend_nhwindows, safe_resume_nhwindows, safe_exit_nhwindows, safe_suspend_nhwindows, safe_resume_nhwindows,
safe_create_nhwindow, safe_clear_nhwindow, safe_display_nhwindow, safe_create_nhwindow, safe_clear_nhwindow, safe_display_nhwindow,
safe_destroy_nhwindow, safe_curs, safe_putstr, safe_putmixed, safe_destroy_nhwindow, safe_curs, safe_putstr, safe_putmixed,
safe_display_file, safe_start_menu, safe_add_menu, safe_end_menu, safe_display_file, safe_start_menu, safe_add_menu, safe_end_menu,
safe_select_menu, safe_message_menu, safe_update_inventory, safe_mark_synch, safe_select_menu, safe_message_menu, safe_update_inventory,
safe_mark_synch,
safe_wait_synch, safe_wait_synch,
#ifdef CLIPPING #ifdef CLIPPING
safe_cliparound, safe_cliparound,
@@ -269,7 +271,7 @@ safe_message_menu(
} }
void void
safe_update_inventory(void) safe_update_inventory(int arg UNUSED)
{ {
return; return;
} }
+3 -1
View File
@@ -3151,9 +3151,11 @@ tty_message_menu(char let, int how, const char *mesg)
return ((how == PICK_ONE && morc == let) || morc == '\033') ? morc : '\0'; return ((how == PICK_ONE && morc == let) || morc == '\033') ? morc : '\0';
} }
/* update persistent inventory window */
void void
tty_update_inventory(void) tty_update_inventory(int arg UNUSED)
{ {
/* tty doesn't support persistent inventory window */
return; return;
} }
+9 -6
View File
@@ -1233,9 +1233,9 @@ mswin_select_menu(winid wid, int how, MENU_ITEM_P **selected)
window up, otherwise empty. window up, otherwise empty.
*/ */
void void
mswin_update_inventory(void) mswin_update_inventory(int arg)
{ {
logDebug("mswin_update_inventory()\n"); logDebug("mswin_update_inventory(%d)\n", arg);
if (iflags.perm_invent && g.program_state.something_worth_saving if (iflags.perm_invent && g.program_state.something_worth_saving
&& iflags.window_inited && WIN_INVEN != WIN_ERR) && iflags.window_inited && WIN_INVEN != WIN_ERR)
display_inventory(NULL, FALSE); display_inventory(NULL, FALSE);
@@ -1303,7 +1303,8 @@ void
mswin_print_glyph(winid wid, xchar x, xchar y, mswin_print_glyph(winid wid, xchar x, xchar y,
const glyph_info *glyphinfo, const glyph_info *bkglyphinfo) const glyph_info *glyphinfo, const glyph_info *bkglyphinfo)
{ {
logDebug("mswin_print_glyph(%d, %d, %d, %d, %d, %lu)\n", wid, x, y, glyphinfo->glyph, bkglyphinfo->glyph); logDebug("mswin_print_glyph(%d, %d, %d, %d, %d, %lu)\n",
wid, x, y, glyphinfo->glyph, bkglyphinfo->glyph);
if ((wid >= 0) && (wid < MAXWINDOWS) if ((wid >= 0) && (wid < MAXWINDOWS)
&& (GetNHApp()->windowlist[wid].win != NULL)) { && (GetNHApp()->windowlist[wid].win != NULL)) {
@@ -2058,7 +2059,7 @@ mswin_preference_update(const char *pref)
} }
if (stricmp(pref, "perm_invent") == 0) { if (stricmp(pref, "perm_invent") == 0) {
mswin_update_inventory(); mswin_update_inventory(0);
return; return;
} }
} }
@@ -3077,14 +3078,16 @@ status_update(int fldindex, genericptr_t ptr, int chg, int percent, int color, u
DISABLE_WARNING_FORMAT_NONLITERAL DISABLE_WARNING_FORMAT_NONLITERAL
void void
mswin_status_update(int idx, genericptr_t ptr, int chg, int percent, int color, unsigned long *condmasks) mswin_status_update(int idx, genericptr_t ptr, int chg, int percent,
int color, unsigned long *condmasks)
{ {
long cond, *condptr = (long *) ptr; long cond, *condptr = (long *) ptr;
char *text = (char *) ptr; char *text = (char *) ptr;
MSNHMsgUpdateStatus update_cmd_data; MSNHMsgUpdateStatus update_cmd_data;
int ochar, ci; int ochar, ci;
logDebug("mswin_status_update(%d, %p, %d, %d, %x, %p)\n", idx, ptr, chg, percent, color, condmasks); logDebug("mswin_status_update(%d, %p, %d, %d, %x, %p)\n",
idx, ptr, chg, percent, color, condmasks);
if (idx >= 0) { if (idx >= 0) {
+1 -1
View File
@@ -161,7 +161,7 @@ void mswin_add_menu(winid wid, const glyph_info *glyphinfo,
const char *str, unsigned int itemflags); const char *str, unsigned int itemflags);
void mswin_end_menu(winid wid, const char *prompt); void mswin_end_menu(winid wid, const char *prompt);
int mswin_select_menu(winid wid, int how, MENU_ITEM_P **selected); int mswin_select_menu(winid wid, int how, MENU_ITEM_P **selected);
void mswin_update_inventory(void); void mswin_update_inventory(int);
void mswin_mark_synch(void); void mswin_mark_synch(void);
void mswin_wait_synch(void); void mswin_wait_synch(void);
void mswin_cliparound(int x, int y); void mswin_cliparound(int x, int y);