Просмотр исходного кода

interactive mode: print '\n' in sigint_handler, this flush stdout thus ensure color reset. (#283)

Qingyou Meng 2 лет назад
Родитель
Сommit
084e2f0ec0
1 измененных файлов с 1 добавлено и 0 удалено
  1. 1 0
      main.cpp

+ 1 - 0
main.cpp

@@ -747,6 +747,7 @@ static bool is_interacting = false;
 #if defined (__unix__) || (defined (__APPLE__) && defined (__MACH__)) || defined (_WIN32)
 #if defined (__unix__) || (defined (__APPLE__) && defined (__MACH__)) || defined (_WIN32)
 void sigint_handler(int signo) {
 void sigint_handler(int signo) {
     printf(ANSI_COLOR_RESET);
     printf(ANSI_COLOR_RESET);
+    printf("\n"); // this also force flush stdout.
     if (signo == SIGINT) {
     if (signo == SIGINT) {
         if (!is_interacting) {
         if (!is_interacting) {
             is_interacting=true;
             is_interacting=true;