From 8c8d862d23b516b3740bb6c7d07d01d336a16ad2 Mon Sep 17 00:00:00 2001 From: nick black Date: Wed, 3 Jun 2020 03:22:43 -0400 Subject: [PATCH] allglyph: only render at end of line --- src/demo/all.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/demo/all.c b/src/demo/all.c index 0e6421277..232fa9319 100644 --- a/src/demo/all.c +++ b/src/demo/all.c @@ -12,21 +12,21 @@ // works on a scrolling plane static int allglyphs(struct notcurses* nc, struct ncplane* column){ - const int PERIOD = 8; const int valid_planes[] = { 0, 1, 2, 3, 14, 15, 16, -1 }; - int period = 0; + const int dimx = ncplane_dim_x(column); for(const int* plane = valid_planes ; *plane >= 0 ; ++plane){ for(long int c = 0 ; c < 0x10000l ; ++c){ - wchar_t w[2] = { *plane * 0x10000l + c, L'\0' }; - if(wcswidth(w, UINT_MAX) >= 1){ + wchar_t w[2] = { *plane * 0x10000l + c, L'\0', }; + if(wcwidth(w[0]) >= 1){ + int x; if(ncplane_putwegc(column, w, NULL) < 0){ return -1; } - if(++period % PERIOD == 0){ + ncplane_cursor_yx(column, NULL, &x); + if(x >= dimx){ DEMO_RENDER(nc); - period = 0; } } }