pass encoding to GapBuffer
This commit is contained in:
parent
2598b10e36
commit
a865ff0163
@ -22,7 +22,7 @@ Buffer::Buffer(const char * filename)
|
|||||||
|
|
||||||
void Buffer::load_empty_buffer()
|
void Buffer::load_empty_buffer()
|
||||||
{
|
{
|
||||||
m_gap_buffer = std::make_shared<GapBuffer>();
|
m_gap_buffer = std::make_shared<GapBuffer>(Encoding::UTF_8);
|
||||||
m_eol_at_eof = true;
|
m_eol_at_eof = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,7 +57,7 @@ bool Buffer::load_from_file(const char * filename)
|
|||||||
size_t loaded_size;
|
size_t loaded_size;
|
||||||
text_loader.load_buffer(buffer, file_size, &loaded_size);
|
text_loader.load_buffer(buffer, file_size, &loaded_size);
|
||||||
|
|
||||||
m_gap_buffer = std::make_shared<GapBuffer>(buffer, buffer_size, loaded_size);
|
m_gap_buffer = std::make_shared<GapBuffer>(buffer, buffer_size, loaded_size, text_loader.get_encoding());
|
||||||
m_eol_at_eof = text_loader.get_eol_at_eof();
|
m_eol_at_eof = text_loader.get_eol_at_eof();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -1,20 +1,22 @@
|
|||||||
#include "GapBuffer.h"
|
#include "GapBuffer.h"
|
||||||
#include "System.h"
|
#include "System.h"
|
||||||
|
|
||||||
GapBuffer::GapBuffer()
|
GapBuffer::GapBuffer(Encoding::Type encoding)
|
||||||
{
|
{
|
||||||
m_buffer = (uint8_t *)System::alloc_pages(1u);
|
m_buffer = (uint8_t *)System::alloc_pages(1u);
|
||||||
m_buffer_size = System::page_size;
|
m_buffer_size = System::page_size;
|
||||||
m_size = 0u;
|
m_size = 0u;
|
||||||
m_gap_position = 0u;
|
m_gap_position = 0u;
|
||||||
|
m_encoding = encoding;
|
||||||
}
|
}
|
||||||
|
|
||||||
GapBuffer::GapBuffer(uint8_t * buffer, size_t buffer_size, size_t size)
|
GapBuffer::GapBuffer(uint8_t * buffer, size_t buffer_size, size_t size, Encoding::Type encoding)
|
||||||
{
|
{
|
||||||
m_buffer = buffer;
|
m_buffer = buffer;
|
||||||
m_buffer_size = buffer_size;
|
m_buffer_size = buffer_size;
|
||||||
m_size = size;
|
m_size = size;
|
||||||
m_gap_position = size;
|
m_gap_position = size;
|
||||||
|
m_encoding = encoding;
|
||||||
}
|
}
|
||||||
|
|
||||||
GapBuffer::~GapBuffer()
|
GapBuffer::~GapBuffer()
|
||||||
|
@ -3,12 +3,13 @@
|
|||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include "Encoding.h"
|
||||||
|
|
||||||
class GapBuffer
|
class GapBuffer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
GapBuffer();
|
GapBuffer(Encoding::Type encoding);
|
||||||
GapBuffer(uint8_t * buffer, size_t buffer_size, size_t size);
|
GapBuffer(uint8_t * buffer, size_t buffer_size, size_t size, Encoding::Type encoding);
|
||||||
~GapBuffer();
|
~GapBuffer();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -16,6 +17,7 @@ protected:
|
|||||||
size_t m_buffer_size;
|
size_t m_buffer_size;
|
||||||
size_t m_size;
|
size_t m_size;
|
||||||
size_t m_gap_position;
|
size_t m_gap_position;
|
||||||
|
Encoding::Type m_encoding;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user