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;
|
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
|
struct scoped_undo_group
|
||||||
{
|
{
|
||||||
scoped_undo_group(Buffer& buffer)
|
scoped_undo_group(Buffer& buffer)
|
||||||
|
|
|
@ -14,8 +14,15 @@ namespace Kakoune
|
||||||
|
|
||||||
struct Selection
|
struct Selection
|
||||||
{
|
{
|
||||||
Selection(const BufferIterator& first, const BufferIterator& last)
|
typedef std::vector<BufferString> CaptureList;
|
||||||
: m_first(first), m_last(last) {}
|
|
||||||
|
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 begin() const;
|
||||||
BufferIterator end() const;
|
BufferIterator end() const;
|
||||||
|
@ -25,9 +32,14 @@ struct Selection
|
||||||
|
|
||||||
void merge_with(const Selection& selection);
|
void merge_with(const Selection& selection);
|
||||||
|
|
||||||
|
BufferString capture(size_t index) const;
|
||||||
|
const CaptureList& captures() const { return m_captures; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DynamicBufferIterator m_first;
|
DynamicBufferIterator m_first;
|
||||||
DynamicBufferIterator m_last;
|
DynamicBufferIterator m_last;
|
||||||
|
|
||||||
|
CaptureList m_captures;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::vector<Selection> SelectionList;
|
typedef std::vector<Selection> SelectionList;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user