stage_cursor(): verify cuf1/cuf before using them #789

This commit is contained in:
nick black 2020-07-20 03:57:13 -04:00
parent 3aedec2501
commit 889f02bf6e
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

View File

@ -734,13 +734,15 @@ stage_cursor(notcurses* nc, FILE* out, int y, int x){
if(nc->rstate.y == y){ // only need move x
const int xdiff = x - nc->rstate.x;
if(xdiff > 0){
if(xdiff == 1){
ret = term_emit("cuf1", tiparm(nc->tcache.cuf1), out, false);
}else{
ret = term_emit("cuf", tiparm(nc->tcache.cuf, xdiff), out, false);
if(nc->tcache.cuf && nc->tcache.cuf1){
if(xdiff == 1){
ret = term_emit("cuf1", tiparm(nc->tcache.cuf1), out, false);
}else{
ret = term_emit("cuf", tiparm(nc->tcache.cuf, xdiff), out, false);
}
nc->rstate.x = x;
return ret;
}
nc->rstate.x = x;
return ret;
}else if(xdiff == 0){
return 0; // no move needed
}