diff --git a/src/window.cc b/src/window.cc index 4c3b87d9..d3cb630b 100644 --- a/src/window.cc +++ b/src/window.cc @@ -155,6 +155,18 @@ void Window::select(bool append, const Selector& selector) scroll_to_keep_cursor_visible_ifn(); } +BufferString Window::selection_content() const +{ + if (m_selections.empty()) + { + BufferIterator it = iterator_at(m_cursor); + return m_buffer.string(it, it+1); + } + else + return m_buffer.string(m_selections.back().begin(), + m_selections.back().end()); +} + void Window::move_cursor(const WindowCoord& offset) { move_cursor_to(m_cursor + offset); diff --git a/src/window.hh b/src/window.hh index 9dafed25..4314da8e 100644 --- a/src/window.hh +++ b/src/window.hh @@ -65,6 +65,7 @@ public: void empty_selections(); void select(bool append, const Selector& selector); + BufferString selection_content() const; void set_dimensions(const WindowCoord& dimensions);