1
0
Fork 0
mirror of https://github.com/eosswedenorg/antelope-keygen synced 2026-06-16 03:44:56 +02:00

console: add isColorsSupported()

This commit is contained in:
Henrik Hautakoski 2020-03-02 14:36:41 +01:00
parent f7858cb5bd
commit f676f2e7ca
2 changed files with 20 additions and 0 deletions

View file

@ -21,10 +21,28 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#include <iostream>
#include "core/isatty.h"
#include "console.h"
namespace eoskeygen { namespace console {
bool disable_color = false;
FILE* _getFileFromStream(const std::ostream& os) {
if (&os == &std::cout) {
return stdout;
} else if (&os == &std::cerr) {
return stderr;
}
return NULL;
}
bool isColorsSupported(const std::ostream& os) {
FILE* fd = _getFileFromStream(os);
return disable_color == false && isatty(fd);
}
} } // namespace eoskeygen::console