From 4addb711c6a1a282b0a59bf03e850a86ba2ead69 Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Sun, 8 Jan 2017 22:43:35 +0100 Subject: Initial --- textblob.h | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 textblob.h (limited to 'textblob.h') diff --git a/textblob.h b/textblob.h new file mode 100644 index 0000000..3246c8d --- /dev/null +++ b/textblob.h @@ -0,0 +1,59 @@ +#pragma once + +#include +#include +#include + +#include "global.h" + +using namespace std; + + +class TextBlob{ + deque 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(); + + void read(istream &is); + void 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; +}; -- cgit v1.2.3-54-g00ecf