]> git.sur5r.net Git - tio/blob - src/include/tio/print.h
New upstream version 1.32
[tio] / src / include / tio / print.h
1 /*
2  * tio - a simple TTY terminal I/O application
3  *
4  * Copyright (c) 2014-2017  Martin Lund
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19  * 02110-1301, USA.
20  */
21
22 #ifndef PRINT_H
23 #define PRINT_H
24
25 #define ANSI_COLOR_GRAY      "\x1b[1;30m"
26 #define ANSI_COLOR_RED       "\x1b[1;31m"
27 #define ANSI_COLOR_GREEN     "\x1b[1;32m"
28 #define ANSI_COLOR_YELLOW    "\x1b[1;33m"
29 #define ANSI_COLOR_BLUE      "\x1b[1;34m"
30 #define ANSI_COLOR_PINK      "\x1b[1;35m"
31 #define ANSI_COLOR_CYAN      "\x1b[1;36m"
32 #define ANSI_COLOR_WHITE     "\x1b[1;37m"
33 #define ANSI_COLOR_RESET     "\x1b[0m"
34
35 #define color_printf(format, args...) \
36    { \
37      fprintf (stdout, "\r" ANSI_COLOR_YELLOW format ANSI_COLOR_RESET "\r\n", ## args); \
38      fflush(stdout); \
39    }
40
41 #define warning_printf(format, args...) \
42    { \
43      fprintf (stdout, "\rWarning: " format "\r\n", ## args); \
44      fflush(stdout); \
45    }
46
47 #ifdef DEBUG
48 #define debug_printf(format, args...) \
49    fprintf (stdout, "[debug] " format, ## args)
50 #define debug_printf_raw(format, args...) \
51    fprintf (stdout, "" format, ## args)
52 #else
53 #define debug_printf(format, args...)
54 #define debug_printf_raw(format, args...)
55 #endif
56
57 #endif