MCPcopy Create free account
hub / github.com/crawl/crawl / init_keybindings

Function init_keybindings

crawl-ref/source/macro.cc:2114–2155  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2112#define VALID_BIND_COMMAND(cmd) (cmd > CMD_NO_CMD && cmd < CMD_MIN_SYNTHETIC)
2113
2114void init_keybindings()
2115{
2116 int i;
2117
2118 for (i = 0; _command_name_list[i].cmd != CMD_NO_CMD
2119 && _command_name_list[i].name != nullptr; i++)
2120 {
2121 command_name &data = _command_name_list[i];
2122
2123 ASSERT(VALID_BIND_COMMAND(data.cmd));
2124 ASSERT(!_names_to_cmds.count(data.name));
2125 ASSERT(_cmds_to_names.find(data.cmd) == _cmds_to_names.end());
2126
2127 _names_to_cmds[data.name] = data.cmd;
2128 _cmds_to_names[data.cmd] = data.name;
2129 }
2130
2131 ASSERT(i >= 130);
2132
2133 for (i = 0; _default_binding_list[i].cmd != CMD_NO_CMD
2134 && _default_binding_list[i].key != '\0'; i++)
2135 {
2136 default_binding &data = _default_binding_list[i];
2137 ASSERT(VALID_BIND_COMMAND(data.cmd));
2138
2139 KeymapContext context = context_for_command(data.cmd);
2140
2141 ASSERT(context < KMC_CONTEXT_COUNT);
2142
2143 key_to_cmd_map &key_map = _keys_to_cmds[context];
2144 cmd_to_key_map &cmd_map = _cmds_to_keys[context];
2145
2146 // Only one command per key, but it's okay to have several
2147 // keys map to the same command.
2148 ASSERTM(!key_map.count(data.key), "bad mapping for key '%c'", data.key);
2149
2150 key_map[data.key] = data.cmd;
2151 cmd_map[data.cmd] = data.key;
2152 }
2153
2154 ASSERT(i >= 130);
2155}
2156
2157command_type name_to_command(string name)
2158{

Callers 1

mainFunction · 0.85

Calls 4

context_for_commandFunction · 0.85
countMethod · 0.45
findMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected