teditor  1.8.0@@fee5e94
Terminal based editor written in C++
line.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <string>
4 
5 
6 namespace teditor {
7 
9 
11 class Line {
12 public:
13  Line() {}
14 
19  void append(char c) { line.push_back(c); }
20  void append(const char* c) { line += c; }
21  void append(const std::string& str) { line += str; }
22  void prepend(char c) { insert(c, 0); }
23  void prepend(const char* c) { insert(c, 0); }
24  void prepend(char c, int count);
25  void insert(char c, int idx);
26  void insert(const char* c, int idx);
27  void insert(const std::string& str, int idx);
31  std::string erase(int idx, int len=1);
32 
37  Line split(int idx);
38  void join(const Line& other);
42  int numLinesNeeded(int wid) const;
43 
45  bool empty() const { return line.empty(); }
46 
48  int length() const { return (int)line.length(); }
49 
51  const std::string& get() const { return line; }
52 
54  char at(int idx) const { return line[idx]; }
55 
57  void clear() { line.clear(); }
58 
63  int findFirstNotOf(const std::string& str, int pos) const;
64 
69  int findLastNotOf(const std::string& str, int pos) const;
70 
72  int indentSize() const;
73 
74 private:
76  std::string line;
77 };
78 
79 
84 bool LineCompare(const Line& a, const Line& b);
85 
86 }; // end namespace teditor
teditor::Line::indentSize
int indentSize() const
Definition: line.cpp:68
teditor::Line
Definition: line.h:11
teditor::Line::prepend
void prepend(const char *c)
Definition: line.h:23
teditor::Line::split
Line split(int idx)
Definition: line.cpp:15
teditor::Line::get
const std::string & get() const
Definition: line.h:51
teditor::Line::numLinesNeeded
int numLinesNeeded(int wid) const
Definition: line.cpp:49
teditor::Line::empty
bool empty() const
Definition: line.h:45
line.h
teditor::Line::erase
std::string erase(int idx, int len=1)
Definition: line.cpp:7
teditor::Line::at
char at(int idx) const
Definition: line.h:54
teditor::Line::append
void append(const std::string &str)
Definition: line.h:21
teditor::Line::clear
void clear()
Definition: line.h:57
teditor::Line::append
void append(const char *c)
Definition: line.h:20
teditor::Line::length
int length() const
Definition: line.h:48
teditor::Line::Line
Line()
Definition: line.h:13
teditor::Line::insert
void insert(char c, int idx)
Definition: line.cpp:34
teditor::Line::findLastNotOf
int findLastNotOf(const std::string &str, int pos) const
Definition: line.cpp:62
teditor::Line::prepend
void prepend(char c)
Definition: line.h:22
teditor::Line::append
void append(char c)
Definition: line.h:19
teditor::Line::findFirstNotOf
int findFirstNotOf(const std::string &str, int pos) const
Definition: line.cpp:56
teditor::LineCompare
bool LineCompare(const Line &a, const Line &b)
Definition: line.cpp:75
teditor
Definition: any.hpp:10
teditor::Line::join
void join(const Line &other)
Definition: line.cpp:25