Rename DisplayAtom::Types to avoid conflicts with struct BufferRange
This commit is contained in:
parent
1f3e424047
commit
6bfc68d4f3
|
@ -41,7 +41,7 @@ StringView DisplayAtom::content() const
|
||||||
{
|
{
|
||||||
switch (m_type)
|
switch (m_type)
|
||||||
{
|
{
|
||||||
case BufferRange:
|
case Range:
|
||||||
{
|
{
|
||||||
auto line = (*m_buffer)[m_range.begin.line];
|
auto line = (*m_buffer)[m_range.begin.line];
|
||||||
if (m_range.begin.line == m_range.end.line)
|
if (m_range.begin.line == m_range.end.line)
|
||||||
|
@ -51,7 +51,7 @@ StringView DisplayAtom::content() const
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Text:
|
case Text:
|
||||||
case ReplacedBufferRange:
|
case ReplacedRange:
|
||||||
return m_text;
|
return m_text;
|
||||||
}
|
}
|
||||||
kak_assert(false);
|
kak_assert(false);
|
||||||
|
@ -62,10 +62,10 @@ ColumnCount DisplayAtom::length() const
|
||||||
{
|
{
|
||||||
switch (m_type)
|
switch (m_type)
|
||||||
{
|
{
|
||||||
case BufferRange:
|
case Range:
|
||||||
return column_length(*m_buffer, m_range.begin, m_range.end);
|
return column_length(*m_buffer, m_range.begin, m_range.end);
|
||||||
case Text:
|
case Text:
|
||||||
case ReplacedBufferRange:
|
case ReplacedRange:
|
||||||
return m_text.column_length();
|
return m_text.column_length();
|
||||||
}
|
}
|
||||||
kak_assert(false);
|
kak_assert(false);
|
||||||
|
@ -74,7 +74,7 @@ ColumnCount DisplayAtom::length() const
|
||||||
|
|
||||||
void DisplayAtom::trim_begin(ColumnCount count)
|
void DisplayAtom::trim_begin(ColumnCount count)
|
||||||
{
|
{
|
||||||
if (m_type == BufferRange)
|
if (m_type == Range)
|
||||||
m_range.begin = utf8::advance(m_buffer->iterator_at(m_range.begin),
|
m_range.begin = utf8::advance(m_buffer->iterator_at(m_range.begin),
|
||||||
m_buffer->iterator_at(m_range.end),
|
m_buffer->iterator_at(m_range.end),
|
||||||
count).coord();
|
count).coord();
|
||||||
|
@ -85,7 +85,7 @@ void DisplayAtom::trim_begin(ColumnCount count)
|
||||||
|
|
||||||
void DisplayAtom::trim_end(ColumnCount count)
|
void DisplayAtom::trim_end(ColumnCount count)
|
||||||
{
|
{
|
||||||
if (m_type == BufferRange)
|
if (m_type == Range)
|
||||||
m_range.end = utf8::advance(m_buffer->iterator_at(m_range.end),
|
m_range.end = utf8::advance(m_buffer->iterator_at(m_range.end),
|
||||||
m_buffer->iterator_at(m_range.begin),
|
m_buffer->iterator_at(m_range.begin),
|
||||||
-count).coord();
|
-count).coord();
|
||||||
|
@ -113,7 +113,7 @@ DisplayLine::DisplayLine(AtomList atoms)
|
||||||
|
|
||||||
DisplayLine::iterator DisplayLine::split(iterator it, BufferCoord pos)
|
DisplayLine::iterator DisplayLine::split(iterator it, BufferCoord pos)
|
||||||
{
|
{
|
||||||
kak_assert(it->type() == DisplayAtom::BufferRange);
|
kak_assert(it->type() == DisplayAtom::Range);
|
||||||
kak_assert(it->begin() < pos);
|
kak_assert(it->begin() < pos);
|
||||||
kak_assert(it->end() > pos);
|
kak_assert(it->end() > pos);
|
||||||
|
|
||||||
|
@ -182,12 +182,12 @@ void DisplayLine::optimize()
|
||||||
atom.type() == next_atom.type())
|
atom.type() == next_atom.type())
|
||||||
{
|
{
|
||||||
auto type = atom.type();
|
auto type = atom.type();
|
||||||
if ((type == DisplayAtom::BufferRange or
|
if ((type == DisplayAtom::Range or
|
||||||
type == DisplayAtom::ReplacedBufferRange) and
|
type == DisplayAtom::ReplacedRange) and
|
||||||
next_atom.begin() == atom.end())
|
next_atom.begin() == atom.end())
|
||||||
{
|
{
|
||||||
atom.m_range.end = next_atom.end();
|
atom.m_range.end = next_atom.end();
|
||||||
if (type == DisplayAtom::ReplacedBufferRange)
|
if (type == DisplayAtom::ReplacedRange)
|
||||||
atom.m_text += next_atom.m_text;
|
atom.m_text += next_atom.m_text;
|
||||||
merged = true;
|
merged = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,10 +30,10 @@ size_t hash_value(const BufferRange& range)
|
||||||
struct DisplayAtom : public UseMemoryDomain<MemoryDomain::Display>
|
struct DisplayAtom : public UseMemoryDomain<MemoryDomain::Display>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum Type { BufferRange, ReplacedBufferRange, Text };
|
enum Type { Range, ReplacedRange, Text };
|
||||||
|
|
||||||
DisplayAtom(const Buffer& buffer, BufferCoord begin, BufferCoord end)
|
DisplayAtom(const Buffer& buffer, BufferCoord begin, BufferCoord end)
|
||||||
: m_type(BufferRange), m_buffer(&buffer), m_range{begin, end}
|
: m_type(Range), m_buffer(&buffer), m_range{begin, end}
|
||||||
{ check_invariant(); }
|
{ check_invariant(); }
|
||||||
|
|
||||||
DisplayAtom(String str, Face face = Face{})
|
DisplayAtom(String str, Face face = Face{})
|
||||||
|
@ -57,14 +57,14 @@ public:
|
||||||
|
|
||||||
void replace(String text)
|
void replace(String text)
|
||||||
{
|
{
|
||||||
kak_assert(m_type == BufferRange);
|
kak_assert(m_type == Range);
|
||||||
m_type = ReplacedBufferRange;
|
m_type = ReplacedRange;
|
||||||
m_text = std::move(text);
|
m_text = std::move(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool has_buffer_range() const
|
bool has_buffer_range() const
|
||||||
{
|
{
|
||||||
return m_type == BufferRange or m_type == ReplacedBufferRange;
|
return m_type == Range or m_type == ReplacedRange;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Buffer& buffer() const { kak_assert(m_buffer); return *m_buffer; }
|
const Buffer& buffer() const { kak_assert(m_buffer); return *m_buffer; }
|
||||||
|
@ -91,7 +91,7 @@ private:
|
||||||
Type m_type;
|
Type m_type;
|
||||||
|
|
||||||
const Buffer* m_buffer = nullptr;
|
const Buffer* m_buffer = nullptr;
|
||||||
Kakoune::BufferRange m_range;
|
BufferRange m_range;
|
||||||
String m_text;
|
String m_text;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ void highlight_range(DisplayBuffer& display_buffer,
|
||||||
|
|
||||||
for (auto atom_it = line.begin(); atom_it != line.end(); ++atom_it)
|
for (auto atom_it = line.begin(); atom_it != line.end(); ++atom_it)
|
||||||
{
|
{
|
||||||
bool is_replaced = atom_it->type() == DisplayAtom::ReplacedBufferRange;
|
bool is_replaced = atom_it->type() == DisplayAtom::ReplacedRange;
|
||||||
|
|
||||||
if (not atom_it->has_buffer_range() or
|
if (not atom_it->has_buffer_range() or
|
||||||
(skip_replaced and is_replaced))
|
(skip_replaced and is_replaced))
|
||||||
|
@ -103,7 +103,7 @@ void apply_highlighter(const Context& context,
|
||||||
if (not atom_it->has_buffer_range() or end <= atom_it->begin() or begin >= atom_it->end())
|
if (not atom_it->has_buffer_range() or end <= atom_it->begin() or begin >= atom_it->end())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
bool is_replaced = atom_it->type() == DisplayAtom::ReplacedBufferRange;
|
bool is_replaced = atom_it->type() == DisplayAtom::ReplacedRange;
|
||||||
if (atom_it->begin() <= begin)
|
if (atom_it->begin() <= begin)
|
||||||
{
|
{
|
||||||
if (is_replaced or atom_it->begin() == begin)
|
if (is_replaced or atom_it->begin() == begin)
|
||||||
|
@ -654,7 +654,7 @@ void expand_tabulations(const Context& context, HighlightFlags flags, DisplayBuf
|
||||||
{
|
{
|
||||||
for (auto atom_it = line.begin(); atom_it != line.end(); ++atom_it)
|
for (auto atom_it = line.begin(); atom_it != line.end(); ++atom_it)
|
||||||
{
|
{
|
||||||
if (atom_it->type() != DisplayAtom::BufferRange)
|
if (atom_it->type() != DisplayAtom::Range)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
auto begin = buffer.iterator_at(atom_it->begin());
|
auto begin = buffer.iterator_at(atom_it->begin());
|
||||||
|
@ -690,7 +690,7 @@ void show_whitespaces(const Context& context, HighlightFlags flags, DisplayBuffe
|
||||||
{
|
{
|
||||||
for (auto atom_it = line.begin(); atom_it != line.end(); ++atom_it)
|
for (auto atom_it = line.begin(); atom_it != line.end(); ++atom_it)
|
||||||
{
|
{
|
||||||
if (atom_it->type() != DisplayAtom::BufferRange)
|
if (atom_it->type() != DisplayAtom::Range)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
auto begin = buffer.iterator_at(atom_it->begin());
|
auto begin = buffer.iterator_at(atom_it->begin());
|
||||||
|
@ -878,7 +878,7 @@ void expand_unprintable(const Context& context, HighlightFlags flags, DisplayBuf
|
||||||
{
|
{
|
||||||
for (auto atom_it = line.begin(); atom_it != line.end(); ++atom_it)
|
for (auto atom_it = line.begin(); atom_it != line.end(); ++atom_it)
|
||||||
{
|
{
|
||||||
if (atom_it->type() == DisplayAtom::BufferRange)
|
if (atom_it->type() == DisplayAtom::Range)
|
||||||
{
|
{
|
||||||
for (auto it = buffer.iterator_at(atom_it->begin()),
|
for (auto it = buffer.iterator_at(atom_it->begin()),
|
||||||
end = buffer.iterator_at(atom_it->end()); it < end;)
|
end = buffer.iterator_at(atom_it->end()); it < end;)
|
||||||
|
|
|
@ -197,7 +197,7 @@ static ColumnCount adapt_view_pos(const DisplayBuffer& display_buffer, ColumnCou
|
||||||
if (atom.begin() <= pos and atom.end() > pos)
|
if (atom.begin() <= pos and atom.end() > pos)
|
||||||
{
|
{
|
||||||
ColumnCount pos_beg, pos_end;
|
ColumnCount pos_beg, pos_end;
|
||||||
if (atom.type() == DisplayAtom::BufferRange)
|
if (atom.type() == DisplayAtom::Range)
|
||||||
{
|
{
|
||||||
auto& buf = atom.buffer();
|
auto& buf = atom.buffer();
|
||||||
pos_beg = buffer_column +
|
pos_beg = buffer_column +
|
||||||
|
@ -271,7 +271,7 @@ ColumnCount find_display_column(const DisplayLine& line, const Buffer& buffer,
|
||||||
if (atom.has_buffer_range() and
|
if (atom.has_buffer_range() and
|
||||||
coord >= atom.begin() and coord < atom.end())
|
coord >= atom.begin() and coord < atom.end())
|
||||||
{
|
{
|
||||||
if (atom.type() == DisplayAtom::BufferRange)
|
if (atom.type() == DisplayAtom::Range)
|
||||||
column += column_length(buffer, atom.begin(), coord);
|
column += column_length(buffer, atom.begin(), coord);
|
||||||
return column;
|
return column;
|
||||||
}
|
}
|
||||||
|
@ -289,7 +289,7 @@ BufferCoord find_buffer_coord(const DisplayLine& line, const Buffer& buffer,
|
||||||
ColumnCount len = atom.length();
|
ColumnCount len = atom.length();
|
||||||
if (atom.has_buffer_range() and column < len)
|
if (atom.has_buffer_range() and column < len)
|
||||||
{
|
{
|
||||||
if (atom.type() == DisplayAtom::BufferRange)
|
if (atom.type() == DisplayAtom::Range)
|
||||||
return buffer.clamp(
|
return buffer.clamp(
|
||||||
utf8::advance(buffer.iterator_at(atom.begin()),
|
utf8::advance(buffer.iterator_at(atom.begin()),
|
||||||
buffer.iterator_at(range.end),
|
buffer.iterator_at(range.end),
|
||||||
|
|
Loading…
Reference in New Issue
Block a user