ANSI-Project 1.0
Make quick ANSI formats to beautify terminal output
|
#include <stdio.h>
Go to the source code of this file.
Macros | |
#define | ANSI_ESC "\x1B" |
#define | ANSI_CSI "\x9B" |
#define | ANSI_DSC "\x90" |
#define | ANSI_OSC "\x9D" |
#define | ANSI_RESET ANSI_ESC "[0m" |
#define | ANSI_BOLD ANSI_ESC "[1m" |
#define | ANSI_FAINT ANSI_ESC "[2m" |
#define | ANSI_ITALIC ANSI_ESC "[3m" |
#define | ANSI_UNDER ANSI_ESC "[4m" |
#define | ANSI_SBLINK ANSI_ESC "[5m" |
#define | ANSI_RBLINK ANSI_ESC "[6m" |
#define | ANSI_REVERSE ANSI_ESC "[7m" |
#define | ANSI_HIDE ANSI_ESC "[8m" |
#define | ANSI_STRIKE ANSI_ESC "[9m" |
#define | ANSI_DEF_FONT ANSI_ESC "[10m" |
#define | ANSI_Franktur ANSI_ESC "[20m" |
#define | ANSI_BOLD_OFF ANSI_ESC "[21m" |
#define | ANSI_HI_OFF ANSI_ESC "[22m" |
#define | ANSI_ITALIC_OFF ANSI_ESC "[23m" |
#define | ANSI_UNDER_OFF ANSI_ESC "[24m" |
#define | ANSI_BLINK_OFF ANSI_ESC "[25m" |
#define | ANSI_REVERSE_OFF ANSI_ESC "[27m" |
#define | ANSI_REVEAL ANSI_ESC "[28m" |
#define | ANSI_STRIKE_OFF ANSI_ESC "[29m" |
#define | ANSI_BLACK ANSI_ESC "[30m" |
#define | ANSI_RED ANSI_ESC "[31m" |
#define | ANSI_GREEN ANSI_ESC "[32m" |
#define | ANSI_YELLOW ANSI_ESC "[33m" |
#define | ANSI_BLUE ANSI_ESC "[34m" |
#define | ANSI_PURPLE ANSI_ESC "[35m" |
#define | ANSI_CYAN ANSI_ESC "[36m" |
#define | ANSI_WHITE ANSI_ESC "[37m" |
#define | ANSI_DEFAULT ANSI_ESC "[39m" |
#define | ANSI_BK_BLACK ANSI_ESC "[40m" |
#define | ANSI_BK_RED ANSI_ESC "[41m" |
#define | ANSI_BK_GREEN ANSI_ESC "[42m" |
#define | ANSI_BK_YELLOW ANSI_ESC "[43m" |
#define | ANSI_BK_BLUE ANSI_ESC "[44m" |
#define | ANSI_BK_PURPLE ANSI_ESC "[45m" |
#define | ANSI_BK_CYAN ANSI_ESC "[46m" |
#define | ANSI_BK_WHITE ANSI_ESC "[47m" |
#define | ANSI_BK_DEFAULT ANSI_ESC "[49m" |
#define | ANSI_BLACK_HI ANSI_ESC "[90m" |
#define | ANSI_RED_HI ANSI_ESC "[91m" |
#define | ANSI_GREEN_HI ANSI_ESC "[92m" |
#define | ANSI_YELLOW_HI ANSI_ESC "[93m" |
#define | ANSI_BLUE_HI ANSI_ESC "[94m" |
#define | ANSI_PURPLE_HI ANSI_ESC "[95m" |
#define | ANSI_CYAN_HI ANSI_ESC "[96m" |
#define | ANSI_WHITE_HI ANSI_ESC "[97m" |
#define | ANSI_BK_BLACK_HI ANSI_ESC "[100m" |
#define | ANSI_BK_RED_HI ANSI_ESC "[101m" |
#define | ANSI_BK_GREEN_HI ANSI_ESC "[102m" |
#define | ANSI_BK_YELLOW_HI ANSI_ESC "[103m" |
#define | ANSI_BK_BLUE_HI ANSI_ESC "[104m" |
#define | ANSI_BK_PURPLE_HI ANSI_ESC "[105m" |
#define | ANSI_BK_CYAN_HI ANSI_ESC "[106m" |
#define | ANSI_BK_WHITE_HI ANSI_ESC "[107m" |
#define | ANSI_SGR(str) ANSI_ESC "[" #str "m" |
#define | ANSI_RGB(r, g, b) ANSI_ESC "[38;2;" #r ";" #g ";" #b "m" |
#define | ANSI_BK_RGB(r, g, b) ANSI_ESC "[48;2;" #r ";" #g ";" #b "m" |
#define | ANSI_C0 ANSI_ESC "[1;1H" |
#define | ANSI_CUU1 ANSI_ESC "[1A" |
#define | ANSI_CUD1 ANSI_ESC "[1B" |
#define | ANSI_CUF1 ANSI_ESC "[1C" |
#define | ANSI_CUB1 ANSI_ESC "[1D" |
#define | ANSI_CNL1 ANSI_ESC "[1E" |
#define | ANSI_CPL1 ANSI_ESC "[1F" |
#define | ANSI_SU1 ANSI_ESC "[1S" |
#define | ANSI_SD1 ANSI_ESC "[1T" |
#define | ANSI_ED0 ANSI_ESC "[0J" |
#define | ANSI_ED1 ANSI_ESC "[1J" |
#define | ANSI_ED2 ANSI_ESC "[2J" |
#define | ANSI_ED3 ANSI_ESC "[3J" |
#define | ANSI_EL0 ANSI_ESC "[0K" |
#define | ANSI_EL1 ANSI_ESC "[1K" |
#define | ANSI_EL2 ANSI_ESC "[2K" |
#define | ANSI_AUX_PORT_ON ANSI_ESC "[5i" |
#define | ANSI_AUX_PORT_OFF ANSI_ESC "[4i" |
#define | ANSI_DSR ANSI_ESC "[6n" |
#define | ANSI_SCP ANSI_ESC "[s" |
#define | ANSI_RCP ANSI_ESC "[u" |
#define | ANSI_CUU(n) ANSI_ESC "[" #n "A" |
#define | ANSI_CUD(n) ANSI_ESC "[" #n "B" |
#define | ANSI_CUF(n) ANSI_ESC "[" #n "C" |
#define | ANSI_CUB(n) ANSI_ESC "[" #n "D" |
#define | ANSI_CNL(n) ANSI_ESC "[" #n "E" |
#define | ANSI_CPL(n) ANSI_ESC "[" #n "F" |
#define | ANSI_CHA(n) ANSI_ESC "[" #n "G" |
#define | ANSI_CUP(row, col) ANSI_ESC "[" #row ";" #col "H" |
#define | ANSI_ED(n) ANSI_ESC "[" #n "J" |
#define | ANSI_EL(n) ANSI_ESC "[" #n "K" |
#define | ANSI_SU(n) ANSI_ESC "[" #n "S" |
#define | ANSI_SD(n) ANSI_ESC "[" #n "T" |
#define | ANSI_HVP(row, col) ANSI_ESC "[" #row ";" #col "f" |
#define | ANSI_custom(str) ANSI_ESC "[" #str |
#define ANSI_AUX_PORT_OFF ANSI_ESC "[4i" |
Enable aux serial port usually for local serial printer
#define ANSI_AUX_PORT_ON ANSI_ESC "[5i" |
Enable aux serial port usually for local serial printer
#define ANSI_BK_BLACK ANSI_ESC "[40m" |
#define ANSI_BK_BLACK_HI ANSI_ESC "[100m" |
#define ANSI_BK_BLUE ANSI_ESC "[44m" |
#define ANSI_BK_BLUE_HI ANSI_ESC "[104m" |
#define ANSI_BK_CYAN ANSI_ESC "[46m" |
#define ANSI_BK_CYAN_HI ANSI_ESC "[106m" |
#define ANSI_BK_DEFAULT ANSI_ESC "[49m" |
#define ANSI_BK_GREEN ANSI_ESC "[42m" |
#define ANSI_BK_GREEN_HI ANSI_ESC "[102m" |
#define ANSI_BK_PURPLE ANSI_ESC "[45m" |
#define ANSI_BK_PURPLE_HI ANSI_ESC "[105m" |
#define ANSI_BK_RED ANSI_ESC "[41m" |
#define ANSI_BK_RED_HI ANSI_ESC "[101m" |
#define ANSI_BK_RGB | ( | r, | |
g, | |||
b | |||
) | ANSI_ESC "[48;2;" #r ";" #g ";" #b "m" |
Specify the Background color in RGB
r | Red value |
g | Green value |
b | Blue value |
#define ANSI_BK_WHITE ANSI_ESC "[47m" |
#define ANSI_BK_WHITE_HI ANSI_ESC "[107m" |
#define ANSI_BK_YELLOW ANSI_ESC "[43m" |
#define ANSI_BK_YELLOW_HI ANSI_ESC "[103m" |
#define ANSI_BLACK ANSI_ESC "[30m" |
#define ANSI_BLACK_HI ANSI_ESC "[90m" |
#define ANSI_BLINK_OFF ANSI_ESC "[25m" |
#define ANSI_BLUE ANSI_ESC "[34m" |
#define ANSI_BLUE_HI ANSI_ESC "[94m" |
#define ANSI_BOLD ANSI_ESC "[1m" |
#define ANSI_BOLD_OFF ANSI_ESC "[21m" |
#define ANSI_C0 ANSI_ESC "[1;1H" |
Place the cursor in top-left corner Same as CUP(1,1)
#define ANSI_CHA | ( | n | ) | ANSI_ESC "[" #n "G" |
Moves the cursor to column n (default 1)
n |
#define ANSI_CNL | ( | n | ) | ANSI_ESC "[" #n "E" |
Moves cursor to beginning of the line n (default 1) lines down.
n |
#define ANSI_CNL1 ANSI_ESC "[1E" |
Moves cursor to beginning of the next line
#define ANSI_CPL | ( | n | ) | ANSI_ESC "[" #n "F" |
Moves cursor to beginning of the line n (default 1) lines up.
n |
#define ANSI_CPL1 ANSI_ESC "[1F" |
Moves cursor to beginning of the previous line
#define ANSI_CSI "\x9B" |
#define ANSI_CUB | ( | n | ) | ANSI_ESC "[" #n "D" |
Moves the cursor n (default 1) cells backwards
n |
#define ANSI_CUB1 ANSI_ESC "[1D" |
Move the cursor 1 cell backwards
#define ANSI_CUD | ( | n | ) | ANSI_ESC "[" #n "B" |
Moves the cursor n (default 1) cells down
n |
#define ANSI_CUD1 ANSI_ESC "[1B" |
Move the cursor 1 row down
#define ANSI_CUF | ( | n | ) | ANSI_ESC "[" #n "C" |
Moves the cursor n (default 1) cells forwards
n |
#define ANSI_CUF1 ANSI_ESC "[1C" |
Move the cursor 1 cell forwards
#define ANSI_CUP | ( | row, | |
col | |||
) | ANSI_ESC "[" #row ";" #col "H" |
Moves the cursor to [row, column]. The values are 1-based.
row | |
col |
#define ANSI_custom | ( | str | ) | ANSI_ESC "[" #str |
Returns a custom ANSI ESCAPE SEQUENCE
str |
#define ANSI_CUU | ( | n | ) | ANSI_ESC "[" #n "A" |
Moves the cursor n (default 1) cells up
n |
#define ANSI_CUU1 ANSI_ESC "[1A" |
Move the cursor 1 row up
#define ANSI_CYAN ANSI_ESC "[36m" |
#define ANSI_CYAN_HI ANSI_ESC "[96m" |
#define ANSI_DEF_FONT ANSI_ESC "[10m" |
Default font
#define ANSI_DEFAULT ANSI_ESC "[39m" |
#define ANSI_DSC "\x90" |
#define ANSI_DSR ANSI_ESC "[6n" |
Reports the cursor position (CPR) by transmitting ESC[n;mR, where n is the row and m is the column.
#define ANSI_ED | ( | n | ) | ANSI_ESC "[" #n "J" |
Clears part of the screen. If n is 0 (or missing), clear from cursor to end of screen. If n is 1, clear from cursor to beginning of the screen. If n is 2, clear entire screen (and moves cursor to upper left on DOS ANSI.SYS). If n is 3, clear entire screen and delete all lines saved in the scrollback buffer (this feature was added for xterm and is supported by other terminal applications).
n |
#define ANSI_ED0 ANSI_ESC "[0J" |
Clear from cursor to end of screen.
#define ANSI_ED1 ANSI_ESC "[1J" |
Clear from cursor to beginning of the screen
#define ANSI_ED2 ANSI_ESC "[2J" |
Clear entire screen (and moves cursor to upper left on DOS ANSI.SYS)
#define ANSI_ED3 ANSI_ESC "[3J" |
Clear entire screen and delete all lines saved in the scrollback buffer (this feature was added for xterm and is supported by other terminal applications)
#define ANSI_EL | ( | n | ) | ANSI_ESC "[" #n "K" |
Erases part of the line If n is 0 (or missing), clear from cursor to the end of the line If n is 1, clear from cursor to beginning of the line If n is 2, clear entire line. Cursor position does not change.
n |
#define ANSI_EL0 ANSI_ESC "[0K" |
Clear from cursor to the end of the line
#define ANSI_EL1 ANSI_ESC "[1K" |
Clear from cursor to beginning of the line
#define ANSI_EL2 ANSI_ESC "[2K" |
Clear entire line. Cursor position does not change.
#define ANSI_ESC "\x1B" |
#define ANSI_FAINT ANSI_ESC "[2m" |
#define ANSI_Franktur ANSI_ESC "[20m" |
Rarely supported font
#define ANSI_GREEN ANSI_ESC "[32m" |
#define ANSI_GREEN_HI ANSI_ESC "[92m" |
#define ANSI_HI_OFF ANSI_ESC "[22m" |
#define ANSI_HIDE ANSI_ESC "[8m" |
#define ANSI_HVP | ( | row, | |
col | |||
) | ANSI_ESC "[" #row ";" #col "f" |
Same as CUP, but counts as a format effector function (like CR or LF) rather than an editor function (like CUD or CNL) This can lead to different handling in certain terminal modes
row | |
col |
#define ANSI_ITALIC ANSI_ESC "[3m" |
#define ANSI_ITALIC_OFF ANSI_ESC "[23m" |
#define ANSI_OSC "\x9D" |
#define ANSI_PURPLE ANSI_ESC "[35m" |
#define ANSI_PURPLE_HI ANSI_ESC "[95m" |
#define ANSI_RBLINK ANSI_ESC "[6m" |
#define ANSI_RCP ANSI_ESC "[u" |
Restores the cursor position/state in SCO console mode.
#define ANSI_RED ANSI_ESC "[31m" |
#define ANSI_RED_HI ANSI_ESC "[91m" |
#define ANSI_RESET ANSI_ESC "[0m" |
#define ANSI_REVEAL ANSI_ESC "[28m" |
#define ANSI_REVERSE ANSI_ESC "[7m" |
#define ANSI_REVERSE_OFF ANSI_ESC "[27m" |
#define ANSI_RGB | ( | r, | |
g, | |||
b | |||
) | ANSI_ESC "[38;2;" #r ";" #g ";" #b "m" |
Specify the Foreground color in RGB
r | Red value |
g | Green value |
b | Blue value |
#define ANSI_SBLINK ANSI_ESC "[5m" |
#define ANSI_SCP ANSI_ESC "[s" |
Saves the cursor position/state in SCO console mode In vertical split screen mode, instead used to set (as CSI n ; n s) or reset left and right margins.
#define ANSI_SD | ( | n | ) | ANSI_ESC "[" #n "T" |
Scroll whole page down by n (default 1) lines. New lines are added at the top. (not ANSI.SYS)
n |
#define ANSI_SD1 ANSI_ESC "[1T" |
Scroll whole page down by 1 line
#define ANSI_SGR | ( | str | ) | ANSI_ESC "[" #str "m" |
Sets colors and style of the characters following this code Example: ANSI_SGR(40;91) makes RED_HI over BK_BLACK
str |
#define ANSI_STRIKE ANSI_ESC "[9m" |
#define ANSI_STRIKE_OFF ANSI_ESC "[29m" |
#define ANSI_SU | ( | n | ) | ANSI_ESC "[" #n "S" |
Scroll whole page up by n (default 1) lines. New lines are added at the bottom. (not ANSI.SYS)
n |
#define ANSI_SU1 ANSI_ESC "[1S" |
Scroll whole page up by 1 line
#define ANSI_UNDER ANSI_ESC "[4m" |
#define ANSI_UNDER_OFF ANSI_ESC "[24m" |
#define ANSI_WHITE ANSI_ESC "[37m" |
#define ANSI_WHITE_HI ANSI_ESC "[97m" |
#define ANSI_YELLOW ANSI_ESC "[33m" |
#define ANSI_YELLOW_HI ANSI_ESC "[93m" |