Bugz Door Project
Public Member Functions | Private Attributes | Friends | List of all members
door::ANSIColor Class Reference

Foreground, Background and Attributes. More...

#include <door.h>

Public Member Functions

 ANSIColor ()
 
 ANSIColor (ATTR a)
 
 ANSIColor (COLOR f)
 
 ANSIColor (COLOR f, ATTR a)
 
 ANSIColor (COLOR f, ATTR a1, ATTR a2)
 
 ANSIColor (COLOR f, COLOR b)
 
 ANSIColor (COLOR f, COLOR b, ATTR a)
 
 ANSIColor (COLOR f, COLOR b, ATTR a1, ATTR a2)
 
ANSIColorAttr (ATTR a)
 
bool operator== (const ANSIColor &c) const
 
bool operator!= (const ANSIColor &c) const
 
void setFg (COLOR f)
 Set foreground color. More...
 
void setFg (COLOR f, ATTR a)
 Set foreground color and attribute. More...
 
void setBg (COLOR b)
 Set background color. More...
 
COLOR getFg ()
 
COLOR getBg ()
 
void attr (ATTR a)
 Set attribute. More...
 
std::string output (void) const
 
std::string debug (void)
 Output debug string for ANSIColor. More...
 
std::string output (ANSIColor &previous) const
 

Private Attributes

COLOR fg
 
COLOR bg
 
unsigned int reset: 1
 
unsigned int bold: 1
 
unsigned int blink: 1
 
unsigned int inverse: 1
 

Friends

std::ostream & operator<< (std::ostream &os, const ANSIColor &c)
 

Detailed Description

Foreground, Background and Attributes.

This holds foreground, background and ANSI-BBS attribute information. The special attribute RESET forces attribute and color output always.

Examples
menu-example.cpp.

Constructor & Destructor Documentation

◆ ANSIColor() [1/8]

door::ANSIColor::ANSIColor ( )

Construct a new ANSIColor::ANSIColor object with sensible defaults (White on Black).

◆ ANSIColor() [2/8]

door::ANSIColor::ANSIColor ( ATTR  a)

Construct a new ANSIColor::ANSIColor object with attribute set.

Parameters
[in]aATTR

◆ ANSIColor() [3/8]

door::ANSIColor::ANSIColor ( COLOR  f)

Construct a new ANSIColor::ANSIColor object with a foreground color.

Parameters
[in]fCOLOR

◆ ANSIColor() [4/8]

door::ANSIColor::ANSIColor ( COLOR  f,
ATTR  a 
)

Construct a new ANSIColor::ANSIColor object with a foreground color and attribute.

Parameters
[in]fCOLOR
[in]aATTR

◆ ANSIColor() [5/8]

door::ANSIColor::ANSIColor ( COLOR  f,
ATTR  a1,
ATTR  a2 
)

Construct a new ANSIColor::ANSIColor object with a foreground color and attributes.

Parameters
[in]fCOLOR
[in]a1ATTR
[in]a2ATTR

◆ ANSIColor() [6/8]

door::ANSIColor::ANSIColor ( COLOR  f,
COLOR  b 
)

Construct a new ANSIColor::ANSIColor object with a foreground and background color.

Parameters
[in]fforeground COLOR
[in]bbackground COLOR

◆ ANSIColor() [7/8]

door::ANSIColor::ANSIColor ( COLOR  f,
COLOR  b,
ATTR  a 
)

Construct a new ANSIColor::ANSIColor object with a foreground color, background color, and attribute.

Parameters
[in]fforeground COLOR
[in]bbackground COLOR
[in]aATTR

◆ ANSIColor() [8/8]

door::ANSIColor::ANSIColor ( COLOR  f,
COLOR  b,
ATTR  a1,
ATTR  a2 
)

Construct a new ANSIColor::ANSIColor object with foreground, background color and attributes.

Parameters
[in]fforeground COLOR
[in]bbackground COLOR
[in]a1ATTR
[in]a2ATTR

Member Function Documentation

◆ Attr()

ANSIColor & door::ANSIColor::Attr ( ATTR  a)

Set attribute. We return the object so calls can be chained.

Parameters
[in]aATTR
Returns
ANSIColor&

◆ attr()

void door::ANSIColor::attr ( ATTR  a)

Set attribute.

This clears all the attributes before setting the selected ATTR.

Parameters
[in]aATTR

◆ debug()

std::string door::ANSIColor::debug ( void  )

Output debug string for ANSIColor.

Returns
std::string

◆ getBg()

COLOR door::ANSIColor::getBg ( )
inline

Get the background color

Returns
COLOR

◆ getFg()

COLOR door::ANSIColor::getFg ( )
inline

Get the foreground color

Returns
COLOR

◆ operator!=()

bool door::ANSIColor::operator!= ( const ANSIColor c) const

Not-equal operator.

This compares colors and attributes, but ignores reset.

Parameters
[in]cconst ANSIColor &
Returns
bool

◆ operator==()

bool door::ANSIColor::operator== ( const ANSIColor c) const

Equal operator.

This compares colors and attributes, but ignores reset.

Parameters
[in]cconst ANSIColor &
Returns
bool

◆ output() [1/2]

std::string door::ANSIColor::output ( ANSIColor previous) const

Output only what ANSI attributes and colors have changed. This uses the previous ANSIColor value to determine what has changed.

This sets previous to the current upon completion.

◆ output() [2/2]

std::string door::ANSIColor::output ( void  ) const

Output the full ANSI codes for attributes and color. This does not look at the previous values.

◆ setBg()

void door::ANSIColor::setBg ( COLOR  b)

Set background color.

Parameters
[in]bbackground COLOR

◆ setFg() [1/2]

void door::ANSIColor::setFg ( COLOR  f)

Set foreground color.

Parameters
[in]fforeground COLOR

◆ setFg() [2/2]

void door::ANSIColor::setFg ( COLOR  f,
ATTR  a 
)

Set foreground color and attribute.

Parameters
[in]fforeground COLOR
[in]aATTR

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  os,
const ANSIColor c 
)
friend

This converts ANSI COLOR and ATTR to ANSI codes understood by the Door output class.

Member Data Documentation

◆ bg

COLOR door::ANSIColor::bg
private

Background color

◆ blink

unsigned int door::ANSIColor::blink
private

blink slow blinking text

◆ bold

unsigned int door::ANSIColor::bold
private

bold / bright flag

◆ fg

COLOR door::ANSIColor::fg
private

Foreground color

◆ inverse

unsigned int door::ANSIColor::inverse
private

inverse

◆ reset

unsigned int door::ANSIColor::reset
private

reset flag / always send color and attributes


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