diff options
author | Tiger Wang <ziwei.tiger@hotmail.co.uk> | 2013-08-14 13:03:13 +0200 |
---|---|---|
committer | Tiger Wang <ziwei.tiger@hotmail.co.uk> | 2013-08-14 13:03:13 +0200 |
commit | 77468f87b75204ed55147761290bb3450ddb1436 (patch) | |
tree | e1ca5f65763b7835d682246a613419277e8f22d1 /Tests | |
parent | Alpha sorted PistonBreakable list (diff) | |
parent | Partially fixed tonibm19's mess. (diff) | |
download | cuberite-77468f87b75204ed55147761290bb3450ddb1436.tar cuberite-77468f87b75204ed55147761290bb3450ddb1436.tar.gz cuberite-77468f87b75204ed55147761290bb3450ddb1436.tar.bz2 cuberite-77468f87b75204ed55147761290bb3450ddb1436.tar.lz cuberite-77468f87b75204ed55147761290bb3450ddb1436.tar.xz cuberite-77468f87b75204ed55147761290bb3450ddb1436.tar.zst cuberite-77468f87b75204ed55147761290bb3450ddb1436.zip |
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/ConsoleColors/ConsoleColors.cpp | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/Tests/ConsoleColors/ConsoleColors.cpp b/Tests/ConsoleColors/ConsoleColors.cpp new file mode 100644 index 000000000..7efc698b2 --- /dev/null +++ b/Tests/ConsoleColors/ConsoleColors.cpp @@ -0,0 +1,62 @@ + +// ConsoleColors.cpp + +// Tests the various console color combinations + +#include <stdio.h> +#include <stdlib.h> + + + + + +/// Evaluates to the number of elements in an array (compile-time!) +#define ARRAYCOUNT(X) (sizeof(X) / sizeof(*(X))) + + + + + +int main(void) +{ + static const char * Attribs[] = + { + "0", // All attribs off + "1", // bold + "2", // faint + "7", // inverse + "1;7", // bold inverse + "2;7", // faint inverse + } ; + for (int i = 0; i < ARRAYCOUNT(Attribs); i++) + { + const char * Attrib = Attribs[i]; + for (int fg = 30; fg <= 37; fg++) + { + for (int bg = 40; bg <= 47; bg++) + { + printf("\x1b[%s;%d;%dm %s;%d;%d ", Attrib, fg, bg, Attrib, fg, bg); + } // for bg + puts("\x1b[0m"); // Reset terminal back to normal colors for the newline + } // for fg + } // for i - Attribs[] + + for (int i = 1; i < ARRAYCOUNT(Attribs); i++) + { + const char * Attrib = Attribs[i]; + for (int fg = 30; fg <= 37; fg++) + { + for (int bg = 40; bg <= 47; bg++) + { + printf("\x1b[%d;%d;%sm %d;%d;%s ", fg, bg, Attrib, fg, bg, Attrib); + } // for bg + puts("\x1b[0m"); // Reset terminal back to normal colors for the newline + } // for fg + } // for i - Attribs[] + + return 0; +} + + + + |