simplify wide handling in putc_yx #362

This commit is contained in:
nick black 2020-04-12 06:57:03 -04:00 committed by Nick Black
parent e6a80ab98d
commit b0aa6b9a7f
2 changed files with 4 additions and 10 deletions

View File

@ -1239,14 +1239,8 @@ int ncplane_putc_yx(ncplane* n, int y, int x, const cell* c){
return -1;
}
int cols = 1;
if(wide){
++cols;
cell* rtarg = &n->fb[nfbcellidx(n, n->y, n->x + 1)];
cell_release(n, rtarg);
cell_init(rtarg);
cell_set_wide(rtarg);
}
if(wide){ // must set our right wide, and check for further damage
++cols;
if(n->x < n->lenx - 1){ // check to our right
cell* candidate = &n->fb[nfbcellidx(n, n->y, n->x + 1)];
if(n->x < n->lenx - 2){
@ -1254,8 +1248,8 @@ int ncplane_putc_yx(ncplane* n, int y, int x, const cell* c){
cell_obliterate(n, &n->fb[nfbcellidx(n, n->y, n->x + 2)]);
}
}
cell_obliterate(n, candidate);
cell_set_wide(candidate);
cell_release(n, candidate);
}
}
n->x += cols;

View File

@ -103,7 +103,7 @@ TEST_CASE("RenderTest") {
// should be nothing, having been stomped
egc = notcurses_at_yx(nc_, 0, 0, &c.attrword, &c.channels);
REQUIRE(egc);
CHECK(0 == strcmp("", egc));
CHECK(0 == strcmp(" ", egc));
free(egc);
cell_init(&c);
// should be character from higher plane
@ -122,7 +122,7 @@ TEST_CASE("RenderTest") {
// should be nothing, having been stomped
egc = notcurses_at_yx(nc_, 0, 3, &c.attrword, &c.channels);
REQUIRE(egc);
CHECK(0 == strcmp("", egc));
CHECK(0 == strcmp(" ", egc));
free(egc);
cell_init(&c);