From 4a0086b241b42ad6d3882503c97ee5facdf685b0 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 10 Dec 2024 07:17:14 +0530 Subject: [PATCH] Fix vertical_align serialization --- kitty/client.py | 12 ++++++++---- kitty/line.c | 3 +++ kitty_tests/multicell.py | 2 +- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/kitty/client.py b/kitty/client.py index 4faf92047..51fce68cb 100644 --- a/kitty/client.py +++ b/kitty/client.py @@ -274,14 +274,18 @@ def multicell_command(payload: str) -> None: c = json.loads(payload) text = c.pop('', '') m = '' - if (w := c.get('width')) is not None and w > 0: + if (w := c.pop('width', None)) is not None and w > 0: m += f'w={w}:' - if (s := c.get('scale')) is not None and s > 1: + if (s := c.pop('scale', None)) is not None and s > 1: m += f's={s}:' - if (n := c.get('subscale_n')) is not None and n > 0: + if (n := c.pop('subscale_n', None)) is not None and n > 0: m += f'n={n}:' - if (d := c.get('subscale_d')) is not None and d > 0: + if (d := c.pop('subscale_d', None)) is not None and d > 0: m += f'd={d}:' + if (v := c.pop('vertical_align', None)) is not None and v > 0: + m += f'v={v}:' + if c: + raise Exception('Unknown keys in multicell_command: ' + ', '.join(c)) write(f'{OSC}{TEXT_SIZE_CODE};{m.rstrip(":")};{text}\a') diff --git a/kitty/line.c b/kitty/line.c index 306f3a9dd..e5be99128 100644 --- a/kitty/line.c +++ b/kitty/line.c @@ -78,6 +78,9 @@ write_multicell_ansi_prefix(ANSILineState *s, const CPUCell *mcd) { if (mcd->subscale_d) { w('d'); w('='); nonnegative_integer_as_utf32(mcd->subscale_d, s->output_buf); w(':'); } + if (mcd->vertical_align) { + w('v'); w('='); nonnegative_integer_as_utf32(mcd->vertical_align, s->output_buf); w(':'); + } if (s->output_buf->buf[s->output_buf->len - 1] == ':') s->output_buf->len--; w(';'); #undef w diff --git a/kitty_tests/multicell.py b/kitty_tests/multicell.py index 023f23927..4fb8ca048 100644 --- a/kitty_tests/multicell.py +++ b/kitty_tests/multicell.py @@ -400,7 +400,7 @@ def ta(expected): s.reset() multicell(s, 'a', width=2, scale=3, subscale_n=1, subscale_d=2, vertical_align=1) - ta('\x1b]66;w=2:s=3:n=1:d=2;a\x07') + ta('\x1b]66;w=2:s=3:n=1:d=2:v=1;a\x07') s.draw('a') multicell(s, 'b', width=2) s.draw('c')