termdesc: set up termversion #1798, print in banners

This commit is contained in:
nick black 2021-06-20 05:43:34 -04:00
parent 8d86fd3162
commit ed04cb72c5
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC
4 changed files with 15 additions and 10 deletions

View File

@ -594,16 +594,8 @@ void sigwinch_handler(int signo);
void init_lang(void); void init_lang(void);
// load |ti| from the terminfo database, which must already have been
// initialized. set |utf8| if we've verified UTF8 output encoding.
// set |noaltscreen| to inhibit alternate screen detection. |fd| ought
// be connected to a terminal device, or -1 if no terminal is available.
int interrogate_terminfo(tinfo* ti, int fd, const char* termname, unsigned utf8,
unsigned noaltscreen, unsigned nocbreak);
int term_supported_styles(const tinfo* ti);
int reset_term_attributes(const tinfo* ti, FILE* fp); int reset_term_attributes(const tinfo* ti, FILE* fp);
void free_terminfo_cache(tinfo* ti);
// if there were missing elements we wanted from terminfo, bitch about them here // if there were missing elements we wanted from terminfo, bitch about them here
void warn_terminfo(const notcurses* nc, const tinfo* ti); void warn_terminfo(const notcurses* nc, const tinfo* ti);

View File

@ -876,7 +876,8 @@ init_banner(const notcurses* nc){
char prefixbuf[BPREFIXSTRLEN + 1]; char prefixbuf[BPREFIXSTRLEN + 1];
term_fg_palindex(nc, stdout, 50 % nc->tcache.caps.colors); term_fg_palindex(nc, stdout, 50 % nc->tcache.caps.colors);
printf("\n notcurses %s by nick black et al", notcurses_version()); printf("\n notcurses %s by nick black et al", notcurses_version());
printf(" on %s", nc->tcache.termname ? nc->tcache.termname : "?"); printf(" on %s %s", nc->tcache.termname ? nc->tcache.termname : "?",
nc->tcache.termversion ? nc->tcache.termversion : "");
term_fg_palindex(nc, stdout, 12 % nc->tcache.caps.colors); term_fg_palindex(nc, stdout, 12 % nc->tcache.caps.colors);
if(nc->tcache.cellpixy && nc->tcache.cellpixx){ if(nc->tcache.cellpixy && nc->tcache.cellpixx){
printf("\n %d rows (%dpx) %d cols (%dpx) (%sB) %zuB crend %d colors", printf("\n %d rows (%dpx) %d cols (%dpx) (%sB) %zuB crend %d colors",

View File

@ -107,8 +107,9 @@ match_termname(const char* termname, queried_terminals_e* qterm){
} }
void free_terminfo_cache(tinfo* ti){ void free_terminfo_cache(tinfo* ti){
free(ti->esctable);
ncinputlayer_stop(&ti->input); ncinputlayer_stop(&ti->input);
free(ti->termversion);
free(ti->esctable);
} }
// tlen -- size of escape table. tused -- used bytes in same. // tlen -- size of escape table. tused -- used bytes in same.
@ -505,5 +506,6 @@ int interrogate_terminfo(tinfo* ti, int fd, const char* termname, unsigned utf8,
err: err:
free(ti->esctable); free(ti->esctable);
free(ti->termversion);
return -1; return -1;
} }

View File

@ -144,6 +144,7 @@ typedef struct tinfo {
int (*pixel_clear_all)(int fd); // called during startup, kitty only int (*pixel_clear_all)(int fd); // called during startup, kitty only
int sprixel_scale_height; // sprixel must be a multiple of this many rows int sprixel_scale_height; // sprixel must be a multiple of this many rows
const char* termname; // terminal name from environment variables/init const char* termname; // terminal name from environment variables/init
char* termversion; // terminal version (freeform) from query responses
struct termios tpreserved; // terminal state upon entry struct termios tpreserved; // terminal state upon entry
ncinputlayer input; // input layer ncinputlayer input; // input layer
bool bitmap_supported; // do we support bitmaps (post pixel_query_done)? bool bitmap_supported; // do we support bitmaps (post pixel_query_done)?
@ -170,6 +171,15 @@ term_supported_styles(const tinfo* ti){
return ti->supported_styles; return ti->supported_styles;
} }
// load |ti| from the terminfo database, which must already have been
// initialized. set |utf8| if we've verified UTF8 output encoding.
// set |noaltscreen| to inhibit alternate screen detection. |fd| ought
// be connected to a terminal device, or -1 if no terminal is available.
int interrogate_terminfo(tinfo* ti, int fd, const char* termname, unsigned utf8,
unsigned noaltscreen, unsigned nocbreak);
void free_terminfo_cache(tinfo* ti);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif