2012-12-11 19:51:59 +01:00
|
|
|
#include "dynamic_selection_list.hh"
|
|
|
|
|
|
|
|
namespace Kakoune
|
|
|
|
{
|
|
|
|
|
2013-12-20 21:10:08 +01:00
|
|
|
DynamicSelectionList::DynamicSelectionList(Buffer& buffer,
|
2012-12-11 19:51:59 +01:00
|
|
|
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
|
|
|
SelectionList::check_invariant();
|
2013-05-27 14:22:45 +02:00
|
|
|
const Buffer& buffer = registry();
|
|
|
|
for (size_t i = 0; i < size(); ++i)
|
|
|
|
{
|
|
|
|
auto& sel = (*this)[i];
|
2014-01-28 20:05:49 +01:00
|
|
|
kak_assert(buffer.is_valid(sel.anchor()));
|
|
|
|
kak_assert(buffer.is_valid(sel.cursor()));
|
|
|
|
kak_assert(not buffer.is_end(sel.anchor()));
|
|
|
|
kak_assert(not buffer.is_end(sel.cursor()));
|
|
|
|
kak_assert(utf8::is_character_start(buffer.iterator_at(sel.anchor())));
|
|
|
|
kak_assert(utf8::is_character_start(buffer.iterator_at(sel.cursor())));
|
2013-05-27 14:22:45 +02:00
|
|
|
}
|
2013-02-27 19:03:33 +01:00
|
|
|
#endif
|
2012-12-11 19:51:59 +01:00
|
|
|
}
|
|
|
|
|
2014-05-07 20:51:01 +02:00
|
|
|
void DynamicSelectionList::on_insert(const Buffer& buffer, ByteCoord begin, ByteCoord end)
|
2012-12-11 19:51:59 +01:00
|
|
|
{
|
2013-06-01 00:48:46 +02:00
|
|
|
update_insert(buffer, begin, end);
|
2012-12-11 19:51:59 +01:00
|
|
|
}
|
|
|
|
|
2014-05-07 20:51:01 +02:00
|
|
|
void DynamicSelectionList::on_erase(const Buffer& buffer, ByteCoord begin, ByteCoord end)
|
2012-12-11 19:51:59 +01:00
|
|
|
{
|
2013-06-01 00:48:46 +02:00
|
|
|
update_erase(buffer, begin, end);
|
2012-12-11 19:51:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|