librnr  1.14.5
RoadNarrows Robotics Common Library 1
color.h File Reference

Non-GUI color systems. More...

#include <stdio.h>
#include "rnr/rnrconfig.h"

Go to the source code of this file.

Macros

#define ANSI_CSI   "\033["
 Control Sequence Introducer.
 
#define ANSI_COLOR_PRE   ANSI_CSI
 color escape sequence prefix
 
#define ANSI_COLOR_SEP   ";"
 color values separator
 
#define ANSI_COLOR_MODE   "m"
 color mode
 
#define ANSI_SGR_TEXT_NORMAL   "0"
 color normal and reset to default
 
#define ANSI_SGR_TEXT_BOLD   "1"
 bold or increase intensity
 
#define ANSI_SGR_TEXT_UNDERSCORE   "4"
 underscore
 
#define ANSI_SGR_TEXT_BLINK   "5"
 slow blink
 
#define ANSI_SGR_TEXT_REVERSE   "7"
 swap fg and bg colors
 
#define ANSI_SGR_FG_COLOR_BLACK   "30"
 normal black
 
#define ANSI_SGR_FG_COLOR_RED   "31"
 normal red
 
#define ANSI_SGR_FG_COLOR_GREEN   "32"
 normal green
 
#define ANSI_SGR_FG_COLOR_YELLOW   "33"
 normal yellow (brown)
 
#define ANSI_SGR_FG_COLOR_BLUE   "34"
 normal blue
 
#define ANSI_SGR_FG_COLOR_MAGENTA   "35"
 normal magenta
 
#define ANSI_SGR_FG_COLOR_CYAN   "36"
 normal cyan
 
#define ANSI_SGR_FG_COLOR_WHITE   "37"
 normal white (gray)
 
#define ANSI_SGR_BG_COLOR_BLACK   "40"
 normal black
 
#define ANSI_SGR_BG_COLOR_RED   "41"
 normal red
 
#define ANSI_SGR_BG_COLOR_GREEN   "42"
 normal green
 
#define ANSI_SGR_BG_COLOR_YELLOW   "43"
 normal yellow (brown)
 
#define ANSI_SGR_BG_COLOR_BLUE   "44"
 normal blue
 
#define ANSI_SGR_BG_COLOR_MAGENTA   "45"
 normal magenta
 
#define ANSI_SGR_BG_COLOR_CYAN   "46"
 normal cyan
 
#define ANSI_SGR_BG_COLOR_WHITE   "47"
 normal white (gray)
 
#define ANSI_COLOR(_attr, _fg, _bg)   ANSI_COLOR_PRE _attr ANSI_COLOR_SEP _fg ANSI_COLOR_SEP _bg ANSI_COLOR_MODE
 Macro to build color escape sequence string. More...
 
#define ANSI_FG_COLOR(_fg)   ANSI_COLOR_PRE ANSI_SGR_TEXT_NORMAL ANSI_COLOR_SEP _fg ANSI_COLOR_MODE
 Macro to build normal foreground color escape sequence string. More...
 
#define ANSI_FG_BRIGHT_COLOR(_fg)   ANSI_COLOR_PRE ANSI_SGR_TEXT_BOLD ANSI_COLOR_SEP _fg ANSI_COLOR_MODE
 Macro to build bright foreground color escape sequence string. More...
 
#define ANSI_FG_ATTR_COLOR(_attr, _fg)   ANSI_COLOR_PRE _attr ANSI_COLOR_SEP _fg ANSI_COLOR_MODE
 Macro to build foreground color with the given text attribute escape sequence string. More...
 
#define ANSI_BG_COLOR(_bg)   ANSI_COLOR_PRE _bg ANSI_COLOR_MODE
 Macro to build background color escape sequence string. More...
 
#define ANSI_NORMAL_COLOR(_fg, _bg)   ANSI_COLOR(ANSI_SGR_TEXT_NORMAL, _fg, _bg)
 Macro to build normal color escape sequence string. More...
 
#define ANSI_BRIGHT_COLOR(_fg, _bg)   ANSI_COLOR(ANSI_SGR_TEXT_BOLD, _fg, _bg)
 Macro to build bright color escape sequence string. More...
 
#define ANSI_COLOR_RESET   ANSI_CSI ANSI_SGR_TEXT_NORMAL ANSI_COLOR_MODE
 color reset to default
 
