mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-02 12:44:01 +02:00
DRYer
This commit is contained in:
16
kitty/line.h
16
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;
|
||||
};
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user