From 21871dcd58fac0fe232b1e6c6437f6b302bdd8ac Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 23 Nov 2024 13:38:50 +0530 Subject: [PATCH] Drop val access to CPUCell Allows us to increase CPUCell beyond 8 bytes if needed --- kitty/line.c | 6 +++--- kitty/line.h | 4 ++-- kitty/lineops.h | 1 - kitty/screen.c | 2 +- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/kitty/line.c b/kitty/line.c index e5deedafd..476aebfcc 100644 --- a/kitty/line.c +++ b/kitty/line.c @@ -568,7 +568,7 @@ set_text(Line* self, PyObject *args) { color_type dfg = cursor->decoration_fg & COL_MASK; for (index_type i = cursor->x; offset < limit && i < self->xnum; i++, offset++) { - self->cpu_cells[i].val = 0; + self->cpu_cells[i] = (CPUCell){0}; self->cpu_cells[i].ch_or_idx = PyUnicode_READ(kind, buf, offset); self->gpu_cells[i].attrs = attrs; self->gpu_cells[i].fg = fg; @@ -684,7 +684,7 @@ line_get_char(Line *self, index_type at) { } -void +static void line_set_char(Line *self, unsigned int at, uint32_t ch, Cursor *cursor, hyperlink_id_type hyperlink_id) { GPUCell *g = self->gpu_cells + at; if (cursor != NULL) { @@ -694,7 +694,7 @@ line_set_char(Line *self, unsigned int at, uint32_t ch, Cursor *cursor, hyperlin g->decoration_fg = cursor->decoration_fg & COL_MASK; } CPUCell *c = self->cpu_cells + at; - c->val = 0; + *c = (CPUCell){0}; cell_set_char(c, ch); c->hyperlink_id = hyperlink_id; if (OPT(underline_hyperlinks) == UNDERLINE_ALWAYS && hyperlink_id) { diff --git a/kitty/line.h b/kitty/line.h index 8cf2cd936..0239e4574 100644 --- a/kitty/line.h +++ b/kitty/line.h @@ -81,9 +81,9 @@ typedef union CPUCell { }; struct { char_type ch_and_idx: sizeof(char_type) * 8; - char_type : sizeof(char_type) * 8; + char_type : sizeof(hyperlink_id_type) * 8; + char_type : 16; }; - uint64_t val; } CPUCell; static_assert(sizeof(CPUCell) == sizeof(uint64_t), "Fix the ordering of CPUCell"); diff --git a/kitty/lineops.h b/kitty/lineops.h index 04573b3a9..78923329f 100644 --- a/kitty/lineops.h +++ b/kitty/lineops.h @@ -69,7 +69,6 @@ typedef Line*(get_line_func)(void *, int); void line_clear_text(Line *self, unsigned int at, unsigned int num, char_type ch); void line_apply_cursor(Line *self, const Cursor *cursor, unsigned int at, unsigned int num, bool clear_char); char_type line_get_char(Line *self, index_type at); -void line_set_char(Line *, unsigned int , uint32_t , Cursor *, hyperlink_id_type); index_type line_url_start_at(Line *self, index_type x); index_type line_url_end_at(Line *self, index_type x, bool, char_type, bool, bool, index_type); bool line_startswith_url_chars(Line*, bool); diff --git a/kitty/screen.c b/kitty/screen.c index d2bad8638..5a2c42790 100644 --- a/kitty/screen.c +++ b/kitty/screen.c @@ -769,7 +769,7 @@ halve_multicell_width(Screen *self, index_type x_, index_type y_) { Line *line = range_line_(self, y); cp = line->cpu_cells; gp = line->gpu_cells; for (index_type x = 0; x < half_x_limit; x++) cp[x].ch_or_idx = idx; for (index_type x = half_x_limit; x < x_limit; x++) { - cp[x].val = 0; clear_sprite_position(gp[x]); + cp[x] = (CPUCell){0}; clear_sprite_position(gp[x]); } if (y > -1) linebuf_mark_line_dirty(self->linebuf, y); }