Add Buffer::erase_range()
This commit is contained in:
1 parent
438a3e6960
commit
c3852e950a
3 files changed
+46
No files matched your search
@@ -212,6 +212,19 @@ void Buffer::erase_code_point(const Buffer::Iterator & position)
|
||||
}
|
||||
}
|
||||
|
||||
void Buffer::erase_range(const Buffer::Iterator & start,
|
||||
const Buffer::Iterator & end)
|
||||
{
|
||||
if (start.valid() && (start < end))
|
||||
{
|
||||
push_operation();
|
||||
size_t start_offset = start.offset();
|
||||
size_t end_offset = end.valid() ? end.offset() : m_gap_buffer->size();
|
||||
erase_data(start_offset, end_offset - start_offset, true);
|
||||
pop_operation();
|
||||
}
|
||||
}
|
||||
|
||||
void Buffer::erase_data(size_t offset, size_t length, bool do_record_change)
|
||||
{
|
||||
warp_iterators_before_delete(offset, length);
|
||||
|
||||
@@ -131,6 +131,8 @@ public:
|
||||
bool insert_mode() const { return m_insert_mode; }
|
||||
void insert_code_point(const Buffer::Iterator & position, uint32_t code_point);
|
||||
void erase_code_point(const Buffer::Iterator & position);
|
||||
void erase_range(const Buffer::Iterator & start,
|
||||
const Buffer::Iterator & end);
|
||||
std::shared_ptr<std::string> filename() const { return m_filename; }
|
||||
Iterator begin() const { return Iterator(this); }
|
||||
Iterator end() const { return *m_eof_iterator; }
|
||||
|
||||
Reference in new issue
Block a user