diff --git a/src/window.cc b/src/window.cc index 6fd4c541f..80a70f057 100644 --- a/src/window.cc +++ b/src/window.cc @@ -28,6 +28,13 @@ void Selection::merge_with(const Selection& selection) m_last = selection.m_last; } +BufferString Selection::capture(size_t index) const +{ + if (index < m_captures.size()) + return m_captures[index]; + return ""; +} + struct scoped_undo_group { scoped_undo_group(Buffer& buffer) diff --git a/src/window.hh b/src/window.hh index a3d1c4abc..c84bf8c79 100644 --- a/src/window.hh +++ b/src/window.hh @@ -14,8 +14,15 @@ namespace Kakoune struct Selection { - Selection(const BufferIterator& first, const BufferIterator& last) - : m_first(first), m_last(last) {} + typedef std::vector CaptureList; + + Selection(const BufferIterator& first, const BufferIterator& last, + const CaptureList& captures = CaptureList()) + : m_first(first), m_last(last), m_captures(captures) {} + + Selection(const BufferIterator& first, const BufferIterator& last, + CaptureList&& captures) + : m_first(first), m_last(last), m_captures(captures) {} BufferIterator begin() const; BufferIterator end() const; @@ -25,9 +32,14 @@ struct Selection void merge_with(const Selection& selection); + BufferString capture(size_t index) const; + const CaptureList& captures() const { return m_captures; } + private: DynamicBufferIterator m_first; DynamicBufferIterator m_last; + + CaptureList m_captures; }; typedef std::vector SelectionList;