| 2799 | } |
| 2800 | |
| 2801 | staticfn int |
| 2802 | keylist_putcmds(winid datawin, boolean docount, |
| 2803 | int incl_flags, int excl_flags, |
| 2804 | boolean *keys_used) /* boolean keys_used[256] */ |
| 2805 | { |
| 2806 | const struct ext_func_tab *extcmd; |
| 2807 | int i; |
| 2808 | char buf[BUFSZ], buf2[QBUFSZ]; |
| 2809 | boolean keys_already_used[256]; /* copy of keys_used[] before updates */ |
| 2810 | int count = 0; |
| 2811 | struct Cmd_bind *bind; |
| 2812 | |
| 2813 | for (i = 0; i < 256; i++) { |
| 2814 | uchar key = (uchar) i; |
| 2815 | |
| 2816 | keys_already_used[i] = keys_used[i]; |
| 2817 | if (keys_used[i]) |
| 2818 | continue; |
| 2819 | if (key == ' ' && !flags.rest_on_space) |
| 2820 | continue; |
| 2821 | bind = cmdbind_get(key); |
| 2822 | if (bind && bind->cmd != (struct ext_func_tab *) 0) { |
| 2823 | if ((incl_flags && !(bind->cmd->flags & incl_flags)) |
| 2824 | || (excl_flags && (bind->cmd->flags & excl_flags))) |
| 2825 | continue; |
| 2826 | if (docount) { |
| 2827 | count++; |
| 2828 | continue; |
| 2829 | } |
| 2830 | if ((bind->cmd->flags & CMD_PARAM) != 0) |
| 2831 | Sprintf(buf, "%-7s %-13s %s \"%s\"", key2txt(key, buf2), |
| 2832 | bind->cmd->ef_txt, bind->cmd->ef_desc, |
| 2833 | bind->param); |
| 2834 | else |
| 2835 | Sprintf(buf, "%-7s %-13s %s", key2txt(key, buf2), |
| 2836 | bind->cmd->ef_txt, bind->cmd->ef_desc); |
| 2837 | putstr(datawin, 0, buf); |
| 2838 | keys_used[i] = TRUE; |
| 2839 | } |
| 2840 | } |
| 2841 | /* also list commands that lack key assignments; most are wizard mode */ |
| 2842 | for (extcmd = extcmdlist; extcmd->ef_txt; ++extcmd) { |
| 2843 | if ((incl_flags && !(extcmd->flags & incl_flags)) |
| 2844 | || (excl_flags && (extcmd->flags & excl_flags))) |
| 2845 | continue; |
| 2846 | /* can't just check for non-Null extcmd->key; it holds the |
| 2847 | default assignment and a user-specified binding might hijack |
| 2848 | this command's default key for some other command; or this |
| 2849 | command might have been assigned a key being used for |
| 2850 | movement or as a prefix, intercepting that keystroke */ |
| 2851 | if (keylist_func_has_key(extcmd, keys_already_used)) |
| 2852 | continue; |
| 2853 | /* found a command for current category without any key assignment */ |
| 2854 | if (docount) { |
| 2855 | count++; |
| 2856 | continue; |
| 2857 | } |
| 2858 | /* '#'+20 for one column here == 7+' '+13 for two columns above */ |
no test coverage detected