2012-12-11 19:51:59 +01:00
|
|
|
#include "dynamic_selection_list.hh"
|
|
|
|
|
|
|
|
namespace Kakoune
|
|
|
|
{
|
|
|
|
|
|
|
|
DynamicSelectionList::DynamicSelectionList(const Buffer& buffer,
|
|
|
|
SelectionList selections)
|
2013-03-31 13:49:56 +02:00
|
|
|
: SelectionList(std::move(selections)),
|
|
|
|
BufferChangeListener_AutoRegister(buffer)
|
2012-12-11 19:51:59 +01:00
|
|
|
{
|
2012-12-12 14:21:50 +01:00
|
|
|
check_invariant();
|
2012-12-11 19:51:59 +01:00
|
|
|
}
|
|
|
|
|
2012-12-12 14:21:50 +01:00
|
|
|
DynamicSelectionList& DynamicSelectionList::operator=(SelectionList selections)
|
2012-12-11 19:51:59 +01:00
|
|
|
{
|
2012-12-12 14:21:50 +01:00
|
|
|
SelectionList::operator=(std::move(selections));
|
|
|
|
check_invariant();
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DynamicSelectionList::check_invariant() const
|
|
|
|
{
|
2013-02-27 19:03:33 +01:00
|
|
|
#ifdef KAK_DEBUG
|
2013-05-03 13:38:48 +02:00
|
|
|
if (empty())
|
|
|
|
return;
|
2013-03-31 13:49:56 +02:00
|
|
|
const Buffer* buf = &buffer();
|
2013-05-03 13:38:48 +02:00
|
|
|
kak_assert(&front().buffer() == buf);
|
|
|
|
SelectionList::check_invariant();
|
2013-02-27 19:03:33 +01:00
|
|
|
#endif
|
2012-12-11 19:51:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void DynamicSelectionList::on_insert(const BufferIterator& begin, const BufferIterator& end)
|
|
|
|
{
|
2013-05-02 19:04:59 +02:00
|
|
|
update_insert(begin.coord(), end.coord());
|
2012-12-11 19:51:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void DynamicSelectionList::on_erase(const BufferIterator& begin, const BufferIterator& end)
|
|
|
|
{
|
2013-05-02 19:04:59 +02:00
|
|
|
update_erase(begin.coord(), end.coord());
|
2012-12-11 19:51:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|