locate_cursor_early: require ttyfd #1880

pull/1867/head
nick black 3 years ago
parent acc66372b5
commit e870e12285
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

@ -794,18 +794,20 @@ int cursor_yx_get(int ttyfd, const char* u7, int* y, int* x){
}
int locate_cursor_early(struct notcurses* nc, int* cursor_y, int* cursor_x){
const char* u7 = get_escape(&nc->tcache, ESCAPE_DSRCPR);
// FIXME ought check for cursor inversion!
int ret = cursor_yx_get(nc->ttyfd, u7, cursor_y, cursor_x);
if(ret == 0){
if(nc->tcache.inverted_cursor){
int tmp = *cursor_y;
*cursor_y = *cursor_x;
*cursor_x = tmp;
}
// we use 0-based coordinates, but known terminals use 1-based coordinates
--*cursor_y;
--*cursor_x;
if(nc->ttyfd >= 0){
const char* u7 = get_escape(&nc->tcache, ESCAPE_DSRCPR);
// FIXME ought check for cursor inversion!
int ret = cursor_yx_get(nc->ttyfd, u7, cursor_y, cursor_x);
if(ret == 0){
if(nc->tcache.inverted_cursor){
int tmp = *cursor_y;
*cursor_y = *cursor_x;
*cursor_x = tmp;
}
// we use 0-based coordinates, but known terminals use 1-based coordinates
--*cursor_y;
--*cursor_x;
}
}
return ret;
}

Loading…
Cancel
Save