mirror of
https://github.com/mawww/kakoune.git
synced 2024-11-30 23:37:17 +03:00
Selections: add captures field
Selections now can have associated captures, for backreferences when selections are created from a regex search
This commit is contained in:
parent
b82631aa3d
commit
52b8abfe02
@ -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)
|
||||
|
@ -14,8 +14,15 @@ namespace Kakoune
|
||||
|
||||
struct Selection
|
||||
{
|
||||
Selection(const BufferIterator& first, const BufferIterator& last)
|
||||
: m_first(first), m_last(last) {}
|
||||
typedef std::vector<BufferString> 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<Selection> SelectionList;
|
||||
|
Loading…
Reference in New Issue
Block a user