notcurses_init: properly initialize rstate cursor

When we first begin operations, we need emit a cursor homing, which
we were not doing for the first line. As a result, the first row
didn't show up until you rendered something else, and even then
didn't show up unless you changed it (as it was otherwise undamaged).
This explains a lot of mystery behavior in notcurses-demo that I've
long told myself I'd hallucinated or imagined. Hurrah! but also
supershittytothemax! Thanks Marek Habersack for pointing out something
which led to an experiment which led to chasing this down once and
forever. Closes #619, w00t!
pull/665/head
nick black 4 years ago
parent 002f65fb54
commit 38c0509d86
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

@ -852,6 +852,7 @@ notcurses* notcurses_init(const notcurses_options* opts, FILE* outfp){
free_plane(ret->top);
goto err;
}
ret->rstate.x = ret->rstate.y = -1;
ret->suppress_banner = opts->suppress_banner;
init_banner(ret);
// flush on the switch to alternate screen, lest initial output be swept away

@ -347,7 +347,7 @@ paint(ncplane* p, cell* lastframe, struct crender* rvec,
lock_in_highcontrast(targc, crender);
cell* prevcell = &lastframe[fbcellidx(absy, lfdimx, absx)];
/*if(cell_simple_p(targc)){
fprintf(stderr, "WROTE %u [%c] to %d/%d (%d/%d)\n", targc->gcluster, prevcell->gcluster, y, x, absy, absx);
fprintf(stderr, "WROTE %u [%c] to %d/%d (%d/%d)\n", targc->gcluster, targc->gcluster, y, x, absy, absx);
}else{
fprintf(stderr, "WROTE %u [%s] to %d/%d (%d/%d)\n", targc->gcluster, extended_gcluster(crender->p, targc), y, x, absy, absx);
}*/
@ -478,7 +478,7 @@ term_putc(FILE* out, const egcpool* e, const cell* c){
return -1;
}
}else{
// fprintf(stderr, "[%c]\n", c->gcluster);
//fprintf(stderr, "[%c]\n", c->gcluster);
if(ncfputc(c->gcluster, out) == EOF){
return -1;
}

@ -0,0 +1,26 @@
#include <unistd.h>
#include "notcurses/notcurses.h"
int main(void){
struct notcurses_options nopts = {
.inhibit_alternate_screen = true,
};
struct notcurses* nc = notcurses_init(&nopts, NULL);
if(nc == NULL){
return EXIT_FAILURE;
}
if(ncplane_putstr_aligned(notcurses_stdplane(nc), 0, NCALIGN_CENTER,
"Heute Die Welt, Morgens Das Sonnensystem!") <= 0){
notcurses_stop(nc);
return EXIT_FAILURE;
}
if(ncplane_putstr_aligned(notcurses_stdplane(nc), 2, NCALIGN_CENTER,
"Heute Die Welt, Morgens Das Sonnensystem!") <= 0){
notcurses_stop(nc);
return EXIT_FAILURE;
}
notcurses_render(nc);
sleep(5);
notcurses_stop(nc);
return EXIT_SUCCESS;
}
Loading…
Cancel
Save