-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathvterm_buffer.h
113 lines (88 loc) · 3.26 KB
/
vterm_buffer.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#ifndef _VTERM_BUFFER_H_
#define _VTERM_BUFFER_H_
#include <string.h>
#include <stdio.h>
#include <wchar.h>
#include "vterm.h"
void vterm_buffer_alloc(vterm_t *vterm, int idx, int width, int height);
void vterm_buffer_realloc(vterm_t *vterm, int idx, int width, int height);
void vterm_buffer_dealloc(vterm_t *vterm, int idx);
int vterm_buffer_set_active(vterm_t *vterm, int idx);
int vterm_buffer_get_active(vterm_t *vterm);
int vterm_buffer_shift_up(vterm_t *vterm, int idx,
int top_row, int bottom_row, int stride);
int vterm_buffer_shift_down(vterm_t *vterm, int idx,
int top_row, int bottom_row, int stride);
int vterm_buffer_clone(vterm_t *vterm, int src_idx, int dst_idx,
int src_offset, int dst_offset, int rows);
#define VCELL_ZERO_ALL(_cell) \
{ \
memset(&_cell, 0, sizeof(_cell)); \
_cell.dirty = 1; \
}
#define VCELL_ROW_SET_DIRTY(_cell, _stride) \
{ \
__typeof__ (_cell) _ctmp = (_cell); \
__typeof__ (_stride) _stmp= (_stride); \
do \
{ \
_ctmp->dirty = 1; \
_ctmp++; \
_stmp--; \
} \
while(_stmp > 0); \
}
#define VCELL_ROW_SET_CLEAN(_cell, _stride) \
{ \
__typeof__ (_cell) _ctmp = (_cell); \
__typeof__ (_stride) _stmp = (_stride); \
do \
{ \
_ctmp->dirty = 0; \
_ctmp++; \
_stmp--; \
} \
while(_stmp > 0); \
}
#define VCELL_ALL_SET_DIRTY(_vdesc) \
{ \
__typeof__ (_vdesc) _vtmp = (_vdesc); \
for(int _r = 0; _r < _vtmp->rows; _r++) \
{ \
VCELL_ROW_SET_DIRTY(_vtmp->cells[_r], _vtmp->cols); \
} \
}
#define VCELL_SET_CHAR(_cell, _ch) \
{ \
_cell.wch[0] = _ch; \
_cell.wch[1] = '\0'; \
_cell.dirty = 1; \
}
#define VCELL_SET_ATTR(_cell, _attr) \
{ \
_cell.attr = _attr; \
_cell.dirty = 1 ; \
}
#define VCELL_GET_ATTR(_cell, _attr_ptr) \
{ *_attr_ptr = _cell.attr; }
#define VCELL_SET_COLORS(_cell, _desc) \
{ \
_cell.colors = _desc->colors; \
_cell.fg = _desc->fg; \
_cell.bg = _desc->bg; \
_cell.f_rgb[0] = _desc->f_rgb[0]; \
_cell.f_rgb[1] = _desc->f_rgb[1]; \
_cell.f_rgb[2] = _desc->f_rgb[2]; \
_cell.b_rgb[0] = _desc->b_rgb[0]; \
_cell.b_rgb[1] = _desc->b_rgb[1]; \
_cell.b_rgb[2] = _desc->b_rgb[2]; \
_cell.dirty = 1; \
}
#define VCELL_SET_DEFAULT_COLORS(_cell, _desc) \
{ \
_cell.colors = _desc->default_colors; \
_cell.dirty = 1; \
}
#define VCELL_GET_COLORS(_cell, _colors_ptr) \
{ *_colors_ptr = _cell.colors; }
#endif