1 #include "internal.hpp" 2 3 namespace CaDiCaL { 4 Terminal(FILE * f)5Terminal::Terminal (FILE * f) : file (f), reset_on_exit (false) { 6 assert (file); 7 int fd = fileno (f); 8 assert (fd == 1 || fd == 2); 9 use_colors = connected = isatty (fd); 10 } 11 force_colors()12void Terminal::force_colors () { use_colors = connected = true;} force_no_colors()13void Terminal::force_no_colors () { use_colors = false; } force_reset_on_exit()14void Terminal::force_reset_on_exit () { reset_on_exit = true; } 15 reset()16void Terminal::reset () { 17 if (!connected) return; 18 erase_until_end_of_line (); 19 cursor (true); 20 normal (); 21 fflush (file); 22 } 23 disable()24void Terminal::disable () { 25 reset (); 26 connected = use_colors = false; 27 } 28 ~Terminal()29Terminal::~Terminal () { if (reset_on_exit) reset (); } 30 31 Terminal tout (stdout); 32 Terminal terr (stderr); 33 34 } 35