diff --git a/src/core/Buffer.cc b/src/core/Buffer.cc index 71228b8..52dd692 100644 --- a/src/core/Buffer.cc +++ b/src/core/Buffer.cc @@ -180,3 +180,21 @@ void Buffer::insert_code_point(uint32_t code_point) m_insert_position += bytes; } } + +void Buffer::erase_code_point(const Buffer::Iterator & position) +{ + if (position.valid()) + { + uint8_t bytes = 0u; + uint32_t code_point = Encoding::decode(m_encoding, position.address(), &bytes); + m_gap_buffer->erase(position.offset(), bytes); + ssize_t lines = (code_point == '\n') ? -1 : 0; + for (auto iterator : m_iterators) + { + if (*iterator > position) + { + iterator->warp(-(ssize_t)bytes, lines); + } + } + } +} diff --git a/src/core/Buffer.h b/src/core/Buffer.h index f93e716..e37ef74 100644 --- a/src/core/Buffer.h +++ b/src/core/Buffer.h @@ -106,6 +106,7 @@ public: void exit_insert_mode(); bool insert_mode() const { return m_insert_mode; } void insert_code_point(uint32_t code_point); + void erase_code_point(const Buffer::Iterator & position); protected: bool m_eol_at_eof;