]> git.sur5r.net Git - tio/blobdiff - src/print.h
Update upstream source from tag 'upstream/2.0'
[tio] / src / print.h
index c212a7c875cd82bdc04cc40a87f0745eebad8e99..e3f61939f32a7ecad9347465373be03f0bbc5bed 100644 (file)
 
 #pragma once
 
+#include <stdio.h>
 #include <stdbool.h>
 #include "misc.h"
 #include "error.h"
 #include "options.h"
+#include "timestamp.h"
 
 extern bool print_tainted;
 extern char ansi_format[];
@@ -33,45 +35,65 @@ extern char ansi_format[];
 
 #define ansi_printf(format, args...) \
 { \
+  if (!option.mute) { \
   if (option.color < 0) \
     fprintf (stdout, "\r" format "\r\n", ## args); \
   else \
     fprintf (stdout, "\r%s" format ANSI_RESET "\r\n", ansi_format, ## args); \
+  } \
 }
 
 #define ansi_error_printf(format, args...) \
 { \
+  if (!option.mute) { \
   if (option.color < 0) \
     fprintf (stderr, "\r" format "\r\n", ## args); \
   else \
     fprintf (stderr, "\r%s" format ANSI_RESET "\r\n", ansi_format, ## args); \
   fflush(stderr); \
+  } \
 }
 
 #define ansi_printf_raw(format, args...) \
 { \
+  if (!option.mute) { \
   if (option.color < 0) \
     fprintf (stdout, format, ## args); \
   else \
     fprintf (stdout, "%s" format ANSI_RESET, ansi_format, ## args); \
+  } \
 }
 
 #define tio_warning_printf(format, args...) \
 { \
+  if (!option.mute) { \
   if (print_tainted) \
     putchar('\n'); \
   if (option.color < 0) \
-    fprintf (stdout, "\r[%s] Warning: " format "\r\n", current_time(), ## args); \
+    fprintf (stdout, "\r[%s] Warning: " format "\r\n", timestamp_current_time(), ## args); \
   else \
-    ansi_printf("[%s] Warning: " format, current_time(), ## args); \
+    ansi_printf("[%s] Warning: " format, timestamp_current_time(), ## args); \
+  } \
 }
 
 #define tio_printf(format, args...) \
 { \
+  if (!option.mute) { \
   if (print_tainted) \
     putchar('\n'); \
-  ansi_printf("[%s] " format, current_time(), ## args); \
+  ansi_printf("[%s] " format, timestamp_current_time(), ## args); \
   print_tainted = false; \
+  } \
+}
+
+#define tio_printf_raw(format, args...) \
+{ \
+  if (!option.mute) { \
+  if (print_tainted) \
+    putchar('\n'); \
+  ansi_printf_raw("[%s] " format, timestamp_current_time(), ## args); \
+  print_tainted = false; \
+  } \
 }
 
 #ifdef DEBUG
@@ -87,3 +109,4 @@ extern char ansi_format[];
 void print_hex(char c);
 void print_normal(char c);
 void print_init_ansi_formatting(void);
+void tio_printf_array(const char *array);