MCPcopy Index your code
hub / github.com/NetHack/NetHack / dokeylist

Function dokeylist

src/cmd.c:2866–3013  ·  view source on GitHub ↗

list all keys and their bindings, like dat/hh but dynamic */

Source from the content-addressed store, hash-verified

2864
2865/* list all keys and their bindings, like dat/hh but dynamic */
2866void
2867dokeylist(void)
2868{
2869 const struct ext_func_tab *extcmd;
2870 winid datawin;
2871 char buf[BUFSZ], buf2[BUFSZ];
2872 uchar key;
2873 boolean spkey_gap, keys_used[256], mov_seen[256];
2874 int i, j, pfx_seen[256];
2875
2876 (void) memset((genericptr_t) keys_used, 0, sizeof keys_used);
2877 (void) memset((genericptr_t) pfx_seen, 0, sizeof pfx_seen);
2878
2879#ifndef NO_SIGNAL
2880 /* this is actually ambiguous; tty raw mode will override SIGINT;
2881 when enabled, treat it like a movement command since assigning
2882 other commands to this keystroke would be unwise... */
2883 key = (uchar) C('c');
2884 keys_used[key] = TRUE;
2885#endif
2886
2887 /* movement keys have been flagged in keys_used[]; clone them */
2888 (void) memcpy((genericptr_t) mov_seen, (genericptr_t) keys_used,
2889 sizeof mov_seen);
2890
2891 spkey_gap = FALSE;
2892 for (i = 0; misc_keys[i].desc; ++i) {
2893 if (misc_keys[i].numpad && !iflags.num_pad)
2894 continue;
2895 j = misc_keys[i].nhkf;
2896 key = (uchar) gc.Cmd.spkeys[j];
2897 if (key && !mov_seen[key] && !pfx_seen[key]) {
2898 keys_used[key] = TRUE;
2899 pfx_seen[key] = j;
2900 } else
2901 spkey_gap = TRUE;
2902 }
2903
2904 datawin = create_nhwindow(NHW_TEXT);
2905 putstr(datawin, 0, "");
2906 Sprintf(buf, "%7s %s", "", " Full Current Key Bindings List");
2907 putstr(datawin, 0, buf);
2908 for (extcmd = extcmdlist; extcmd->ef_txt; ++extcmd)
2909 if (spkey_gap || !keylist_func_has_key(extcmd, keys_used)) {
2910 Sprintf(buf, "%7s %s", "",
2911 "(also commands with no key assignment)");
2912 putstr(datawin, 0, buf);
2913 break;
2914 }
2915
2916 /* directional keys */
2917 putstr(datawin, 0, "");
2918 putstr(datawin, 0, "Directional keys:");
2919 show_direction_keys(datawin, '.', FALSE); /* '.'==self in direct'n grid */
2920
2921 if (!iflags.num_pad) {
2922 putstr(datawin, 0, "");
2923 putstr(datawin, 0,

Callers

nothing calls this directly

Calls 6

keylist_func_has_keyFunction · 0.85
show_direction_keysFunction · 0.85
key2txtFunction · 0.85
spkey_nameFunction · 0.85
show_menu_controlsFunction · 0.85
keylist_putcmdsFunction · 0.85

Tested by

no test coverage detected