Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
text_style Class Reference

#include <color.h>

Public Member Functions

FMT_CONSTEXPR text_style (emphasis em=emphasis()) FMT_NOEXCEPT
 
FMT_CONSTEXPR text_styleoperator|= (const text_style &rhs)
 
FMT_CONSTEXPR text_styleoperator&= (const text_style &rhs)
 
FMT_CONSTEXPR bool has_foreground () const FMT_NOEXCEPT
 
FMT_CONSTEXPR bool has_background () const FMT_NOEXCEPT
 
FMT_CONSTEXPR bool has_emphasis () const FMT_NOEXCEPT
 
FMT_CONSTEXPR internal::color_type get_foreground () const FMT_NOEXCEPT
 
FMT_CONSTEXPR internal::color_type get_background () const FMT_NOEXCEPT
 
FMT_CONSTEXPR emphasis get_emphasis () const FMT_NOEXCEPT
 

Private Member Functions

FMT_CONSTEXPR text_style (bool is_foreground, internal::color_type text_color) FMT_NOEXCEPT
 

Private Attributes

internal::color_type foreground_color
 
internal::color_type background_color
 
bool set_foreground_color
 
bool set_background_color
 
emphasis ems
 

Friends

FMT_CONSTEXPR text_style operator| (text_style lhs, const text_style &rhs)
 
FMT_CONSTEXPR text_style operator& (text_style lhs, const text_style &rhs)
 
FMT_CONSTEXPR_DECL text_style fg (internal::color_type foreground) FMT_NOEXCEPT
 
FMT_CONSTEXPR_DECL text_style bg (internal::color_type background) FMT_NOEXCEPT
 

Detailed Description

Definition at line 265 of file color.h.

Constructor & Destructor Documentation

FMT_CONSTEXPR text_style::text_style ( emphasis  em = emphasis())
inline

Definition at line 267 of file color.h.

emphasis ems
Definition: color.h:374
bool set_foreground_color
Definition: color.h:372
bool set_background_color
Definition: color.h:373
FMT_CONSTEXPR text_style::text_style ( bool  is_foreground,
internal::color_type  text_color 
)
inlineprivate

Definition at line 351 of file color.h.

355  ems() {
356  if (is_foreground) {
357  foreground_color = text_color;
358  set_foreground_color = true;
359  } else {
360  background_color = text_color;
361  set_background_color = true;
362  }
363  }
internal::color_type background_color
Definition: color.h:371
emphasis ems
Definition: color.h:374
internal::color_type foreground_color
Definition: color.h:370
bool set_foreground_color
Definition: color.h:372
bool set_background_color
Definition: color.h:373

Member Function Documentation

FMT_CONSTEXPR internal::color_type text_style::get_background ( ) const
inline

Definition at line 341 of file color.h.

341  {
342  assert(has_background() && "no background specified for this style");
343  return background_color;
344  }
internal::color_type background_color
Definition: color.h:371
FMT_CONSTEXPR bool has_background() const FMT_NOEXCEPT
Definition: color.h:331
FMT_CONSTEXPR emphasis text_style::get_emphasis ( ) const
inline

Definition at line 345 of file color.h.

345  {
346  assert(has_emphasis() && "no emphasis specified for this style");
347  return ems;
348  }
FMT_CONSTEXPR bool has_emphasis() const FMT_NOEXCEPT
Definition: color.h:334
emphasis ems
Definition: color.h:374
FMT_CONSTEXPR internal::color_type text_style::get_foreground ( ) const
inline

Definition at line 337 of file color.h.

337  {
338  assert(has_foreground() && "no foreground specified for this style");
339  return foreground_color;
340  }
FMT_CONSTEXPR bool has_foreground() const FMT_NOEXCEPT
Definition: color.h:328
internal::color_type foreground_color
Definition: color.h:370
FMT_CONSTEXPR bool text_style::has_background ( ) const
inline

Definition at line 331 of file color.h.