#define ANSI_FG_BLACK   ANSI_FG_COLOR(ANSI_SGR_FG_COLOR_BLACK)
 Foreground colors escape sequences.
 
#define ANSI_FG_RED   ANSI_FG_COLOR(ANSI_SGR_FG_COLOR_RED)
 
#define ANSI_FG_GREEN   ANSI_FG_COLOR(ANSI_SGR_FG_COLOR_GREEN)
 
#define ANSI_FG_YELLOW   ANSI_FG_COLOR(ANSI_SGR_FG_COLOR_YELLOW)
 
#define ANSI_FG_BLUE   ANSI_FG_COLOR(ANSI_SGR_FG_COLOR_BLUE)
 
#define ANSI_FG_MAGENTA   ANSI_FG_COLOR(ANSI_SGR_FG_COLOR_MAGENTA)
 
#define ANSI_FG_CYAN   ANSI_FG_COLOR(ANSI_SGR_FG_COLOR_CYAN)
 
#define ANSI_FG_WHITE   ANSI_FG_COLOR(ANSI_SGR_FG_COLOR_WHITE)
 
#define ANSI_FG_BRIGHT_BLACK   ANSI_FG_BRIGHT_COLOR(ANSI_SGR_FG_COLOR_BLACK)
 
#define ANSI_FG_BRIGHT_RED   ANSI_FG_BRIGHT_COLOR(ANSI_SGR_FG_COLOR_RED)
 
#define ANSI_FG_BRIGHT_GREEN   ANSI_FG_BRIGHT_COLOR(ANSI_SGR_FG_COLOR_GREEN)
 
#define ANSI_FG_BRIGHT_YELLOW   ANSI_FG_BRIGHT_COLOR(ANSI_SGR_FG_COLOR_YELLOW)
 
#define ANSI_FG_BRIGHT_BLUE   ANSI_FG_BRIGHT_COLOR(ANSI_SGR_FG_COLOR_BLUE)
 
#define ANSI_FG_BRIGHT_MAGENTA   ANSI_FG_BRIGHT_COLOR(ANSI_SGR_FG_COLOR_MAGENTA)
 
#define ANSI_FG_BRIGHT_CYAN   ANSI_FG_BRIGHT_COLOR(ANSI_SGR_FG_COLOR_CYAN)
 
#define ANSI_FG_BRIGHT_WHITE   ANSI_FG_BRIGHT_COLOR(ANSI_SGR_FG_COLOR_WHITE)
 
#define ANSI_BG_BLACK   ANSI_FG_COLOR(ANSI_SGR_BG_COLOR_BLACK)
 Background colors escape sequences.
 
#define ANSI_BG_RED   ANSI_FG_COLOR(ANSI_SGR_BG_COLOR_RED)
 
#define ANSI_BG_GREEN   ANSI_FG_COLOR(ANSI_SGR_BG_COLOR_GREEN)
 
#define ANSI_BG_YELLOW   ANSI_FG_COLOR(ANSI_SGR_BG_COLOR_YELLOW)
 
#define ANSI_BG_BLUE   ANSI_FG_COLOR(ANSI_SGR_BG_COLOR_BLUE)
 
#define ANSI_BG_MAGENTA   ANSI_FG_COLOR(ANSI_SGR_BG_COLOR_MAGENTA)
 
#define ANSI_BG_CYAN   ANSI_FG_COLOR(ANSI_SGR_BG_COLOR_CYAN)
 
#define ANSI_BG_WHITE   ANSI_FG_COLOR(ANSI_SGR_BG_COLOR_WHITE)
 

Functions

INLINE_IN_H void set_color (const char *sColor)
 Set foreground or background color. More...
 
INLINE_IN_H void reset_colors ()
 Reset foreground and background colors to defaults.
 
int colorprintf (const char *sFgColor, const char *sFmt,...)
 Print output in the specified foreground color. More...
 

Detailed Description

Non-GUI color systems.

Supported Color Systems:

  • ANSI escape sequence colors.
Package
RoadNarrows Robotics Common Library 1
Library
librnr
File
rnr/color.h
Author
Robin Knight (robin.nosp@m..kni.nosp@m.ght@r.nosp@m.oadn.nosp@m.arrow.nosp@m.s.co.nosp@m.m)
License
MIT
EULA
See the README and EULA files for any copyright and licensing information.

Definition in file color.h.