IncrementalInserter: add insert_capture method bound to ^B<num>
This commit is contained in:
parent
52b8abfe02
commit
18913cfbff
|
@ -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;
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user