Ansicodes

This commit is contained in:
Imbus 2025-09-14 13:30:11 +02:00
parent d4da05253d
commit 80825e620c
3 changed files with 136 additions and 0 deletions

64
ansicodes/ansi.h Normal file
View file

@ -0,0 +1,64 @@
#ifndef ANSI_H
#define ANSI_H
/* Set this to make all the codes no-ops */
//#define ANSI_DISABLE
#ifndef ANSI_DISABLE
#define ESC(x) x
#else
#define ESC(x)
#endif
/* Reset */
#define ANSI_RESET ESC("\033[0m")
/* Styles */
#define ANSI_BOLD ESC("\033[1m")
#define ANSI_DIM ESC("\033[2m")
#define ANSI_UNDER ESC("\033[4m")
#define ANSI_BLINK ESC("\033[5m")
#define ANSI_REV ESC("\033[7m")
#define ANSI_HIDDEN ESC("\033[8m")
/* Foreground colors */
#define ANSI_FG_BLACK ESC("\033[30m")
#define ANSI_FG_RED ESC("\033[31m")
#define ANSI_FG_GREEN ESC("\033[32m")
#define ANSI_FG_YELLOW ESC("\033[33m")
#define ANSI_FG_BLUE ESC("\033[34m")
#define ANSI_FG_MAGENTA ESC("\033[35m")
#define ANSI_FG_CYAN ESC("\033[36m")
#define ANSI_FG_WHITE ESC("\033[37m")
/* Bright foreground colors */
#define ANSI_FG_BBLACK ESC("\033[90m")
#define ANSI_FG_BRED ESC("\033[91m")
#define ANSI_FG_BGREEN ESC("\033[92m")
#define ANSI_FG_BYELLOW ESC("\033[93m")
#define ANSI_FG_BBLUE ESC("\033[94m")
#define ANSI_FG_BMAGENTA ESC("\033[95m")
#define ANSI_FG_BCYAN ESC("\033[96m")
#define ANSI_FG_BWHITE ESC("\033[97m")
/* Background colors */
#define ANSI_BG_BLACK ESC("\033[40m")
#define ANSI_BG_RED ESC("\033[41m")
#define ANSI_BG_GREEN ESC("\033[42m")
#define ANSI_BG_YELLOW ESC("\033[43m")
#define ANSI_BG_BLUE ESC("\033[44m")
#define ANSI_BG_MAGENTA ESC("\033[45m")
#define ANSI_BG_CYAN ESC("\033[46m")
#define ANSI_BG_WHITE ESC("\033[47m")
/* Bright background colors */
#define ANSI_BG_BBLACK ESC("\033[100m")
#define ANSI_BG_BRED ESC("\033[101m")
#define ANSI_BG_BGREEN ESC("\033[102m")
#define ANSI_BG_BYELLOW ESC("\033[103m")
#define ANSI_BG_BBLUE ESC("\033[104m")
#define ANSI_BG_BMAGENTA ESC("\033[105m")
#define ANSI_BG_BCYAN ESC("\033[106m")
#define ANSI_BG_BWHITE ESC("\033[107m")
#endif // ANSI_H