]> granicus.if.org Git - nethack/commitdiff
\#perminv, 1 of 2: groundwork
authorPatR <rankin@nethack.org>
Sun, 14 Mar 2021 02:17:00 +0000 (18:17 -0800)
committerPatR <rankin@nethack.org>
Sun, 14 Mar 2021 02:17:00 +0000 (18:17 -0800)
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.

21 files changed:
dat/opthelp
doc/window.doc
include/winX.h
include/wincurs.h
include/winprocs.h
include/wintty.h
src/invent.c
src/windows.c
win/Qt/qt_bind.cpp
win/Qt/qt_bind.h
win/X11/winX.c
win/chain/wc_chainin.c
win/chain/wc_chainout.c
win/chain/wc_trace.c
win/curses/cursdial.c
win/curses/cursdial.h
win/curses/cursmain.c
win/share/safeproc.c
win/tty/wintty.c
win/win32/mswproc.c
win/win32/winMS.h

index 2d82a4e855973142f39e1c48a37ed316d4c31005..5b031eb03189bbc6ea4d7cdb7cc957167e8efa94 100644 (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
                lib, whether or not to pause for visual effect.
 
-Boolean option for Amiga, or for others if ALTMETA was set at compile time:
-altmeta        For Amiga, treat Alt+key as Meta+key.               [True]
+Boolean option if ALTMETA was set at compile time:
 altmeta        For unix and VMS, treat two character sequence
                "ESC c" as M-c (Meta+c, 8th bit set) when nethack  [False]
                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.
            Here is a list of all commands with their default keystroke
            followed by a list of window-ports that implement them:
-           'x' is X11, 't' is tty, 'g' is Gem, 'a' is Amiga.
-           menu_deselect_all  deselect all items in a menu         [-](xtga)
-           menu_deselect_page deselect all items on this menu page [\](tga)
-           menu_first_page    jump to the first page in a menu     [^](tga)
-           menu_invert_all    invert all items in a menu           [@](xtga)
-           menu_invert_page   invert all items on this menu page   [~](tga)
-           menu_last_page     jump to the last page in a menu      [|](tga)
-           menu_next_page     goto the next menu page              [>](tga)
-           menu_previous_page goto the previous menu page          [<](tga)
-           menu_search        search for a menu item               [:](xtga)
-           menu_select_all    select all items in a menu           [.](xtga)
-           menu_select_page   select all items on this menu page   [,](tga)
+           (t is tty, c is curses, w is Windows GUI, x is X11, q is Qt)
+           menu_first_page    jump to the first page in a menu     [^](tcwxq)
+           menu_last_page     jump to the last page in a menu      [|](tcwxq)
+           menu_next_page     advance to the next menu page        [>](tcwxq)
+           menu_previous_page back up to the previous menu page    [<](tcwxq)
+           menu_select_all    select all items in a menu           [.](tcwxq)
+           menu_select_page   select all items on this menu page   [,](tcwq)
+           menu_deselect_all  deselect all items in a menu         [-](tcwxq)
+           menu_deselect_page deselect all items on this menu page [\](tcwq)
+           menu_invert_all    invert all items in a menu           [@](tcwxq)
+           menu_invert_page   invert all items on this menu page   [~](tcwq)
+           menu_search        prompt for target text and invert    [:](tcwxq)
+                              items which match that
 msghistory number of top line messages to save                         [20]
 name       the name of your character      [defaults to username on multi-
            user systems, asks "who are you?" on single-user systems or if
index 6e7df40dd37c1c2b96ec809a7779062b37d539a0..1c26bf9523a639d250dbed86a2569a7589d33408 100644 (file)
@@ -258,11 +258,12 @@ player_selection()
 display_file(str, boolean complain)
                -- Display the file named str.  Complain about missing files
                   iff complain is TRUE.
-update_inventory()
+update_inventory(arg)
                -- Indicate to the window port that the inventory has been
                   changed.
                -- Merely calls display_inventory() for window-ports that
                   leave the window up, otherwise empty.
+               -- 'arg' is not used yet
 doprev_message()
                -- Display previous messages.  Used by the ^P command.
                -- On the tty-port this scrolls WIN_MESSAGE back one line.
index 1ecfaf681c1d4228357103e27b2483bd19fc2da4..4fc4279bdc4424ff0ef44fd7f987b65aca3fb329 100644 (file)
@@ -253,6 +253,11 @@ struct xwindow {
 #define DEFAULT_LINES_DISPLAYED 12 /* # of lines displayed 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). */
 extern struct xwindow window_list[MAX_WINDOWS];
 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);
 extern void X11_end_menu(winid, const char *);
 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_wait_synch(void);
 #ifdef CLIPPING
@@ -456,6 +461,7 @@ extern int X11_nhgetch(void);
 extern int X11_nh_poskey(int *, int *, int *);
 extern void X11_nhbell(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 void X11_getlin(const char *, char *);
 extern int X11_get_ext_cmd(void);
index 5cd8502a12006f9d52dbabaf62d673f6ec663896..252af8e6e86291206c10f22b76ca5fab2f2d390d 100644 (file)
@@ -87,7 +87,7 @@ extern void curses_add_menu(winid wid, const glyph_info *,
                             const char *str, unsigned int itemflags);
 extern void curses_end_menu(winid wid, const char *prompt);
 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_wait_synch(void);
 extern void curses_cliparound(int x, int y);
index ca0b0387a7402dc778846d9f0b1932fa75661659..581a5dbc645cddd301255820eb5a6c389140ba6f 100644 (file)
@@ -37,7 +37,7 @@ struct window_procs {
     void (*win_end_menu)(winid, const char *);
     int (*win_select_menu)(winid, int, MENU_ITEM_P **);
     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_wait_synch)(void);
 #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 int safe_select_menu(winid, int, MENU_ITEM_P **);
 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_wait_synch(void);
 #ifdef CLIPPING
index 31b68c5035b6d027dcc20134907b437adc2f4370..3c3d92a130b12b38a6deac56850f1ee1ad8ba1da 100644 (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 int tty_select_menu(winid, int, MENU_ITEM_P **);
 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_wait_synch(void);
 #ifdef CLIPPING
index e1426e80320f90ed54d12cf60cfd22466671e82c..bd36622e3b362ceb4e57d7a16765c3308441f251 100644 (file)
@@ -2282,13 +2282,13 @@ update_inventory(void)
         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
      * because curses uses that to disable a previous perm_invent window
      * (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 */
index 5234213405a95e7d6166616dfd9062b6c3749414..48fe2ac944d1e91b09a3a2db98e815a53594e70f 100644 (file)
@@ -551,15 +551,14 @@ static struct window_procs hup_procs = {
     hup_curs, hup_putstr, hup_putstr,                  /* putmixed */
     hup_display_file, hup_void_fdecl_winid_ulong,      /* start_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,                                    /* wait_synch */
 #ifdef CLIPPING
     hup_cliparound,
 #endif
 #ifdef POSITIONBAR
-    (void (*)(char *)) hup_void_fdecl_constchar_p,
-                                                      /* update_positionbar */
+    (void (*)(char *)) hup_void_fdecl_constchar_p,    /* update_positionbar */
 #endif
     hup_print_glyph,
     hup_void_fdecl_constchar_p,                       /* raw_print */
index 9d9d9ca3b377231d234b1298fb9cb5477047f037..9a525d9883e0ea6950b9173195437f6d26b40a89 100644 (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);
 }
 
-void NetHackQtBind::qt_update_inventory()
+void NetHackQtBind::qt_update_inventory(int arg UNUSED)
 {
     if (main)
        main->updateInventory(); // update the paper doll inventory subset
+
     /* doesn't work yet
     if (g.program_state.something_worth_saving && iflags.perm_invent)
         display_inventory(NULL, false);
index d170e2b1b8d47f41cd6ef2abf00301b18b421a43..aff4170b6d1e2faba460e4339a78132c06f64b5a 100644 (file)
@@ -57,7 +57,7 @@ public:
                const char *str, unsigned int itemflags);
        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 void qt_update_inventory();
+       static void qt_update_inventory(int);
        static void qt_mark_synch();
        static void qt_wait_synch();
 
index f2f5a24fb68e9d87a2ceb02cd750e727048ed04e..c9bf7d2b2f861a6201bf489063df03030c2c4c09 100644 (file)
@@ -84,7 +84,7 @@ AppResources appResources;
 void (*input_func)(Widget, XEvent *, String *, Cardinal *);
 int click_x, click_y, click_button; /* Click position on a map window   */
                                     /* (filled by set_button_values()). */
-int updated_inventory;
+int updated_inventory; /* used to indicate perm_invent updating */
 
 static int (*old_error_handler) (Display *, XErrorEvent *);
 
@@ -1239,8 +1239,9 @@ X11_destroy_nhwindow(winid window)
     }
 }
 
+/* display persistent inventory in its own window */
 void
-X11_update_inventory(void)
+X11_update_inventory(int arg UNUSED)
 {
     struct xwindow *wp = 0;
 
@@ -1259,6 +1260,7 @@ X11_update_inventory(void)
         /* persistent inventory is up but perm_invent is off, take it down */
         x11_no_perminv(wp);
     }
+    return;
 }
 
 /* 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;
 }
 
-/* X11-specific edition of yn_function(), the routine called by the core
-   to show a prompt and get a single keystroke answer, often 'y' vs 'n' */
+/* guts of the X11_yn_function(), not to be confused with core code;
+   requires an extra argument: ynflags */
 char
-X11_yn_function(
+X11_yn_function_core(
     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 def,             /* default if user hits <space> or <return> */
+    unsigned ynflags)     /* flags; currently just log-it or not */
 {
     static XFontStruct *yn_font = 0;
     static Dimension yn_minwidth = 0;
     char buf[BUFSZ], buf2[BUFSZ];
     Arg args[4];
     Cardinal num_args;
+    boolean suppress_logging = (ynflags & YN_NO_LOGMESG) != 0U;
 
     yn_choices = choices; /* set up globals for callback to use */
     yn_def = def;
@@ -2341,12 +2345,28 @@ X11_yn_function(
         nh_XtPopdown(yn_popup); /* this removes the event grab */
     }
 
-    char *p = trimspaces(buf); /* remove !slow's extra whitespace */
-    pline("%s %s", p, (yn_return == '\033') ? "ESC" : visctrl(yn_return));
+    if (!suppress_logging) {
+        char *p = trimspaces(buf); /* remove !slow's extra whitespace */
+
+        pline("%s %s", p, (yn_return == '\033') ? "ESC" : visctrl(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;
    we support toggling tiles on and off via iflags.wc_tiled_map */
 void
@@ -2355,6 +2375,8 @@ X11_preference_update(const char *pref)
     if (!strcmp(pref, "tiled_map")) {
         if (WIN_MAP != WIN_ERR)
             display_map_window(&window_list[WIN_MAP]);
+    } else if (!strcmp(pref, "perm_invent")) {
+        ; /* TODO... */
     }
 }
 
index 020cbe2b51dca1eac6b3ee5d3f46c45f0c2b3b64..a11913791dbdcdc755bc32207a72a66f461b69e7 100644 (file)
@@ -234,9 +234,9 @@ const char *mesg;
 }
 
 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
index 056476ff2f017870d3c37804d96eb59df083622d..894dc8a268a2680a813926f71e149f0f6008a4be 100644 (file)
@@ -284,12 +284,11 @@ const char *mesg;
 }
 
 void
-chainout_update_inventory(vp)
-void *vp;
+chainout_update_inventory(void *vp, int arg)
 {
     struct chainout_data *tdp = vp;
 
-    (*tdp->nprocs->win_update_inventory)();
+    (*tdp->nprocs->win_update_inventory)(arg);
 }
 
 void
index e0895a865468901473311bdf10da41176c207691..4bdf751923a6c291c2ee0ce992a2c96ca1a92191 100644 (file)
@@ -500,15 +500,14 @@ const char *mesg;
 }
 
 void
-trace_update_inventory(vp)
-void *vp;
+trace_update_inventory(void *vp, int arg)
 {
     struct trace_data *tdp = vp;
 
-    fprintf(wc_tracelogf, "%supdate_inventory()\n", INDENT);
+    fprintf(wc_tracelogf, "%supdate_inventory(%d)\n", INDENT, arg);
 
     PRE;
-    (*tdp->nprocs->win_update_inventory)(tdp->ndata);
+    (*tdp->nprocs->win_update_inventory)(tdp->ndata, arg);
     POST;
 }
 
index 999db17f4ac7a2785ff56bdef6646ef60dd9305e..a1f7179637b900a64966e459082be184a355affa 100644 (file)
@@ -50,14 +50,14 @@ typedef struct nhm {
     const char *prompt;         /* Menu prompt text */
     nhmenu_item *entries;       /* 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 width;                  /* Window width of menu */
     unsigned long mbehavior;    /* menu flags */
     boolean reuse_accels;       /* Non-unique accelerators per page */
     boolean bottom_heavy;       /* display multi-page menu starting at end */
-    struct nhm *prev_menu;      /* Pointer to previous entry */
-    struct nhm *next_menu;      /* Pointer to next entry */
+    struct nhm *prev_menu;      /* Pointer to previous menu */
+    struct nhm *next_menu;      /* Pointer to next menu */
 } nhmenu;
 
 typedef enum menu_op_type {
@@ -877,7 +877,6 @@ get_menu(winid wid)
     return NULL;                /* Not found */
 }
 
-
 static char
 menu_get_accel(boolean first)
 {
@@ -1301,9 +1300,138 @@ menu_display_page(nhmenu *menu, WINDOW * win, int page_num, char *selectors)
     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
-menu_get_selections(WINDOW * win, nhmenu *menu, int how)
+menu_get_selections(WINDOW *win, nhmenu *menu, int how)
 {
     int curletter, menucmd;
     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 num_selected = 0;
     boolean dismiss = FALSE;
-    char search_key[BUFSZ], selectors[256];
+    char selectors[256];
     nhmenu_item *menu_item_ptr = menu->entries;
 
     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]) {
-            menucmd = (curletter <= 0 || curletter >= 255) ? curletter
-                      : (int) (uchar) map_menu_cmd(curletter);
-            switch (menucmd) {
-            case KEY_ESC:
-                num_selected = -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;
-                }
-            }
+            dismiss = curs_nonselect_menu_action(win, (void *) menu, how,
+                                                 curletter, &curpage,
+                                                 selectors, &num_selected);
+            if (num_selected == -1)
+                return -1;
         }
 
         menu_item_ptr = menu->entries;
@@ -1549,7 +1569,6 @@ menu_get_selections(WINDOW * win, nhmenu *menu, int how)
     return num_selected;
 }
 
-
 /* Select, deselect, or toggle selected for the given menu entry.
    For search operations, the toggled entry might be on a different
    page than the one currently shown. */
index 9d504bc6e3b5f219e729f4876cf8cf2102e18a16..bda9508d9aafd7c761f250a888f3860adb550a93 100644 (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);
 boolean curses_menu_exists(winid wid);
 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 */
index e22b770f55530a2b2c9099bc208dbecae5ab092a..79104a80012d4b99dc8adc5c79fba39798f5a777 100644 (file)
@@ -631,10 +631,10 @@ curses_select_menu(winid wid, int how, MENU_ITEM_P ** selected)
 }
 
 void
-curses_update_inventory(void)
+curses_update_inventory(int arg UNUSED)
 {
-    /* Don't do anything if perm_invent is off unless we
-       changed the option. */
+    /* Don't do anything if perm_invent is off unless it was on and
+       player just changed the option. */
     if (!iflags.perm_invent) {
         if (curses_get_nhwin(INV_WIN)) {
             curs_reset_windows(TRUE, FALSE);
index dacf59d8ad5056e76cbf0307da3007f7d2b8f292..28cfb37a7c87a8703d38f9aa39dc0130790b5394 100644 (file)
 
 struct window_procs safe_procs = {
     "safe-startup", 0L, 0L,
-    {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,
+    {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_exit_nhwindows, safe_suspend_nhwindows, safe_resume_nhwindows,
     safe_create_nhwindow, safe_clear_nhwindow, safe_display_nhwindow,
     safe_destroy_nhwindow, safe_curs, safe_putstr, safe_putmixed,
     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,
 #ifdef CLIPPING
     safe_cliparound,
@@ -269,7 +271,7 @@ safe_message_menu(
 }
 
 void
-safe_update_inventory(void)
+safe_update_inventory(int arg UNUSED)
 {
     return;
 }
index 4fbb855f2cccbed4c516b7da77f58091fcde9237..643544b8ebac140f75c6770f5a1402e0c21945e7 100644 (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';
 }
 
+/* update persistent inventory window */
 void
-tty_update_inventory(void)
+tty_update_inventory(int arg UNUSED)
 {
+    /* tty doesn't support persistent inventory window */
     return;
 }
 
index a6f1db9bcb85b0520a0331391e88d256b3ec4ee3..15bda0b854cc8ccfb7d9563ef5f8fcb86547027d 100644 (file)
@@ -1233,9 +1233,9 @@ mswin_select_menu(winid wid, int how, MENU_ITEM_P **selected)
         window up, otherwise empty.
 */
 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
         && iflags.window_inited && WIN_INVEN != WIN_ERR)
         display_inventory(NULL, FALSE);
@@ -1303,7 +1303,8 @@ void
 mswin_print_glyph(winid wid, xchar x, xchar y,
                   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)
         && (GetNHApp()->windowlist[wid].win != NULL)) {
@@ -2058,7 +2059,7 @@ mswin_preference_update(const char *pref)
     }
 
     if (stricmp(pref, "perm_invent") == 0) {
-        mswin_update_inventory();
+        mswin_update_inventory(0);
         return;
     }
 }
@@ -3077,14 +3078,16 @@ status_update(int fldindex, genericptr_t ptr, int chg, int percent, int color, u
 DISABLE_WARNING_FORMAT_NONLITERAL
 
 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;
     char *text = (char *) ptr;
     MSNHMsgUpdateStatus update_cmd_data;
     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) {
 
index 1b2e664b4558dcb6e6256b0f1e2cabd88cd00198..5d6b53c501b22a436bd24a8cc1a992bd4aeb5521 100644 (file)
@@ -161,7 +161,7 @@ void mswin_add_menu(winid wid, const glyph_info *glyphinfo,
                     const char *str, unsigned int itemflags);
 void mswin_end_menu(winid wid, const char *prompt);
 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_wait_synch(void);
 void mswin_cliparound(int x, int y);