diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2011-09-29 08:55:08 +0000 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2011-09-29 08:55:08 +0000 |
| commit | e659ea2dab4b91d6f5a8905f4a854f7be82343e3 (patch) | |
| tree | fa524ef699fc5546a81d4e5b72d1b5da0d3b5015 /src/display_buffer.cc | |
| parent | 822fc0f82247e4f83b3776bfd38ebbab3e7fd9d6 (diff) | |
DisplayBuffer: add a split method to split an atom
Diffstat (limited to 'src/display_buffer.cc')
| -rw-r--r-- | src/display_buffer.cc | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/display_buffer.cc b/src/display_buffer.cc index ea5342bc..03cc5b18 100644 --- a/src/display_buffer.cc +++ b/src/display_buffer.cc @@ -1,5 +1,7 @@ #include "display_buffer.hh" +#include "assert.h" + namespace Kakoune { @@ -7,4 +9,17 @@ DisplayBuffer::DisplayBuffer() { } +DisplayBuffer::iterator DisplayBuffer::split(iterator atom, size_t pos_in_atom) +{ + assert(atom < end()); + assert(pos_in_atom < atom->content.length()); + DisplayAtom new_atom(atom->begin, atom->begin + pos_in_atom, + atom->content.substr(0, pos_in_atom), + atom->fg_color, atom->bg_color, atom->attribute); + + atom->begin = atom->begin + pos_in_atom; + atom->content = atom->content.substr(pos_in_atom); + return insert(atom, std::move(new_atom)); +} + } |
