teditor  1.8.0@@fee5e94
Terminal based editor written in C++
cell_buffer.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "colors.h"
4 #include <vector>
5 
6 
7 namespace teditor {
8 
9 // a Unicode character
10 typedef uint32_t Chr;
11 
13 struct Cell {
16 
17  void set(Chr c, AttrColor f, AttrColor b);
18  void set(Chr c, color_t f, color_t b);
19  void copy(const Cell& from);
20  int width() const;
21 };
22 
23 bool operator==(const Cell& a, const Cell& b);
24 
25 
27 class CellBuffer {
28 public:
29  CellBuffer(int w=0, int h=0);
30  void clear(AttrColor fg, AttrColor bg);
31  void resize(int w, int h);
32  const Cell& at(int x, int y) const { return cells[y*width+x]; }
33  Cell& at(int x, int y) { return cells[y*width+x]; }
34  unsigned w() const { return (unsigned)width; }
35  unsigned h() const { return (unsigned)height; }
36 
37 private:
38  int width, height;
39  std::vector<Cell> cells;
40 };
41 
42 }; // end namespace teditor
teditor::Cell
Definition: cell_buffer.h:13
MESSAGE
#define MESSAGE(ed, fmt,...)
Definition: logger.h:50
teditor::Cell::copy
void copy(const Cell &from)
Definition: cell_buffer.cpp:11
teditor::CellBuffer::clear
void clear(AttrColor fg, AttrColor bg)
Definition: cell_buffer.cpp:40
teditor::Option::getBool
bool getBool() const
Definition: option.h:39
teditor::CellBuffer::at
Cell & at(int x, int y)
Definition: cell_buffer.h:33
teditor::Cell::ch
Chr ch
Definition: cell_buffer.h:14
teditor::Chr
uint32_t Chr
Definition: cell_buffer.h:10
CMBAR_MSG
#define CMBAR_MSG(ed, fmt,...)
Definition: logger.h:52
teditor::Cell::set
void set(Chr c, AttrColor f, AttrColor b)
Definition: cell_buffer.cpp:17
teditor::Cell::bg
AttrColor bg
Definition: cell_buffer.h:15
teditor::CellBuffer::CellBuffer
CellBuffer(int w=0, int h=0)
Definition: cell_buffer.cpp:37
teditor::check_output
CmdStatus check_output(const std::string &cmd)
Definition: utils.cpp:110
teditor::AttrColor
Definition: colors.h:56
teditor::parser::NFA
Ken-Thompson NFA as described here: https://swtch.com/~rsc/regexp/regexp1.html but adjusted to work w...
Definition: nfa.h:23
teditor::Cell::fg
AttrColor fg
Definition: cell_buffer.h:15
isearch.h
command.h
DEF_OP
#define DEF_OP()
Definition: command.h:55
teditor::CellBuffer::resize
void resize(int w, int h)
Definition: cell_buffer.cpp:47
teditor::CellBuffer::at
const Cell & at(int x, int y) const
Definition: cell_buffer.h:32
teditor::buffer::ops::DEF_CMD
DEF_CMD(CommandUndo, "command-undo", "buffer_ops", DEF_OP() { if(!ed.getBuff().undo()) CMBAR_MSG(ed, "No further undo information\n");})
teditor::Editor::getBuff
Buffer & getBuff()
Definition: editor.h:28
teditor::CellBuffer::w
unsigned w() const
Definition: cell_buffer.h:34
teditor::Cell::width
int width() const
Definition: cell_buffer.cpp:29
teditor::operator==
bool operator==(const Cell &a, const Cell &b)
Definition: cell_buffer.cpp:33
teditor::Editor
Definition: editor.h:23
cell_buffer.h
colors.h
teditor::CellBuffer::h
unsigned h() const
Definition: cell_buffer.h:35
teditor::CellBuffer
Definition: cell_buffer.h:27
teditor::Option::get
static Option & get(const std::string &n)
Definition: option.cpp:40
option.h
editor.h
teditor::buffer::ops::keepRemoveLines
void keepRemoveLines(Editor &ed, bool keep)
Definition: buffer_ops.cpp:279
teditor::downloadUrlToString
std::string downloadUrlToString(const std::string &url, const std::string &dnldProg, const std::string &dnldProgOpts)
Download the content of input url into a string.
Definition: utils.cpp:187
teditor::Editor::prompt
std::string prompt(const std::string &msg, KeyCmdMap *kcMap=nullptr, Choices *choices=nullptr, const std::string &defVal=std::string())
Definition: editor.cpp:413
teditor
Definition: any.hpp:10
teditor::color_t
uint16_t color_t
Definition: colors.h:11