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)
 
void setFg (COLOR f, ATTR a)
 
void setBg (COLOR b)
 
COLOR getFg ()
 
COLOR getBg ()
 
void attr (ATTR a)
 
std::string output (void) const
 
std::string debug (void)
 
std::string output (ANSIColor &previous) const
 

Private Attributes

COLOR fg
 Foreground color.
 
COLOR bg
 Background color.
 
unsigned int reset: 1
 reset flag / always send color and attributes
 
unsigned int bold: 1
 bold / bright flag
 
unsigned int blink: 1
 blink slow blinking text
 
unsigned int inverse: 1
 inverse
 

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
door-example.cpp, and 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
aATTR

◆ ANSIColor() [3/8]

door::ANSIColor::ANSIColor ( COLOR  f)

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

Parameters
fCOLOR

◆ ANSIColor() [4/8]

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

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

Parameters
fCOLOR
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
fCOLOR
a1ATTR
a2ATTR

◆ ANSIColor() [6/8]

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

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

Parameters
fCOLOR
bCOLOR

◆ 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
fCOLOR
bCOLOR
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
fCOLOR
bCOLOR
a1ATTR
a2ATTR

Member Function Documentation

◆ Attr()

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

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

Parameters
aATTR
Returns
ANSIColor&

◆ operator!=()

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

Not-equal operator.

This compares colors and attributes, but ignores reset.

Parameters
cconst ANSIColor &
Returns
bool

◆ operator==()

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

Equal operator.

This compares colors and attributes, but ignores reset.

Parameters
cconst ANSIColor &
Returns
bool

◆ output() [1/2]

std::string door::ANSIColor::output ( ANSIColor previous) const
Parameters
previousthe previous attributes and colors
Returns
std::string

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
Returns
std::string

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

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  os,
const ANSIColor c 
)
friend
Parameters
osOutput stream
cANSIColor
Returns
std::ostream&

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


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