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

Text and ANSIColor. More...

#include <door.h>

Collaboration diagram for door::Line:
Collaboration graph
[legend]

Public Member Functions

 Line (const std::string &txt, int width=0)
 
 Line (const char *txt, int width=0)
 
 Line (const std::string &txt, int width, ANSIColor c)
 
 Line (const char *txt, int width, ANSIColor c)
 
 Line (const std::string &txt, int width, renderFunction rf)
 
 Line (const char *txt, int width, renderFunction rf)
 
 Line (const Line &rhs)
 
 Line (Line &&rhs)
 
bool hasRender (void)
 
int length (void)
 
void fit (void)
 
void setPadding (std::string &padstring, ANSIColor padColor)
 
void setPadding (const char *padstring, ANSIColor padcolor)
 
void setText (std::string &txt)
 
void setText (const char *txt)
 
const char * getText (void)
 
void setColor (ANSIColor c)
 
void setRender (renderFunction rf)
 
void setUpdater (updateFunction uf)
 
bool update (void)
 
std::string debug (void)
 

Private Attributes

std::string text
 Text of the line.
 
bool hasColor
 Do we have color?
 
ANSIColor color
 Line color.
 
std::string padding
 Padding characters.
 
ANSIColor paddingColor
 Padding color.
 
renderFunction render
 renderFunction to use when rendering Line.
 
updateFunction updater
 updateFunction to use when updating.
 
int width
 

Friends

std::ostream & operator<< (std::ostream &os, const Line &l)
 

Detailed Description

Text and ANSIColor.

This holds text and ANSIColor information, and knows how to send them out to the Door.

Constructor & Destructor Documentation

◆ Line() [1/3]

door::Line::Line ( const std::string &  txt,
int  w = 0 
)
Parameters
widthint

Construct a new Line:: Line object with string and total width.

Parameters
txtstd::string
widthint

◆ Line() [2/3]

door::Line::Line ( const char *  txt,
int  w = 0 
)

Construct a new Line:: Line object with const char * and total width

Parameters
txtconst char *
widthint

◆ Line() [3/3]

door::Line::Line ( const Line rhs)

Construct a new Line:: Line object from an existing Line

Parameters
rhsconst Line&

Member Function Documentation

◆ fit()

void door::Line::fit ( void  )

Make text the given width by padding string with spaces.

Parameters
widthint

◆ hasRender()

bool door::Line::hasRender ( void  )

Has a render function been set?

Returns
bool

◆ length()

int door::Line::length ( void  )

Return total length of Line

text.length + 2 * padding length

Returns
int

◆ setColor()

void door::Line::setColor ( ANSIColor  c)

set color

Parameters
cANSIColor

◆ setPadding() [1/2]

void door::Line::setPadding ( const char *  padstring,
ANSIColor  padColor 
)
Parameters
padstringconst char *
padColorANSIColor

set padding (color and text)

Parameters
padstringconst char *
padColorANSIColor

◆ setPadding() [2/2]

void door::Line::setPadding ( std::string &  padstring,
ANSIColor  padColor 
)
Parameters
padstringstd::string &
padColorANSIColor

set padding (color and text)

Parameters
padstringstd::string
padColorANSIColor

◆ setRender()

void door::Line::setRender ( renderFunction  rf)

set render

Set the renderFunction to use for this Line. This replaces the colorizer.

Parameters
rfrenderFunction

◆ setText() [1/2]

void door::Line::setText ( const char *  txt)

Set Line text.

Parameters
txtconst char *

◆ setText() [2/2]

void door::Line::setText ( std::string &  txt)

Set Line text.

Parameters
txtstd::string

◆ setUpdater()

void door::Line::setUpdater ( updateFunction  newUpdater)

set updater function

This can update the line text when called.

Todo:
Define an updateFunction.
Parameters
newUpdaterupdateFunction

◆ update()

bool door::Line::update ( void  )

Call updater, report if the text was actually changed.

Returns
bool

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  os,
const Line l 
)
friend
Todo:
This might be a problem, because const Line wouldn't allow me to track "updates". I.E. I send the line, I'd need to change the line's State to "nothing changed". Then, if something did change, the next update request would be able to know that yes, this does indeed need to be sent.
Bug:
This also might cause problems if I display a shared BasicLine (in multiple places), and then update it. It would only update in the first place (the others wouldn't show it needs an update).

Output Line

This looks for padding and paddingColor. This uses the render function if set.

Parameters
osstd::ostream
lconst Line &
Returns
std::ostream&

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