MOS Source Code
Loading...
Searching...
No Matches
libs.AnsiColors

ANSI color codes. More...

+ Collaboration diagram for libs.AnsiColors:

Macros

#define STD_COLOR_LIGHT   0x8
 
#define ANSI_COLOR(...)   "\033[" _ANSI_COLOR_N(__VA_ARGS__, _ANSI_COLOR_3, _ANSI_COLOR_2, _ANSI_COLOR_1, _)(__VA_ARGS__) "m"
 ANSI color codes creator.
 
#define ANSI_COLOR_RESET   "\033[0m"
 
#define _ANSI_FG   "3"
 
#define _ANSI_BG   "4"
 
#define _ANSI_COLOR_black   "0"
 
#define _ANSI_COLOR_red   "1"
 
#define _ANSI_COLOR_green   "2"
 
#define _ANSI_COLOR_yellow   "3"
 
#define _ANSI_COLOR_blue   "4"
 
#define _ANSI_COLOR_magenta   "5"
 
#define _ANSI_COLOR_cyan   "6"
 
#define _ANSI_COLOR_white   "7"
 
#define _ANSI_STYLE_regular   "0"
 
#define _ANSI_STYLE_bright   "1"
 
#define _ANSI_STYLE_faint   "2"
 
#define _ANSI_STYLE_italic   "3"
 
#define _ANSI_STYLE_underline   "4"
 
#define _ANSI_STYLE_blink   "5"
 
#define _ANSI_STYLE_blink_fast   "6"
 
#define _ANSI_STYLE_reverse   "7"
 
#define _ANSI_STYLE_invisible   "8"
 
#define _ANSI_COLOR_1(fg)   _ANSI_FG _ANSI_COLOR_##fg
 
#define _ANSI_COLOR_2(fg, style)   _ANSI_STYLE_##style ";" _ANSI_FG _ANSI_COLOR_##fg
 
#define _ANSI_COLOR_3(fg, style, bg)   _ANSI_STYLE_##style ";" _ANSI_FG _ANSI_COLOR_##fg ";" _ANSI_BG _ANSI_COLOR_##bg
 
#define _ANSI_COLOR_N(_1, _2, _3, N, ...)   N
 

Enumerations

enum  standard_color_t {
  Black = 0x0 , Blue = 0x1 , Green = 0x2 , Cyan = 0x3 ,
  Red = 0x4 , Magenta = 0x5 , Brown = 0x6 , Gray = 0x7 ,
  DarkGray = Black | STD_COLOR_LIGHT , LightBlue = Blue | STD_COLOR_LIGHT , LightGreen = Green | STD_COLOR_LIGHT , LightCyan = Cyan | STD_COLOR_LIGHT ,
  LightRed = Red | STD_COLOR_LIGHT , LightMagenta = Magenta | STD_COLOR_LIGHT , Yellow = Brown | STD_COLOR_LIGHT , White = Gray | STD_COLOR_LIGHT
}
 

Functions

should_inline void get_ansi_color (char *buf, standard_color_t fg, standard_color_t bg)
 

Detailed Description

ANSI color codes.

Macro Definition Documentation

◆ STD_COLOR_LIGHT

#define STD_COLOR_LIGHT   0x8

Definition at line 15 of file ansi_colors.h.

◆ ANSI_COLOR

#define ANSI_COLOR ( ...)    "\033[" _ANSI_COLOR_N(__VA_ARGS__, _ANSI_COLOR_3, _ANSI_COLOR_2, _ANSI_COLOR_1, _)(__VA_ARGS__) "m"

ANSI color codes creator.

Usage:

Definition at line 48 of file ansi_colors.h.

Referenced by get_ansi_color().

◆ ANSI_COLOR_RESET

#define ANSI_COLOR_RESET   "\033[0m"

Definition at line 49 of file ansi_colors.h.

◆ _ANSI_FG

#define _ANSI_FG   "3"

Definition at line 53 of file ansi_colors.h.

◆ _ANSI_BG

#define _ANSI_BG   "4"

Definition at line 54 of file ansi_colors.h.

