move cursor to logend{yx} post rasterization #1906

pull/1920/head
nick black 3 years ago committed by nick black
parent af418a221f
commit 5725605167

@ -246,7 +246,6 @@ tinfo_debug_bitmaps(struct ncplane* n, const tinfo* ti, const char* indent){
}
char* path = prefix_data("notcurses.png");
if(path){
// FIXME hold off until #1883 is resolved
display_logo(ti, n, path);
free(path);
}

@ -1158,7 +1158,7 @@ notcurses* notcurses_core_init(const notcurses_options* opts, FILE* outfp){
free_plane(ret->stdplane);
goto err;
}
if(ret->rstate.logendy >= 0 && ret->rstate.logendx >= 0){
if(ret->rstate.logendy >= 0){ // if either is set, both are
if(!ret->suppress_banner){
if(locate_cursor_early(ret, &ret->rstate.logendy, &ret->rstate.logendx)){
free_plane(ret->stdplane);

@ -1222,6 +1222,8 @@ notcurses_rasterize(notcurses* nc, ncpile* p, FILE* out){
int ret = raster_and_write(nc, p, out);
if(cursory >= 0){
notcurses_cursor_enable(nc, cursory, cursorx);
}else if(nc->rstate.logendy >= 0){
goto_location(nc, nc->ttyfp, nc->rstate.logendy, nc->rstate.logendx);
}
nc->last_pile = p;
return ret;
@ -1536,21 +1538,24 @@ int notcurses_cursor_enable(notcurses* nc, int y, int x){
if(nc->cursory == y && nc->cursorx == x){
return 0;
}
const char* cnorm = get_escape(&nc->tcache, ESCAPE_CNORM);
if(nc->ttyfd < 0 || !cnorm){
if(nc->ttyfd < 0){
return -1;
}
// updates nc->rstate.cursor{y,x}
if(goto_location(nc, nc->ttyfp, y + nc->margin_t, x + nc->margin_l)){
return -1;
}
if(ncflush(nc->ttyfp)){
return -1;
}
// if we were already positive, we're already visible, no need to write cnorm
if(nc->cursory >= 0 && nc->cursorx >= 0){
nc->cursory = y;
nc->cursorx = x;
return 0;
}
if(tty_emit(cnorm, nc->ttyfd) || ncflush(nc->ttyfp)){
const char* cnorm = get_escape(&nc->tcache, ESCAPE_CNORM);
if(!cnorm || tty_emit(cnorm, nc->ttyfd)){
return -1;
}
nc->cursory = y;

Loading…
Cancel
Save