blob: b06952195e3eef7054c598a602637ee1b378df85 [file] [log] [blame]
Bram Moolenaare4f25e42017-07-07 11:54:15 +02001/*
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
8extern "C" {
9#endif
10
Bram Moolenaare4f25e42017-07-07 11:54:15 +020011#include <stdlib.h>
Bram Moolenaare4f25e42017-07-07 11:54:15 +020012
13#include "vterm_keycodes.h"
14
Bram Moolenaarb2a76ec2017-07-25 21:34:46 +020015#define TRUE 1
16#define FALSE 0
17
Bram Moolenaardb1085a2019-08-18 20:41:38 +020018// from stdint.h
Bram Moolenaar607985a2017-07-28 17:04:15 +020019typedef unsigned char uint8_t;
20typedef unsigned int uint32_t;
21
Bram Moolenaare4f25e42017-07-07 11:54:15 +020022typedef struct VTerm VTerm;
23typedef struct VTermState VTermState;
24typedef struct VTermScreen VTermScreen;
25
Bram Moolenaardb1085a2019-08-18 20:41:38 +020026// Specifies a screen point.
Bram Moolenaare4f25e42017-07-07 11:54:15 +020027typedef struct {
28 int row;
29 int col;
30} VTermPos;
31
32/*
33 * Some small utility functions; we can just keep these static here.
34 */
35
36/*
37 * Order points by on-screen flow order:
38 * Return < 0 if "a" is before "b"
39 * Return 0 if "a" and "b" are equal
40 * Return > 0 if "a" is after "b".
41 */
42int vterm_pos_cmp(VTermPos a, VTermPos b);
43
44#if defined(DEFINE_INLINES) || USE_INLINE
45INLINE int vterm_pos_cmp(VTermPos a, VTermPos b)
46{
47 return (a.row == b.row) ? a.col - b.col : a.row - b.row;
48}
49#endif
50
Bram Moolenaardb1085a2019-08-18 20:41:38 +020051// Specifies a rectangular screen area.
Bram Moolenaare4f25e42017-07-07 11:54:15 +020052typedef struct {
53 int start_row;
54 int end_row;
55 int start_col;
56 int end_col;
57} VTermRect;
58
Bram Moolenaardb1085a2019-08-18 20:41:38 +020059// Return true if the rect "r" contains the point "p".
Bram Moolenaare4f25e42017-07-07 11:54:15 +020060int vterm_rect_contains(VTermRect r, VTermPos p);
61
62#if defined(DEFINE_INLINES) || USE_INLINE
63INLINE int vterm_rect_contains(VTermRect r, VTermPos p)
64{
65 return p.row >= r.start_row && p.row < r.end_row &&
66 p.col >= r.start_col && p.col < r.end_col;
67}
68#endif
69
Bram Moolenaardb1085a2019-08-18 20:41:38 +020070// Move "rect" "row_delta" down and "col_delta" right.
71// Does not check boundaries.
Bram Moolenaare4f25e42017-07-07 11:54:15 +020072void vterm_rect_move(VTermRect *rect, int row_delta, int col_delta);
73
74#if defined(DEFINE_INLINES) || USE_INLINE
75INLINE void vterm_rect_move(VTermRect *rect, int row_delta, int col_delta)
76{
77 rect->start_row += row_delta; rect->end_row += row_delta;
78 rect->start_col += col_delta; rect->end_col += col_delta;
79}
80#endif
81
Bram Moolenaardb1085a2019-08-18 20:41:38 +020082// The ansi_index is used for the lower 16 colors, which can be set to any
83// color.
84#define VTERM_ANSI_INDEX_DEFAULT 0 // color cleared
Bram Moolenaar46359e12017-11-29 22:33:38 +010085#define VTERM_ANSI_INDEX_MIN 1
86#define VTERM_ANSI_INDEX_MAX 16
Bram Moolenaardb1085a2019-08-18 20:41:38 +020087#define VTERM_ANSI_INDEX_NONE 255 // non-ANSI color, use red/green/blue
Bram Moolenaar46359e12017-11-29 22:33:38 +010088
Bram Moolenaare4f25e42017-07-07 11:54:15 +020089typedef struct {
90 uint8_t red, green, blue;
Bram Moolenaar46359e12017-11-29 22:33:38 +010091 uint8_t ansi_index;
Bram Moolenaare4f25e42017-07-07 11:54:15 +020092} VTermColor;
93
94typedef enum {
Bram Moolenaardb1085a2019-08-18 20:41:38 +020095 // VTERM_VALUETYPE_NONE = 0
Bram Moolenaare4f25e42017-07-07 11:54:15 +020096 VTERM_VALUETYPE_BOOL = 1,
97 VTERM_VALUETYPE_INT,
98 VTERM_VALUETYPE_STRING,
Bram Moolenaarb5b49a32018-03-25 16:20:37 +020099 VTERM_VALUETYPE_COLOR,
100
101 VTERM_N_VALUETYPES
Bram Moolenaare4f25e42017-07-07 11:54:15 +0200102} VTermValueType;
103
104typedef union {
105 int boolean;
106 int number;
107 char *string;
108 VTermColor color;
109} VTermValue;
110
111typedef enum {
Bram Moolenaardb1085a2019-08-18 20:41:38 +0200112 // VTERM_ATTR_NONE = 0
Bram Moolenaarb691de02018-04-24 18:39:14 +0200113 VTERM_ATTR_BOLD = 1, // bool: 1, 22
114 VTERM_ATTR_UNDERLINE, // number: 4, 21, 24
115 VTERM_ATTR_ITALIC, // bool: 3, 23
116 VTERM_ATTR_BLINK, // bool: 5, 25
117 VTERM_ATTR_REVERSE, // bool: 7, 27
118 VTERM_ATTR_STRIKE, // bool: 9, 29
119 VTERM_ATTR_FONT, // number: 10-19
120 VTERM_ATTR_FOREGROUND, // color: 30-39 90-97
121 VTERM_ATTR_BACKGROUND, // color: 40-49 100-107
Bram Moolenaarb5b49a32018-03-25 16:20:37 +0200122
123 VTERM_N_ATTRS
Bram Moolenaare4f25e42017-07-07 11:54:15 +0200124} VTermAttr;
125
126typedef enum {
Bram Moolenaardb1085a2019-08-18 20:41:38 +0200127 // VTERM_PROP_NONE = 0
Bram Moolenaarb691de02018-04-24 18:39:14 +0200128 VTERM_PROP_CURSORVISIBLE = 1, // bool
129 VTERM_PROP_CURSORBLINK, // bool
130 VTERM_PROP_ALTSCREEN, // bool
131 VTERM_PROP_TITLE, // string
132 VTERM_PROP_ICONNAME, // string
133 VTERM_PROP_REVERSE, // bool
134 VTERM_PROP_CURSORSHAPE, // number
135 VTERM_PROP_MOUSE, // number
136 VTERM_PROP_CURSORCOLOR, // string
Bram Moolenaarb5b49a32018-03-25 16:20:37 +0200137
138 VTERM_N_PROPS
Bram Moolenaare4f25e42017-07-07 11:54:15 +0200139} VTermProp;
140
141enum {
142 VTERM_PROP_CURSORSHAPE_BLOCK = 1,
143 VTERM_PROP_CURSORSHAPE_UNDERLINE,
Bram Moolenaarb5b49a32018-03-25 16:20:37 +0200144 VTERM_PROP_CURSORSHAPE_BAR_LEFT,
145
146 VTERM_N_PROP_CURSORSHAPES
Bram Moolenaare4f25e42017-07-07 11:54:15 +0200147};
148
149enum {
150 VTERM_PROP_MOUSE_NONE = 0,
151 VTERM_PROP_MOUSE_CLICK,
152 VTERM_PROP_MOUSE_DRAG,
Bram Moolenaarb5b49a32018-03-25 16:20:37 +0200153 VTERM_PROP_MOUSE_MOVE,
154
155 VTERM_N_PROP_MOUSES
Bram Moolenaare4f25e42017-07-07 11:54:15 +0200156};
157
158typedef struct {
159 const uint32_t *chars;
160 int width;
Bram Moolenaardb1085a2019-08-18 20:41:38 +0200161 unsigned int protected_cell:1; // DECSCA-protected against DECSEL/DECSED
162 unsigned int dwl:1; // DECDWL or DECDHL double-width line
163 unsigned int dhl:2; // DECDHL double-height line (1=top 2=bottom)
Bram Moolenaare4f25e42017-07-07 11:54:15 +0200164} VTermGlyphInfo;
165
166typedef struct {
Bram Moolenaardb1085a2019-08-18 20:41:38 +0200167 unsigned int doublewidth:1; // DECDWL or DECDHL line
168 unsigned int doubleheight:2; // DECDHL line (1=top 2=bottom)
Bram Moolenaare4f25e42017-07-07 11:54:15 +0200169} VTermLineInfo;
170
171typedef struct {
Bram Moolenaardb1085a2019-08-18 20:41:38 +0200172 // libvterm relies on the allocated memory to be zeroed out before it is
173 // returned by the allocator.
Bram Moolenaare4f25e42017-07-07 11:54:15 +0200174 void *(*malloc)(size_t size, void *allocdata);
175 void (*free)(void *ptr, void *allocdata);
176} VTermAllocatorFunctions;
177
Bram Moolenaardb1085a2019-08-18 20:41:38 +0200178// Allocate and initialize a new terminal with default allocators.
Bram Moolenaare4f25e42017-07-07 11:54:15 +0200179VTerm *vterm_new(int rows, int cols);
180
Bram Moolenaardb1085a2019-08-18 20:41:38 +0200181// Allocate and initialize a new terminal with specified allocators.
Bram Moolenaare4f25e42017-07-07 11:54:15 +0200182VTerm *vterm_new_with_allocator(int rows, int cols, VTermAllocatorFunctions *funcs, void *allocdata);
183
Bram Moolenaardb1085a2019-08-18 20:41:38 +0200184// Free and cleanup a terminal and all its data.
Bram Moolenaare4f25e42017-07-07 11:54:15 +0200185void vterm_free(VTerm* vt);
186
Bram Moolenaardb1085a2019-08-18 20:41:38 +0200187// Get the current size of the terminal and store in "rowsp" and "colsp".
Bram Moolenaare4f25e42017-07-07 11:54:15 +0200188void vterm_get_size(const VTerm *vt, int *rowsp, int *colsp);
Bram Moolenaar9cc5f752017-07-23 22:07:27 +0200189
Bram Moolenaare4f25e42017-07-07 11:54:15 +0200190void vterm_set_size(VTerm *vt, int rows, int cols);
191
192int vterm_get_utf8(const VTerm *vt);
193void vterm_set_utf8(VTerm *vt, int is_utf8);
194
195size_t vterm_input_write(VTerm *vt, const char *bytes, size_t len);
196
Bram Moolenaar94d729c2020-05-17 21:50:16 +0200197/* Setting output callback will override the buffer logic */
198typedef void VTermOutputCallback(const char *s, size_t len, void *user);
199void vterm_output_set_callback(VTerm *vt, VTermOutputCallback *func, void *user);
200
201/* These buffer functions only work if output callback is NOT set
202 * These are deprecated and will be removed in a later version */
Bram Moolenaare4f25e42017-07-07 11:54:15 +0200203size_t vterm_output_get_buffer_size(const VTerm *vt);
204size_t vterm_output_get_buffer_current(const VTerm *vt);
205size_t vterm_output_get_buffer_remaining(const VTerm *vt);
206
Bram Moolenaar94d729c2020-05-17 21:50:16 +0200207/* This too */
Bram Moolenaare4f25e42017-07-07 11:54:15 +0200208size_t vterm_output_read(VTerm *vt, char *buffer, size_t len);
209
Bram Moolenaar6a0299d2019-10-10 21:14:03 +0200210int vterm_is_modify_other_keys(VTerm *vt);
Bram Moolenaare4f25e42017-07-07 11:54:15 +0200211void vterm_keyboard_unichar(VTerm *vt, uint32_t c, VTermModifier mod);
212void vterm_keyboard_key(VTerm *vt, VTermKey key, VTermModifier mod);
213
214void vterm_keyboard_start_paste(VTerm *vt);
215void vterm_keyboard_end_paste(VTerm *vt);
216
217void vterm_mouse_move(VTerm *vt, int row, int col, VTermModifier mod);
Bram Moolenaardb1085a2019-08-18 20:41:38 +0200218// "button" is 1 for left, 2 for middle, 3 for right.
219// Button 4 is scroll wheel down, button 5 is scroll wheel up.
Bram Moolenaarb2a76ec2017-07-25 21:34:46 +0200220void vterm_mouse_button(VTerm *vt, int button, int pressed, VTermModifier mod);
Bram Moolenaare4f25e42017-07-07 11:54:15 +0200221
Bram Moolenaarb691de02018-04-24 18:39:14 +0200222// ------------
223// Parser layer
224// ------------
Bram Moolenaare4f25e42017-07-07 11:54:15 +0200225
Bram Moolenaar707d2262019-12-04 22:16:54 +0100226// Flag to indicate non-final subparameters in a single CSI parameter.
227// Consider
228// CSI 1;2:3:4;5a
229// 1 4 and 5 are final.
230// 2 and 3 are non-final and will have this bit set
231//
232// Don't confuse this with the final byte of the CSI escape; 'a' in this case.
Bram Moolenaarb5b49a32018-03-25 16:20:37 +0200233#define CSI_ARG_FLAG_MORE (1U<<31)
234#define CSI_ARG_MASK (~(1U<<31))
Bram Moolenaare4f25e42017-07-07 11:54:15 +0200235
236#define CSI_ARG_HAS_MORE(a) ((a) & CSI_ARG_FLAG_MORE)
237#define CSI_ARG(a) ((a) & CSI_ARG_MASK)
238
Bram Moolenaardb1085a2019-08-18 20:41:38 +0200239// Can't use -1 to indicate a missing argument; use this instead
Bram Moolenaar9cc5f752017-07-23 22:07:27 +0200240#define CSI_ARG_MISSING ((1<<30)-1)
Bram Moolenaare4f25e42017-07-07 11:54:15 +0200241
242#define CSI_ARG_IS_MISSING(a) (CSI_ARG(a) == CSI_ARG_MISSING)
243#define CSI_ARG_OR(a,def) (CSI_ARG(a) == CSI_ARG_MISSING ? (def) : CSI_ARG(a))
244#define CSI_ARG_COUNT(a) (CSI_ARG(a) == CSI_ARG_MISSING || CSI_ARG(a) == 0 ? 1 : CSI_ARG(a))
245
246typedef struct {
247 int (*text)(const char *bytes, size_t len, void *user);
248 int (*control)(unsigned char control, void *user);
249 int (*escape)(const char *bytes, size_t len, void *user);
250 int (*csi)(const char *leader, const long args[], int argcount, const char *intermed, char command, void *user);
251 int (*osc)(const char *command, size_t cmdlen, void *user);
252 int (*dcs)(const char *command, size_t cmdlen, void *user);
253 int (*resize)(int rows, int cols, void *user);
254} VTermParserCallbacks;
255
256void vterm_parser_set_callbacks(VTerm *vt, const VTermParserCallbacks *callbacks, void *user);
257void *vterm_parser_get_cbdata(VTerm *vt);
258
Bram Moolenaarb691de02018-04-24 18:39:14 +0200259// -----------
260// State layer
261// -----------
Bram Moolenaare4f25e42017-07-07 11:54:15 +0200262
263typedef struct {
264 int (*putglyph)(VTermGlyphInfo *info, VTermPos pos, void *user);
265 int (*movecursor)(VTermPos pos, VTermPos oldpos, int visible, void *user);
266 int (*scrollrect)(VTermRect rect, int downward, int rightward, void *user);
267 int (*moverect)(VTermRect dest, VTermRect src, void *user);
268 int (*erase)(VTermRect rect, int selective, void *user);
269 int (*initpen)(void *user);
270 int (*setpenattr)(VTermAttr attr, VTermValue *val, void *user);
Bram Moolenaardb1085a2019-08-18 20:41:38 +0200271 // Callback for setting various properties. Must return 1 if the property
272 // was accepted, 0 otherwise.
Bram Moolenaare4f25e42017-07-07 11:54:15 +0200273 int (*settermprop)(VTermProp prop, VTermValue *val, void *user);
274 int (*bell)(void *user);
275 int (*resize)(int rows, int cols, VTermPos *delta, void *user);
276 int (*setlineinfo)(int row, const VTermLineInfo *newinfo, const VTermLineInfo *oldinfo, void *user);
277} VTermStateCallbacks;
278
Bram Moolenaarc48369c2018-03-11 19:30:45 +0100279typedef struct {
280 VTermPos pos;
281 int buttons;
282#define MOUSE_BUTTON_LEFT 0x01
283#define MOUSE_BUTTON_MIDDLE 0x02
284#define MOUSE_BUTTON_RIGHT 0x04
285 int flags;
286#define MOUSE_WANT_CLICK 0x01
287#define MOUSE_WANT_DRAG 0x02
288#define MOUSE_WANT_MOVE 0x04
Bram Moolenaardb1085a2019-08-18 20:41:38 +0200289 // useful to add protocol?
Bram Moolenaarc48369c2018-03-11 19:30:45 +0100290} VTermMouseState;
291
Bram Moolenaare4f25e42017-07-07 11:54:15 +0200292VTermState *vterm_obtain_state(VTerm *vt);
293
294void vterm_state_set_callbacks(VTermState *state, const VTermStateCallbacks *callbacks, void *user);
295void *vterm_state_get_cbdata(VTermState *state);
296
Bram Moolenaarb691de02018-04-24 18:39:14 +0200297// Only invokes control, csi, osc, dcs
Bram Moolenaare4f25e42017-07-07 11:54:15 +0200298void vterm_state_set_unrecognised_fallbacks(VTermState *state, const VTermParserCallbacks *fallbacks, void *user);
299void *vterm_state_get_unrecognised_fbdata(VTermState *state);
300
Bram Moolenaardb1085a2019-08-18 20:41:38 +0200301// Initialize the state.
Bram Moolenaare4f25e42017-07-07 11:54:15 +0200302void vterm_state_reset(VTermState *state, int hard);
Bram Moolenaar9cc5f752017-07-23 22:07:27 +0200303
Bram Moolenaare4f25e42017-07-07 11:54:15 +0200304void vterm_state_get_cursorpos(const VTermState *state, VTermPos *cursorpos);
Bram Moolenaarc48369c2018-03-11 19:30:45 +0100305void vterm_state_get_mousestate(const VTermState *state, VTermMouseState *mousestate);
Bram Moolenaare4f25e42017-07-07 11:54:15 +0200306void vterm_state_get_default_colors(const VTermState *state, VTermColor *default_fg, VTermColor *default_bg);
307void vterm_state_get_palette_color(const VTermState *state, int index, VTermColor *col);
308void vterm_state_set_default_colors(VTermState *state, const VTermColor *default_fg, const VTermColor *default_bg);
309void vterm_state_set_palette_color(VTermState *state, int index, const VTermColor *col);
310void vterm_state_set_bold_highbright(VTermState *state, int bold_is_highbright);
311int vterm_state_get_penattr(const VTermState *state, VTermAttr attr, VTermValue *val);
312int vterm_state_set_termprop(VTermState *state, VTermProp prop, VTermValue *val);
Bram Moolenaarb5b49a32018-03-25 16:20:37 +0200313void vterm_state_focus_in(VTermState *state);
314void vterm_state_focus_out(VTermState *state);
Bram Moolenaare4f25e42017-07-07 11:54:15 +0200315const VTermLineInfo *vterm_state_get_lineinfo(const VTermState *state, int row);
316
Bram Moolenaarb691de02018-04-24 18:39:14 +0200317// ------------
318// Screen layer
319// ------------
Bram Moolenaare4f25e42017-07-07 11:54:15 +0200320
321typedef struct {
322 unsigned int bold : 1;
323 unsigned int underline : 2;
324 unsigned int italic : 1;
325 unsigned int blink : 1;
326 unsigned int reverse : 1;
327 unsigned int strike : 1;
Bram Moolenaardb1085a2019-08-18 20:41:38 +0200328 unsigned int font : 4; // 0 to 9
329 unsigned int dwl : 1; // On a DECDWL or DECDHL line
330 unsigned int dhl : 2; // On a DECDHL line (1=top 2=bottom)
Bram Moolenaare4f25e42017-07-07 11:54:15 +0200331} VTermScreenCellAttrs;
332
333typedef struct {
334#define VTERM_MAX_CHARS_PER_CELL 6
335 uint32_t chars[VTERM_MAX_CHARS_PER_CELL];
336 char width;
337 VTermScreenCellAttrs attrs;
338 VTermColor fg, bg;
339} VTermScreenCell;
340
Bram Moolenaardb1085a2019-08-18 20:41:38 +0200341// All fields are optional, NULL when not used.
Bram Moolenaare4f25e42017-07-07 11:54:15 +0200342typedef struct {
343 int (*damage)(VTermRect rect, void *user);
344 int (*moverect)(VTermRect dest, VTermRect src, void *user);
345 int (*movecursor)(VTermPos pos, VTermPos oldpos, int visible, void *user);
346 int (*settermprop)(VTermProp prop, VTermValue *val, void *user);
347 int (*bell)(void *user);
348 int (*resize)(int rows, int cols, void *user);
Bram Moolenaardb1085a2019-08-18 20:41:38 +0200349 // A line was pushed off the top of the window.
350 // "cells[cols]" contains the cells of that line.
351 // Return value is unused.
Bram Moolenaare4f25e42017-07-07 11:54:15 +0200352 int (*sb_pushline)(int cols, const VTermScreenCell *cells, void *user);
353 int (*sb_popline)(int cols, VTermScreenCell *cells, void *user);
354} VTermScreenCallbacks;
355
Bram Moolenaardb1085a2019-08-18 20:41:38 +0200356// Return the screen of the vterm.
Bram Moolenaare4f25e42017-07-07 11:54:15 +0200357VTermScreen *vterm_obtain_screen(VTerm *vt);
358
359/*
360 * Install screen callbacks. These are invoked when the screen contents is
361 * changed. "user" is passed into to the callback.
362 */
363void vterm_screen_set_callbacks(VTermScreen *screen, const VTermScreenCallbacks *callbacks, void *user);
364void *vterm_screen_get_cbdata(VTermScreen *screen);
365
Bram Moolenaar707d2262019-12-04 22:16:54 +0100366// Only invokes control, csi, osc, dcs
Bram Moolenaare4f25e42017-07-07 11:54:15 +0200367void vterm_screen_set_unrecognised_fallbacks(VTermScreen *screen, const VTermParserCallbacks *fallbacks, void *user);
368void *vterm_screen_get_unrecognised_fbdata(VTermScreen *screen);
369
Bram Moolenaardb1085a2019-08-18 20:41:38 +0200370// Enable support for using the alternate screen if "altscreen" is non-zero.
371// Before that switching to the alternate screen won't work.
372// Calling with "altscreen" zero has no effect.
Bram Moolenaare4f25e42017-07-07 11:54:15 +0200373void vterm_screen_enable_altscreen(VTermScreen *screen, int altscreen);
374
375typedef enum {
Bram Moolenaardb1085a2019-08-18 20:41:38 +0200376 VTERM_DAMAGE_CELL, // every cell
377 VTERM_DAMAGE_ROW, // entire rows
378 VTERM_DAMAGE_SCREEN, // entire screen
379 VTERM_DAMAGE_SCROLL, // entire screen + scrollrect
Bram Moolenaarb5b49a32018-03-25 16:20:37 +0200380
381 VTERM_N_DAMAGES
Bram Moolenaare4f25e42017-07-07 11:54:15 +0200382} VTermDamageSize;
383
Bram Moolenaardb1085a2019-08-18 20:41:38 +0200384// Invoke the relevant callbacks to update the screen.
Bram Moolenaare4f25e42017-07-07 11:54:15 +0200385void vterm_screen_flush_damage(VTermScreen *screen);
Bram Moolenaar9cc5f752017-07-23 22:07:27 +0200386
Bram Moolenaare4f25e42017-07-07 11:54:15 +0200387void vterm_screen_set_damage_merge(VTermScreen *screen, VTermDamageSize size);
388
Bram Moolenaar9cc5f752017-07-23 22:07:27 +0200389/*
390 * Reset the screen. Also invokes vterm_state_reset().
391 * Must be called before the terminal can be used.
392 */
Bram Moolenaare4f25e42017-07-07 11:54:15 +0200393void vterm_screen_reset(VTermScreen *screen, int hard);
394
Bram Moolenaardb1085a2019-08-18 20:41:38 +0200395// Neither of these functions NUL-terminate the buffer
Bram Moolenaare4f25e42017-07-07 11:54:15 +0200396size_t vterm_screen_get_chars(const VTermScreen *screen, uint32_t *chars, size_t len, const VTermRect rect);
397size_t vterm_screen_get_text(const VTermScreen *screen, char *str, size_t len, const VTermRect rect);
398
399typedef enum {
400 VTERM_ATTR_BOLD_MASK = 1 << 0,
401 VTERM_ATTR_UNDERLINE_MASK = 1 << 1,
402 VTERM_ATTR_ITALIC_MASK = 1 << 2,
403 VTERM_ATTR_BLINK_MASK = 1 << 3,
404 VTERM_ATTR_REVERSE_MASK = 1 << 4,
405 VTERM_ATTR_STRIKE_MASK = 1 << 5,
406 VTERM_ATTR_FONT_MASK = 1 << 6,
407 VTERM_ATTR_FOREGROUND_MASK = 1 << 7,
Bram Moolenaarb5b49a32018-03-25 16:20:37 +0200408 VTERM_ATTR_BACKGROUND_MASK = 1 << 8,
409
410 VTERM_ALL_ATTRS_MASK = (1 << 9) - 1
Bram Moolenaare4f25e42017-07-07 11:54:15 +0200411} VTermAttrMask;
412
413int vterm_screen_get_attrs_extent(const VTermScreen *screen, VTermRect *extent, VTermPos pos, VTermAttrMask attrs);
414
415int vterm_screen_get_cell(const VTermScreen *screen, VTermPos pos, VTermScreenCell *cell);
416
417int vterm_screen_is_eol(const VTermScreen *screen, VTermPos pos);
418
Bram Moolenaarb691de02018-04-24 18:39:14 +0200419// ---------
420// Utilities
421// ---------
Bram Moolenaare4f25e42017-07-07 11:54:15 +0200422
423VTermValueType vterm_get_attr_type(VTermAttr attr);
424VTermValueType vterm_get_prop_type(VTermProp prop);
425
426void vterm_scroll_rect(VTermRect rect,
427 int downward,
428 int rightward,
429 int (*moverect)(VTermRect src, VTermRect dest, void *user),
430 int (*eraserect)(VTermRect rect, int selective, void *user),
431 void *user);
432
433void vterm_copy_cells(VTermRect dest,
434 VTermRect src,
435 void (*copycell)(VTermPos dest, VTermPos src, void *user),
436 void *user);
437
438#ifdef __cplusplus
439}
440#endif
441
442#endif