return the key bound to extended command */
| 3033 | |
| 3034 | /* return the key bound to extended command */ |
| 3035 | char |
| 3036 | cmd_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. */ |
no test coverage detected