Fix truecolor support detection

This commit is contained in:
Bob Polis 2024-01-27 17:08:48 +01:00
parent d4b0ae591d
commit f785ecf9c1

View File

@ -9,9 +9,12 @@ static inline int t2p(int val) {
} }
static void write(std::ostream& os, FILE* in) { static void write(std::ostream& os, FILE* in) {
char* tc = getenv("TRUECOLOR"); char* tc = getenv("COLORTERM");
std::string truecolor {tc ? tc : ""}; std::string colorterm {tc ? tc : ""};
bool has_truecolor = truecolor.size() > 0; bool has_truecolor = colorterm.size() > 0;
if (has_truecolor) {
has_truecolor = colorterm == "truecolor" || colorterm == "24bit";
}
struct pam info; struct pam info;
pnm_readpaminit(in, &info, PAM_STRUCT_SIZE(tuple_type)); pnm_readpaminit(in, &info, PAM_STRUCT_SIZE(tuple_type));
std::unique_ptr<tuple, void(*)(void*)> row1 {pnm_allocpamrow(&info), pm_freerow}; std::unique_ptr<tuple, void(*)(void*)> row1 {pnm_allocpamrow(&info), pm_freerow};