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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
#pragma once
#include <iostream>
#include <deque>
#include <string>
#include "global.h"
using namespace std;
class TextBlob{
deque<string> lines;
void checkInRange(i64 y,i64 x) const;
void checkInRangeP1(i64 y,i64 x) const;
void checkInRange(i64 y) const;
void checkInRangeP1(i64 y) const;
public:
TextBlob() = default;
TextBlob(const TextBlob&) = default;
TextBlob(TextBlob&&) = default;
TextBlob& operator=(const TextBlob &other) = default;
TextBlob& operator=(TextBlob &&other) = default;
bool isInRange(i64 y,i64 x) const;
bool isInRangeP1(i64 y,i64 x) const;
bool isInRange(i64 y) const;
bool isInRangeP1(i64 y) const;
void clear();
//Return how many characters were read/written.
i64 read(istream &is);
i64 write(ostream &os) const;
void setText(const string &text);
string fullText() const;
//returns original
char replace(i64 y,i64 x,char c);
//All inserts are BEFORE. Pass one-past-end index to append.
void insert(i64 y,i64 x,char c);
void insertLine(i64 y,const string &line);
void insertString(i64 y,i64 x,const string &str);
//functions return original
char erase(i64 y,i64 x);
string erase(i64 y,i64 x,i64 nchars);
string& operator[](i64 y);
const string& operator[](i64 y) const;
string getLine(i64 y) const; //returns a copy
i64 numLines() const;
i64 lineLen(i64 y) const;
};
|