Add DisplayAtom::check_invariant method
This commit is contained in:
parent
277b02eee6
commit
bd80cf0404
|
@ -12,6 +12,7 @@ void DisplayAtom::trim_begin(CharCount count)
|
||||||
m_buffer->iterator_at(m_end), count).coord();
|
m_buffer->iterator_at(m_end), count).coord();
|
||||||
else
|
else
|
||||||
m_text = m_text.substr(count);
|
m_text = m_text.substr(count);
|
||||||
|
check_invariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DisplayAtom::trim_end(CharCount count)
|
void DisplayAtom::trim_end(CharCount count)
|
||||||
|
@ -21,6 +22,18 @@ void DisplayAtom::trim_end(CharCount count)
|
||||||
m_buffer->iterator_at(m_begin), -count).coord();
|
m_buffer->iterator_at(m_begin), -count).coord();
|
||||||
else
|
else
|
||||||
m_text = m_text.substr(0, m_text.char_length() - count);
|
m_text = m_text.substr(0, m_text.char_length() - count);
|
||||||
|
check_invariant();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DisplayAtom::check_invariant() const
|
||||||
|
{
|
||||||
|
#ifdef KAK_DEBUG
|
||||||
|
if (has_buffer_range())
|
||||||
|
{
|
||||||
|
kak_assert(m_buffer->is_valid(m_begin));
|
||||||
|
kak_assert(m_buffer->is_valid(m_end));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
DisplayLine::DisplayLine(AtomList atoms)
|
DisplayLine::DisplayLine(AtomList atoms)
|
||||||
|
@ -38,6 +51,8 @@ DisplayLine::iterator DisplayLine::split(iterator it, BufferCoord pos)
|
||||||
DisplayAtom atom = *it;
|
DisplayAtom atom = *it;
|
||||||
atom.m_end = pos;
|
atom.m_end = pos;
|
||||||
it->m_begin = pos;
|
it->m_begin = pos;
|
||||||
|
atom.check_invariant();
|
||||||
|
it->check_invariant();
|
||||||
return m_atoms.insert(it, std::move(atom));
|
return m_atoms.insert(it, std::move(atom));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,6 +120,7 @@ void DisplayLine::optimize()
|
||||||
next_atom_it = m_atoms.erase(next_atom_it);
|
next_atom_it = m_atoms.erase(next_atom_it);
|
||||||
else
|
else
|
||||||
atom_it = next_atom_it++;
|
atom_it = next_atom_it++;
|
||||||
|
atom_it->check_invariant();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,11 +35,13 @@ public:
|
||||||
enum Type { BufferRange, ReplacedBufferRange, Text };
|
enum Type { BufferRange, ReplacedBufferRange, Text };
|
||||||
|
|
||||||
DisplayAtom(const Buffer& buffer, BufferCoord begin, BufferCoord end)
|
DisplayAtom(const Buffer& buffer, BufferCoord begin, BufferCoord end)
|
||||||
: m_type(BufferRange), m_buffer(&buffer), m_begin(begin), m_end(end) {}
|
: m_type(BufferRange), m_buffer(&buffer), m_begin(begin), m_end(end)
|
||||||
|
{ check_invariant(); }
|
||||||
|
|
||||||
DisplayAtom(String str, ColorPair colors = { Colors::Default, Colors::Default },
|
DisplayAtom(String str, ColorPair colors = { Colors::Default, Colors::Default },
|
||||||
Attribute attribute = Normal)
|
Attribute attribute = Normal)
|
||||||
: m_type(Text), m_text(std::move(str)), colors(colors), attribute(attribute) {}
|
: m_type(Text), m_text(std::move(str)), colors(colors), attribute(attribute)
|
||||||
|
{ check_invariant(); }
|
||||||
|
|
||||||
String content() const
|
String content() const
|
||||||
{
|
{
|
||||||
|
@ -99,6 +101,7 @@ public:
|
||||||
void trim_begin(CharCount count);
|
void trim_begin(CharCount count);
|
||||||
void trim_end(CharCount count);
|
void trim_end(CharCount count);
|
||||||
|
|
||||||
|
void check_invariant() const;
|
||||||
public:
|
public:
|
||||||
ColorPair colors = {Colors::Default, Colors::Default};
|
ColorPair colors = {Colors::Default, Colors::Default};
|
||||||
Attribute attribute = Normal;
|
Attribute attribute = Normal;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user