From 39176a1d06dccae9340383f818a556df4cea3335 Mon Sep 17 00:00:00 2001 From: David Phillips Date: Wed, 16 May 2018 19:25:58 +1200 Subject: Add compile-time flag to disable coloured output Turns out windows builds run in plain powershell or cmd.exe display the raw ANSI escape sequences rather than interpreting. No official support for interpreting them that I can see. --- README.md | 5 ++++- colour.h | 35 ++++++++++++++++++++++++++++++++++- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index fd7f6c6..9fd1b80 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ platforms with both gcc and clang. Builds and tests have been successfully carried out for: -* Windows with MinGW on Linux +* Windows with MinGW on Linux - I cannot support coloured output for Windows * Solaris 10 but these are not automated, nor are they part of the primarily supported @@ -64,3 +64,6 @@ similar tools out there when pushing work across cores. ## Inspiration sand leek was greatly inspired by schallot, escahlot and scallion. +## Compile-time flags + +* `SAND_LEEK_DISABLE_COLOUR` - Don't compile in any support for coloured output. Recommended for Windows builds unless support can be had for ANSI escape sequences diff --git a/colour.h b/colour.h index 2fe75c2..c1723c5 100644 --- a/colour.h +++ b/colour.h @@ -1,6 +1,8 @@ #ifndef SAND_LEEK_COLOUR_H #define SAND_LEEK_COLOUR_H +#ifndef SAND_LEEK_DISABLE_COLOUR + #define ANSI_ESC "\x1b[" #define COLOUR_BLACK ANSI_ESC"30m" #define COLOUR_RED ANSI_ESC"31m" @@ -28,4 +30,35 @@ #define COLOUR_ERASE ANSI_ESC"2K" -#endif +#else /* ifndef SAND_LEEK_DISABLE_COLOUR */ + +#define ANSI_ESC "" +#define COLOUR_BLACK "" +#define COLOUR_RED "" +#define COLOUR_GREEN "" +#define COLOUR_YELLOW "" +#define COLOUR_BLUE "" +#define COLOUR_MAGENTA "" +#define COLOUR_CYAN "" +#define COLOUR_WHITE "" + +#define COLOUR_BBLACK "" +#define COLOUR_BRED "" +#define COLOUR_BGREEN "" +#define COLOUR_BYELLOW "" +#define COLOUR_BBLUE "" +#define COLOUR_BMAGENTA "" +#define COLOUR_BCYAN "" +#define COLOUR_BWHITE "" + +#define COLOUR_BOLD "" +#define COLOUR_BOLD_OFF "" + +#define COLOUR_OFF "" +#define COLOUR_ALL_OFF "" + +#define COLOUR_ERASE "" + +#endif /* ifndef SAND_LEEK_DISABLE_COLOUR */ + +#endif /* #ifndef SAND_LEEK_COLOUR_H */ -- cgit v1.1