Branch data Line data Source code
1 : : #include <mutable/util/terminal.hpp> 2 : : 3 : : #include <mutable/util/fn.hpp> 4 : : #include <cstdlib> 5 : : 6 : : 7 : 0 : bool m::term::has_color() 8 : : { 9 : 0 : constexpr const char *SUPPORTED_TERMS[] = { 10 : : "ansi", 11 : : "color", 12 : : "cygwin", 13 : : "linux", 14 : : "rxvt-unicode-256color", 15 : : "vt100", 16 : : "xterm", 17 : : "xterm-256", 18 : : "xterm-256color", 19 : : }; 20 [ # # ]: 0 : if (auto term = std::getenv("TERM")) { 21 [ # # ]: 0 : for (auto supported : SUPPORTED_TERMS) { 22 [ # # ]: 0 : if (m::streq(term, supported)) 23 : 0 : return true; 24 : : } 25 : 0 : } 26 : 0 : return false; 27 : 0 : }