summaryrefslogtreecommitdiff
path: root/src/display_buffer.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/display_buffer.cc')
-rw-r--r--src/display_buffer.cc15
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));
+}
+
}