Skip to content

Commit

Permalink
Finish up the redraw multicell tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kovidgoyal committed Dec 30, 2024
1 parent 2f45d13 commit 7f3feef
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
3 changes: 1 addition & 2 deletions kitty/line.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
12 changes: 6 additions & 6 deletions kitty/rewrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
13 changes: 13 additions & 0 deletions kitty_tests/multicell.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()) # ]]]]]]]

0 comments on commit 7f3feef

Please sign in to comment.