1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
|
/**
* @file
* @brief Crude macro-capability
**/
#pragma once
#include <deque>
#include <vector>
#include "command-type.h"
#include "enum.h"
#include "KeymapContext.h"
using std::vector;
class key_recorder;
typedef deque<int> keyseq;
class key_recorder
{
public:
bool paused;
keyseq keys;
public:
key_recorder();
void add_key(int key, bool reverse = false);
void clear();
};
class pause_all_key_recorders
{
public:
pause_all_key_recorders();
~pause_all_key_recorders();
private:
vector<bool> prev_pause_status;
};
int getchm(KeymapContext context = KMC_DEFAULT);
int get_ch();
int getch_with_command_macros(); // keymaps and macros (ie for commands)
void flush_input_buffer(int reason);
void macro_quick_add();
void macro_menu();
void macro_init();
void macro_save();
void macro_clear_buffers();
void macro_userfn(const char *keys, const char *registryname);
// Add macro-expanded keys to the end or start of the keyboard buffer.
void macro_sendkeys_end_add_expanded(int key);
// [ds] Unless you know what you're doing, prefer macro_sendkeys_add_expanded
// to direct calls to macro_buf_add for pre-expanded key sequences.
//
// Crawl doesn't like holes in macro-expanded sequences in its main buffer.
void macro_buf_add(int key,
bool reverse = false, bool expanded = true);
void macro_buf_add(const keyseq &actions,
bool reverse = false, bool expanded = true);
int macro_buf_get();
void macro_buf_add_cmd(command_type cmd, bool reverse = false);
void macro_buf_add_with_keymap(keyseq keys, KeymapContext mc);
void process_command_on_record(command_type cmd);
bool is_userfunction(int key);
bool is_synthetic_key(int key);
string get_userfunction(int key);
void add_key_recorder(key_recorder* recorder);
void remove_key_recorder(key_recorder* recorder);
class key_recorder_raii
{
public:
key_recorder_raii(key_recorder* recorder) : m_recorder(recorder)
{
add_key_recorder(m_recorder);
}
~key_recorder_raii()
{
remove_key_recorder(m_recorder);
}
private:
key_recorder *m_recorder;
};
bool is_processing_macro();
bool has_pending_input();
int get_macro_buf_size();
///////////////////////////////////////////////////////////////
// Keybinding stuff
void init_keybindings();
command_type name_to_command(string name);
string command_to_name(command_type cmd);
bool keycode_is_printable(int keycode);
string keycode_to_name(int keycode, bool shorten = true);
string keyseq_to_str(const keyseq &seq);
keyseq parse_keyseq(string s);
int read_key_code(string s);
command_type key_to_command(int key, KeymapContext context);
int command_to_key(command_type cmd);
vector<int> command_to_keys(command_type cmd);
KeymapContext context_for_command(command_type cmd);
void bind_command_to_key(command_type cmd, int key);
string command_to_string(command_type cmd, bool tutorial = false);
void insert_commands(string &desc, const vector<command_type> &cmds,
bool formatted = true);
// Let rc files declare macros:
string read_rc_file_macro(const string& field);
|