diff options
author | Matthew Cline <zelgadis@sourceforge.net> | 2009-11-18 00:34:23 -0800 |
---|---|---|
committer | Matthew Cline <zelgadis@sourceforge.net> | 2009-11-18 01:36:13 -0800 |
commit | 8dda54788b998a0348304aabeb5c4d727fd9e544 (patch) | |
tree | 8f483dc224da5c25aafef3281b1700ef1391bef7 /crawl-ref | |
parent | 09d3bbd8814bd8dde7bf85b5e7a0fa8ef19fea2f (diff) | |
download | crawl-ref-8dda54788b998a0348304aabeb5c4d727fd9e544.tar.gz crawl-ref-8dda54788b998a0348304aabeb5c4d727fd9e544.zip |
Key press buffer can hold raw commands
Raw commands (command_type enumerations) can be added to the key press
buffer with macro_buf_add(), and key_to_command() will return them
unaltered. This is useful for commands which have no key bidnings.
Diffstat (limited to 'crawl-ref')
-rw-r--r-- | crawl-ref/source/macro.cc | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/crawl-ref/source/macro.cc b/crawl-ref/source/macro.cc index 427e1ca4ce..831d7d2ca0 100644 --- a/crawl-ref/source/macro.cc +++ b/crawl-ref/source/macro.cc @@ -1090,6 +1090,36 @@ std::string command_to_name(command_type cmd) command_type key_to_command(int key, KeymapContext context) { + if (key >= CMD_NO_CMD && key < CMD_MIN_SYNTHETIC) + { + command_type cmd = (command_type) key; + KeymapContext cmd_context = context_for_command(cmd); + + if (cmd == CMD_NO_CMD) + return (CMD_NO_CMD); + + if (cmd_context != context) + { + mprf(MSGCH_ERROR, + "key_to_command(): command '%s' (%d:%d) wrong for desired " + "context", + command_to_name(cmd).c_str(), key - CMD_NO_CMD, + CMD_MAX_CMD - key); + if (is_processing_macro()) + flush_input_buffer(FLUSH_ABORT_MACRO); + if (crawl_state.is_replaying_keys() + || crawl_state.cmd_repeat_start) + { + flush_input_buffer(FLUSH_KEY_REPLAY_CANCEL); + } + flush_input_buffer(FLUSH_BEFORE_COMMAND); + + return (CMD_NO_CMD); + } + + return (cmd); + } + key_to_cmd_map &key_map = _keys_to_cmds[context]; key_to_cmd_map::iterator it = key_map.find(key); @@ -1100,6 +1130,7 @@ command_type key_to_command(int key, KeymapContext context) ASSERT(context_for_command(cmd) == context); + return cmd; } |