1
1
mirror of https://github.com/mawww/kakoune.git synced 2024-12-18 17:02:06 +03:00

extract exec_keys function from exec_string

This commit is contained in:
Maxime Coste 2012-02-07 13:35:41 +00:00
parent 0483e951ad
commit 1e5d930f35

View File

@ -1019,16 +1019,9 @@ std::unordered_map<Key, std::function<void (Editor& editor, int count)>> keymap
{ { Key::Modifiers::Alt, 'x' }, [](Editor& editor, int count) { editor.multi_select(select_whole_lines); } },
};
void exec_string(const CommandParameters& params,
void exec_keys(const KeyList& keys,
const Context& context)
{
if (params.size() != 1)
throw wrong_argument_count();
size_t pos = 0;
KeyList keys = parse_keys(params[0]);
auto prompt_save = prompt_func;
auto get_key_save = get_key_func;
@ -1037,6 +1030,8 @@ void exec_string(const CommandParameters& params,
get_key_func = get_key_save;
});
size_t pos = 0;
prompt_func = [&](const std::string&, Completer) {
size_t begin = pos;
while (pos < keys.size() and keys[pos].key != '\n')
@ -1080,6 +1075,17 @@ void exec_string(const CommandParameters& params,
}
}
void exec_string(const CommandParameters& params,
const Context& context)
{
if (params.size() != 1)
throw wrong_argument_count();
KeyList keys = parse_keys(params[0]);
exec_keys(keys, context);
}
int main(int argc, char* argv[])
{
init_ncurses();