MCPcopy Create free account
hub / github.com/NetHack/NetHack / x11_scroll_perminv

Function x11_scroll_perminv

win/X11/winmenu.c:690–771  ·  view source on GitHub ↗

called by X11_update_inventory() if user has executed #perminv command */

Source from the content-addressed store, hash-verified

688
689/* called by X11_update_inventory() if user has executed #perminv command */
690void
691x11_scroll_perminv(int arg UNUSED) /* arg is always 1 */
692{
693 static const char extrakeys[] = "\033 \n\r\003\177\b";
694 char ch, menukeys[QBUFSZ];
695 boolean save_is_active;
696 unsigned scrlmask;
697 Cardinal no_args = 0;
698 struct xwindow *wp = &window_list[WIN_INVEN];
699
700 /* caller has ensured that perm_invent is enabled, but the window
701 might not be displayed; if that's the case, display it */
702 if (wp->type == NHW_MENU && !wp->menu_information->is_up)
703 X11_update_inventory(0);
704 /* if it's still not displayed for some reason, bail out now */
705 if (wp->type != NHW_MENU || !wp->menu_information->is_up) {
706 X11_nhbell();
707 return;
708 }
709
710 do {
711 scrlmask = menu_scrollmask(wp);
712 (void) collect_menu_keys(menukeys, scrlmask, FALSE);
713 /*
714 * Add quitchars plus a few others to the player's scrolling keys.
715 * We accept some extra characters that menus usually ignore:
716 * ^C will be treated like <escape>, leaving menu positioned as-is
717 * and returning to play; <delete> or <backspace> will be treated
718 * like <return> and <space>, resetting the menu to its top and
719 * returning to play; other characters will either be rejected by
720 * yn_function or stay here for scrolling.
721 */
722 Strcat(menukeys, extrakeys);
723 /* append any scrolling keys excluded by scrlmask, after the \033
724 added by extrakeys; they'll be acceptable but not shown */
725 (void) collect_menu_keys(eos(menukeys), ~scrlmask, FALSE);
726
727 /* normally the perm_invent menu is not flagged 'is_active' because
728 it doesn't accept input, so menu_popdown() doesn't set the flag
729 for the event loop to exit; force 'is_active' while this prompt
730 is in progress so that the prompt won't be left pending if
731 player closes the menu via mouse */
732 save_is_active = wp->menu_information->is_active;
733 wp->menu_information->is_active = TRUE;
734 ch = X11_yn_function_core("Inventory scroll:", menukeys,
735 0, (YN_NO_LOGMESG | YN_NO_DEFAULT));
736 if (wp->menu_information->is_up)
737 wp->menu_information->is_active = save_is_active;
738 else
739 ch = 0;
740
741 if (ch == C('c')) /* ^C */
742 ch = '\033';
743 else if (ch == '\177' || ch == '\b') /* <delete> or <backspace> */
744 ch = '\n';
745
746 if (ch && ch != '\033') {
747 /* in case persistent inventory window is covered, force it

Callers 1

X11_update_inventoryFunction · 0.85

Calls 7

X11_update_inventoryFunction · 0.85
X11_nhbellFunction · 0.85
menu_scrollmaskFunction · 0.85
collect_menu_keysFunction · 0.85
eosFunction · 0.85
X11_yn_function_coreFunction · 0.85
menu_keyFunction · 0.85

Tested by

no test coverage detected