argos_colored_text.h
Go to the documentation of this file.
1 
12 #ifndef ARGOS_COLORED_TEXT_H
13 #define ARGOS_COLORED_TEXT_H
14 
15 #include <argos3/core/utility/datatypes/datatypes.h>
16 
17 namespace argos {
18 
30  };
31 
44  };
45 
49  struct SLogColor {
58 
69  EARGoSLogColors e_foreground_color) :
70  Attribute(e_attribute),
71  Foreground(e_foreground_color) {}
72  };
73 
78  inline std::ostream& operator<<(std::ostream& c_os, const SLogColor& s_log_color)
79  {
80  c_os << "\033["
81  << s_log_color.Attribute << ";"
82  << (s_log_color.Foreground + 30) << "m";
83  return c_os;
84  }
85 
89 #define DEFINE_ARGOS_STREAM_COLOR_HELPER(lc_color, uc_color) \
90  inline std::ostream& lc_color(std::ostream& c_os) { \
91  c_os << SLogColor(ARGOS_LOG_ATTRIBUTE_BRIGHT, ARGOS_LOG_COLOR_ ## uc_color); \
92  return c_os; \
93  }
94 
123 
128  inline std::ostream& reset(std::ostream& c_os) {
129  c_os << "\033["
131  << "m";
132  return c_os;
133  }
134 
135 }
136 
137 #endif
unsigned char UInt8
8-bit unsigned integer.
Definition: datatypes.h:60
The namespace containing all the ARGoS related code.
Definition: ci_actuator.h:12
std::ostream & reset(std::ostream &c_os)
Resets the text to the default settings.
std::ostream & operator<<(std::ostream &c_os, const CByteArray &c_byte_array)
Definition: byte_array.cpp:530
EARGoSLogAttributes
The possible attributes of the logged text.
@ ARGOS_LOG_ATTRIBUTE_BRIGHT
@ ARGOS_LOG_ATTRIBUTE_DIM
@ ARGOS_LOG_ATTRIBUTE_HIDDEN
@ ARGOS_LOG_ATTRIBUTE_BLINK
@ ARGOS_LOG_ATTRIBUTE_RESET
@ ARGOS_LOG_ATTRIBUTE_UNDERSCORE
@ ARGOS_LOG_ATTRIBUTE_REVERSE
DEFINE_ARGOS_STREAM_COLOR_HELPER(red, RED)
Bright red text modifier.
EARGoSLogColors
The possible colors of the logged text.
@ ARGOS_LOG_COLOR_RED
@ ARGOS_LOG_COLOR_BLUE
@ ARGOS_LOG_COLOR_MAGENTA
@ ARGOS_LOG_COLOR_YELLOW
@ ARGOS_LOG_COLOR_GREEN
@ ARGOS_LOG_COLOR_CYAN
@ ARGOS_LOG_COLOR_WHITE
@ ARGOS_LOG_COLOR_BLACK
Stream modifier to set attribute and color of the subsequent text.
UInt8 Attribute
The text attribute.
SLogColor()
Constructor with standard settings.
SLogColor(EARGoSLogAttributes e_attribute, EARGoSLogColors e_foreground_color)
Constructor with custom settings.
UInt8 Foreground
The foreground color.