teditor  1.8.0@@fee5e94
Terminal based editor written in C++
window.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "pos2d.h"
4 #include <vector>
5 
6 
7 namespace teditor {
8 
9 class Buffer;
10 class Buffers;
11 class Editor;
12 class Windows;
13 
15 class Window {
16 public:
17  Window();
18 
24  void attachBuffs(Buffers* bs);
25 
27  void copyTo(Window& w) { w.buffs = buffs; w.currBuff = currBuff; }
28 
34  Buffer& getBuff();
35  const Buffer& getBuff() const;
43  void resize(const Pos2di& start, const Pos2di& dim);
44 
49  void draw(Editor& ed);
50  void drawPoint(Editor& ed, const AttrColor& bg);
53  void incrementCurrBuff();
54  void decrementCurrBuff();
55  int currBuffId() const { return currBuff; }
56  void setCurrBuff(int i) { currBuff = i; }
57 
58  const Pos2di& start() const { return screenStart; }
59  const Pos2di& dim() const { return screenDim; }
60 
61 protected:
62  Buffers* buffs; // NOT owned by this class
63  int currBuff;
65 };
66 
67 
69 struct Border {
70  int sy, ey, x;
71 };
72 
73 
75 class Windows {
76 public:
77  Windows();
78  ~Windows();
79  Window& getWindow() { return *wins[currWin]; }
80  const Window& getWindow() const { return *wins[currWin]; }
81  int currWinId() const { return currWin; }
82  size_t size() const { return wins.size(); }
83  void incrementCurrWin();
84  void decrementCurrWin();
85  Window* operator[](int idx) { return wins[idx]; }
86  const Window* operator[](int idx) const { return wins[idx]; }
87  void draw(Editor& ed, bool cmdMsgBarActive);
92  bool splitVertically();
93  void clearAll();
94  void resize(int cmBarHt);
95 
96 private:
97  std::vector<Window*> wins;
98  int currWin;
99  std::vector<Border> borders;
100  Pos2di screenDim;
101 };
102 
103 }; // end namespace teditor
teditor::Window::attachBuffs
void attachBuffs(Buffers *bs)
attach buffers list to this window. This list should be shared with all the other windows being displ...
Definition: window.cpp:13
teditor::Window::decrementCurrBuff
void decrementCurrBuff()
Definition: window.cpp:23
teditor::Window::draw
void draw(Editor &ed)
Definition: window.cpp:33
teditor::Windows::getWindow
const Window & getWindow() const
Definition: window.h:80
teditor::Window::Window
Window()
Definition: window.cpp:10
teditor::Window::screenDim
Pos2di screenDim
Definition: window.h:64
logger.h
teditor::Windows::incrementCurrWin
void incrementCurrWin()
Definition: window.cpp:82
teditor::Windows::clearAll
void clearAll()
Definition: window.cpp:150
teditor::Window::screenStart
Pos2di screenStart
Definition: window.h:64
teditor::Windows::size
size_t size() const
Definition: window.h:82
teditor::Windows::Windows
Windows()
Definition: window.cpp:46
teditor::Window::start
const Pos2di & start() const
Definition: window.h:58
teditor::Window::currBuff
int currBuff
Definition: window.h:63
teditor::Pos2d::y
T y
Definition: pos2d.h:16
teditor::Buffers
Definition: buffer.h:355
teditor::AttrColor
Definition: colors.h:56
teditor::Editor::sendChar
int sendChar(int x, int y, const AttrColor &fg, const AttrColor &bg, char c)
Definition: editor.cpp:295
teditor::Windows::decrementCurrWin
void decrementCurrWin()
Definition: window.cpp:87
teditor::Option::getChar
char getChar() const
Definition: option.h:56
teditor::Window::copyTo
void copyTo(Window &w)
Definition: window.h:27
teditor::Window::currBuffId
int currBuffId() const
Definition: window.h:55
teditor::Windows::splitVertically
bool splitVertically()
split the window into 2 vertical parts
Definition: window.cpp:129
teditor::Window
Definition: window.h:15
teditor::Windows::getWindow
Window & getWindow()
Definition: window.h:79
teditor::Window::resize
void resize(const Pos2di &start, const Pos2di &dim)
resize the window in case of window size change
Definition: window.cpp:28
teditor::Windows::draw
void draw(Editor &ed, bool cmdMsgBarActive)
Definition: window.cpp:92
teditor::Buffer::drawPoint
void drawPoint(Editor &ed, const AttrColor &bg, const Window &win)
Definition: buffer.cpp:402
teditor::Window::getBuff
Buffer & getBuff()
Definition: window.cpp:15
buffer.h
teditor::Editor
Definition: editor.h:23
teditor::Pos2d< int >
DEBUG
#define DEBUG(fmt,...)
Definition: logger.h:73
teditor::Border::sy
int sy
Definition: window.h:70
teditor::Windows::resize
void resize(int cmBarHt)
Definition: window.cpp:59
teditor::Windows
Definition: window.h:75
teditor::Windows::operator[]
const Window * operator[](int idx) const
Definition: window.h:86
pos2d.h
teditor::Window::drawPoint
void drawPoint(Editor &ed, const AttrColor &bg)
Definition: window.cpp:41
teditor::Windows::~Windows
~Windows()
Definition: window.cpp:53
window.h
teditor::Border::ey
int ey
Definition: window.h:70
teditor::Windows::operator[]
Window * operator[](int idx)
Definition: window.h:85
teditor::Option::get
static Option & get(const std::string &n)
Definition: option.cpp:40
teditor::Terminal::getInstance
static Terminal & getInstance()
Definition: terminal.cpp:57
option.h
teditor::Buffer::getColor
const AttrColor & getColor(const std::string &name) const
Definition: buffer.cpp:303
editor.h
teditor::Border::x
int x
Definition: window.h:70
teditor::Window::setCurrBuff
void setCurrBuff(int i)
Definition: window.h:56
teditor::Window::buffs
Buffers * buffs
Definition: window.h:62
terminal.h
teditor::Pos2d::x
T x
Definition: pos2d.h:16
teditor::Border
Definition: window.h:69
teditor::Windows::currWinId
int currWinId() const
Definition: window.h:81
teditor::Window::dim
const Pos2di & dim() const
Definition: window.h:59
teditor::Buffer
Definition: buffer.h:25
teditor
Definition: any.hpp:10
teditor::Window::incrementCurrBuff
void incrementCurrBuff()
Definition: window.cpp:18