implement initial Text functionality
This commit is contained in:
parent
346dbaa783
commit
39aa6bbd42
@ -1,12 +1,29 @@
|
||||
#ifndef JES_TEXT_H
|
||||
#define JES_TEXT_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "jes/Ref.h"
|
||||
|
||||
namespace jes
|
||||
{
|
||||
class Text
|
||||
{
|
||||
public:
|
||||
typedef char Character;
|
||||
Text();
|
||||
Text(const uint8_t buf[], size_t size);
|
||||
size_t get_size() { return m_size - m_gap_size; }
|
||||
|
||||
Character operator[](int index)
|
||||
{
|
||||
return (Character)(m_buffer[index < m_insert_index ? index : index + m_gap_size]);
|
||||
}
|
||||
|
||||
protected:
|
||||
uint8_t * m_buffer;
|
||||
size_t m_size;
|
||||
size_t m_insert_index;
|
||||
size_t m_gap_size;
|
||||
};
|
||||
typedef Ref<Text> TextRef;
|
||||
}
|
||||
|
@ -1 +1,22 @@
|
||||
#include "jes/Text.h"
|
||||
#include <string.h>
|
||||
|
||||
namespace jes
|
||||
{
|
||||
Text::Text()
|
||||
{
|
||||
m_buffer = NULL;
|
||||
m_size = 0;
|
||||
m_insert_index = 0;
|
||||
m_gap_size = 0;
|
||||
}
|
||||
|
||||
Text::Text(const uint8_t buf[], size_t size)
|
||||
{
|
||||
m_buffer = new uint8_t[size];
|
||||
m_size = size;
|
||||
m_insert_index = size;
|
||||
m_gap_size = 0;
|
||||
memcpy(m_buffer, &buf[0], size);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user