blob: 7e474e484f227c16cf2be7a46c5770f4ec08e392 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
#pragma once
#include "cuki.h"
#include "Line.h"
#include "Position.h"
#include "OwnPtr.h"
#include <string>
class Document {
public:
explicit Document(const std::string& path) : m_path(path) { }
~Document() { }
std::string path() const { return m_path; }
Line& line(size_t index) { return *m_lines[index]; }
const Line& line(size_t index) const { return *m_lines[index]; }
size_t line_count() const { return m_lines.size(); }
static OwnPtr<Document> create_from_file(const std::string& path);
bool insert_at(Position, const std::string&);
bool newline_at(Position);
bool backspace_at(Position);
void dump();
private:
std::deque<OwnPtr<Line>> m_lines;
std::string m_path;
};
|