Window: add replace method

permits to replace selection by a string in a single undo step
This commit is contained in:
Maxime Coste 2011-11-22 14:23:46 +00:00
parent a7309fbe87
commit 95f87a6694
2 changed files with 9 additions and 0 deletions

View File

@ -139,6 +139,14 @@ void Window::append_noundo(const String& string)
scroll_to_keep_cursor_visible_ifn();
}
void Window::replace(const std::string& string)
{
scoped_undo_group undo_group(m_buffer);
erase_noundo();
insert_noundo(string);
}
bool Window::undo()
{
return m_buffer.undo();

View File

@ -56,6 +56,7 @@ public:
void erase();
void insert(const String& string);
void append(const String& string);
void replace(const String& string);
const BufferCoord& position() const { return m_position; }
DisplayCoord cursor_position() const;