[tcache] always track most recent cell geometry #2233

pull/2239/head
nick black 3 years ago
parent 4c81a72bab
commit 9502fcea80
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

@ -259,19 +259,20 @@ int update_term_dimensions(int* rows, int* cols, tinfo* tcache, int margin_b){
}
return 0;
}
int rowsafe, colsafe;
if(rows == NULL){
rows = &rowsafe;
}
if(cols == NULL){
cols = &colsafe;
}
#ifndef __MINGW64__
struct winsize ws;
if(tiocgwinsz(tcache->ttyfd, &ws)){
return -1;
}
int rowsafe;
if(rows == NULL){
rows = &rowsafe;
}
*rows = ws.ws_row;
if(cols){
*cols = ws.ws_col;
}
*cols = ws.ws_col;
if(tcache){
#ifdef __linux__
if(tcache->linux_fb_fd >= 0){
@ -296,21 +297,14 @@ int update_term_dimensions(int* rows, int* cols, tinfo* tcache, int margin_b){
#else
CONSOLE_SCREEN_BUFFER_INFO csbi;
if(GetConsoleScreenBufferInfo(tcache->outhandle, &csbi)){
if(cols){
*cols = csbi.srWindow.Right - csbi.srWindow.Left + 1;
}
if(rows){
*rows = csbi.srWindow.Bottom - csbi.srWindow.Top + 1;
}
*cols = csbi.srWindow.Right - csbi.srWindow.Left + 1;
*rows = csbi.srWindow.Bottom - csbi.srWindow.Top + 1;
}else{
if(rows){
*rows = tcache->default_rows;
}
if(cols){
*cols = tcache->default_cols;
}
*rows = tcache->default_rows;
*cols = tcache->default_cols;
}
#endif
update_tinfo_geometry(tcache, *rows, *cols);
if(tcache->sixel_maxy_pristine){
int sixelrows = *rows - 1;
// if the bottom margin is at least one row, we can draw into the last

@ -41,6 +41,8 @@ get_default_geometry(tinfo* ti){
loginfo("Default geometry: %d row%s, %d column%s\n",
ti->default_rows, ti->default_rows != 1 ? "s" : "",
ti->default_cols, ti->default_cols != 1 ? "s" : "");
ti->dimy = ti->default_rows;
ti->dimx = ti->default_cols;
}
// we found Sixel support -- set up its API. invert80 refers to whether the
@ -943,6 +945,8 @@ int interrogate_terminfo(tinfo* ti, const char* termtype, FILE* out, unsigned ut
// random transient measurement?
ti->default_rows = iresp->dimy;
ti->default_cols = iresp->dimx;
ti->dimy = iresp->dimy;
ti->dimx = iresp->dimx;
}
if(iresp->pixy && iresp->pixx){
ti->pixy = iresp->pixy;

@ -106,6 +106,7 @@ typedef struct tinfo {
// be acquired on all terminals with pixel support.
int cellpixy; // cell pixel height, might be 0
int cellpixx; // cell pixel width, might be 0
int dimy, dimx; // most recent cell geometry
unsigned supported_styles; // bitmask over NCSTYLE_* driven via sgr/ncv
@ -189,6 +190,13 @@ typedef struct tinfo {
bool in_alt_screen; // are we in the alternate screen?
} tinfo;
static inline void
update_tinfo_geometry(tinfo* ti, int dimy, int dimx){
// FIXME probably need a lock on this!
ti->dimy = dimy;
ti->dimx = dimx;
}
// retrieve the terminfo(5)-style escape 'e' from tdesc (NULL if undefined).
static inline __attribute__ ((pure)) const char*
get_escape(const tinfo* tdesc, escape_e e){

Loading…
Cancel
Save