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

Function bind_mousebtn

src/cmd.c:2623–2659  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2621}
2622
2623boolean
2624bind_mousebtn(int btn, const char *command)
2625{
2626 struct ext_func_tab *extcmd;
2627
2628 if (btn < 1 || btn > NUM_MOUSE_BUTTONS) {
2629 config_error_add("Wrong mouse button, valid are 1-%i",
2630 NUM_MOUSE_BUTTONS);
2631 return FALSE;
2632 }
2633 btn--;
2634
2635 /* special case: "nothing" is reserved for unbinding */
2636 if (!strcmpi(command, "nothing")) {
2637 gc.Cmd.mousebtn[btn] = (struct ext_func_tab *) 0;
2638 return TRUE;
2639 }
2640
2641 for (extcmd = extcmdlist; extcmd->ef_txt; extcmd++) {
2642 if (strcmpi(command, extcmd->ef_txt))
2643 continue;
2644 if (!(extcmd->flags & MOUSECMD))
2645 continue;
2646 gc.Cmd.mousebtn[btn] = extcmd;
2647#if 0 /* silently accept key binding for unavailable command (!SHELL,&c) */
2648 if ((extcmd->flags & CMD_NOT_AVAILABLE) != 0) {
2649 char buf[BUFSZ];
2650
2651 Sprintf(buf, cmdnotavail, extcmd->ef_txt);
2652 config_error_add("%s", buf);
2653 }
2654#endif
2655 return TRUE;
2656 }
2657
2658 return FALSE;
2659}
2660
2661boolean
2662bind_key(uchar key, const char *command, boolean user)

Callers 2

parsebindingsFunction · 0.85
commands_initFunction · 0.85

Calls 1

config_error_addFunction · 0.85

Tested by

no test coverage detected