merge AtomContent into DisplayAtom
This commit is contained in:
parent
f6308409a1
commit
d6425f1d50
|
@ -5,7 +5,7 @@
|
||||||
namespace Kakoune
|
namespace Kakoune
|
||||||
{
|
{
|
||||||
|
|
||||||
void AtomContent::trim_begin(CharCount count)
|
void DisplayAtom::trim_begin(CharCount count)
|
||||||
{
|
{
|
||||||
if (m_type == BufferRange)
|
if (m_type == BufferRange)
|
||||||
m_begin = utf8::advance(m_buffer->iterator_at(m_begin),
|
m_begin = utf8::advance(m_buffer->iterator_at(m_begin),
|
||||||
|
@ -14,7 +14,7 @@ void AtomContent::trim_begin(CharCount count)
|
||||||
m_text = m_text.substr(count);
|
m_text = m_text.substr(count);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AtomContent::trim_end(CharCount count)
|
void DisplayAtom::trim_end(CharCount count)
|
||||||
{
|
{
|
||||||
if (m_type == BufferRange)
|
if (m_type == BufferRange)
|
||||||
m_end = utf8::advance(m_buffer->iterator_at(m_end),
|
m_end = utf8::advance(m_buffer->iterator_at(m_end),
|
||||||
|
@ -31,32 +31,32 @@ DisplayLine::DisplayLine(AtomList atoms)
|
||||||
|
|
||||||
DisplayLine::iterator DisplayLine::split(iterator it, BufferCoord pos)
|
DisplayLine::iterator DisplayLine::split(iterator it, BufferCoord pos)
|
||||||
{
|
{
|
||||||
kak_assert(it->content.type() == AtomContent::BufferRange);
|
kak_assert(it->type() == DisplayAtom::BufferRange);
|
||||||
kak_assert(it->content.begin() < pos);
|
kak_assert(it->begin() < pos);
|
||||||
kak_assert(it->content.end() > pos);
|
kak_assert(it->end() > pos);
|
||||||
|
|
||||||
DisplayAtom atom = *it;
|
DisplayAtom atom = *it;
|
||||||
atom.content.m_end = pos;
|
atom.m_end = pos;
|
||||||
it->content.m_begin = pos;
|
it->m_begin = pos;
|
||||||
return m_atoms.insert(it, std::move(atom));
|
return m_atoms.insert(it, std::move(atom));
|
||||||
}
|
}
|
||||||
|
|
||||||
DisplayLine::iterator DisplayLine::insert(iterator it, DisplayAtom atom)
|
DisplayLine::iterator DisplayLine::insert(iterator it, DisplayAtom atom)
|
||||||
{
|
{
|
||||||
if (atom.content.has_buffer_range())
|
if (atom.has_buffer_range())
|
||||||
{
|
{
|
||||||
m_range.first = std::min(m_range.first, atom.content.begin());
|
m_range.first = std::min(m_range.first, atom.begin());
|
||||||
m_range.second = std::max(m_range.second, atom.content.end());
|
m_range.second = std::max(m_range.second, atom.end());
|
||||||
}
|
}
|
||||||
return m_atoms.insert(it, std::move(atom));
|
return m_atoms.insert(it, std::move(atom));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DisplayLine::push_back(DisplayAtom atom)
|
void DisplayLine::push_back(DisplayAtom atom)
|
||||||
{
|
{
|
||||||
if (atom.content.has_buffer_range())
|
if (atom.has_buffer_range())
|
||||||
{
|
{
|
||||||
m_range.first = std::min(m_range.first, atom.content.begin());
|
m_range.first = std::min(m_range.first, atom.begin());
|
||||||
m_range.second = std::max(m_range.second, atom.content.end());
|
m_range.second = std::max(m_range.second, atom.end());
|
||||||
}
|
}
|
||||||
m_atoms.push_back(std::move(atom));
|
m_atoms.push_back(std::move(atom));
|
||||||
}
|
}
|
||||||
|
@ -76,21 +76,21 @@ void DisplayLine::optimize()
|
||||||
|
|
||||||
if (atom.colors == next_atom.colors and
|
if (atom.colors == next_atom.colors and
|
||||||
atom.attribute == next_atom.attribute and
|
atom.attribute == next_atom.attribute and
|
||||||
atom.content.type() == next_atom.content.type())
|
atom.type() == next_atom.type())
|
||||||
{
|
{
|
||||||
auto type = atom.content.type();
|
auto type = atom.type();
|
||||||
if ((type == AtomContent::BufferRange or
|
if ((type == DisplayAtom::BufferRange or
|
||||||
type == AtomContent::ReplacedBufferRange) and
|
type == DisplayAtom::ReplacedBufferRange) and
|
||||||
next_atom.content.begin() == atom.content.end())
|
next_atom.begin() == atom.end())
|
||||||
{
|
{
|
||||||
atom.content.m_end = next_atom.content.end();
|
atom.m_end = next_atom.end();
|
||||||
if (type == AtomContent::ReplacedBufferRange)
|
if (type == DisplayAtom::ReplacedBufferRange)
|
||||||
atom.content.m_text += next_atom.content.m_text;
|
atom.m_text += next_atom.m_text;
|
||||||
merged = true;
|
merged = true;
|
||||||
}
|
}
|
||||||
if (type == AtomContent::Text)
|
if (type == DisplayAtom::Text)
|
||||||
{
|
{
|
||||||
atom.content.m_text += next_atom.content.m_text;
|
atom.m_text += next_atom.m_text;
|
||||||
merged = true;
|
merged = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -105,7 +105,7 @@ CharCount DisplayLine::length() const
|
||||||
{
|
{
|
||||||
CharCount len = 0;
|
CharCount len = 0;
|
||||||
for (auto& atom : m_atoms)
|
for (auto& atom : m_atoms)
|
||||||
len += atom.content.length();
|
len += atom.length();
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,13 +113,13 @@ void DisplayLine::trim(CharCount first_char, CharCount char_count)
|
||||||
{
|
{
|
||||||
for (auto it = begin(); first_char > 0 and it != end(); )
|
for (auto it = begin(); first_char > 0 and it != end(); )
|
||||||
{
|
{
|
||||||
if (not it->content.has_buffer_range())
|
if (not it->has_buffer_range())
|
||||||
{
|
{
|
||||||
++it;
|
++it;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto len = it->content.length();
|
auto len = it->length();
|
||||||
if (len <= first_char)
|
if (len <= first_char)
|
||||||
{
|
{
|
||||||
m_atoms.erase(it);
|
m_atoms.erase(it);
|
||||||
|
@ -127,16 +127,16 @@ void DisplayLine::trim(CharCount first_char, CharCount char_count)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
it->content.trim_begin(first_char);
|
it->trim_begin(first_char);
|
||||||
first_char = 0;
|
first_char = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
auto it = begin();
|
auto it = begin();
|
||||||
for (; it != end() and char_count > 0; ++it)
|
for (; it != end() and char_count > 0; ++it)
|
||||||
char_count -= it->content.length();
|
char_count -= it->length();
|
||||||
|
|
||||||
if (char_count < 0)
|
if (char_count < 0)
|
||||||
(it-1)->content.trim_end(-char_count);
|
(it-1)->trim_end(-char_count);
|
||||||
m_atoms.erase(it, end());
|
m_atoms.erase(it, end());
|
||||||
|
|
||||||
compute_range();
|
compute_range();
|
||||||
|
@ -147,10 +147,10 @@ void DisplayLine::compute_range()
|
||||||
m_range = { {INT_MAX, INT_MAX}, {INT_MIN, INT_MIN} };
|
m_range = { {INT_MAX, INT_MAX}, {INT_MIN, INT_MIN} };
|
||||||
for (auto& atom : m_atoms)
|
for (auto& atom : m_atoms)
|
||||||
{
|
{
|
||||||
if (not atom.content.has_buffer_range())
|
if (not atom.has_buffer_range())
|
||||||
continue;
|
continue;
|
||||||
m_range.first = std::min(m_range.first, atom.content.begin());
|
m_range.first = std::min(m_range.first, atom.begin());
|
||||||
m_range.second = std::max(m_range.second, atom.content.end());
|
m_range.second = std::max(m_range.second, atom.end());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,16 +29,17 @@ enum Attributes
|
||||||
Bold = 8
|
Bold = 8
|
||||||
};
|
};
|
||||||
|
|
||||||
struct AtomContent
|
struct DisplayAtom
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum Type { BufferRange, ReplacedBufferRange, Text };
|
enum Type { BufferRange, ReplacedBufferRange, Text };
|
||||||
|
|
||||||
AtomContent(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) {}
|
||||||
|
|
||||||
AtomContent(String str)
|
DisplayAtom(String str, ColorPair colors = { Colors::Default, Colors::Default },
|
||||||
: m_type(Text), m_text(std::move(str)) {}
|
Attribute attribute = Normal)
|
||||||
|
: m_type(Text), m_text(std::move(str)), colors(colors), attribute(attribute) {}
|
||||||
|
|
||||||
String content() const
|
String content() const
|
||||||
{
|
{
|
||||||
|
@ -97,6 +98,11 @@ public:
|
||||||
|
|
||||||
void trim_begin(CharCount count);
|
void trim_begin(CharCount count);
|
||||||
void trim_end(CharCount count);
|
void trim_end(CharCount count);
|
||||||
|
|
||||||
|
public:
|
||||||
|
ColorPair colors = {Colors::Default, Colors::Default};
|
||||||
|
Attribute attribute = Normal;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class DisplayLine;
|
friend class DisplayLine;
|
||||||
|
|
||||||
|
@ -108,19 +114,6 @@ private:
|
||||||
String m_text;
|
String m_text;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DisplayAtom
|
|
||||||
{
|
|
||||||
ColorPair colors;
|
|
||||||
Attribute attribute;
|
|
||||||
AtomContent content;
|
|
||||||
|
|
||||||
DisplayAtom(AtomContent content,
|
|
||||||
ColorPair colors = {Colors::Default, Colors::Default},
|
|
||||||
Attribute attribute = Normal)
|
|
||||||
: content{std::move(content)}, colors{colors}, attribute{attribute}
|
|
||||||
{}
|
|
||||||
};
|
|
||||||
|
|
||||||
using BufferRange = std::pair<BufferCoord, BufferCoord>;
|
using BufferRange = std::pair<BufferCoord, BufferCoord>;
|
||||||
using AtomList = std::vector<DisplayAtom>;
|
using AtomList = std::vector<DisplayAtom>;
|
||||||
|
|
||||||
|
|
|
@ -37,19 +37,19 @@ 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->content.type() == AtomContent::ReplacedBufferRange;
|
bool is_replaced = atom_it->type() == DisplayAtom::ReplacedBufferRange;
|
||||||
|
|
||||||
if (not atom_it->content.has_buffer_range() or
|
if (not atom_it->has_buffer_range() or
|
||||||
(skip_replaced and is_replaced))
|
(skip_replaced and is_replaced))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (end <= atom_it->content.begin() or begin >= atom_it->content.end())
|
if (end <= atom_it->begin() or begin >= atom_it->end())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (not is_replaced and begin > atom_it->content.begin())
|
if (not is_replaced and begin > atom_it->begin())
|
||||||
atom_it = ++line.split(atom_it, begin);
|
atom_it = ++line.split(atom_it, begin);
|
||||||
|
|
||||||
if (not is_replaced and end < atom_it->content.end())
|
if (not is_replaced and end < atom_it->end())
|
||||||
{
|
{
|
||||||
atom_it = line.split(atom_it, end);
|
atom_it = line.split(atom_it, end);
|
||||||
func(*atom_it);
|
func(*atom_it);
|
||||||
|
@ -221,11 +221,11 @@ void expand_tabulations(const Window& window, 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)
|
||||||
{
|
{
|
||||||
if (atom_it->content.type() != AtomContent::BufferRange)
|
if (atom_it->type() != DisplayAtom::BufferRange)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
auto begin = buffer.iterator_at(atom_it->content.begin());
|
auto begin = buffer.iterator_at(atom_it->begin());
|
||||||
auto end = buffer.iterator_at(atom_it->content.end());
|
auto end = buffer.iterator_at(atom_it->end());
|
||||||
for (BufferIterator it = begin; it != end; ++it)
|
for (BufferIterator it = begin; it != end; ++it)
|
||||||
{
|
{
|
||||||
if (*it == '\t')
|
if (*it == '\t')
|
||||||
|
@ -250,7 +250,7 @@ void expand_tabulations(const Window& window, DisplayBuffer& display_buffer)
|
||||||
String padding;
|
String padding;
|
||||||
for (int i = 0; i < count; ++i)
|
for (int i = 0; i < count; ++i)
|
||||||
padding += ' ';
|
padding += ' ';
|
||||||
atom_it->content.replace(padding);
|
atom_it->replace(padding);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -272,7 +272,7 @@ void show_line_numbers(const Window& window, DisplayBuffer& display_buffer)
|
||||||
{
|
{
|
||||||
char buffer[10];
|
char buffer[10];
|
||||||
snprintf(buffer, 10, format, (int)line.range().first.line + 1);
|
snprintf(buffer, 10, format, (int)line.range().first.line + 1);
|
||||||
DisplayAtom atom = DisplayAtom(AtomContent(buffer));
|
DisplayAtom atom{buffer};
|
||||||
atom.colors = colors;
|
atom.colors = colors;
|
||||||
line.insert(line.begin(), std::move(atom));
|
line.insert(line.begin(), std::move(atom));
|
||||||
}
|
}
|
||||||
|
@ -309,11 +309,11 @@ void expand_unprintable(const Window& window, 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)
|
||||||
{
|
{
|
||||||
if (atom_it->content.type() == AtomContent::BufferRange)
|
if (atom_it->type() == DisplayAtom::BufferRange)
|
||||||
{
|
{
|
||||||
using Utf8It = utf8::utf8_iterator<BufferIterator, utf8::InvalidBytePolicy::Pass>;
|
using Utf8It = utf8::utf8_iterator<BufferIterator, utf8::InvalidBytePolicy::Pass>;
|
||||||
for (Utf8It it = buffer.iterator_at(atom_it->content.begin()),
|
for (Utf8It it = buffer.iterator_at(atom_it->begin()),
|
||||||
end = buffer.iterator_at(atom_it->content.end()); it != end; ++it)
|
end = buffer.iterator_at(atom_it->end()); it != end; ++it)
|
||||||
{
|
{
|
||||||
Codepoint cp = *it;
|
Codepoint cp = *it;
|
||||||
if (cp != '\n' and iscntrl((int)cp))
|
if (cp != '\n' and iscntrl((int)cp))
|
||||||
|
@ -321,11 +321,11 @@ void expand_unprintable(const Window& window, DisplayBuffer& display_buffer)
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
oss << "U+" << std::hex << cp;
|
oss << "U+" << std::hex << cp;
|
||||||
String str = oss.str();
|
String str = oss.str();
|
||||||
if (it.base().coord() != atom_it->content.begin())
|
if (it.base().coord() != atom_it->begin())
|
||||||
atom_it = ++line.split(atom_it, it.base().coord());
|
atom_it = ++line.split(atom_it, it.base().coord());
|
||||||
if ((it+1).base().coord() != atom_it->content.end())
|
if ((it+1).base().coord() != atom_it->end())
|
||||||
atom_it = line.split(atom_it, (it+1).base().coord());
|
atom_it = line.split(atom_it, (it+1).base().coord());
|
||||||
atom_it->content.replace(str);
|
atom_it->replace(str);
|
||||||
atom_it->colors = { Colors::Red, Colors::Black };
|
atom_it->colors = { Colors::Red, Colors::Black };
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -363,7 +363,7 @@ public:
|
||||||
auto it = find_if(lines, [&](const LineAndFlag& l) { return std::get<0>(l) == line_num; });
|
auto it = find_if(lines, [&](const LineAndFlag& l) { return std::get<0>(l) == line_num; });
|
||||||
String content = it != lines.end() ? std::get<2>(*it) : empty;
|
String content = it != lines.end() ? std::get<2>(*it) : empty;
|
||||||
content += String(' ', width - content.char_length());
|
content += String(' ', width - content.char_length());
|
||||||
DisplayAtom atom{AtomContent(std::move(content))};
|
DisplayAtom atom{std::move(content)};
|
||||||
atom.colors = { it != lines.end() ? std::get<1>(*it) : Colors::Default , m_bg };
|
atom.colors = { it != lines.end() ? std::get<1>(*it) : Colors::Default , m_bg };
|
||||||
line.insert(line.begin(), std::move(atom));
|
line.insert(line.begin(), std::move(atom));
|
||||||
}
|
}
|
||||||
|
|
|
@ -221,7 +221,7 @@ void NCursesUI::draw_line(const DisplayLine& line, CharCount col_index) const
|
||||||
|
|
||||||
set_color(stdscr, atom.colors);
|
set_color(stdscr, atom.colors);
|
||||||
|
|
||||||
String content = atom.content.content();
|
String content = atom.content();
|
||||||
if (content[content.length()-1] == '\n' and
|
if (content[content.length()-1] == '\n' and
|
||||||
content.char_length() - 1 < m_dimensions.column - col_index)
|
content.char_length() - 1 < m_dimensions.column - col_index)
|
||||||
{
|
{
|
||||||
|
@ -281,7 +281,7 @@ void NCursesUI::draw(const DisplayBuffer& display_buffer,
|
||||||
{
|
{
|
||||||
String title;
|
String title;
|
||||||
for (auto& atom : mode_line)
|
for (auto& atom : mode_line)
|
||||||
title += atom.content.content();
|
title += atom.content();
|
||||||
title += " - Kakoune";
|
title += " - Kakoune";
|
||||||
printf("%s%s%s", tsl, title.c_str(), fsl);
|
printf("%s%s%s", tsl, title.c_str(), fsl);
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,7 +94,7 @@ public:
|
||||||
|
|
||||||
void write(const DisplayAtom& atom)
|
void write(const DisplayAtom& atom)
|
||||||
{
|
{
|
||||||
write(atom.content.content());
|
write(atom.content());
|
||||||
write(atom.colors);
|
write(atom.colors);
|
||||||
write(atom.attribute);
|
write(atom.attribute);
|
||||||
}
|
}
|
||||||
|
@ -186,7 +186,7 @@ ColorPair read<ColorPair>(int socket)
|
||||||
template<>
|
template<>
|
||||||
DisplayAtom read<DisplayAtom>(int socket)
|
DisplayAtom read<DisplayAtom>(int socket)
|
||||||
{
|
{
|
||||||
DisplayAtom atom(AtomContent(read<String>(socket)));
|
DisplayAtom atom(read<String>(socket));
|
||||||
atom.colors = read<ColorPair>(socket);
|
atom.colors = read<ColorPair>(socket);
|
||||||
atom.attribute = read<Attribute>(socket);
|
atom.attribute = read<Attribute>(socket);
|
||||||
return atom;
|
return atom;
|
||||||
|
|
|
@ -74,7 +74,7 @@ void Window::update_display_buffer()
|
||||||
LineCount buffer_line = m_position.line + line;
|
LineCount buffer_line = m_position.line + line;
|
||||||
if (buffer_line >= buffer().line_count())
|
if (buffer_line >= buffer().line_count())
|
||||||
break;
|
break;
|
||||||
lines.emplace_back(AtomList{ {AtomContent(buffer(), buffer_line, buffer_line+1)} });
|
lines.emplace_back(AtomList{ {buffer(), buffer_line, buffer_line+1} });
|
||||||
}
|
}
|
||||||
|
|
||||||
m_display_buffer.compute_range();
|
m_display_buffer.compute_range();
|
||||||
|
@ -118,21 +118,21 @@ static CharCount adapt_view_pos(const DisplayLine& line, BufferCoord pos, CharCo
|
||||||
CharCount non_buffer_column = 0;
|
CharCount non_buffer_column = 0;
|
||||||
for (auto& atom : line)
|
for (auto& atom : line)
|
||||||
{
|
{
|
||||||
if (atom.content.has_buffer_range())
|
if (atom.has_buffer_range())
|
||||||
{
|
{
|
||||||
if (atom.content.begin() <= pos and atom.content.end() > pos)
|
if (atom.begin() <= pos and atom.end() > pos)
|
||||||
{
|
{
|
||||||
if (buffer_column < view_pos)
|
if (buffer_column < view_pos)
|
||||||
return buffer_column;
|
return buffer_column;
|
||||||
|
|
||||||
auto last_column = buffer_column + atom.content.length();
|
auto last_column = buffer_column + atom.length();
|
||||||
if (last_column >= view_pos + view_size - non_buffer_column)
|
if (last_column >= view_pos + view_size - non_buffer_column)
|
||||||
return last_column - view_size + non_buffer_column;
|
return last_column - view_size + non_buffer_column;
|
||||||
}
|
}
|
||||||
buffer_column += atom.content.length();
|
buffer_column += atom.length();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
non_buffer_column += atom.content.length();
|
non_buffer_column += atom.length();
|
||||||
}
|
}
|
||||||
return view_pos;
|
return view_pos;
|
||||||
}
|
}
|
||||||
|
@ -154,7 +154,7 @@ void Window::scroll_to_keep_cursor_visible_ifn()
|
||||||
// highlight only the line containing the cursor
|
// highlight only the line containing the cursor
|
||||||
DisplayBuffer display_buffer;
|
DisplayBuffer display_buffer;
|
||||||
DisplayBuffer::LineList& lines = display_buffer.lines();
|
DisplayBuffer::LineList& lines = display_buffer.lines();
|
||||||
lines.emplace_back(AtomList{ AtomContent(buffer(), last.line, last.line+1) });
|
lines.emplace_back(AtomList{ {buffer(), last.line, last.line+1} });
|
||||||
|
|
||||||
display_buffer.compute_range();
|
display_buffer.compute_range();
|
||||||
m_highlighters(*this, display_buffer);
|
m_highlighters(*this, display_buffer);
|
||||||
|
@ -179,16 +179,15 @@ CharCount find_display_column(const DisplayLine& line, const Buffer& buffer,
|
||||||
CharCount column = 0;
|
CharCount column = 0;
|
||||||
for (auto& atom : line)
|
for (auto& atom : line)
|
||||||
{
|
{
|
||||||
auto& content = atom.content;
|
if (atom.has_buffer_range() and
|
||||||
if (content.has_buffer_range() and
|
coord >= atom.begin() and coord < atom.end())
|
||||||
coord >= content.begin() and coord < content.end())
|
|
||||||
{
|
{
|
||||||
if (content.type() == AtomContent::BufferRange)
|
if (atom.type() == DisplayAtom::BufferRange)
|
||||||
column += utf8::distance(buffer.iterator_at(content.begin()),
|
column += utf8::distance(buffer.iterator_at(atom.begin()),
|
||||||
buffer.iterator_at(coord));
|
buffer.iterator_at(coord));
|
||||||
return column;
|
return column;
|
||||||
}
|
}
|
||||||
column += content.length();
|
column += atom.length();
|
||||||
}
|
}
|
||||||
return column;
|
return column;
|
||||||
}
|
}
|
||||||
|
@ -199,14 +198,13 @@ BufferCoord find_buffer_coord(const DisplayLine& line, const Buffer& buffer,
|
||||||
auto& range = line.range();
|
auto& range = line.range();
|
||||||
for (auto& atom : line)
|
for (auto& atom : line)
|
||||||
{
|
{
|
||||||
auto& content = atom.content;
|
CharCount len = atom.length();
|
||||||
CharCount len = content.length();
|
if (atom.has_buffer_range() and column < len)
|
||||||
if (content.has_buffer_range() and column < len)
|
|
||||||
{
|
{
|
||||||
if (content.type() == AtomContent::BufferRange)
|
if (atom.type() == DisplayAtom::BufferRange)
|
||||||
return utf8::advance(buffer.iterator_at(content.begin()), buffer.iterator_at(range.second),
|
return utf8::advance(buffer.iterator_at(atom.begin()), buffer.iterator_at(range.second),
|
||||||
std::max(0_char, column)).coord();
|
std::max(0_char, column)).coord();
|
||||||
return content.begin();
|
return atom.begin();
|
||||||
}
|
}
|
||||||
column -= len;
|
column -= len;
|
||||||
}
|
}
|
||||||
|
@ -232,8 +230,8 @@ BufferCoord Window::offset_coord(const BufferCoord& coord, LineCount offset)
|
||||||
auto line = clamp(coord.line + offset, 0_line, buffer().line_count()-1);
|
auto line = clamp(coord.line + offset, 0_line, buffer().line_count()-1);
|
||||||
DisplayBuffer display_buffer;
|
DisplayBuffer display_buffer;
|
||||||
DisplayBuffer::LineList& lines = display_buffer.lines();
|
DisplayBuffer::LineList& lines = display_buffer.lines();
|
||||||
lines.emplace_back(AtomList{ {AtomContent(buffer(), coord.line, coord.line+1)} });
|
lines.emplace_back(AtomList{ {buffer(), coord.line, coord.line+1} });
|
||||||
lines.emplace_back(AtomList{ {AtomContent(buffer(), line, line+1)} });
|
lines.emplace_back(AtomList{ {buffer(), line, line+1} });
|
||||||
display_buffer.compute_range();
|
display_buffer.compute_range();
|
||||||
m_highlighters(*this, display_buffer);
|
m_highlighters(*this, display_buffer);
|
||||||
m_builtin_highlighters(*this, display_buffer);
|
m_builtin_highlighters(*this, display_buffer);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user