cursor: always flush for immediate action

pull/955/head
nick black 4 years ago committed by Nick Black
parent 73221dff2a
commit aff9ae62ef

@ -1103,6 +1103,10 @@ int ncdirect_fg(ncdirect* nc, unsigned rgb){
}
int notcurses_cursor_enable(notcurses* nc, int y, int x){
if(nc->cursory >= 0 || nc->cursorx >= 0){
logerror(nc, "Cursor is already enabled\n");
return -1;
}
if(y < 0 || x < 0){
logerror(nc, "Illegal cursor placement: %d, %d\n", y, x);
return -1;
@ -1113,13 +1117,12 @@ int notcurses_cursor_enable(notcurses* nc, int y, int x){
}
if(nc->ttyfd >= 0){
if(nc->tcache.cnorm){
if(stage_cursor(nc, nc->ttyfp, y, x) || fflush(nc->ttyfp)){
return -1;
}
nc->cursory = y;
nc->cursorx = x;
if(tty_emit("cnorm", nc->tcache.cnorm, nc->ttyfd) == 0){
return 0;
if(stage_cursor(nc, nc->ttyfp, y, x) == 0){
if(!tty_emit("cnorm", nc->tcache.cnorm, nc->ttyfd) && !fflush(nc->ttyfp)){
nc->cursory = y;
nc->cursorx = x;
return 0;
}
}
}
}
@ -1127,11 +1130,15 @@ int notcurses_cursor_enable(notcurses* nc, int y, int x){
}
int notcurses_cursor_disable(notcurses* nc){
nc->cursory = -1;
nc->cursorx = -1;
if(nc->cursorx < 0 || nc->cursory < 0){
logerror(nc, "Cursor is not enabled");
return -1;
}
if(nc->ttyfd >= 0){
if(nc->tcache.civis){
if(tty_emit("civis", nc->tcache.civis, nc->ttyfd) == 0){
if(!tty_emit("civis", nc->tcache.civis, nc->ttyfd) && !fflush(nc->ttyfp)){
nc->cursory = -1;
nc->cursorx = -1;
return 0;
}
}
@ -1140,7 +1147,12 @@ int notcurses_cursor_disable(notcurses* nc){
}
int notcurses_cursor_move_yx(notcurses* nc, int y, int x){
if(nc->cursory >= 0 && nc->cursorx >= 0){
if(nc->cursory < 0 || nc->cursorx < 0){
logerror(nc, "Cursor is not enabled");
return -1;
}
if(y < 0 || x < 0){
logerror(nc, "Illegal cursor placement: %d, %d\n", y, x);
return -1;
}
if(stage_cursor(nc, nc->ttyfp, y, x) || fflush(nc->ttyfp)){

Loading…
Cancel
Save