-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathscreen.hpp
86 lines (83 loc) · 2 KB
/
screen.hpp
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#pragma once
#include "widget.hpp"
#include "color.hpp"
#include "coord.hpp"
#include "layout.hpp"
#include <string>
class BaseTextBuffer;
class StatusBar;
class Screen: public Widget
{
public:
Screen(Widget * = nullptr);
~Screen();
struct Char
{
Char(wchar_t = L'\0', Color fg = Black, Color bg = White);
bool operator!=(const Char &) const;
wchar_t ch;
Color fg;
Color bg;
};
int widthCh() const;
int heightCh() const;
Char &ch(int x, int y);
const Char &ch(int x, int y) const;
Coord cursor() const;
void setCursor(Coord);
void setCursor(int x, int y);
BaseTextBuffer *textBuffer() const;
void setTextBuffer(BaseTextBuffer *);
int hScroll() const;
void setHScroll(int);
int vScroll() const;
void setVScroll(int);
Coord startSelection() const;
void setStartSelection(Coord);
Coord endSelection() const;
void setEndSelection(Coord);
bool isSelected(Coord) const;
StatusBar *statusBar() const;
void setStatusBar(StatusBar *);
void moveCursorLeft();
void moveCursorRight();
void moveCursorUp();
void moveCursorDown();
void moveCursorHome();
void moveCursorEnd();
void moveCursorPageUp();
void moveCursorPageDown();
int copy();
void paste();
void cut();
void selectAll();
void startIsearch();
void escStatusBar();
protected:
int glyphHeight() const;
int glyphWidth() const;
private:
int glyphWidth_;
int glyphHeight_;
Coord cursor_;
Coord startSelection_;
Coord endSelection_;
int hScroll_;
int vScroll_;
BaseTextBuffer *textBuffer_;
StatusBar *statusBar_;
int prevX_;
int prevY_;
std::vector<std::vector<Char> > ch_;
std::vector<std::vector<Char> > prevCh_;
void select(void (Screen::*moveCursor)());
void moveCursor(void (Screen::*moveCursor)());
std::wstring getSelected() const;
void render();
int deleteSelected();
protected:
virtual void resizeEvent(ResizeEvent &);
virtual void paintEvent(PaintEvent &);
virtual bool keyPressEvent(KeyEvent &);
virtual bool textInputEvent(TextInputEvent &);
};