From 7f3feef5826edd588f4c2ee605a52e452b73f9df Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 30 Dec 2024 06:41:09 +0530 Subject: [PATCH] Finish up the redraw multicell tests --- kitty/line.h | 3 +-- kitty/rewrap.c | 12 ++++++------ kitty_tests/multicell.py | 13 +++++++++++++ 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/kitty/line.h b/kitty/line.h index bae95b9102b..aff9d25c50b 100644 --- a/kitty/line.h +++ b/kitty/line.h @@ -11,8 +11,7 @@ // TODO: Handle selection with multicell // TODO: URL detection with multicell -// TODO: Handle rewrap and restitch of multiline chars -// TODO: Handle rewrap when a character is too wide/tall to fit on resized screen +// TODO: Handle restitch of multiline chars typedef union CellAttrs { struct { diff --git a/kitty/rewrap.c b/kitty/rewrap.c index e442b400661..bc81774935d 100644 --- a/kitty/rewrap.c +++ b/kitty/rewrap.c @@ -219,19 +219,19 @@ fast_copy_src_to_dest(Rewrap *r) { } } index_type num = MIN(r->src_x_limit - r->src_x, r->dest_xnum - r->dest_x); - bool do_copy = true; if (num && (c = &r->src.cpu_cells[r->src_x + num - 1])->is_multicell && c->x != (mc_width = mcd_x_limit(c)) - 1) { // we have a split multicell at the right edge of the copy region if (num > mc_width) num = MIN(r->src_x_limit - r->src_x - mc_width, num); else { - if (mc_width > r->dest_xnum) do_copy = false; - else { - r->dest_x = r->dest_xnum; - continue; + if (mc_width > r->dest_xnum) { + multiline_copy_src_to_dest(r); + return; } + r->dest_x = r->dest_xnum; + continue; } } - if (do_copy) copy_range(&r->src, r->src_x, &r->dest, r->dest_x, num); + copy_range(&r->src, r->src_x, &r->dest, r->dest_x, num); update_tracked_cursors(r, num, r->src_y, r->src_x_limit); r->src_x += num; r->dest_x += num; } diff --git a/kitty_tests/multicell.py b/kitty_tests/multicell.py index 48234900660..b99bb3b94f3 100644 --- a/kitty_tests/multicell.py +++ b/kitty_tests/multicell.py @@ -536,3 +536,16 @@ def reset(): ac(s.columns-x -1, y, is_multicell=True) for x in (0, 1): ac(x, y, is_multicell=False) + + reset() + multicell(s, 'X', scale=4), s.draw('abc') + s.resize(3, 3) + self.ae('\x1b[mabc', as_ansi().rstrip()) # ]]]]]]] + reset() + multicell(s, 'X', width=4), s.draw('abc') + s.resize(3, 3) + self.ae('\x1b[mabc', as_ansi().rstrip()) # ]]]]]]] + reset() + s.draw('1'), multicell(s, 'X', width=4), s.draw('abc') + s.resize(3, 3) + self.ae('\x1b[m1ab\x1b[mc', as_ansi().rstrip()) # ]]]]]]]