diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2011-11-22 14:23:46 +0000 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2011-11-22 14:23:46 +0000 |
| commit | 95f87a66948045c42fce822ea7b382c3f394c17c (patch) | |
| tree | dd31b15d6dcf7f9edaefd135c3498b7beae02f80 /src | |
| parent | a7309fbe87f02591b709e769962d0859482b1053 (diff) | |
Window: add replace method
permits to replace selection by a string in a single undo step
Diffstat (limited to 'src')
| -rw-r--r-- | src/window.cc | 8 | ||||
| -rw-r--r-- | src/window.hh | 1 |
2 files changed, 9 insertions, 0 deletions
diff --git a/src/window.cc b/src/window.cc index 906258be..4782d3b5 100644 --- a/src/window.cc +++ b/src/window.cc @@ -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(); diff --git a/src/window.hh b/src/window.hh index 41556386..aa8c066e 100644 --- a/src/window.hh +++ b/src/window.hh @@ -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; |
