remove knowledge of Cursor from GapBuffer

This commit is contained in:
Josh Holtrop 2016-12-07 23:01:03 -05:00
parent 7384128d40
commit 3784b89ca9
3 changed files with 3 additions and 11 deletions

View File

@ -21,10 +21,6 @@ public:
return std::make_shared<Cursor>(&*m_gap_buffer, m_encoding);
}
auto get_string() { return m_gap_buffer->get_string(); }
void insert(Cursor & insert_cursor, uint32_t code_point)
{
m_gap_buffer->insert(insert_cursor, code_point);
}
protected:
bool m_eol_at_eof;

View File

@ -1,7 +1,6 @@
#include "GapBuffer.h"
#include "System.h"
#include <string.h>
#include "Cursor.h"
GapBuffer::GapBuffer(Encoding::Type encoding)
{
@ -40,12 +39,11 @@ void GapBuffer::compact()
/**
* Insert code_point into the gap buffer at position position.
*
* @param insert_cursor Cursor in the gap buffer to insert the code point at.
* @param position Position in the gap buffer to insert the code point at.
* @param code_point The code point to insert.
*/
void GapBuffer::insert(Cursor & insert_cursor, uint32_t code_point)
void GapBuffer::insert(size_t position, uint32_t code_point)
{
size_t position = insert_cursor.iterator().offset();
check_grow();
move_gap(position);
size_t size = Encoding::encode(code_point, m_encoding, &m_buffer[m_gap_position]);

View File

@ -8,8 +8,6 @@
#include <list>
#include <string>
class Cursor;
class GapBuffer
{
public:
@ -33,7 +31,7 @@ public:
}
size_t gap_size() const { return m_buffer_size - m_size; }
void compact();
void insert(Cursor & insert_cursor, uint32_t code_point);
void insert(size_t position, uint32_t code_point);
std::string get_string();
Encoding::Type encoding() { return m_encoding; }