2021-09-04 22:59:45 +00:00
|
|
|
#include <zlib.h>
|
|
|
|
#include "internal.h"
|
|
|
|
|
|
|
|
// only invoked without suppress banners flag. prints various warnings based on
|
|
|
|
// the environment / terminal definition. returns the number of lines printed.
|
|
|
|
static int
|
2021-09-04 23:19:55 +00:00
|
|
|
init_banner_warnings(const notcurses* nc, fbuf* f, const char* clreol){
|
2021-09-04 22:59:45 +00:00
|
|
|
term_fg_palindex(nc, f, nc->tcache.caps.colors <= 88 ? 1 : 0xcb);
|
|
|
|
if(!notcurses_canutf8(nc)){
|
2021-09-04 23:19:55 +00:00
|
|
|
fbuf_puts(f, clreol);
|
2021-10-07 21:43:21 +00:00
|
|
|
fbuf_puts(f, " Warning! Encoding is not UTF-8; output may be degraded." NL);
|
2021-09-04 22:59:45 +00:00
|
|
|
}
|
|
|
|
if(!get_escape(&nc->tcache, ESCAPE_HPA)){
|
2021-09-04 23:19:55 +00:00
|
|
|
fbuf_puts(f, clreol);
|
2021-10-07 21:43:21 +00:00
|
|
|
fbuf_puts(f, " Warning! No absolute horizontal placement." NL);
|
2021-09-04 22:59:45 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// unless the suppress_banner flag was set, print some version information and
|
|
|
|
// (if applicable) warnings to ttyfp. we are not yet on the alternate screen.
|
|
|
|
int init_banner(const notcurses* nc, fbuf* f){
|
2021-09-04 23:19:55 +00:00
|
|
|
const char* clreol = get_escape(&nc->tcache, ESCAPE_EL);
|
|
|
|
if(clreol == NULL){
|
|
|
|
clreol = "";
|
|
|
|
}
|
2021-09-04 22:59:45 +00:00
|
|
|
if(!nc->suppress_banner){
|
|
|
|
term_fg_palindex(nc, f, 50 % nc->tcache.caps.colors);
|
2021-10-21 23:02:09 +00:00
|
|
|
char* osver = notcurses_osversion();
|
2021-10-20 13:52:56 +00:00
|
|
|
fbuf_printf(f, "%snotcurses %s on %s %s%s(%s)" NL,
|
2021-09-05 20:40:38 +00:00
|
|
|
clreol, notcurses_version(),
|
2021-09-04 22:59:45 +00:00
|
|
|
nc->tcache.termname ? nc->tcache.termname : "?",
|
2021-10-20 08:49:08 +00:00
|
|
|
nc->tcache.termversion ? nc->tcache.termversion : "",
|
2021-10-21 23:02:09 +00:00
|
|
|
nc->tcache.termversion ? " " : "", osver ? osver : "unknown");
|
|
|
|
free(osver);
|
2021-09-04 22:59:45 +00:00
|
|
|
term_fg_palindex(nc, f, nc->tcache.caps.colors <= 256 ?
|
|
|
|
14 % nc->tcache.caps.colors : 0x2080e0);
|
|
|
|
if(nc->tcache.cellpixy && nc->tcache.cellpixx){
|
2021-09-04 23:19:55 +00:00
|
|
|
fbuf_printf(f, "%s%d rows (%dpx) %d cols (%dpx) %dx%d ",
|
|
|
|
clreol,
|
2021-09-04 22:59:45 +00:00
|
|
|
nc->stdplane->leny, nc->tcache.cellpixy,
|
|
|
|
nc->stdplane->lenx, nc->tcache.cellpixx,
|
|
|
|
nc->stdplane->leny * nc->tcache.cellpixy,
|
|
|
|
nc->stdplane->lenx * nc->tcache.cellpixx);
|
|
|
|
}else{
|
|
|
|
fbuf_printf(f, "%d rows %d cols ",
|
|
|
|
nc->stdplane->leny, nc->stdplane->lenx);
|
|
|
|
}
|
|
|
|
if(nc->tcache.caps.rgb && get_escape(&nc->tcache, ESCAPE_SETAF)){
|
|
|
|
term_fg_rgb8(&nc->tcache, f, 0xe0, 0x60, 0x60);
|
|
|
|
fbuf_putc(f, 'r');
|
|
|
|
term_fg_rgb8(&nc->tcache, f, 0x60, 0xe0, 0x60);
|
|
|
|
fbuf_putc(f, 'g');
|
|
|
|
term_fg_rgb8(&nc->tcache, f, 0x20, 0x80, 0xff);
|
|
|
|
fbuf_putc(f, 'b');
|
|
|
|
term_fg_palindex(nc, f, nc->tcache.caps.colors <= 256 ?
|
|
|
|
14 % nc->tcache.caps.colors : 0x2080e0);
|
|
|
|
fbuf_putc(f, '+');
|
|
|
|
}
|
2021-10-26 13:46:44 +00:00
|
|
|
// we want the terminfo version, which is tied to ncurses
|
|
|
|
const char* ncursesver = curses_version();
|
|
|
|
const char* ncver = strchr(ncursesver, ' ');
|
|
|
|
ncver = ncver ? ncver + 1 : ncursesver;
|
|
|
|
fbuf_printf(f, "%u colors" NL "%s%s%s (%s)" NL "%sterminfo %s zlib %s GPM %s" NL,
|
2021-09-04 23:19:55 +00:00
|
|
|
nc->tcache.caps.colors, clreol,
|
2021-09-04 22:59:45 +00:00
|
|
|
#ifdef __clang__
|
|
|
|
"", // name is contained in __VERSION__
|
|
|
|
#else
|
|
|
|
#ifdef __GNUC__
|
|
|
|
"gcc-",
|
|
|
|
#else
|
|
|
|
#error "Unknown compiler"
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
__VERSION__,
|
|
|
|
#ifdef __BYTE_ORDER__
|
|
|
|
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
|
|
|
"LE",
|
|
|
|
#else
|
|
|
|
"BE",
|
|
|
|
#endif
|
|
|
|
#else
|
|
|
|
#error "No __BYTE_ORDER__ definition"
|
|
|
|
#endif
|
2021-10-26 13:46:44 +00:00
|
|
|
clreol, ncver, zlibVersion(), gpm_version());
|
2021-09-04 23:19:55 +00:00
|
|
|
fbuf_puts(f, clreol); // for ncvisual banner
|
2021-09-04 22:59:45 +00:00
|
|
|
ncvisual_printbanner(f);
|
2021-09-04 23:19:55 +00:00
|
|
|
init_banner_warnings(nc, f, clreol);
|
2021-09-04 22:59:45 +00:00
|
|
|
const char* esc;
|
|
|
|
if( (esc = get_escape(&nc->tcache, ESCAPE_SGR0)) ||
|
|
|
|
(esc = get_escape(&nc->tcache, ESCAPE_OP))){
|
|
|
|
fbuf_emit(f, esc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|