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

Function collect_menu_keys

src/options.c:8125–8161  ·  view source on GitHub ↗

get keystrokes that are used for menu scrolling operations which apply; printable: for use in a prompt, non-printable: for yn_function() choices */

Source from the content-addressed store, hash-verified

8123/* get keystrokes that are used for menu scrolling operations which apply;
8124 printable: for use in a prompt, non-printable: for yn_function() choices */
8125char *
8126collect_menu_keys(
8127 char *outbuf, /* at least big enough for 6 "M-^X" sequences +'\0'*/
8128 unsigned scrollmask, /* 1: backwards, "^<"; 2: forwards, ">|";
8129 * 4: left, "{"; 8: right, "}"; */
8130 boolean printable) /* False: output is string of raw characters,
8131 * True: output is a string of visctrl() sequences;
8132 * matters iff user has mapped any menu scrolling
8133 * commands to control or meta characters */
8134{
8135 struct menuscrollinfo {
8136 char cmdkey;
8137 uchar maskindx;
8138 };
8139 static const struct menuscrollinfo scroll_keys[] = {
8140 { MENU_FIRST_PAGE, 1 },
8141 { MENU_PREVIOUS_PAGE, 1 },
8142 { MENU_NEXT_PAGE, 2 },
8143 { MENU_LAST_PAGE, 2 },
8144 { MENU_SHIFT_LEFT, 4 },
8145 { MENU_SHIFT_RIGHT, 8 },
8146 };
8147 int i;
8148
8149 outbuf[0] = '\0';
8150 for (i = 0; i < SIZE(scroll_keys); ++i) {
8151 if (scrollmask & scroll_keys[i].maskindx) {
8152 char c = get_menu_cmd_key(scroll_keys[i].cmdkey);
8153
8154 if (printable)
8155 Strcat(outbuf, visctrl(c));
8156 else
8157 (void) strkitten(outbuf, c);
8158 }
8159 }
8160 return outbuf;
8161}
8162
8163/* Returns the fid of the fruit type; if that type already exists, it
8164 * returns the fid of that one; if it does not exist, it adds a new fruit

Callers 2

curs_scroll_invtFunction · 0.85
x11_scroll_perminvFunction · 0.85

Calls 3

get_menu_cmd_keyFunction · 0.85
visctrlFunction · 0.85
strkittenFunction · 0.85

Tested by

no test coverage detected