331  {
332  return set_background_color;
333  }
bool set_background_color
Definition: color.h:373
FMT_CONSTEXPR bool text_style::has_emphasis ( ) const
inline

Definition at line 334 of file color.h.

334  {
335  return static_cast<uint8_t>(ems) != 0;
336  }
emphasis ems
Definition: color.h:374
unsigned char uint8_t
Definition: stdint.h:124
FMT_CONSTEXPR bool text_style::has_foreground ( ) const
inline

Definition at line 328 of file color.h.

328  {
329  return set_foreground_color;
330  }
bool set_foreground_color
Definition: color.h:372
FMT_CONSTEXPR text_style& text_style::operator&= ( const text_style rhs)
inline

Definition at line 299 of file color.h.

299  {
300  if (!set_foreground_color) {
303  } else if (rhs.set_foreground_color) {
305  throw format_error("can't AND a terminal color");
307  }
308 
309  if (!set_background_color) {
312  } else if (rhs.set_background_color) {
314  throw format_error("can't AND a terminal color");
316  }
317 
318  ems = static_cast<emphasis>(static_cast<uint8_t>(ems) &
319  static_cast<uint8_t>(rhs.ems));
320  return *this;
321  }
internal::color_type background_color
Definition: color.h:371
emphasis ems
Definition: color.h:374
unsigned char uint8_t
Definition: stdint.h:124
internal::color_type foreground_color
Definition: color.h:370
emphasis
Definition: color.h:213
bool set_foreground_color
Definition: color.h:372
bool set_background_color
Definition: color.h:373
Definition: DirOfGamma.h:17
union internal::color_type::color_union value
FMT_CONSTEXPR text_style& text_style::operator|= ( const text_style rhs)
inline

Definition at line 270 of file color.h.

270  {
271  if (!set_foreground_color) {
274  } else if (rhs.set_foreground_color) {
276  throw format_error("can't OR a terminal color");
278  }
279 
280  if (!set_background_color) {
283  } else if (rhs.set_background_color) {
285  throw format_error("can't OR a terminal color");
287  }
288 
289  ems = static_cast<emphasis>(static_cast<uint8_t>(ems) |
290  static_cast<uint8_t>(rhs.ems));
291  return *this;
292  }
internal::color_type background_color
Definition: color.h:371
emphasis ems
Definition: color.h:374
unsigned char uint8_t
Definition: stdint.h:124
internal::color_type foreground_color
Definition: color.h:370
emphasis
Definition: color.h:213
bool set_foreground_color
Definition: color.h:372
bool set_background_color
Definition: color.h:373
Definition: DirOfGamma.h:17
union internal::color_type::color_union value

Friends And Related Function Documentation

Definition at line 381 of file color.h.

381  {
382  return text_style(/*is_foreground=*/false, background);
383 }
FMT_CONSTEXPR text_style(emphasis em=emphasis()) FMT_NOEXCEPT
Definition: color.h:267

Definition at line 377 of file color.h.

377  {
378  return text_style(/*is_foreground=*/true, foreground);
379 }
FMT_CONSTEXPR text_style(emphasis em=emphasis()) FMT_NOEXCEPT
Definition: color.h:267
FMT_CONSTEXPR text_style operator& ( text_style  lhs,
const text_style rhs 
)
friend

Definition at line 324 of file color.h.

324  {
325  return lhs &= rhs;
326  }
FMT_CONSTEXPR text_style operator| ( text_style  lhs,
const text_style rhs 
)
friend

Definition at line 295 of file color.h.

295  {
296  return lhs |= rhs;
297  }

Member Data Documentation

internal::color_type text_style::background_color
private

Definition at line 371 of file color.h.

emphasis text_style::ems
private

Definition at line 374 of file color.h.

internal::color_type text_style::foreground_color
private

Definition at line 370 of file color.h.

bool text_style::set_background_color
private

Definition at line 373 of file color.h.

bool text_style::set_foreground_color
private

Definition at line 372 of file color.h.


The documentation for this class was generated from the following file: