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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
|
/*
* Copyright (C) 2002 Red Hat, Inc.
*
* This is free software; you can redistribute it and/or modify it under
* the terms of the GNU Library General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* The interfaces in this file are subject to change at any time. */
#ifndef vte_ring_h_included
#define vte_ring_h_included
#include <glib.h>
#include "debug.h"
#include "vteunistr.h"
G_BEGIN_DECLS
#define VTE_DEF_FG 256
#define VTE_DEF_BG 257
#define VTE_BOLD_FG 258
#define VTE_DIM_FG 259
#define VTE_DEF_HL 260
#define VTE_CUR_BG 261
#define VTE_PALETTE_SIZE 262
/*
* VteCellAttr: A single cell style attributes
*
* Ordered by most commonly changed attributes, to
* optimize the compact representation.
*/
typedef struct _VteCellAttr {
guint32 fragment: 1; /* A continuation cell. */
guint32 columns: 4; /* Number of visible columns
(as determined by g_unicode_iswide(c)).
Also abused for tabs; bug 353610
Keep at least 4 for tabs to work
*/
guint32 bold: 1;
guint32 fore: 9; /* Index into color palette */
guint32 back: 9; /* Index into color palette. */
guint32 standout: 1;
guint32 underline: 1;
guint32 strikethrough: 1;
guint32 reverse: 1;
guint32 blink: 1;
guint32 half: 1;
guint32 invisible: 1;
/* unused; bug 499893
guint32 protect: 1;
*/
/* 30 bits */
} VteCellAttr;
ASSERT_STATIC (sizeof (VteCellAttr) == 4);
/*
* VteCell: A single cell's data
*/
typedef struct _VteCell {
vteunistr c;
VteCellAttr attr;
} VteCell;
ASSERT_STATIC (sizeof (VteCell) == 8);
static const union {
VteCell cell;
struct {
guint32 c;
guint32 attr;
} i;
} basic_cell = {
{
0,
{
0, /* fragment */
1, /* columns */
0, /* bold */
VTE_DEF_FG, /* fore */
VTE_DEF_BG, /* back */
0, /* standout */
0, /* underline */
0, /* strikethrough */
0, /* reverse */
0, /* blink */
0, /* half */
0 /* invisible */
}
}
};
/*
* VteRowAttr: A single row's attributes
*/
typedef struct _VteRowAttr {
guint8 soft_wrapped: 1;
} VteRowAttr;
ASSERT_STATIC (sizeof (VteRowAttr) == 1);
/*
* VteRowData: A single row's data
*/
typedef struct _VteRowData {
VteCell *cells;
guint16 len;
VteRowAttr attr;
} VteRowData;
#define _vte_row_data_length(__row) ((__row)->len + 0)
static inline const VteCell *
_vte_row_data_get (const VteRowData *row, guint col)
{
if (G_UNLIKELY (row->len <= col))
return NULL;
return &row->cells[col];
}
static inline VteCell *
_vte_row_data_get_writable (VteRowData *row, guint col)
{
if (G_UNLIKELY (row->len <= col))
return NULL;
return &row->cells[col];
}
void _vte_row_data_insert (VteRowData *row, guint col, const VteCell *cell);
void _vte_row_data_append (VteRowData *row, const VteCell *cell);
void _vte_row_data_remove (VteRowData *row, guint col);
void _vte_row_data_fill (VteRowData *row, const VteCell *cell, guint len);
void _vte_row_data_shrink (VteRowData *row, guint max_len);
/*
* VteRingChunk: A chunk of the scrollback buffer ring
*/
typedef enum _VteRingChunkType VteRingChunkType;
enum _VteRingChunkType {
VTE_RING_CHUNK_TYPE_INVALID,
VTE_RING_CHUNK_TYPE_WRITABLE,
VTE_RING_CHUNK_TYPE_COMPACT
};
typedef struct _VteRingChunk VteRingChunk;
struct _VteRingChunk {
VteRingChunkType type; /* Chunk implementation type */
VteRingChunk *prev_chunk, *next_chunk;
guint start, end;
};
typedef struct _VteRingChunkWritable {
VteRingChunk base;
guint mask;
VteRowData *array;
} VteRingChunkWritable;
/*
* VteRing: A scrollback buffer ring
*/
typedef struct _VteRing VteRing;
struct _VteRing {
guint max;
VteRowData cached_row;
guint cached_row_num;
VteRingChunk *tail, *cursor;
VteRingChunkWritable head[1];
};
#define _vte_ring_contains(__ring, __position) \
(((__position) >= (__ring)->tail->start) && \
((__position) < (__ring)->head->base.end))
#define _vte_ring_delta(__ring) ((__ring)->tail->start + 0)
#define _vte_ring_length(__ring) ((__ring)->head->base.end - (__ring)->tail->start)
#define _vte_ring_next(__ring) ((__ring)->head->base.end + 0)
const VteRowData *_vte_ring_index (VteRing *ring, guint position);
VteRowData *_vte_ring_index_writable (VteRing *ring, guint position);
void _vte_ring_init (VteRing *ring, guint max_rows);
void _vte_ring_fini (VteRing *ring);
void _vte_ring_resize (VteRing *ring, guint max_rows);
void _vte_ring_shrink (VteRing *ring, guint max_len);
VteRowData *_vte_ring_insert (VteRing *ring, guint position);
VteRowData *_vte_ring_append (VteRing *ring);
void _vte_ring_remove (VteRing *ring, guint position);
G_END_DECLS
#endif
|