save and restore " and / registers in exec_keys
This commit is contained in:
parent
13d74414e1
commit
c03506ca04
20
src/main.cc
20
src/main.cc
|
@ -798,6 +798,22 @@ std::unordered_map<Key, std::function<void (Editor& editor, int count)>> keymap
|
||||||
{ { Key::Modifiers::Alt, 'x' }, [](Editor& editor, int count) { editor.select(select_whole_lines); } },
|
{ { Key::Modifiers::Alt, 'x' }, [](Editor& editor, int count) { editor.select(select_whole_lines); } },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class RegisterRestorer
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
RegisterRestorer(char name)
|
||||||
|
: m_name(name),
|
||||||
|
m_save(RegisterManager::instance()[name].content())
|
||||||
|
{}
|
||||||
|
|
||||||
|
~RegisterRestorer()
|
||||||
|
{ RegisterManager::instance()[m_name] = m_save; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::vector<std::string> m_save;
|
||||||
|
char m_name;
|
||||||
|
};
|
||||||
|
|
||||||
void exec_keys(const KeyList& keys,
|
void exec_keys(const KeyList& keys,
|
||||||
const Context& context)
|
const Context& context)
|
||||||
{
|
{
|
||||||
|
@ -830,11 +846,13 @@ void exec_keys(const KeyList& keys,
|
||||||
return keys[pos++];
|
return keys[pos++];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
RegisterRestorer quote('"');
|
||||||
|
RegisterRestorer slash('/');
|
||||||
|
|
||||||
Editor batch_editor(context.buffer());
|
Editor batch_editor(context.buffer());
|
||||||
Editor& editor = context.has_window() ? static_cast<Editor&>(context.window())
|
Editor& editor = context.has_window() ? static_cast<Editor&>(context.window())
|
||||||
: static_cast<Editor&>(batch_editor);
|
: static_cast<Editor&>(batch_editor);
|
||||||
|
|
||||||
|
|
||||||
scoped_edition edition(editor);
|
scoped_edition edition(editor);
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
|
@ -21,6 +21,7 @@ public:
|
||||||
operator memoryview<std::string>() const
|
operator memoryview<std::string>() const
|
||||||
{ return memoryview<std::string>(m_content); }
|
{ return memoryview<std::string>(m_content); }
|
||||||
|
|
||||||
|
const std::vector<std::string>& content() const { return m_content; }
|
||||||
private:
|
private:
|
||||||
std::vector<std::string> m_content;
|
std::vector<std::string> m_content;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user