comparison src/libvterm/include/vterm.h @ 20518:a4652d7ec99f v8.2.0813

patch 8.2.0813: libvterm code is slightly different from upstream Commit: https://github.com/vim/vim/commit/591cec8366e87a172495c362477cbf5de8d399f0 Author: Bram Moolenaar <Bram@vim.org> Date: Fri May 22 22:06:06 2020 +0200 patch 8.2.0813: libvterm code is slightly different from upstream Problem: libvterm code is slightly different from upstream. Solution: Use upstream text to avoid future merge problems. Mainly comment style changes.
author Bram Moolenaar <Bram@vim.org>
date Fri, 22 May 2020 22:15:04 +0200
parents 03826c672315
children c83460a14407
comparison
equal deleted inserted replaced
20517:a7c6cd0d7ba0 20518:a4652d7ec99f
33 typedef struct { 33 typedef struct {
34 int row; 34 int row;
35 int col; 35 int col;
36 } VTermPos; 36 } VTermPos;
37 37
38 /* 38 /* some small utility functions; we can just keep these static here */
39 * Some small utility functions; we can just keep these static here.
40 */
41 39
42 /* 40 /*
43 * Order points by on-screen flow order: 41 * Order points by on-screen flow order:
44 * Return < 0 if "a" is before "b" 42 * Return < 0 if "a" is before "b"
45 * Return 0 if "a" and "b" are equal 43 * Return 0 if "a" and "b" are equal
60 int end_row; 58 int end_row;
61 int start_col; 59 int start_col;
62 int end_col; 60 int end_col;
63 } VTermRect; 61 } VTermRect;
64 62
65 // Return true if the rect "r" contains the point "p". 63 /* true if the rect contains the point */
66 int vterm_rect_contains(VTermRect r, VTermPos p); 64 int vterm_rect_contains(VTermRect r, VTermPos p);
67 65
68 #if defined(DEFINE_INLINES) || USE_INLINE 66 #if defined(DEFINE_INLINES) || USE_INLINE
69 INLINE int vterm_rect_contains(VTermRect r, VTermPos p) 67 INLINE int vterm_rect_contains(VTermRect r, VTermPos p)
70 { 68 {
71 return p.row >= r.start_row && p.row < r.end_row && 69 return p.row >= r.start_row && p.row < r.end_row &&
72 p.col >= r.start_col && p.col < r.end_col; 70 p.col >= r.start_col && p.col < r.end_col;
73 } 71 }
74 #endif 72 #endif
75 73
74 /* move a rect */
76 // Move "rect" "row_delta" down and "col_delta" right. 75 // Move "rect" "row_delta" down and "col_delta" right.
77 // Does not check boundaries. 76 // Does not check boundaries.
78 void vterm_rect_move(VTermRect *rect, int row_delta, int col_delta); 77 void vterm_rect_move(VTermRect *rect, int row_delta, int col_delta);
79 78
80 #if defined(DEFINE_INLINES) || USE_INLINE 79 #if defined(DEFINE_INLINES) || USE_INLINE
183 /** 182 /**
184 * Compares two colours. Returns true if the colors are equal, false otherwise. 183 * Compares two colours. Returns true if the colors are equal, false otherwise.
185 */ 184 */
186 int vterm_color_is_equal(const VTermColor *a, const VTermColor *b); 185 int vterm_color_is_equal(const VTermColor *a, const VTermColor *b);
187 186
188
189 typedef enum { 187 typedef enum {
190 // VTERM_VALUETYPE_NONE = 0 188 /* VTERM_VALUETYPE_NONE = 0 */
191 VTERM_VALUETYPE_BOOL = 1, 189 VTERM_VALUETYPE_BOOL = 1,
192 VTERM_VALUETYPE_INT, 190 VTERM_VALUETYPE_INT,
193 VTERM_VALUETYPE_STRING, 191 VTERM_VALUETYPE_STRING,
194 VTERM_VALUETYPE_COLOR, 192 VTERM_VALUETYPE_COLOR,
195 193
209 VTermStringFragment string; 207 VTermStringFragment string;
210 VTermColor color; 208 VTermColor color;
211 } VTermValue; 209 } VTermValue;
212 210
213 typedef enum { 211 typedef enum {
214 // VTERM_ATTR_NONE = 0 212 /* VTERM_ATTR_NONE = 0 */
215 VTERM_ATTR_BOLD = 1, // bool: 1, 22 213 VTERM_ATTR_BOLD = 1, // bool: 1, 22
216 VTERM_ATTR_UNDERLINE, // number: 4, 21, 24 214 VTERM_ATTR_UNDERLINE, // number: 4, 21, 24
217 VTERM_ATTR_ITALIC, // bool: 3, 23 215 VTERM_ATTR_ITALIC, // bool: 3, 23
218 VTERM_ATTR_BLINK, // bool: 5, 25 216 VTERM_ATTR_BLINK, // bool: 5, 25
219 VTERM_ATTR_REVERSE, // bool: 7, 27 217 VTERM_ATTR_REVERSE, // bool: 7, 27
225 223
226 VTERM_N_ATTRS 224 VTERM_N_ATTRS
227 } VTermAttr; 225 } VTermAttr;
228 226
229 typedef enum { 227 typedef enum {
230 // VTERM_PROP_NONE = 0 228 /* VTERM_PROP_NONE = 0 */
231 VTERM_PROP_CURSORVISIBLE = 1, // bool 229 VTERM_PROP_CURSORVISIBLE = 1, // bool
232 VTERM_PROP_CURSORBLINK, // bool 230 VTERM_PROP_CURSORBLINK, // bool
233 VTERM_PROP_ALTSCREEN, // bool 231 VTERM_PROP_ALTSCREEN, // bool
234 VTERM_PROP_TITLE, // string 232 VTERM_PROP_TITLE, // string
235 VTERM_PROP_ICONNAME, // string 233 VTERM_PROP_ICONNAME, // string
259 }; 257 };
260 258
261 typedef struct { 259 typedef struct {
262 const uint32_t *chars; 260 const uint32_t *chars;
263 int width; 261 int width;
264 unsigned int protected_cell:1; // DECSCA-protected against DECSEL/DECSED 262 unsigned int protected_cell:1; /* DECSCA-protected against DECSEL/DECSED */
265 unsigned int dwl:1; // DECDWL or DECDHL double-width line 263 unsigned int dwl:1; /* DECDWL or DECDHL double-width line */
266 unsigned int dhl:2; // DECDHL double-height line (1=top 2=bottom) 264 unsigned int dhl:2; /* DECDHL double-height line (1=top 2=bottom) */
267 } VTermGlyphInfo; 265 } VTermGlyphInfo;
268 266
269 typedef struct { 267 typedef struct {
270 unsigned int doublewidth:1; /* DECDWL or DECDHL line */ 268 unsigned int doublewidth:1; /* DECDWL or DECDHL line */
271 unsigned int doubleheight:2; /* DECDHL line (1=top 2=bottom) */ 269 unsigned int doubleheight:2; /* DECDHL line (1=top 2=bottom) */
272 unsigned int continuation:1; /* Line is a flow continuation of the previous */ 270 unsigned int continuation:1; /* Line is a flow continuation of the previous */
273 } VTermLineInfo; 271 } VTermLineInfo;
274 272
275 typedef struct { 273 /* Copies of VTermState fields that the 'resize' callback might have reason to
276 // libvterm relies on the allocated memory to be zeroed out before it is 274 * edit. 'resize' callback gets total control of these fields and may
277 // returned by the allocator. 275 * free-and-reallocate them if required. They will be copied back from the
276 * struct after the callback has returned.
277 */
278 typedef struct {
279 VTermPos pos; /* current cursor position */
280 } VTermStateFields;
281
282 typedef struct {
283 /* libvterm relies on this memory to be zeroed out before it is returned
284 * by the allocator. */
278 void *(*malloc)(size_t size, void *allocdata); 285 void *(*malloc)(size_t size, void *allocdata);
279 void (*free)(void *ptr, void *allocdata); 286 void (*free)(void *ptr, void *allocdata);
280 } VTermAllocatorFunctions; 287 } VTermAllocatorFunctions;
281 288
282 void vterm_check_version(int major, int minor); 289 void vterm_check_version(int major, int minor);
327 334
328 // ------------ 335 // ------------
329 // Parser layer 336 // Parser layer
330 // ------------ 337 // ------------
331 338
332 // Flag to indicate non-final subparameters in a single CSI parameter. 339 /* Flag to indicate non-final subparameters in a single CSI parameter.
333 // Consider 340 * Consider
334 // CSI 1;2:3:4;5a 341 * CSI 1;2:3:4;5a
335 // 1 4 and 5 are final. 342 * 1 4 and 5 are final.
336 // 2 and 3 are non-final and will have this bit set 343 * 2 and 3 are non-final and will have this bit set
337 // 344 *
338 // Don't confuse this with the final byte of the CSI escape; 'a' in this case. 345 * Don't confuse this with the final byte of the CSI escape; 'a' in this case.
346 */
339 #define CSI_ARG_FLAG_MORE (1U<<31) 347 #define CSI_ARG_FLAG_MORE (1U<<31)
340 #define CSI_ARG_MASK (~(1U<<31)) 348 #define CSI_ARG_MASK (~(1U<<31))
341 349
342 #define CSI_ARG_HAS_MORE(a) ((a) & CSI_ARG_FLAG_MORE) 350 #define CSI_ARG_HAS_MORE(a) ((a) & CSI_ARG_FLAG_MORE)
343 #define CSI_ARG(a) ((a) & CSI_ARG_MASK) 351 #define CSI_ARG(a) ((a) & CSI_ARG_MASK)
344 352
345 // Can't use -1 to indicate a missing argument; use this instead 353 /* Can't use -1 to indicate a missing argument; use this instead */
346 #define CSI_ARG_MISSING ((1<<30)-1) 354 #define CSI_ARG_MISSING ((1<<30)-1)
347 355
348 #define CSI_ARG_IS_MISSING(a) (CSI_ARG(a) == CSI_ARG_MISSING) 356 #define CSI_ARG_IS_MISSING(a) (CSI_ARG(a) == CSI_ARG_MISSING)
349 #define CSI_ARG_OR(a,def) (CSI_ARG(a) == CSI_ARG_MISSING ? (def) : CSI_ARG(a)) 357 #define CSI_ARG_OR(a,def) (CSI_ARG(a) == CSI_ARG_MISSING ? (def) : CSI_ARG(a))
350 #define CSI_ARG_COUNT(a) (CSI_ARG(a) == CSI_ARG_MISSING || CSI_ARG(a) == 0 ? 1 : CSI_ARG(a)) 358 #define CSI_ARG_COUNT(a) (CSI_ARG(a) == CSI_ARG_MISSING || CSI_ARG(a) == 0 ? 1 : CSI_ARG(a))
363 void *vterm_parser_get_cbdata(VTerm *vt); 371 void *vterm_parser_get_cbdata(VTerm *vt);
364 372
365 // ----------- 373 // -----------
366 // State layer 374 // State layer
367 // ----------- 375 // -----------
368
369 /* Copies of VTermState fields that the 'resize' callback might have reason to
370 * edit. 'resize' callback gets total control of these fields and may
371 * free-and-reallocate them if required. They will be copied back from the
372 * struct after the callback has returned.
373 */
374 typedef struct {
375 VTermPos pos; /* current cursor position */
376 } VTermStateFields;
377 376
378 typedef struct { 377 typedef struct {
379 int (*putglyph)(VTermGlyphInfo *info, VTermPos pos, void *user); 378 int (*putglyph)(VTermGlyphInfo *info, VTermPos pos, void *user);
380 int (*movecursor)(VTermPos pos, VTermPos oldpos, int visible, void *user); 379 int (*movecursor)(VTermPos pos, VTermPos oldpos, int visible, void *user);
381 int (*scrollrect)(VTermRect rect, int downward, int rightward, void *user); 380 int (*scrollrect)(VTermRect rect, int downward, int rightward, void *user);
457 unsigned int italic : 1; 456 unsigned int italic : 1;
458 unsigned int blink : 1; 457 unsigned int blink : 1;
459 unsigned int reverse : 1; 458 unsigned int reverse : 1;
460 unsigned int conceal : 1; 459 unsigned int conceal : 1;
461 unsigned int strike : 1; 460 unsigned int strike : 1;
462 unsigned int font : 4; // 0 to 9 461 unsigned int font : 4; /* 0 to 9 */
463 unsigned int dwl : 1; // On a DECDWL or DECDHL line 462 unsigned int dwl : 1; /* On a DECDWL or DECDHL line */
464 unsigned int dhl : 2; // On a DECDHL line (1=top 2=bottom) 463 unsigned int dhl : 2; /* On a DECDHL line (1=top 2=bottom) */
465 } VTermScreenCellAttrs; 464 } VTermScreenCellAttrs;
466 465
467 enum { 466 enum {
468 VTERM_UNDERLINE_OFF, 467 VTERM_UNDERLINE_OFF,
469 VTERM_UNDERLINE_SINGLE, 468 VTERM_UNDERLINE_SINGLE,
511 // Before that switching to the alternate screen won't work. 510 // Before that switching to the alternate screen won't work.
512 // Calling with "altscreen" zero has no effect. 511 // Calling with "altscreen" zero has no effect.
513 void vterm_screen_enable_altscreen(VTermScreen *screen, int altscreen); 512 void vterm_screen_enable_altscreen(VTermScreen *screen, int altscreen);
514 513
515 typedef enum { 514 typedef enum {
516 VTERM_DAMAGE_CELL, // every cell 515 VTERM_DAMAGE_CELL, /* every cell */
517 VTERM_DAMAGE_ROW, // entire rows 516 VTERM_DAMAGE_ROW, /* entire rows */
518 VTERM_DAMAGE_SCREEN, // entire screen 517 VTERM_DAMAGE_SCREEN, /* entire screen */
519 VTERM_DAMAGE_SCROLL, // entire screen + scrollrect 518 VTERM_DAMAGE_SCROLL, /* entire screen + scrollrect */
520 519
521 VTERM_N_DAMAGES 520 VTERM_N_DAMAGES
522 } VTermDamageSize; 521 } VTermDamageSize;
523 522
524 // Invoke the relevant callbacks to update the screen. 523 // Invoke the relevant callbacks to update the screen.
530 * Reset the screen. Also invokes vterm_state_reset(). 529 * Reset the screen. Also invokes vterm_state_reset().
531 * Must be called before the terminal can be used. 530 * Must be called before the terminal can be used.
532 */ 531 */
533 void vterm_screen_reset(VTermScreen *screen, int hard); 532 void vterm_screen_reset(VTermScreen *screen, int hard);
534 533
535 // Neither of these functions NUL-terminate the buffer 534 /* Neither of these functions NUL-terminate the buffer */
536 size_t vterm_screen_get_chars(const VTermScreen *screen, uint32_t *chars, size_t len, const VTermRect rect); 535 size_t vterm_screen_get_chars(const VTermScreen *screen, uint32_t *chars, size_t len, const VTermRect rect);
537 size_t vterm_screen_get_text(const VTermScreen *screen, char *str, size_t len, const VTermRect rect); 536 size_t vterm_screen_get_text(const VTermScreen *screen, char *str, size_t len, const VTermRect rect);
538 537
539 typedef enum { 538 typedef enum {
540 VTERM_ATTR_BOLD_MASK = 1 << 0, 539 VTERM_ATTR_BOLD_MASK = 1 << 0,