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

Function get_changed_key_binds

src/cmd.c:2234–2287  ·  view source on GitHub ↗

show changed key bindings in text, or if sbuf is non-null, append to it */

Source from the content-addressed store, hash-verified

2232
2233/* show changed key bindings in text, or if sbuf is non-null, append to it */
2234void
2235get_changed_key_binds(strbuf_t *sbuf)
2236{
2237 winid win = WIN_ERR;
2238 int i;
2239 char buf[BUFSZ];
2240 char buf2[QBUFSZ];
2241 struct Cmd_bind *bind = gc.Cmd.cmdbinds;
2242 uchar keys[256];
2243
2244 (void) memset(keys, 0, sizeof(uchar) * 256);
2245
2246 if (!sbuf)
2247 win = create_nhwindow(NHW_TEXT);
2248
2249 /* commands bound to different key */
2250 while (bind) {
2251 keys[bind->key] = 1;
2252 if (bind->userbind && bind->cmd && bind->cmd->key != bind->key) {
2253 if ((bind->cmd->flags & CMD_PARAM) != 0)
2254 Sprintf(buf, "BIND=%s:%s(%s)%s", key2txt(bind->key, buf2),
2255 bind->cmd->ef_txt,
2256 bind->param,
2257 sbuf ? "\n" : "");
2258 else
2259 Sprintf(buf, "BIND=%s:%s%s", key2txt(bind->key, buf2),
2260 bind->cmd->ef_txt,
2261 sbuf ? "\n" : "");
2262 if (sbuf)
2263 strbuf_append(sbuf, buf);
2264 else
2265 putstr(win, 0, buf);
2266 }
2267 bind = bind->next;
2268 }
2269
2270 /* commands which should be bound to a key, but aren't */
2271 for (i = 0; i < extcmdlist_length; i++) {
2272 struct ext_func_tab *ec = &extcmdlist[i];
2273
2274 if (ec->key && !keys[ec->key]) {
2275 Sprintf(buf, "BIND=%s:nothing%s", key2txt(ec->key, buf2),
2276 sbuf ? "\n" : "");
2277 if (sbuf)
2278 strbuf_append(sbuf, buf);
2279 else
2280 putstr(win, 0, buf);
2281 }
2282 }
2283 if (!sbuf) {
2284 display_nhwindow(win, TRUE);
2285 destroy_nhwindow(win);
2286 }
2287}
2288
2289/* interactive key binding */
2290staticfn void

Callers 2

all_options_strbufFunction · 0.85
handler_rebind_keysFunction · 0.85

Calls 2

key2txtFunction · 0.85
strbuf_appendFunction · 0.85

Tested by

no test coverage detected