Mercurial > vim
comparison src/libvterm/include/vterm.h @ 20500:03826c672315 v8.2.0804
patch 8.2.0804: libvterm code lags behind the upstream version
Commit: https://github.com/vim/vim/commit/e5886ccb5163873dd01fc67b09ab10e681351ee9
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu May 21 20:10:04 2020 +0200
patch 8.2.0804: libvterm code lags behind the upstream version
Problem: Libvterm code lags behind the upstream version.
Solution: Include revision 727, but add the index instead of switching
between RGB and indexed.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 21 May 2020 20:15:04 +0200 |
parents | 747a270eb1db |
children | a4652d7ec99f |
comparison
equal
deleted
inserted
replaced
20499:a7a490678633 | 20500:03826c672315 |
---|---|
83 rect->start_row += row_delta; rect->end_row += row_delta; | 83 rect->start_row += row_delta; rect->end_row += row_delta; |
84 rect->start_col += col_delta; rect->end_col += col_delta; | 84 rect->start_col += col_delta; rect->end_col += col_delta; |
85 } | 85 } |
86 #endif | 86 #endif |
87 | 87 |
88 // The ansi_index is used for the lower 16 colors, which can be set to any | 88 /** |
89 // color. | 89 * Bit-field describing the value of VTermColor.type |
90 #define VTERM_ANSI_INDEX_DEFAULT 0 // color cleared | 90 */ |
91 #define VTERM_ANSI_INDEX_MIN 1 | 91 typedef enum { |
92 #define VTERM_ANSI_INDEX_MAX 16 | 92 /** |
93 #define VTERM_ANSI_INDEX_NONE 255 // non-ANSI color, use red/green/blue | 93 * If the lower bit of `type` is not set, the colour is 24-bit RGB. |
94 | 94 */ |
95 typedef struct { | 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 } VTermColorType; | |
128 | |
129 /** | |
130 * Returns true if the VTERM_COLOR_RGB `type` flag is set, indicating that the | |
131 * given VTermColor instance is an indexed colour. | |
132 */ | |
133 #define VTERM_COLOR_IS_INDEXED(col) \ | |
134 (((col)->type & VTERM_COLOR_TYPE_MASK) == VTERM_COLOR_INDEXED) | |
135 | |
136 /** | |
137 * Returns true if the VTERM_COLOR_INDEXED `type` flag is set, indicating that | |
138 * the given VTermColor instance is an rgb colour. | |
139 */ | |
140 #define VTERM_COLOR_IS_RGB(col) \ | |
141 (((col)->type & VTERM_COLOR_TYPE_MASK) == VTERM_COLOR_RGB) | |
142 | |
143 /** | |
144 * Returns true if the VTERM_COLOR_DEFAULT_FG `type` flag is set, indicating | |
145 * that the given VTermColor instance corresponds to the default foreground | |
146 * color. | |
147 */ | |
148 #define VTERM_COLOR_IS_DEFAULT_FG(col) \ | |
149 (!!((col)->type & VTERM_COLOR_DEFAULT_FG)) | |
150 | |
151 /** | |
152 * Returns true if the VTERM_COLOR_DEFAULT_BG `type` flag is set, indicating | |
153 * that the given VTermColor instance corresponds to the default background | |
154 * color. | |
155 */ | |
156 #define VTERM_COLOR_IS_DEFAULT_BG(col) \ | |
157 (!!((col)->type & VTERM_COLOR_DEFAULT_BG)) | |
158 | |
159 typedef struct { | |
160 /** | |
161 * Tag indicating which member is actually valid. | |
162 * Please use the `VTERM_COLOR_IS_*` test macros to check whether a | |
163 * particular type flag is set. | |
164 */ | |
165 uint8_t type; | |
166 | |
96 uint8_t red, green, blue; | 167 uint8_t red, green, blue; |
97 uint8_t ansi_index; | 168 |
169 uint8_t index; | |
98 } VTermColor; | 170 } VTermColor; |
171 | |
172 /** | |
173 * Constructs a new VTermColor instance representing the given RGB values. | |
174 */ | |
175 void vterm_color_rgb(VTermColor *col, uint8_t red, uint8_t green, uint8_t blue); | |
176 | |
177 /** | |
178 * Construct a new VTermColor instance representing an indexed color with the | |
179 * given index. | |
180 */ | |
181 void vterm_color_indexed(VTermColor *col, uint8_t idx); | |
182 | |
183 /** | |
184 * Compares two colours. Returns true if the colors are equal, false otherwise. | |
185 */ | |
186 int vterm_color_is_equal(const VTermColor *a, const VTermColor *b); | |
187 | |
99 | 188 |
100 typedef enum { | 189 typedef enum { |
101 // VTERM_VALUETYPE_NONE = 0 | 190 // VTERM_VALUETYPE_NONE = 0 |
102 VTERM_VALUETYPE_BOOL = 1, | 191 VTERM_VALUETYPE_BOOL = 1, |
103 VTERM_VALUETYPE_INT, | 192 VTERM_VALUETYPE_INT, |
344 int vterm_state_set_termprop(VTermState *state, VTermProp prop, VTermValue *val); | 433 int vterm_state_set_termprop(VTermState *state, VTermProp prop, VTermValue *val); |
345 void vterm_state_focus_in(VTermState *state); | 434 void vterm_state_focus_in(VTermState *state); |
346 void vterm_state_focus_out(VTermState *state); | 435 void vterm_state_focus_out(VTermState *state); |
347 const VTermLineInfo *vterm_state_get_lineinfo(const VTermState *state, int row); | 436 const VTermLineInfo *vterm_state_get_lineinfo(const VTermState *state, int row); |
348 | 437 |
438 /** | |
439 * Makes sure that the given color `col` is indeed an RGB colour. After this | |
440 * function returns, VTERM_COLOR_IS_RGB(col) will return true, while all other | |
441 * flags stored in `col->type` will have been reset. | |
442 * | |
443 * @param state is the VTermState instance from which the colour palette should | |
444 * be extracted. | |
445 * @param col is a pointer at the VTermColor instance that should be converted | |
446 * to an RGB colour. | |
447 */ | |
448 void vterm_state_convert_color_to_rgb(const VTermState *state, VTermColor *col); | |
449 | |
349 // ------------ | 450 // ------------ |
350 // Screen layer | 451 // Screen layer |
351 // ------------ | 452 // ------------ |
352 | 453 |
353 typedef struct { | 454 typedef struct { |
454 | 555 |
455 int vterm_screen_get_cell(const VTermScreen *screen, VTermPos pos, VTermScreenCell *cell); | 556 int vterm_screen_get_cell(const VTermScreen *screen, VTermPos pos, VTermScreenCell *cell); |
456 | 557 |
457 int vterm_screen_is_eol(const VTermScreen *screen, VTermPos pos); | 558 int vterm_screen_is_eol(const VTermScreen *screen, VTermPos pos); |
458 | 559 |
560 /** | |
561 * Same as vterm_state_convert_color_to_rgb(), but takes a `screen` instead of a `state` | |
562 * instance. | |
563 */ | |
564 void vterm_screen_convert_color_to_rgb(const VTermScreen *screen, VTermColor *col); | |
565 | |
459 // --------- | 566 // --------- |
460 // Utilities | 567 // Utilities |
461 // --------- | 568 // --------- |
462 | 569 |
463 VTermValueType vterm_get_attr_type(VTermAttr attr); | 570 VTermValueType vterm_get_attr_type(VTermAttr attr); |