MCPcopy Create free account
hub / github.com/KTH-RPL/dufomap / is_atty

Function is_atty

src/indicators.hpp:856–875  ·  view source on GitHub ↗

Test whether a given `std::ostream` object refers to a terminal.

Source from the content-addressed store, hash-verified

854 //! Test whether a given `std::ostream` object refers to
855 //! a terminal.
856 inline
857 bool is_atty(const std::ostream& stream)
858 {
859 FILE* std_stream = get_standard_stream(stream);
860
861 // Unfortunately, fileno() ends with segmentation fault
862 // if invalid file descriptor is passed. So we need to
863 // handle this case gracefully and assume it's not a tty
864 // if standard stream is not detected, and 0 is returned.
865 if (!std_stream)
866 return false;
867
868 #if defined(TERMCOLOR_TARGET_POSIX)
869 return ::isatty(fileno(std_stream));
870 #elif defined(TERMCOLOR_TARGET_WINDOWS)
871 return ::_isatty(_fileno(std_stream));
872 #else
873 return false;
874 #endif
875 }
876
877 #if defined(TERMCOLOR_TARGET_WINDOWS)
878 //! Change Windows Terminal colors attribute. If some

Callers 2

is_colorizedFunction · 0.85
win_change_attributesFunction · 0.85

Calls 1

get_standard_streamFunction · 0.85

Tested by

no test coverage detected