support Ctrl-R <reg> when inserting to insert a register
This commit is contained in:
parent
a62d56064f
commit
1fd8ec8bfd
23
src/main.cc
23
src/main.cc
|
@ -324,7 +324,7 @@ struct InsertSequence
|
||||||
|
|
||||||
InsertSequence last_insert_sequence;
|
InsertSequence last_insert_sequence;
|
||||||
|
|
||||||
bool insert_char(IncrementalInserter& inserter, const Key& key)
|
bool insert_char(Window& window, IncrementalInserter& inserter, const Key& key)
|
||||||
{
|
{
|
||||||
switch (key.modifiers)
|
switch (key.modifiers)
|
||||||
{
|
{
|
||||||
|
@ -353,6 +353,23 @@ bool insert_char(IncrementalInserter& inserter, const Key& key)
|
||||||
inserter.insert_capture(next_key.key - '0');
|
inserter.insert_capture(next_key.key - '0');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case 'r':
|
||||||
|
{
|
||||||
|
Key next_key = get_key();
|
||||||
|
last_insert_sequence.keys.push_back(next_key);
|
||||||
|
if (next_key.modifiers == Key::Modifiers::None)
|
||||||
|
{
|
||||||
|
switch (next_key.key)
|
||||||
|
{
|
||||||
|
case '%':
|
||||||
|
inserter.insert(window.buffer().name());
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
inserter.insert(RegisterManager::instance()[next_key.key]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
case 'd':
|
case 'd':
|
||||||
inserter.move_cursor({0, -1});
|
inserter.move_cursor({0, -1});
|
||||||
break;
|
break;
|
||||||
|
@ -378,7 +395,7 @@ void do_insert(Window& window, IncrementalInserter::Mode mode)
|
||||||
{
|
{
|
||||||
Key key = get_key();
|
Key key = get_key();
|
||||||
|
|
||||||
if (not insert_char(inserter, key))
|
if (not insert_char(window, inserter, key))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
last_insert_sequence.keys.push_back(key);
|
last_insert_sequence.keys.push_back(key);
|
||||||
|
@ -391,7 +408,7 @@ void do_repeat_insert(Window& window, int count)
|
||||||
IncrementalInserter inserter(window, last_insert_sequence.mode);
|
IncrementalInserter inserter(window, last_insert_sequence.mode);
|
||||||
for (const Key& key : last_insert_sequence.keys)
|
for (const Key& key : last_insert_sequence.keys)
|
||||||
{
|
{
|
||||||
insert_char(inserter, key);
|
insert_char(window, inserter, key);
|
||||||
}
|
}
|
||||||
draw_window(window);
|
draw_window(window);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user