* higher planes stomp wide glyphs * broken unit test * develop out widestomp PoC * fix notcurses_at_yx() * fix up dig_visible_cell() return value * refuse wide glyph on last column #242 * set adjacent cell wide when rendering #158 * xray: eliminate weird color flicker * witherworm: don't eat wide glyphs * unit test for boxed glyph * uniblock: no need to emit so many U+200Es * witherworm: remove wide glyph hackpull/247/head
parent
48177b8474
commit
2fbc94e41c
@ -0,0 +1,75 @@
|
||||
#include <cstdlib>
|
||||
#include <clocale>
|
||||
#include <unistd.h>
|
||||
#include <notcurses.h>
|
||||
|
||||
constexpr auto DELAY = 1;
|
||||
|
||||
// dump two wide glyphs, then create a new plane and drop it atop them
|
||||
|
||||
int stomper(struct notcurses* nc, struct ncplane* nn){
|
||||
ncplane_move_yx(nn, 0, 1);
|
||||
|
||||
notcurses_render(nc);
|
||||
sleep(DELAY);
|
||||
|
||||
// first wide glyph gone, second present
|
||||
ncplane_move_yx(nn, 1, 0);
|
||||
notcurses_render(nc);
|
||||
sleep(DELAY);
|
||||
|
||||
// second wide glyph gone, first present
|
||||
ncplane_move_yx(nn, 2, 2);
|
||||
notcurses_render(nc);
|
||||
sleep(DELAY);
|
||||
|
||||
ncplane_move_yx(nn, 4, 0);
|
||||
notcurses_render(nc);
|
||||
sleep(DELAY);
|
||||
|
||||
ncplane_move_yx(nn, 5, 1);
|
||||
notcurses_render(nc);
|
||||
sleep(DELAY);
|
||||
|
||||
ncplane_move_yx(nn, 6, 2);
|
||||
notcurses_render(nc);
|
||||
sleep(DELAY);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(void){
|
||||
setlocale(LC_ALL, "");
|
||||
notcurses_options opts{};
|
||||
struct notcurses* nc = notcurses_init(&opts, stdout);
|
||||
struct ncplane* n = notcurses_stdplane(nc);
|
||||
|
||||
// first, a 2x1 with "AB"
|
||||
struct ncplane* nn = ncplane_new(nc, 1, 2, 1, 16, nullptr);
|
||||
ncplane_set_fg_rgb(nn, 0xc0, 0x80, 0xc0);
|
||||
ncplane_set_bg_rgb(nn, 0x20, 0x00, 0x20);
|
||||
ncplane_putstr(nn, "AB");
|
||||
|
||||
ncplane_set_fg_rgb(n, 0x80, 0xc0, 0x80);
|
||||
ncplane_set_bg_rgb(n, 0x00, 0x40, 0x00);
|
||||
ncplane_putstr(n, "\xe5\xbd\xa2\xe5\x85\xa8");
|
||||
ncplane_putstr_yx(n, 1, 0, "\xe5\xbd\xa2\xe5\x85\xa8");
|
||||
ncplane_putstr_yx(n, 2, 0, "\xe5\xbd\xa2\xe5\x85\xa8");
|
||||
ncplane_putstr_yx(n, 3, 0, "\xe5\xbd\xa2\xe5\x85\xa8");
|
||||
ncplane_putstr_yx(n, 4, 0, "abcdef");
|
||||
ncplane_putstr_yx(n, 5, 0, "abcdef");
|
||||
ncplane_putstr_yx(n, 6, 0, "abcdef");
|
||||
ncplane_putstr_yx(n, 7, 0, "abcdef");
|
||||
notcurses_render(nc);
|
||||
sleep(1);
|
||||
|
||||
stomper(nc, nn);
|
||||
if(ncplane_putstr_yx(nn, 0, 0, "\xe5\xbd\xa1") <= 0){
|
||||
notcurses_stop(nc);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
stomper(nc, nn);
|
||||
|
||||
notcurses_stop(nc);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
@ -0,0 +1,133 @@
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
#include "internal.h"
|
||||
#include "main.h"
|
||||
|
||||
TEST_CASE("RenderTest") {
|
||||
if(getenv("TERM") == nullptr){
|
||||
return;
|
||||
}
|
||||
notcurses_options nopts{};
|
||||
nopts.inhibit_alternate_screen = true;
|
||||
nopts.suppress_banner = true;
|
||||
FILE* outfp_ = fopen("/dev/tty", "wb");
|
||||
REQUIRE(outfp_);
|
||||
struct notcurses* nc_ = notcurses_init(&nopts, outfp_);
|
||||
REQUIRE(nc_);
|
||||
struct ncplane* n_ = notcurses_stdplane(nc_);
|
||||
REQUIRE(n_);
|
||||
|
||||
// If an ncplane is moved atop the right half of a wide glyph, the entire
|
||||
// glyph should be oblitrated.
|
||||
SUBCASE("PlaneStompsWideGlyph"){
|
||||
cell c = CELL_TRIVIAL_INITIALIZER;
|
||||
char* egc;
|
||||
|
||||
// print two wide glyphs on the standard plane
|
||||
int y, x;
|
||||
ncplane_yx(n_, &y, &x);
|
||||
CHECK(0 == y);
|
||||
CHECK(0 == x);
|
||||
CHECK(3 == ncplane_putstr(n_, "\xe5\x85\xa8"));
|
||||
ncplane_cursor_yx(n_, &y, &x);
|
||||
CHECK(0 == y);
|
||||
CHECK(2 == x);
|
||||
CHECK(3 == ncplane_putstr(n_, "\xe5\xbd\xa2"));
|
||||
ncplane_cursor_yx(n_, &y, &x);
|
||||
CHECK(0 == y);
|
||||
CHECK(4 == x);
|
||||
CHECK(!notcurses_render(nc_));
|
||||
|
||||
// should be wide char 1
|
||||
REQUIRE(3 == ncplane_at_yx(n_, 0, 0, &c));
|
||||
egc = cell_egc_copy(n_, &c);
|
||||
REQUIRE(egc);
|
||||
CHECK(!strcmp("\xe5\x85\xa8", egc));
|
||||
CHECK(cell_double_wide_p(&c));
|
||||
free(egc);
|
||||
egc = notcurses_at_yx(nc_, 0, 0, &c);
|
||||
REQUIRE(egc);
|
||||
CHECK(!strcmp("\xe5\x85\xa8", egc));
|
||||
CHECK(cell_double_wide_p(&c));
|
||||
free(egc);
|
||||
cell_init(&c);
|
||||
// should be wide char 1 right side
|
||||
REQUIRE(0 == ncplane_at_yx(n_, 0, 1, &c));
|
||||
egc = cell_egc_copy(n_, &c);
|
||||
REQUIRE(egc);
|
||||
CHECK(!strcmp("", egc));
|
||||
CHECK(cell_double_wide_p(&c));
|
||||
free(egc);
|
||||
egc = notcurses_at_yx(nc_, 0, 1, &c);
|
||||
REQUIRE(egc);
|
||||
CHECK(!strcmp("", egc));
|
||||
CHECK(cell_double_wide_p(&c));
|
||||
free(egc);
|
||||
cell_init(&c);
|
||||
|
||||
// should be wide char 2
|
||||
REQUIRE(3 == ncplane_at_yx(n_, 0, 2, &c));
|
||||
egc = cell_egc_copy(n_, &c);
|
||||
REQUIRE(egc);
|
||||
CHECK(!strcmp("\xe5\xbd\xa2", egc));
|
||||
CHECK(cell_double_wide_p(&c));
|
||||
free(egc);
|
||||
egc = notcurses_at_yx(nc_, 0, 2, &c);
|
||||
REQUIRE(egc);
|
||||
fprintf(stderr, "HAVE [%s] WANT \xe5\xbd\xa2\n", egc);
|
||||
CHECK(!strcmp("\xe5\xbd\xa2", egc));
|
||||
CHECK(cell_double_wide_p(&c));
|
||||
free(egc);
|
||||
cell_init(&c);
|
||||
// should be wide char 2 right side
|
||||
CHECK(0 == ncplane_at_yx(n_, 0, 3, &c));
|
||||
egc = cell_egc_copy(n_, &c);
|
||||
REQUIRE(egc);
|
||||
CHECK(!strcmp("", egc));
|
||||
CHECK(cell_double_wide_p(&c));
|
||||
free(egc);
|
||||
egc = notcurses_at_yx(nc_, 0, 3, &c);
|
||||
REQUIRE(egc);
|
||||
CHECK(!strcmp("", egc));
|
||||
CHECK(cell_double_wide_p(&c));
|
||||
free(egc);
|
||||
cell_init(&c);
|
||||
|
||||
struct ncplane* n = ncplane_new(nc_, 1, 2, 0, 1, nullptr);
|
||||
REQUIRE(n);
|
||||
CHECK(0 < ncplane_putstr(n, "AB"));
|
||||
CHECK(!notcurses_render(nc_));
|
||||
|
||||
// should be nothing, having been stomped
|
||||
egc = notcurses_at_yx(nc_, 0, 0, &c);
|
||||
REQUIRE(egc);
|
||||
CHECK(!strcmp(" ", egc));
|
||||
free(egc);
|
||||
cell_init(&c);
|
||||
// should be character from higher plane
|
||||
egc = notcurses_at_yx(nc_, 0, 1, &c);
|
||||
REQUIRE(egc);
|
||||
CHECK(!strcmp("A", egc));
|
||||
free(egc);
|
||||
cell_init(&c);
|
||||
|
||||
egc = notcurses_at_yx(nc_, 0, 2, &c);
|
||||
REQUIRE(egc);
|
||||
CHECK(!strcmp("B", egc));
|
||||
free(egc);
|
||||
cell_init(&c);
|
||||
|
||||
// should be nothing, having been stomped
|
||||
egc = notcurses_at_yx(nc_, 0, 3, &c);
|
||||
REQUIRE(egc);
|
||||
CHECK(!strcmp(" ", egc));
|
||||
free(egc);
|
||||
cell_init(&c);
|
||||
|
||||
CHECK(!ncplane_destroy(n));
|
||||
}
|
||||
|
||||
|
||||
CHECK(0 == notcurses_stop(nc_));
|
||||
CHECK(0 == fclose(outfp_));
|
||||
}
|
Loading…
Reference in New Issue