/
VTermMM.h
94 lines (84 loc) · 2.69 KB
/
VTermMM.h
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
87
88
89
90
91
92
93
94
#ifndef VTERMMM_H
#define VTERMMM_H
extern "C" {
#include <vterm.h>
#include <vterm_input.h>
}
#include <iostream>
#include <map>
#include <vector>
#include <boost/thread/mutex.hpp>
#include "VTCell.h"
static VTermColor VTERMMM_WHITE = { 255, 255, 255 };
static VTermColor VTERMMM_BLACK = { 0, 0, 0 };
typedef std::map<std::string, VTCell*> InvalidRegion;
typedef InvalidRegion::const_iterator InvalidRegionIter;
typedef std::pair<std::string, VTCell*> InvalidRegionPair;
class VTermMM
{
private:
VTerm *_term;
int fd;
void process_in_out();
void invalidate(int, int, int, int);
void invalidate(VTermRect);
void invalidate(VTermPos);
VTermColor foreground;
VTermColor background;
bool reverse;
bool bold;
bool italic;
InvalidRegion invalid_region;
typedef std::vector<VTCell> vrow;
std::vector<vrow> cells;
boost::mutex m_mutex;
public:
VTermMM(int rows=25, int columns=80);
void reset_invalid();
InvalidRegionIter GetInvalidBegin();
InvalidRegionIter GetInvalidEnd();
void setFD(int filedesc) { fd = filedesc; }
void feed(const std::string &, VTermModifier mod = VTERM_MOD_NONE);
void feed(VTermKey k, VTermModifier mod = VTERM_MOD_NONE);
void feed(char c, VTermModifier mod = VTERM_MOD_NONE);
bool process();
int putglyph(const uint32_t[], int, VTermPos);
int movecursor(VTermPos pos, VTermPos oldpos, int visible);
int copyrect(VTermRect dest, VTermRect src);
int copycell(VTermPos dest, VTermPos src);
int erase(VTermRect rect);
int initpen();
int setpenattr(VTermAttr, VTermValue *);
int settermprop(VTermProp prop, VTermValue *);
int setmousefunc(VTermMouseFunc, void *);
int bell();
int resize(int, int);
bool cursor_visible;
VTermPos cursor;
boost::mutex& GetLock() { return m_mutex; }
};
int term_putglyph(const uint32_t chars[], int width, VTermPos pos, void *user);
int term_movecursor(VTermPos pos, VTermPos oldpos, int visible, void *user);
int term_copyrect(VTermRect dest, VTermRect src, void *user);
int term_copycell(VTermPos dest, VTermPos src, void *user);
int term_erase(VTermRect rect, void *user);
int term_initpen(void *user);
int term_setpenattr(VTermAttr attr, VTermValue *val, void *user);
int term_settermprop(VTermProp prop, VTermValue *val, void *user);
int term_setmousefunc(VTermMouseFunc func, void *data, void *user);
int term_bell(void *user);
int term_resize(int rows, int cols, void *user);
static VTermStateCallbacks vterm_callbacks = {
&term_putglyph,
&term_movecursor,
&term_copyrect,
&term_copycell,
&term_erase,
&term_initpen,
&term_setpenattr,
&term_settermprop,
&term_setmousefunc,
&term_bell,
&term_resize,
};
#endif