From 9ccd762ee98823e8de27e294ce8b63e3eb8f2f9b Mon Sep 17 00:00:00 2001 From: Wiimm Date: Wed, 7 Apr 2021 11:00:18 +0200 Subject: SZS 2.24a --- project/dclib/dclib-color.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'project/dclib/dclib-color.c') diff --git a/project/dclib/dclib-color.c b/project/dclib/dclib-color.c index 601a920..07e8625 100644 --- a/project/dclib/dclib-color.c +++ b/project/dclib/dclib-color.c @@ -3316,19 +3316,29 @@ const ColorSet_t * GetColorSetAuto ( bool force_on ) if ( auto_mode == COLMD_AUTO ) { + char *term = getenv("TERM"); + + #ifdef __CYGWIN__ + if (!term) + term = "cygwin"; + #else + if (!term) + term = "vt100"; + #endif + int error; - setupterm(getenv("TERM"),1,&error); + setupterm(term,1,&error); const int ncol = tigetnum("colors"); auto_mode = ncol >= 256 ? COLMD_256_COLORS : ncol >= 8 ? COLMD_8_COLORS : COLMD_OFF; - if ( auto_mode == COLMD_OFF && !strcmp(getenv("TERM"),"cygwin") ) + if ( auto_mode == COLMD_OFF && !strcmp(term,"cygwin") ) auto_mode = COLMD_8_COLORS; #ifdef TEST fprintf(stderr,">>> GetColorSetAuto(%d) => \"%s\" n=%d => %d [%s]\n", - force_on, getenv("TERM"), ncol, + force_on, term, ncol, auto_mode, GetColorModeName(auto_mode,0) ); #endif } -- cgit v1.3.1