AtomContent uses coord rather than iterators
This commit is contained in:
parent
81ce4e4720
commit
97df6f2222
|
@ -36,10 +36,8 @@ struct AtomContent
|
||||||
public:
|
public:
|
||||||
enum Type { BufferRange, ReplacedBufferRange, Text };
|
enum Type { BufferRange, ReplacedBufferRange, Text };
|
||||||
|
|
||||||
AtomContent(BufferIterator begin, BufferIterator end)
|
AtomContent(const Buffer& buffer, BufferCoord begin, BufferCoord end)
|
||||||
: m_type(BufferRange),
|
: m_type(BufferRange), m_buffer(&buffer), m_begin(begin), m_end(end) {}
|
||||||
m_begin(std::move(begin)),
|
|
||||||
m_end(std::move(end)) {}
|
|
||||||
|
|
||||||
AtomContent(String str)
|
AtomContent(String str)
|
||||||
: m_type(Text), m_text(std::move(str)) {}
|
: m_type(Text), m_text(std::move(str)) {}
|
||||||
|
@ -49,7 +47,7 @@ public:
|
||||||
switch (m_type)
|
switch (m_type)
|
||||||
{
|
{
|
||||||
case BufferRange:
|
case BufferRange:
|
||||||
return m_begin.buffer().string(m_begin, m_end);
|
return m_buffer->string(m_begin, m_end);
|
||||||
case Text:
|
case Text:
|
||||||
case ReplacedBufferRange:
|
case ReplacedBufferRange:
|
||||||
return m_text;
|
return m_text;
|
||||||
|
@ -63,7 +61,8 @@ public:
|
||||||
switch (m_type)
|
switch (m_type)
|
||||||
{
|
{
|
||||||
case BufferRange:
|
case BufferRange:
|
||||||
return utf8::distance(m_begin, m_end);
|
return utf8::distance(m_buffer->iterator_at(m_begin),
|
||||||
|
m_buffer->iterator_at(m_end));
|
||||||
case Text:
|
case Text:
|
||||||
case ReplacedBufferRange:
|
case ReplacedBufferRange:
|
||||||
return m_text.char_length();
|
return m_text.char_length();
|
||||||
|
@ -72,13 +71,13 @@ public:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const BufferIterator& begin() const
|
const BufferCoord& begin() const
|
||||||
{
|
{
|
||||||
kak_assert(has_buffer_range());
|
kak_assert(has_buffer_range());
|
||||||
return m_begin;
|
return m_begin;
|
||||||
}
|
}
|
||||||
|
|
||||||
const BufferIterator& end() const
|
const BufferCoord& end() const
|
||||||
{
|
{
|
||||||
kak_assert(has_buffer_range());
|
kak_assert(has_buffer_range());
|
||||||
return m_end;
|
return m_end;
|
||||||
|
@ -103,8 +102,9 @@ private:
|
||||||
|
|
||||||
Type m_type;
|
Type m_type;
|
||||||
|
|
||||||
BufferIterator m_begin;
|
const Buffer* m_buffer = nullptr;
|
||||||
BufferIterator m_end;
|
BufferCoord m_begin;
|
||||||
|
BufferCoord m_end;
|
||||||
String m_text;
|
String m_text;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user