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){ int locate_cursor_early(struct notcurses* nc, int* cursor_y, int* cursor_x){
const char* u7 = get_escape(&nc->tcache, ESCAPE_DSRCPR); if(nc->ttyfd >= 0){
// FIXME ought check for cursor inversion! const char* u7 = get_escape(&nc->tcache, ESCAPE_DSRCPR);
int ret = cursor_yx_get(nc->ttyfd, u7, cursor_y, cursor_x); // FIXME ought check for cursor inversion!
if(ret == 0){ int ret = cursor_yx_get(nc->ttyfd, u7, cursor_y, cursor_x);
if(nc->tcache.inverted_cursor){ if(ret == 0){
int tmp = *cursor_y; if(nc->tcache.inverted_cursor){
*cursor_y = *cursor_x; int tmp = *cursor_y;
*cursor_x = tmp; *cursor_y = *cursor_x;
} *cursor_x = tmp;
// we use 0-based coordinates, but known terminals use 1-based coordinates }
--*cursor_y; // we use 0-based coordinates, but known terminals use 1-based coordinates
--*cursor_x; --*cursor_y;
--*cursor_x;
}
} }
return ret; return ret;
} }

Loading…
Cancel
Save