Jens Mueller wrote: >Trass3r wrote: >> >You could use ANSI codes on posix to avoid a dependency on curses: >> >http://en.wikipedia.org/wiki/ANSI_escape_code#Colors >> >But I think using curses is ok. ncurses is MIT licensed and can be >> >used as a dynamic library, so I don't think there are license >> >problems. >> > >> >However, I'd recommend to load ncurses dynamically with dlopen/dlsym >> >and fallback to simple text output if the ncurses library cannot be >> >loaded. >> >> +1 >> There shouldn't be a hard dependency on curses. > >I had the impression that even though there is this standard how do I >know that I have a standard-compliant terminal. Can I just assume this? >I started using curses because I had the impression there may be >non-standard terminals. But this seems to be minor issue. I will change >this if people are happy with Windows and ISO/IEC 6429 compliant >terminals only. >Thanks. > >Jens
AFAIK the capabilities of a terminal are found using the terminfo database: http://en.wikipedia.org/wiki/Terminal_capabilities But it seems there's no standard stand-alone library to access this database. Curses seems the only simple way to access this database, so I'd say: Try to load curses at runtime, if that fails, fall back to simple non-colored text output. BTW: you could also use isatty (http://linux.die.net/man/3/isatty) to detect if stdout has been redirected and disable color output in that case. For windows: https://forums.embarcadero.com/thread.jspa?threadID=21194 or http://msdn.microsoft.com/de-de/library/f4s0ddew(v=vs.80).aspx -- Johannes Pfau