diff options
author | Roy Marples <roy@marples.name> | 2007-04-17 09:32:18 +0000 |
---|---|---|
committer | Roy Marples <roy@marples.name> | 2007-04-17 09:32:18 +0000 |
commit | f657d87b997f5b599d74a8f2eb6fef8dd6381550 (patch) | |
tree | 5bd3799657e97edabe5ff83e5ac145f3d15931d8 /src/einfo.h | |
parent | 0f92b5e7df4ead366984b5624de12446bd968478 (diff) |
Rationalise our colour usage a little.
Diffstat (limited to 'src/einfo.h')
-rw-r--r-- | src/einfo.h | 30 |
1 files changed, 7 insertions, 23 deletions
diff --git a/src/einfo.h b/src/einfo.h index 29f831a2..a99af240 100644 --- a/src/einfo.h +++ b/src/einfo.h @@ -18,30 +18,14 @@ typedef enum { - einfo_good, - einfo_warn, - einfo_bad, - einfo_hilite, - einfo_bracket, - einfo_normal + ecolor_good, + ecolor_warn, + ecolor_bad, + ecolor_hilite, + ecolor_bracket, + ecolor_normal } einfo_color_t; -/* Colour codes used by the below functions. */ -#define EINFO_GOOD "\033[32;01m" -#define EINFO_WARN "\033[33;01m" -#define EINFO_BAD "\033[31;01m" -#define EINFO_HILITE "\033[36;01m" -#define EINFO_BRACKET "\033[34;01m" -#define EINFO_NORMAL "\033[0m" - -/* Handy macros to easily use the above in a custom manner */ -#define PEINFO_GOOD if (colour_terminal ()) printf (EINFO_GOOD) -#define PEINFO_WARN if (colour_terminal ()) printf (EINFO_WARN) -#define PEINFO_BAD if (colour_terminal ()) printf (EINFO_BAD) -#define PEINFO_HILITE if (colour_terminal ()) printf (EINFO_HILITE) -#define PEINFO_BRACKET if (colour_terminal ()) printf (EINFO_BRACKET) -#define PEINFO_NORMAL if (colour_terminal ()) printf (EINFO_NORMAL) - /* We work out if the terminal supports colour or not through the use of the TERM env var. We cache the reslt in a static bool, so subsequent calls are very fast. @@ -51,7 +35,7 @@ typedef enum in the future, but veinfo is used by shell scripts as they don't have the va_list concept */ -bool colour_terminal (void); +const char *ecolor (einfo_color_t); int einfon (const char *fmt, ...) EINFO_PRINTF (1, 2); int ewarnn (const char *fmt, ...) EINFO_PRINTF (1, 2); int eerrorn (const char *fmt, ...) EINFO_PRINTF (1, 2); |