mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-26 18:22:09 +02:00
Track sprite positions in the Cell structure
This commit is contained in:
@@ -8,12 +8,23 @@
|
||||
|
||||
#include "data-types.h"
|
||||
|
||||
static inline void
|
||||
update_sprites_in_line(Cell *cells, index_type xnum) {
|
||||
if (LIKELY(xnum > 0)) {
|
||||
set_sprite_position(cells, NULL);
|
||||
for (index_type i = 1; i < xnum; i++) {
|
||||
set_sprite_position(cells + i, cells + i - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
set_attribute_on_line(Cell *cells, uint32_t shift, uint32_t val, index_type xnum) {
|
||||
uint32_t mask = shift == DECORATION_SHIFT ? 3 : 1;
|
||||
uint32_t aval = (val & mask) << (ATTRS_SHIFT + shift);
|
||||
mask = ~(mask << (ATTRS_SHIFT + shift));
|
||||
for (index_type i = 0; i < xnum; i++) cells[i].ch = (cells[i].ch & mask) | aval;
|
||||
if (shift == BOLD_SHIFT || shift == ITALIC_SHIFT) update_sprites_in_line(cells, xnum);
|
||||
}
|
||||
|
||||
static inline void
|
||||
@@ -28,6 +39,7 @@ copy_line(const Line *src, Line *dest) {
|
||||
|
||||
static inline void
|
||||
clear_chars_in_line(Cell *cells, index_type xnum, char_type ch) {
|
||||
// Clear only the char part of each cell, the rest must have been cleared by a memset or similar
|
||||
char_type c = (1 << ATTRS_SHIFT) | ch;
|
||||
for (index_type i = 0; i < xnum; i++) cells[i].ch = c;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user