From b0aa6b9a7f9e682fceb8c8a9300a7f7c4a1d9d85 Mon Sep 17 00:00:00 2001 From: nick black Date: Sun, 12 Apr 2020 06:57:03 -0400 Subject: [PATCH] simplify wide handling in putc_yx #362 --- src/lib/notcurses.c | 10 ++-------- tests/render.cpp | 4 ++-- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/lib/notcurses.c b/src/lib/notcurses.c index 590c1bc92..78cc84b4c 100644 --- a/src/lib/notcurses.c +++ b/src/lib/notcurses.c @@ -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; diff --git a/tests/render.cpp b/tests/render.cpp index 5b6d9c43a..2a5459437 100644 --- a/tests/render.cpp +++ b/tests/render.cpp @@ -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);