Bugz Door Project
Classes | Typedefs | Enumerations | Functions | Variables
door Namespace Reference

The BBS door project. This is an attempt at writing a C++ BBS door toolkit. More...

Classes

class  ANSIColor
 Foreground, Background and Attributes. More...
 
struct  box_styles
 
class  Clrscr
 Clear the screen. More...
 
class  ColorOutput
 This holds an ANSIColor and text position + length. More...
 
class  Door
 
class  Goto
 ANSI Goto X, Y position. More...
 
class  IConv
 
class  Line
 Text and ANSIColor. More...
 
class  Menu
 
class  NewLine
 CR+LF. More...
 
class  Panel
 
class  Render
 Rendering a string with ANSIColor. More...
 
class  Screen
 

Typedefs

typedef std::function< Render(const std::string &)> renderFunction
 Render output function. More...
 
typedef std::function< std::string(void)> updateFunction
 

Enumerations

enum  COLOR : std::int8_t {
  COLOR::BLACK, COLOR::RED, COLOR::GREEN, COLOR::BROWN,
  COLOR::YELLOW = 3, COLOR::BLUE, COLOR::MAGENTA, COLOR::CYAN,
  COLOR::WHITE
}
 The colors available under ANSI-BBS. More...
 
enum  ATTR : std::int8_t {
  ATTR::RESET, ATTR::BOLD, ATTR::BRIGHT = 1, ATTR::BLINK = 5,
  ATTR::INVERSE = 7
}
 ANSI-BBS text attributes. More...
 
enum  Justify { NONE, LEFT, RIGHT, CENTER }
 
enum  BorderStyle {
  BorderStyle::NONE, BorderStyle::SINGLE, BorderStyle::DOUBLE, BorderStyle::SINGLE_DOUBLE,
  BorderStyle::DOUBLE_SINGLE, BorderStyle::BLANK
}
 

Functions

std::ostream & operator<< (std::ostream &os, const ANSIColor &c)
 
void to_lower (std::string &text)
 
bool replace (std::string &str, const std::string &from, const std::string &to)
 
bool replace (std::string &str, const char *from, const char *to)
 
void sig_handler (int signal)
 
void cp437toUnicode (std::string input, std::string &out)
 
void cp437toUnicode (const char *input, std::string &out)
 
std::ostream & operator<< (std::ostream &os, const Clrscr &clr)
 
std::ostream & operator<< (std::ostream &os, const NewLine &nl)
 
std::ostream & operator<< (std::ostream &os, const Goto &g)
 
std::ostream & operator<< (std::ostream &os, const Line &l)
 
std::ostream & operator<< (std::ostream &os, const Panel &p)
 
std::ostream & operator<< (std::ostream &os, const Screen &s)
 

Variables

ANSIColor reset (ATTR::RESET)
 reset colors to normal More...
 
bool unicode = false
 
bool full_cp437 = false
 
bool debug_capture = false
 
Clrscr cls
 
NewLine nl
 
const char SaveCursor [] = "\x1b[s"
 
const char RestoreCursor [] = "\x1b[u"
 
renderFunction rBlueYellow
 BlueYellow Render example function. More...
 
struct box_styles UBOXES []
 
struct box_styles BOXES []
 
const char * JOIN [2][2][2]
 
const char * UJOIN [2][2][2]
 

Detailed Description

The BBS door project. This is an attempt at writing a C++ BBS door toolkit.

Typedef Documentation

◆ renderFunction

typedef std::function<Render(const std::string &)> door::renderFunction

Render output function.

This defines the render output function. Given the line text, we output the color codes needs to display the line.

door::ANSIColor upperColor, lowerColor;
door::RenderFunction render = [upperColor, lowerColor]
(const std::string &text) -> door::Render {
door::Render r(text);
for (char const &c : text) {
if (std::isupper(c))
r.append(upperColor);
else
r.append(lowerColor);
}
return r;
};

◆ updateFunction

typedef std::function<std::string(void)> door::updateFunction

This defines the update function.

This updates the text.

int score = 0;
door::updateFunction updater = [](void) -> std::string {
std::string text = "Score: ";
text += std::to_string(score);
return text;
};
fancyLine.setUpdater(updater);

Enumeration Type Documentation

◆ ATTR

enum door::ATTR : std::int8_t
strong

ANSI-BBS text attributes.

Enumerator
RESET 

RESET forces all attributes (and Colors) to be sent.

BOLD 

BOLD is the same as BRIGHT.

BRIGHT 

BRIGHT is the same as BOLD.

BLINK 

