diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2014-11-12 21:27:07 +0000 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2014-11-12 21:27:07 +0000 |
| commit | 3a817e2f96a30faef03565c510f626ac73fd46ed (patch) | |
| tree | 4be12e5689f919358a5e1735ac5c8dbf04945302 /src/display_buffer.cc | |
| parent | 58c1721564ea6b52929b189463fc9f54a4711d1d (diff) | |
Cleanup includes
Diffstat (limited to 'src/display_buffer.cc')
| -rw-r--r-- | src/display_buffer.cc | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/display_buffer.cc b/src/display_buffer.cc index af8d15e4..a56fe612 100644 --- a/src/display_buffer.cc +++ b/src/display_buffer.cc @@ -1,10 +1,48 @@ #include "display_buffer.hh" #include "assert.hh" +#include "buffer.hh" +#include "utf8.hh" namespace Kakoune { +StringView DisplayAtom::content() const +{ + switch (m_type) + { + case BufferRange: + { + auto line = (*m_buffer)[m_begin.line]; + if (m_begin.line == m_end.line) + return line.substr(m_begin.column, m_end.column - m_begin.column); + else if (m_begin.line+1 == m_end.line and m_end.column == 0) + return line.substr(m_begin.column); + break; + } + case Text: + case ReplacedBufferRange: + return m_text; + } + kak_assert(false); + return {}; +} + +CharCount DisplayAtom::length() const +{ + switch (m_type) + { + case BufferRange: + return utf8::distance(m_buffer->iterator_at(m_begin), + m_buffer->iterator_at(m_end)); + case Text: + case ReplacedBufferRange: + return m_text.char_length(); + } + kak_assert(false); + return 0; +} + void DisplayAtom::trim_begin(CharCount count) { if (m_type == BufferRange) |
