1 /*
2 * NOTE: This is a MODIFIED version of libvterm, see the README file.
3 */
4 #ifndef __VTERM_H__
5 #define __VTERM_H__
6
7 #ifdef __cplusplus
8 extern "C" {
9 #endif
10
11 #include <stdlib.h>
12
13 #include "vterm_keycodes.h"
14
15 #define TRUE 1
16 #define FALSE 0
17
18 // from stdint.h
19 typedef unsigned char uint8_t;
20 typedef unsigned short uint16_t;
21 typedef unsigned int uint32_t;
22
23 #define VTERM_VERSION_MAJOR 0
24 #define VTERM_VERSION_MINOR 2
25
26 #define VTERM_CHECK_VERSION \
27 vterm_check_version(VTERM_VERSION_MAJOR, VTERM_VERSION_MINOR)
28
29 typedef struct VTerm VTerm;
30 typedef struct VTermState VTermState;
31 typedef struct VTermScreen VTermScreen;
32
33 // Specifies a screen point.
34 typedef struct {
35 int row;
36 int col;
37 } VTermPos;
38
39 /* some small utility functions; we can just keep these static here */
40
41 /*
42 * Order points by on-screen flow order:
43 * Return < 0 if "a" is before "b"
44 * Return 0 if "a" and "b" are equal
45 * Return > 0 if "a" is after "b".
46 */
47 int vterm_pos_cmp(VTermPos a, VTermPos b);
48
49 #if defined(DEFINE_INLINES) || USE_INLINE
vterm_pos_cmp(VTermPos a,VTermPos b)50 INLINE int vterm_pos_cmp(VTermPos a, VTermPos b)
51 {
52 return (a.row == b.row) ? a.col - b.col : a.row - b.row;
53 }
54 #endif
55
56 // Specifies a rectangular screen area.
57 typedef struct {
58 int start_row;
59 int end_row;
60 int start_col;
61 int end_col;
62 } VTermRect;
63
64 /* true if the rect contains the point */
65 int vterm_rect_contains(VTermRect r, VTermPos p);
66
67 #if defined(DEFINE_INLINES) || USE_INLINE
vterm_rect_contains(VTermRect r,VTermPos p)68 INLINE int vterm_rect_contains(VTermRect r, VTermPos p)
69 {
70 return p.row >= r.start_row && p.row < r.end_row &&
71 p.col >= r.start_col && p.col < r.end_col;
72 }
73 #endif
74
75 /* move a rect */
76 // Move "rect" "row_delta" down and "col_delta" right.
77 // Does not check boundaries.
78 void vterm_rect_move(VTermRect *rect, int row_delta, int col_delta);
79
80 #if defined(DEFINE_INLINES) || USE_INLINE
vterm_rect_move(VTermRect * rect,int row_delta,int col_delta)81 INLINE void vterm_rect_move(VTermRect *rect, int row_delta, int col_delta)
82 {
83 rect->start_row += row_delta; rect->end_row += row_delta;
84 rect->start_col += col_delta; rect->end_col += col_delta;
85 }
86 #endif
87
88 /**
89 * Bit-field describing the value of VTermColor.type
90 */
91 typedef enum {
92 /**
93 * If the lower bit of `type` is not set, the colour is 24-bit RGB.
94 */
95 VTERM_COLOR_RGB = 0x00,
96
97 /**
98 * The colour is an index into a palette of 256 colours.
99 */
100 VTERM_COLOR_INDEXED = 0x01,
101
102 /**
103 * Mask that can be used to extract the RGB/Indexed bit.
104 */
105 VTERM_COLOR_TYPE_MASK = 0x01,
106
107 /**
108 * If set, indicates that this colour should be the default foreground
109 * color, i.e. there was no SGR request for another colour. When
110 * rendering this colour it is possible to ignore "idx" and just use a
111 * colour that is not in the palette.
112 */
113 VTERM_COLOR_DEFAULT_FG = 0x02,
114
115 /**
116 * If set, indicates that this colour should be the default background
117 * color, i.e. there was no SGR request for another colour. A common
118 * option when rendering this colour is to not render a background at
119 * all, for example by rendering the window transparently at this spot.
120 */
121 VTERM_COLOR_DEFAULT_BG = 0x04,
122
123 /**
124 * Mask that can be used to extract the default foreground/background bit.
125 */
126 VTERM_COLOR_DEFAULT_MASK = 0x06,
127
128 /**
129 * If set, indicates that the color is invalid.
130 */
131 VTERM_COLOR_INVALID = 0x08
132 } VTermColorType;
133
134 /**
135 * Returns true if the VTERM_COLOR_RGB `type` flag is set, indicating that the
136 * given VTermColor instance is an indexed colour.
137 */
138 #define VTERM_COLOR_IS_INDEXED(col) \
139 (((col)->type & VTERM_COLOR_TYPE_MASK) == VTERM_COLOR_INDEXED)
140
141 /**
142 * Returns true if the VTERM_COLOR_INDEXED `type` flag is set, indicating that
143 * the given VTermColor instance is an rgb colour.
144 */
145 #define VTERM_COLOR_IS_RGB(col) \
146 (((col)->type & VTERM_COLOR_TYPE_MASK) == VTERM_COLOR_RGB)
147
148 /**
149 * Returns true if the VTERM_COLOR_DEFAULT_FG `type` flag is set, indicating
150 * that the given VTermColor instance corresponds to the default foreground
151 * color.
152 */
153 #define VTERM_COLOR_IS_DEFAULT_FG(col) \
154 (!!((col)->type & VTERM_COLOR_DEFAULT_FG))
155
156 /**
157 * Returns true if the VTERM_COLOR_DEFAULT_BG `type` flag is set, indicating
158 * that the given VTermColor instance corresponds to the default background
159 * color.
160 */
161 #define VTERM_COLOR_IS_DEFAULT_BG(col) \
162 (!!((col)->type & VTERM_COLOR_DEFAULT_BG))
163
164 /**
165 * Returns true if the VTERM_COLOR_INVALID `type` flag is set, indicating
166 * that the given VTermColor instance is an invalid color.
167 */
168 #define VTERM_COLOR_IS_INVALID(col) (!!((col)->type & VTERM_COLOR_INVALID))
169
170 typedef struct {
171 /**
172 * Tag indicating which member is actually valid.
173 * Please use the `VTERM_COLOR_IS_*` test macros to check whether a
174 * particular type flag is set.
175 */
176 uint8_t type;
177
178 uint8_t red, green, blue;
179
180 uint8_t index;
181 } VTermColor;
182
183 /**
184 * Constructs a new VTermColor instance representing the given RGB values.
185 */
186 void vterm_color_rgb(VTermColor *col, uint8_t red, uint8_t green, uint8_t blue);
187
188 /**
189 * Construct a new VTermColor instance representing an indexed color with the
190 * given index.
191 */
192 void vterm_color_indexed(VTermColor *col, uint8_t idx);
193
194 /**
195 * Compares two colours. Returns true if the colors are equal, false otherwise.
196 */
197 int vterm_color_is_equal(const VTermColor *a, const VTermColor *b);
198
199 typedef enum {
200 /* VTERM_VALUETYPE_NONE = 0 */
201 VTERM_VALUETYPE_BOOL = 1,
202 VTERM_VALUETYPE_INT,
203 VTERM_VALUETYPE_STRING,
204 VTERM_VALUETYPE_COLOR,
205
206 VTERM_N_VALUETYPES
207 } VTermValueType;
208
209 typedef struct {
210 const char *str;
211 size_t len : 30;
212 unsigned int initial : 1;
213 unsigned int final : 1;
214 } VTermStringFragment;
215
216 typedef union {
217 int boolean;
218 int number;
219 VTermStringFragment string;
220 VTermColor color;
221 } VTermValue;
222
223 typedef enum {
224 /* VTERM_ATTR_NONE = 0 */
225 VTERM_ATTR_BOLD = 1, // bool: 1, 22
226 VTERM_ATTR_UNDERLINE, // number: 4, 21, 24
227 VTERM_ATTR_ITALIC, // bool: 3, 23
228 VTERM_ATTR_BLINK, // bool: 5, 25
229 VTERM_ATTR_REVERSE, // bool: 7, 27
230 VTERM_ATTR_CONCEAL, // bool: 8, 28
231 VTERM_ATTR_STRIKE, // bool: 9, 29
232 VTERM_ATTR_FONT, // number: 10-19
233 VTERM_ATTR_FOREGROUND, // color: 30-39 90-97
234 VTERM_ATTR_BACKGROUND, // color: 40-49 100-107
235
236 VTERM_N_ATTRS
237 } VTermAttr;
238
239 typedef enum {
240 /* VTERM_PROP_NONE = 0 */
241 VTERM_PROP_CURSORVISIBLE = 1, // bool
242 VTERM_PROP_CURSORBLINK, // bool
243 VTERM_PROP_ALTSCREEN, // bool
244 VTERM_PROP_TITLE, // string
245 VTERM_PROP_ICONNAME, // string
246 VTERM_PROP_REVERSE, // bool
247 VTERM_PROP_CURSORSHAPE, // number
248 VTERM_PROP_MOUSE, // number
249 VTERM_PROP_CURSORCOLOR, // string
250
251 VTERM_N_PROPS
252 } VTermProp;
253
254 enum {
255 VTERM_PROP_CURSORSHAPE_BLOCK = 1,
256 VTERM_PROP_CURSORSHAPE_UNDERLINE,
257 VTERM_PROP_CURSORSHAPE_BAR_LEFT,
258
259 VTERM_N_PROP_CURSORSHAPES
260 };
261
262 enum {
263 VTERM_PROP_MOUSE_NONE = 0,
264 VTERM_PROP_MOUSE_CLICK,
265 VTERM_PROP_MOUSE_DRAG,
266 VTERM_PROP_MOUSE_MOVE,
267
268 VTERM_N_PROP_MOUSES
269 };
270
271 typedef enum {
272 VTERM_SELECTION_CLIPBOARD = (1<<0),
273 VTERM_SELECTION_PRIMARY = (1<<1),
274 VTERM_SELECTION_SECONDARY = (1<<2),
275 VTERM_SELECTION_SELECT = (1<<3),
276 VTERM_SELECTION_CUT0 = (1<<4), /* also CUT1 .. CUT7 by bitshifting */
277 } VTermSelectionMask;
278
279 typedef struct {
280 const uint32_t *chars;
281 int width;
282 unsigned int protected_cell:1; /* DECSCA-protected against DECSEL/DECSED */
283 unsigned int dwl:1; /* DECDWL or DECDHL double-width line */
284 unsigned int dhl:2; /* DECDHL double-height line (1=top 2=bottom) */
285 } VTermGlyphInfo;
286
287 typedef struct {
288 unsigned int doublewidth:1; /* DECDWL or DECDHL line */
289 unsigned int doubleheight:2; /* DECDHL line (1=top 2=bottom) */
290 unsigned int continuation:1; /* Line is a flow continuation of the previous */
291 } VTermLineInfo;
292
293 /* Copies of VTermState fields that the 'resize' callback might have reason to
294 * edit. 'resize' callback gets total control of these fields and may
295 * free-and-reallocate them if required. They will be copied back from the
296 * struct after the callback has returned.
297 */
298 typedef struct {
299 VTermPos pos; /* current cursor position */
300 } VTermStateFields;
301
302 typedef struct {
303 /* libvterm relies on this memory to be zeroed out before it is returned
304 * by the allocator. */
305 void *(*malloc)(size_t size, void *allocdata);
306 void (*free)(void *ptr, void *allocdata);
307 } VTermAllocatorFunctions;
308
309 void vterm_check_version(int major, int minor);
310
311 // Allocate and initialize a new terminal with default allocators.
312 VTerm *vterm_new(int rows, int cols);
313
314 // Allocate and initialize a new terminal with specified allocators.
315 VTerm *vterm_new_with_allocator(int rows, int cols, VTermAllocatorFunctions *funcs, void *allocdata);
316
317 // Free and cleanup a terminal and all its data.
318 void vterm_free(VTerm* vt);
319
320 // Get the current size of the terminal and store in "rowsp" and "colsp".
321 void vterm_get_size(const VTerm *vt, int *rowsp, int *colsp);
322
323 void vterm_set_size(VTerm *vt, int rows, int cols);
324
325 int vterm_get_utf8(const VTerm *vt);
326 void vterm_set_utf8(VTerm *vt, int is_utf8);
327
328 size_t vterm_input_write(VTerm *vt, const char *bytes, size_t len);
329
330 /* Setting output callback will override the buffer logic */
331 typedef void VTermOutputCallback(const char *s, size_t len, void *user);
332 void vterm_output_set_callback(VTerm *vt, VTermOutputCallback *func, void *user);
333
334 /* These buffer functions only work if output callback is NOT set
335 * These are deprecated and will be removed in a later version */
336 size_t vterm_output_get_buffer_size(const VTerm *vt);
337 size_t vterm_output_get_buffer_current(const VTerm *vt);
338 size_t vterm_output_get_buffer_remaining(const VTerm *vt);
339
340 /* This too */
341 size_t vterm_output_read(VTerm *vt, char *buffer, size_t len);
342
343 int vterm_is_modify_other_keys(VTerm *vt);
344 void vterm_keyboard_unichar(VTerm *vt, uint32_t c, VTermModifier mod);
345 void vterm_keyboard_key(VTerm *vt, VTermKey key, VTermModifier mod);
346
347 void vterm_keyboard_start_paste(VTerm *vt);
348 void vterm_keyboard_end_paste(VTerm *vt);
349
350 void vterm_mouse_move(VTerm *vt, int row, int col, VTermModifier mod);
351 // "button" is 1 for left, 2 for middle, 3 for right.
352 // Button 4 is scroll wheel down, button 5 is scroll wheel up.
353 void vterm_mouse_button(VTerm *vt, int button, int pressed, VTermModifier mod);
354
355 // ------------
356 // Parser layer
357 // ------------
358
359 /* Flag to indicate non-final subparameters in a single CSI parameter.
360 * Consider
361 * CSI 1;2:3:4;5a
362 * 1 4 and 5 are final.
363 * 2 and 3 are non-final and will have this bit set
364 *
365 * Don't confuse this with the final byte of the CSI escape; 'a' in this case.
366 */
367 #define CSI_ARG_FLAG_MORE (1U<<31)
368 #define CSI_ARG_MASK (~(1U<<31))
369
370 #define CSI_ARG_HAS_MORE(a) ((a) & CSI_ARG_FLAG_MORE)
371 #define CSI_ARG(a) ((a) & CSI_ARG_MASK)
372
373 /* Can't use -1 to indicate a missing argument; use this instead */
374 #define CSI_ARG_MISSING ((1<<30)-1)
375
376 #define CSI_ARG_IS_MISSING(a) (CSI_ARG(a) == CSI_ARG_MISSING)
377 #define CSI_ARG_OR(a,def) (CSI_ARG(a) == CSI_ARG_MISSING ? (def) : CSI_ARG(a))
378 #define CSI_ARG_COUNT(a) (CSI_ARG(a) == CSI_ARG_MISSING || CSI_ARG(a) == 0 ? 1 : CSI_ARG(a))
379
380 typedef struct {
381 int (*text)(const char *bytes, size_t len, void *user);
382 int (*control)(unsigned char control, void *user);
383 int (*escape)(const char *bytes, size_t len, void *user);
384 int (*csi)(const char *leader, const long args[], int argcount, const char *intermed, char command, void *user);
385 int (*osc)(int command, VTermStringFragment frag, void *user);
386 int (*dcs)(const char *command, size_t commandlen, VTermStringFragment frag, void *user);
387 int (*apc)(VTermStringFragment frag, void *user);
388 int (*pm)(VTermStringFragment frag, void *user);
389 int (*sos)(VTermStringFragment frag, void *user);
390 int (*resize)(int rows, int cols, void *user);
391 } VTermParserCallbacks;
392
393 void vterm_parser_set_callbacks(VTerm *vt, const VTermParserCallbacks *callbacks, void *user);
394 void *vterm_parser_get_cbdata(VTerm *vt);
395
396 // -----------
397 // State layer
398 // -----------
399
400 typedef struct {
401 int (*putglyph)(VTermGlyphInfo *info, VTermPos pos, void *user);
402 int (*movecursor)(VTermPos pos, VTermPos oldpos, int visible, void *user);
403 int (*scrollrect)(VTermRect rect, int downward, int rightward, void *user);
404 int (*moverect)(VTermRect dest, VTermRect src, void *user);
405 int (*erase)(VTermRect rect, int selective, void *user);
406 int (*initpen)(void *user);
407 int (*setpenattr)(VTermAttr attr, VTermValue *val, void *user);
408 // Callback for setting various properties. Must return 1 if the property
409 // was accepted, 0 otherwise.
410 int (*settermprop)(VTermProp prop, VTermValue *val, void *user);
411 int (*bell)(void *user);
412 int (*resize)(int rows, int cols, VTermStateFields *fields, void *user);
413 int (*setlineinfo)(int row, const VTermLineInfo *newinfo, const VTermLineInfo *oldinfo, void *user);
414 } VTermStateCallbacks;
415
416 typedef struct {
417 VTermPos pos;
418 int buttons;
419 #define MOUSE_BUTTON_LEFT 0x01
420 #define MOUSE_BUTTON_MIDDLE 0x02
421 #define MOUSE_BUTTON_RIGHT 0x04
422 int flags;
423 #define MOUSE_WANT_CLICK 0x01
424 #define MOUSE_WANT_DRAG 0x02
425 #define MOUSE_WANT_MOVE 0x04
426 // useful to add protocol?
427 } VTermMouseState;
428
429 typedef struct {
430 int (*control)(unsigned char control, void *user);
431 int (*csi)(const char *leader, const long args[], int argcount, const char *intermed, char command, void *user);
432 int (*osc)(int command, VTermStringFragment frag, void *user);
433 int (*dcs)(const char *command, size_t commandlen, VTermStringFragment frag, void *user);
434 int (*apc)(VTermStringFragment frag, void *user);
435 int (*pm)(VTermStringFragment frag, void *user);
436 int (*sos)(VTermStringFragment frag, void *user);
437 } VTermStateFallbacks;
438
439 typedef struct {
440 int (*set)(VTermSelectionMask mask, VTermStringFragment frag, void *user);
441 int (*query)(VTermSelectionMask mask, void *user);
442 } VTermSelectionCallbacks;
443
444 VTermState *vterm_obtain_state(VTerm *vt);
445
446 void vterm_state_set_callbacks(VTermState *state, const VTermStateCallbacks *callbacks, void *user);
447 void *vterm_state_get_cbdata(VTermState *state);
448
449 void vterm_state_set_unrecognised_fallbacks(VTermState *state, const VTermStateFallbacks *fallbacks, void *user);
450 void *vterm_state_get_unrecognised_fbdata(VTermState *state);
451
452 // Initialize the state.
453 void vterm_state_reset(VTermState *state, int hard);
454
455 void vterm_state_get_cursorpos(const VTermState *state, VTermPos *cursorpos);
456 void vterm_state_get_mousestate(const VTermState *state, VTermMouseState *mousestate);
457 void vterm_state_get_default_colors(const VTermState *state, VTermColor *default_fg, VTermColor *default_bg);
458 void vterm_state_get_palette_color(const VTermState *state, int index, VTermColor *col);
459 void vterm_state_set_default_colors(VTermState *state, const VTermColor *default_fg, const VTermColor *default_bg);
460 void vterm_state_set_palette_color(VTermState *state, int index, const VTermColor *col);
461 void vterm_state_set_bold_highbright(VTermState *state, int bold_is_highbright);
462 int vterm_state_get_penattr(const VTermState *state, VTermAttr attr, VTermValue *val);
463 int vterm_state_set_termprop(VTermState *state, VTermProp prop, VTermValue *val);
464 void vterm_state_focus_in(VTermState *state);
465 void vterm_state_focus_out(VTermState *state);
466 const VTermLineInfo *vterm_state_get_lineinfo(const VTermState *state, int row);
467
468 /**
469 * Makes sure that the given color `col` is indeed an RGB colour. After this
470 * function returns, VTERM_COLOR_IS_RGB(col) will return true, while all other
471 * flags stored in `col->type` will have been reset.
472 *
473 * @param state is the VTermState instance from which the colour palette should
474 * be extracted.
475 * @param col is a pointer at the VTermColor instance that should be converted
476 * to an RGB colour.
477 */
478 void vterm_state_convert_color_to_rgb(const VTermState *state, VTermColor *col);
479
480 void vterm_state_set_selection_callbacks(VTermState *state, const VTermSelectionCallbacks *callbacks, void *user,
481 char *buffer, size_t buflen);
482
483 void vterm_state_send_selection(VTermState *state, VTermSelectionMask mask, VTermStringFragment frag);
484
485 // ------------
486 // Screen layer
487 // ------------
488
489 typedef struct {
490 unsigned int bold : 1;
491 unsigned int underline : 2;
492 unsigned int italic : 1;
493 unsigned int blink : 1;
494 unsigned int reverse : 1;
495 unsigned int conceal : 1;
496 unsigned int strike : 1;
497 unsigned int font : 4; /* 0 to 9 */
498 unsigned int dwl : 1; /* On a DECDWL or DECDHL line */
499 unsigned int dhl : 2; /* On a DECDHL line (1=top 2=bottom) */
500 } VTermScreenCellAttrs;
501
502 enum {
503 VTERM_UNDERLINE_OFF,
504 VTERM_UNDERLINE_SINGLE,
505 VTERM_UNDERLINE_DOUBLE,
506 VTERM_UNDERLINE_CURLY,
507 };
508
509 typedef struct {
510 #define VTERM_MAX_CHARS_PER_CELL 6
511 uint32_t chars[VTERM_MAX_CHARS_PER_CELL];
512 char width;
513 VTermScreenCellAttrs attrs;
514 VTermColor fg, bg;
515 } VTermScreenCell;
516
517 // All fields are optional, NULL when not used.
518 typedef struct {
519 int (*damage)(VTermRect rect, void *user);
520 int (*moverect)(VTermRect dest, VTermRect src, void *user);
521 int (*movecursor)(VTermPos pos, VTermPos oldpos, int visible, void *user);
522 int (*settermprop)(VTermProp prop, VTermValue *val, void *user);
523 int (*bell)(void *user);
524 int (*resize)(int rows, int cols, void *user);
525 // A line was pushed off the top of the window.
526 // "cells[cols]" contains the cells of that line.
527 // Return value is unused.
528 int (*sb_pushline)(int cols, const VTermScreenCell *cells, void *user);
529 int (*sb_popline)(int cols, VTermScreenCell *cells, void *user);
530 } VTermScreenCallbacks;
531
532 // Return the screen of the vterm.
533 VTermScreen *vterm_obtain_screen(VTerm *vt);
534
535 /*
536 * Install screen callbacks. These are invoked when the screen contents is
537 * changed. "user" is passed into to the callback.
538 */
539 void vterm_screen_set_callbacks(VTermScreen *screen, const VTermScreenCallbacks *callbacks, void *user);
540 void *vterm_screen_get_cbdata(VTermScreen *screen);
541
542 void vterm_screen_set_unrecognised_fallbacks(VTermScreen *screen, const VTermStateFallbacks *fallbacks, void *user);
543 void *vterm_screen_get_unrecognised_fbdata(VTermScreen *screen);
544
545 // Enable support for using the alternate screen if "altscreen" is non-zero.
546 // Before that switching to the alternate screen won't work.
547 // Calling with "altscreen" zero has no effect.
548 void vterm_screen_enable_altscreen(VTermScreen *screen, int altscreen);
549
550 typedef enum {
551 VTERM_DAMAGE_CELL, /* every cell */
552 VTERM_DAMAGE_ROW, /* entire rows */
553 VTERM_DAMAGE_SCREEN, /* entire screen */
554 VTERM_DAMAGE_SCROLL, /* entire screen + scrollrect */
555
556 VTERM_N_DAMAGES
557 } VTermDamageSize;
558
559 // Invoke the relevant callbacks to update the screen.
560 void vterm_screen_flush_damage(VTermScreen *screen);
561
562 void vterm_screen_set_damage_merge(VTermScreen *screen, VTermDamageSize size);
563
564 /*
565 * Reset the screen. Also invokes vterm_state_reset().
566 * Must be called before the terminal can be used.
567 */
568 void vterm_screen_reset(VTermScreen *screen, int hard);
569
570 /* Neither of these functions NUL-terminate the buffer */
571 size_t vterm_screen_get_chars(const VTermScreen *screen, uint32_t *chars, size_t len, const VTermRect rect);
572 size_t vterm_screen_get_text(const VTermScreen *screen, char *str, size_t len, const VTermRect rect);
573
574 typedef enum {
575 VTERM_ATTR_BOLD_MASK = 1 << 0,
576 VTERM_ATTR_UNDERLINE_MASK = 1 << 1,
577 VTERM_ATTR_ITALIC_MASK = 1 << 2,
578 VTERM_ATTR_BLINK_MASK = 1 << 3,
579 VTERM_ATTR_REVERSE_MASK = 1 << 4,
580 VTERM_ATTR_STRIKE_MASK = 1 << 5,
581 VTERM_ATTR_FONT_MASK = 1 << 6,
582 VTERM_ATTR_FOREGROUND_MASK = 1 << 7,
583 VTERM_ATTR_BACKGROUND_MASK = 1 << 8,
584 VTERM_ATTR_CONCEAL_MASK = 1 << 9,
585
586 VTERM_ALL_ATTRS_MASK = (1 << 10) - 1
587 } VTermAttrMask;
588
589 int vterm_screen_get_attrs_extent(const VTermScreen *screen, VTermRect *extent, VTermPos pos, VTermAttrMask attrs);
590
591 int vterm_screen_get_cell(const VTermScreen *screen, VTermPos pos, VTermScreenCell *cell);
592
593 int vterm_screen_is_eol(const VTermScreen *screen, VTermPos pos);
594
595 /**
596 * Same as vterm_state_convert_color_to_rgb(), but takes a `screen` instead of a `state`
597 * instance.
598 */
599 void vterm_screen_convert_color_to_rgb(const VTermScreen *screen, VTermColor *col);
600
601 // ---------
602 // Utilities
603 // ---------
604
605 VTermValueType vterm_get_attr_type(VTermAttr attr);
606 VTermValueType vterm_get_prop_type(VTermProp prop);
607
608 void vterm_scroll_rect(VTermRect rect,
609 int downward,
610 int rightward,
611 int (*moverect)(VTermRect src, VTermRect dest, void *user),
612 int (*eraserect)(VTermRect rect, int selective, void *user),
613 void *user);
614
615 void vterm_copy_cells(VTermRect dest,
616 VTermRect src,
617 void (*copycell)(VTermPos dest, VTermPos src, void *user),
618 void *user);
619
620 #ifdef __cplusplus
621 }
622 #endif
623
624 #endif
625