mirror of
https://github.com/mawww/kakoune.git
synced 2024-12-24 12:02:15 +03:00
DisplayBuffer: store atoms in a std::list instead of a vector
This commit is contained in:
parent
6fd7f97fa7
commit
32e01947fa
@ -98,7 +98,6 @@ DisplayBuffer::iterator DisplayBuffer::atom_containing(const BufferIterator& whe
|
||||
|
||||
DisplayBuffer::iterator DisplayBuffer::split(iterator atom, const BufferIterator& pos)
|
||||
{
|
||||
assert(atom < end());
|
||||
assert(pos > atom->begin());
|
||||
assert(pos < atom->end());
|
||||
DisplayAtom new_atom(atom->coord(), atom->begin(), pos,
|
||||
@ -113,21 +112,22 @@ DisplayBuffer::iterator DisplayBuffer::split(iterator atom, const BufferIterator
|
||||
|
||||
void DisplayBuffer::check_invariant() const
|
||||
{
|
||||
for (size_t i = 0; i < m_atoms.size(); ++i)
|
||||
const_iterator prev_it;
|
||||
for (const_iterator it = begin(); it != end(); ++it)
|
||||
{
|
||||
assert(m_atoms[i].end() >= m_atoms[i].begin());
|
||||
if (i > 0)
|
||||
assert(it->end() >= it->begin());
|
||||
if (it != begin())
|
||||
{
|
||||
assert(m_atoms[i-1].end() == m_atoms[i].begin());
|
||||
assert(m_atoms[i-1].end_coord() == m_atoms[i].coord());
|
||||
assert(prev_it->end() == it->begin());
|
||||
assert(prev_it->end_coord() == it->coord());
|
||||
}
|
||||
prev_it = it;
|
||||
}
|
||||
}
|
||||
|
||||
void DisplayBuffer::replace_atom_content(iterator atom,
|
||||
const BufferString& replacement)
|
||||
{
|
||||
assert(atom < end());
|
||||
atom->m_replacement_text = replacement;
|
||||
|
||||
// update coordinates of subsequents atoms
|
||||
|
@ -93,7 +93,7 @@ private:
|
||||
class DisplayBuffer
|
||||
{
|
||||
public:
|
||||
typedef std::vector<DisplayAtom> AtomList;
|
||||
typedef std::list<DisplayAtom> AtomList;
|
||||
typedef AtomList::iterator iterator;
|
||||
typedef AtomList::const_iterator const_iterator;
|
||||
|
||||
|
@ -15,7 +15,7 @@ void colorize_regex(DisplayBuffer& display_buffer,
|
||||
{
|
||||
const BufferIterator& begin = matches.begin()->first;
|
||||
if (begin != atom_it->begin())
|
||||
atom_it = display_buffer.split(atom_it, begin) + 1;
|
||||
atom_it = ++display_buffer.split(atom_it, begin);
|
||||
|
||||
const BufferIterator& end = matches.begin()->second;
|
||||
if (end != atom_it->end())
|
||||
@ -64,7 +64,7 @@ void expand_tabulations(DisplayBuffer& display_buffer)
|
||||
if (*it == '\t')
|
||||
{
|
||||
if (it != atom_it->begin())
|
||||
atom_it = display_buffer.split(atom_it, it) + 1;
|
||||
atom_it = ++display_buffer.split(atom_it, it);
|
||||
|
||||
if (it+1 != atom_it->end())
|
||||
atom_it = display_buffer.split(atom_it, it+1);
|
||||
@ -108,7 +108,7 @@ void show_line_numbers(DisplayBuffer& display_buffer)
|
||||
if (not atom_it->splitable())
|
||||
continue;
|
||||
|
||||
atom_it = display_buffer.split(atom_it, line_start) + 1;
|
||||
atom_it = ++display_buffer.split(atom_it, line_start);
|
||||
}
|
||||
atom_it = display_buffer.insert(
|
||||
atom_it,
|
||||
|
@ -71,7 +71,7 @@ public:
|
||||
else if (atom.begin() < sel.begin() and atom.end() > sel.end())
|
||||
{
|
||||
atom_it = display_buffer.split(atom_it, sel.begin());
|
||||
atom_it = display_buffer.split(atom_it + 1, sel.end());
|
||||
atom_it = display_buffer.split(++atom_it, sel.end());
|
||||
atom_it->attribute() |= Attributes::Underline;
|
||||
++atom_it;
|
||||
++sel_it;
|
||||
@ -79,7 +79,7 @@ public:
|
||||
// [------###]
|
||||
else if (atom.begin() < sel.begin() and atom.end() > sel.begin())
|
||||
{
|
||||
atom_it = display_buffer.split(atom_it, sel.begin()) + 1;
|
||||
atom_it = ++display_buffer.split(atom_it, sel.begin());
|
||||
atom_it->attribute() |= Attributes::Underline;
|
||||
++atom_it;
|
||||
}
|
||||
@ -225,8 +225,7 @@ BufferIterator Window::iterator_at(const DisplayCoord& window_pos) const
|
||||
{
|
||||
if (window_pos < atom_it->coord())
|
||||
{
|
||||
const DisplayAtom& atom = *(atom_it - 1);
|
||||
return atom.iterator_at(window_pos);
|
||||
return (--atom_it)->iterator_at(window_pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user