◆ _ANSI_COLOR_black

#define _ANSI_COLOR_black   "0"

Definition at line 56 of file ansi_colors.h.

◆ _ANSI_COLOR_red

#define _ANSI_COLOR_red   "1"

Definition at line 57 of file ansi_colors.h.

◆ _ANSI_COLOR_green

#define _ANSI_COLOR_green   "2"

Definition at line 58 of file ansi_colors.h.

◆ _ANSI_COLOR_yellow

#define _ANSI_COLOR_yellow   "3"

Definition at line 59 of file ansi_colors.h.

◆ _ANSI_COLOR_blue

#define _ANSI_COLOR_blue   "4"

Definition at line 60 of file ansi_colors.h.

◆ _ANSI_COLOR_magenta

#define _ANSI_COLOR_magenta   "5"

Definition at line 61 of file ansi_colors.h.

◆ _ANSI_COLOR_cyan

#define _ANSI_COLOR_cyan   "6"

Definition at line 62 of file ansi_colors.h.

◆ _ANSI_COLOR_white

#define _ANSI_COLOR_white   "7"

Definition at line 63 of file ansi_colors.h.

◆ _ANSI_STYLE_regular

#define _ANSI_STYLE_regular   "0"

Definition at line 65 of file ansi_colors.h.

◆ _ANSI_STYLE_bright

#define _ANSI_STYLE_bright   "1"

Definition at line 66 of file ansi_colors.h.

◆ _ANSI_STYLE_faint

#define _ANSI_STYLE_faint   "2"

Definition at line 67 of file ansi_colors.h.

◆ _ANSI_STYLE_italic

#define _ANSI_STYLE_italic   "3"

Definition at line 68 of file ansi_colors.h.

◆ _ANSI_STYLE_underline

#define _ANSI_STYLE_underline   "4"

Definition at line 69 of file ansi_colors.h.

◆ _ANSI_STYLE_blink

#define _ANSI_STYLE_blink   "5"

Definition at line 70 of file ansi_colors.h.

◆ _ANSI_STYLE_blink_fast

#define _ANSI_STYLE_blink_fast   "6"

Definition at line 71 of file ansi_colors.h.

◆ _ANSI_STYLE_reverse

#define _ANSI_STYLE_reverse   "7"

Definition at line 72 of file ansi_colors.h.

◆ _ANSI_STYLE_invisible

#define _ANSI_STYLE_invisible   "8"

Definition at line 73 of file ansi_colors.h.

◆ _ANSI_COLOR_1

#define _ANSI_COLOR_1 ( fg)    _ANSI_FG _ANSI_COLOR_##fg

Definition at line 75 of file ansi_colors.h.

◆ _ANSI_COLOR_2

#define _ANSI_COLOR_2 ( fg,
style )   _ANSI_STYLE_##style ";" _ANSI_FG _ANSI_COLOR_##fg

Definition at line 76 of file ansi_colors.h.

◆ _ANSI_COLOR_3

#define _ANSI_COLOR_3 ( fg,
style,
bg )   _ANSI_STYLE_##style ";" _ANSI_FG _ANSI_COLOR_##fg ";" _ANSI_BG _ANSI_COLOR_##bg

Definition at line 77 of file ansi_colors.h.

◆ _ANSI_COLOR_N

#define _ANSI_COLOR_N ( _1,
_2,
_3,
N,
... )   N

Definition at line 78 of file ansi_colors.h.

Enumeration Type Documentation

◆ standard_color_t

Enumerator
Black 
Blue 
Green 
Cyan 
Red 
Magenta 
Brown 
Gray 
DarkGray 
LightBlue 
LightGreen 
LightCyan 
LightRed 
LightMagenta 
Yellow 
White 

Definition at line 17 of file ansi_colors.h.

Function Documentation

◆ get_ansi_color()

should_inline void get_ansi_color ( char * buf,
standard_color_t fg,
standard_color_t bg )

Definition at line 80 of file ansi_colors.h.

Referenced by serial_console_set_color().

+ Here is the call graph for this function: