jes/src/core/Buffer.h

30 lines
624 B
C++

#ifndef BUFFER_H
#define BUFFER_H
#include <list>
#include <memory>
#include "LineEndings.h"
#include "Encoding.h"
#include "GapBuffer.h"
class Buffer
{
public:
Buffer(const char * filename = nullptr);
bool write_to_file(const char * filename);
typedef GapBuffer::Cursor Cursor;
auto add_cursor() { return m_gap_buffer->add_cursor(); }
auto get_string() { return m_gap_buffer->get_string(); }
protected:
bool m_eol_at_eof;
LineEndings::Type m_line_endings;
std::shared_ptr<GapBuffer> m_gap_buffer;
bool load_from_file(const char * filename);
void load_empty_buffer();
};
#endif