SLOW BLINK.

INVERSE 

INVERSE is Background on Foreground.

◆ BorderStyle

enum door::BorderStyle
strong

The different Borders supported by Panel.

Enumerator
NONE 

NONE (0)

SINGLE 

SINGLE (1)

DOUBLE 

DOUBLE (2)

SINGLE_DOUBLE 

SINGLE top DOUBLE side (3)

DOUBLE_SINGLE 

DOUBLE top SINGLE side (4)

BLANK 

BLANK (5)

◆ COLOR

enum door::COLOR : std::int8_t
strong

The colors available under ANSI-BBS.

ANSI Color codes

Enumerator
BLACK 

BLACK (0)

RED 

RED (1)

GREEN 

GREEN (2)

BROWN 

BROWN (3)

YELLOW 

YELLOW (3)

BLUE 

BLUE (4)

MAGENTA 

MAGENTA (5)

CYAN 

CYAN (6)

WHITE 

WHITE (7)

◆ Justify

enum door::Justify
strong
Deprecated:
Not used

Function Documentation

◆ operator<<() [1/5]

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

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

◆ operator<<() [2/5]

std::ostream& door::operator<< ( std::ostream &  os,
const Clrscr clr 
)

Clear the screen using ANSI codes.

Not all systems home the cursor after clearing the screen. We automatically home the cursor as well.

Parameters
osstd::ostream&
clrconst Clrscr&
Returns
std::ostream&

◆ operator<<() [3/5]

std::ostream& door::operator<< ( std::ostream &  os,
const Goto g 
)

Output the ANSI codes to position the cursor to the given y,x position.

Todo:

Optimize the ANSI goto string output.

Update the Door object so it know where the cursor is positioned.

Parameters
osstd::ostream
gconst Goto
Returns
std::ostream&

◆ operator<<() [4/5]

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

Output Line

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

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

◆ operator<<() [5/5]

std::ostream& door::operator<< ( std::ostream &  os,
const NewLine nl 
)

Output Newline + CarriageReturn

Parameters
osstd::ostream
nlconst NewLine
Returns
std::ostream&

Variable Documentation

◆ cls

Clrscr door::cls

Clear the BBS terminal.

Examples
door-example.cpp, and menu-example.cpp.

◆ JOIN

const char* door::JOIN[2][2][2]
Initial value:
= {{
{"\xc3", "\xb4"},
{"\xc6", "\xb5"}
},
{
{"\xc7", "\xb6"},
{"\xcc", "\xb9"},
}}

◆ nl

NewLine door::nl

CRLF

Examples
door-example.cpp, and menu-example.cpp.

◆ rBlueYellow

renderFunction door::rBlueYellow
Initial value:
= [](const std::string &txt) -> Render {
Render r(txt);
ANSIColor blue(COLOR::BLUE, ATTR::BOLD);
ANSIColor cyan(COLOR::YELLOW, ATTR::BOLD);
for (char const &c : txt) {
if (isupper(c))
r.append(blue);
else
r.append(cyan);
}
return r;
}

BlueYellow Render example function.

Example BlueYellow renderFunction.

◆ reset

ANSIColor door::reset

reset colors to normal

This resets the colors to normal state.

Examples
door-example.cpp, and menu-example.cpp.

◆ UBOXES

struct box_styles door::UBOXES[]
Initial value:
= {{"\u250c", "\u2510", "\u2500", "\u2502", "\u2514",
"\u2518", "\u251c", "\u2524"},
{"\u2554", "\u2557", "\u2550", "\u2551", "\u255a",
"\u255d", "\u2560", "\u2563"},
{"\u2553", "\u2556", "\u2500", "\u2551", "\u2559",
"\u255c", "\u255f", "\u2562"},
{"\u2552", "\u2555", "\u2550", "\u2502", "\u2558",
"\u255b", "\u255e", "\u2561"}}

use https://en.wikipedia.org/wiki/Code_page_437 for translations between CP437 and unicode symbols.

This holds the characters needed to render the different box styles. tl tr top side bl br ml mr

◆ UJOIN

const char* door::UJOIN[2][2][2]
Initial value:
= {{
{"\u251c", "\u2524"},
{"\u255e", "\u2561"}
},
{
{"\u255f", "\u2562"},
{"\u2560", "\u2563"},
}}
door::ANSIColor
Foreground, Background and Attributes.
Definition: door.h:131
door::updateFunction
std::function< std::string(void)> updateFunction
Definition: door.h:360
door::Render
Rendering a string with ANSIColor.
Definition: door.h:307