diff --git a/kitty/line.h b/kitty/line.h index 580f521f3..bae95b910 100644 --- a/kitty/line.h +++ b/kitty/line.h @@ -44,6 +44,10 @@ typedef struct { } GPUCell; static_assert(sizeof(GPUCell) == 20, "Fix the ordering of GPUCell"); +#define SCALE_BITS 3 +#define WIDTH_BITS 3 +#define SUBSCALE_BITS 4 + typedef union CPUCell { struct { char_type ch_or_idx: sizeof(char_type) * 8 - 1; @@ -52,12 +56,12 @@ typedef union CPUCell { char_type next_char_was_wrapped : 1; char_type is_multicell : 1; char_type natural_width: 1; - char_type x : 8; - char_type y : 4; - char_type subscale_n: 4; - char_type subscale_d: 4; - char_type scale: 3; - char_type width: 3; + char_type x : WIDTH_BITS + SCALE_BITS + 1; + char_type y : SCALE_BITS + 1; + char_type subscale_n: SUBSCALE_BITS; + char_type subscale_d: SUBSCALE_BITS; + char_type scale: SCALE_BITS; + char_type width: WIDTH_BITS; char_type vertical_align: 3; char_type : 15; }; diff --git a/kitty/screen.c b/kitty/screen.c index 44daf3364..d018d3068 100644 --- a/kitty/screen.c +++ b/kitty/screen.c @@ -1209,8 +1209,9 @@ screen_handle_multicell_command(Screen *self, const MultiCellCommand *cmd, const self->lc->count = decode_utf8_safe_string(payload, cmd->payload_sz, self->lc->chars); if (!self->lc->count) return; CPUCell mcd = { - .width=MIN(cmd->width, 15u), .scale=MAX(1u, MIN(cmd->scale, 15u)), .subscale_n=MIN(cmd->subscale_n, 15u), - .subscale_d=MIN(cmd->subscale_d, 15u), .vertical_align=MIN(cmd->vertical_align, 7u), .is_multicell=true + .width=MIN(cmd->width, (WIDTH_BITS << 1) - 1), .scale=MAX(1u, MIN(cmd->scale, (SCALE_BITS << 1) - 1)), + .subscale_n=MIN(cmd->subscale_n, (SUBSCALE_BITS << 1) - 1), .subscale_d=MIN(cmd->subscale_d, (SUBSCALE_BITS << 1) - 1), + .vertical_align=MIN(cmd->vertical_align, 7u), .is_multicell=true }; if (mcd.width) handle_fixed_width_multicell_command(self, mcd, self->lc); else {