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

Function cmd_from_func

src/cmd.c:3035–3066  ·  view source on GitHub ↗

return the key bound to extended command */

Source from the content-addressed store, hash-verified

3033
3034/* return the key bound to extended command */
3035char
3036cmd_from_func(int (*fn)(void))
3037{
3038 int i;
3039 char ret = '\0';
3040 struct Cmd_bind *bind;
3041
3042 for (bind = gc.Cmd.cmdbinds; bind; bind = bind->next) {
3043 i = bind->key;
3044 /* skip space; we'll use it below as last resort if no other
3045 keystroke invokes space's command */
3046 if (i == ' ')
3047 continue;
3048 /* skip digits if number_pad is Off; also skip '-' unless it has
3049 been bound to something other than what number_pad assigns */
3050 if (((i >= '0' && i <= '9') || (i == '-' && fn == do_fight))
3051 && !gc.Cmd.num_pad)
3052 continue;
3053
3054 if (bind->cmd && bind->cmd->ef_funct == fn) {
3055 if (i >= ' ' && i <= '~')
3056 return (char) i;
3057 else {
3058 ret = (char) i;
3059 }
3060 }
3061 }
3062 if ((bind = cmdbind_get(' ')) != 0 && bind->cmd
3063 && bind->cmd->ef_funct == fn)
3064 return ' ';
3065 return ret;
3066}
3067
3068/* return visual interpretation of the key bound to extended command,
3069 or the ext cmd name if not bound to any key. */

Callers 15

NetHackQtMainWindowMethod · 0.85
AddToolButtonMethod · 0.85
cmd_safety_preventionFunction · 0.85
handle_tipFunction · 0.85
wiz_identifyFunction · 0.85
setopt_cmdFunction · 0.85
doextcmdFunction · 0.85
doc_extcmd_flagstrFunction · 0.85
do_reqmenuFunction · 0.85
cmd_from_dirFunction · 0.85
cmd_from_ecnameFunction · 0.85

Calls 1

cmdbind_getFunction · 0.85

Tested by

no test coverage detected