1
1
mirror of https://github.com/mawww/kakoune.git synced 2024-11-28 01:00:28 +03:00

IncrementalInserter: add insert_capture method bound to ^B<num>

This commit is contained in:
Maxime Coste 2011-11-16 19:24:37 +00:00
parent 52b8abfe02
commit 18913cfbff
3 changed files with 15 additions and 1 deletions

View File

@ -284,6 +284,12 @@ void do_insert(Window& window, IncrementalInserter::Mode mode)
case 27:
return;
case 2:
c = getch();
if (c >= '0' and c <= '9')
inserter.insert_capture(c - '0');
break;
case 4:
inserter.move_cursor({0, -1});
break;

View File

@ -410,7 +410,7 @@ IncrementalInserter::IncrementalInserter(Window& window, Mode mode)
++pos;
break;
}
sel = Selection(pos, pos);
sel = Selection(pos, pos, sel.captures());
}
}
@ -428,6 +428,13 @@ void IncrementalInserter::insert(const Window::String& string)
m_window.insert_noundo(string);
}
void IncrementalInserter::insert_capture(size_t index)
{
for (auto& sel : m_window.m_selections)
m_window.m_buffer.insert(sel.begin(), sel.capture(index));
m_window.scroll_to_keep_cursor_visible_ifn();
}
void IncrementalInserter::erase()
{
move_cursor(DisplayCoord(0, -1));

View File

@ -142,6 +142,7 @@ public:
~IncrementalInserter();
void insert(const Window::String& string);
void insert_capture(size_t index);
void erase();
void move_cursor(const DisplayCoord& offset);