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

#include <door.h>

Inheritance diagram for door::Door:
Inheritance graph
[legend]
Collaboration diagram for door::Door:
Collaboration graph
[legend]

Public Member Functions

 Door (std::string dname, int argc, char *argv[])
 
 Door (Door &)=delete
 Default copy ctor deleted.
 
ofstream & log (void)
 Give ofstream handle for logging. More...
 
signed int getkey (void)
 
bool haskey (void)
 
int get_input (void)
 
signed int sleep_key (int secs)
 Waits secs seconds for a keypress. More...
 
std::string input_string (int max)
 Input a string of requested max length. More...
 
int get_one_of (const char *keys)
 Get one of these keys. More...
 

Public Attributes

AnyOption opt
 
std::string debug_buffer
 
ANSIColor previous
 
bool track
 
int cx
 
int cy
 
int width
 
int height
 
int inactivity
 
std::string username
 
std::string handle
 
std::string location
 
std::string sysop
 
int node
 
atomic< int > time_left
 
atomic< int > time_used
 

Private Member Functions

std::streamsize xsputn (const char *s, std::streamsize n) override
 
int overflow (int c) override
 
void parse_dropfile (const char *filepath)
 
void init (void)
 
signed int getch (void)
 
void unget (char c)
 
char get (void)
 
void detect_unicode_and_screen (void)
 
void time_thread_run (std::future< void > future)
 

Private Attributes

std::string doorname
 
std::time_t startup
 
struct termios tio_default
 
char buffer [5]
 
unsigned int bpos
 
bool has_dropfile
 
bool debugging
 
std::string dropfilename
 
vector< std::string > dropfilelines
 
ofstream logf
 
std::promise< void > stop_thread
 
int seconds_elapsed
 
std::thread time_thread
 

Detailed Description

This handles output to the caller, via ostream.

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

Constructor & Destructor Documentation

◆ Door()

door::Door::Door ( std::string  dname,
int  argc,
char *  argv[] 
)
Parameters
argcint
argvchar *[]

Member Function Documentation

◆ get_one_of()

int door::Door::get_one_of ( const char *  keys)

Get one of these keys.

returns char, or < 0 if timeout.

Parameters
keys
Returns
char or < 0

◆ input_string()

std::string door::Door::input_string ( int  max)

Input a string of requested max length.

This first sends out max number of spaces, and max number of backspaces. This will setup the input area. (If you set a background color of blue, this would allow that to be seen by the user.)

It handles input, backspaces / deleting the characters / enter input and timeout/hangup/out of time.

Parameters
max
Returns
std::string

◆ log()

ofstream & door::Door::log ( void  )

Give ofstream handle for logging.

This appends the current date/time stamp into the logfile, and returns a reference.

Example:

door.log() << "Something bad just happened." << std::endl;

Returns
ofstream&

◆ overflow()

int door::Door::overflow ( int  c)
overrideprivate

Stores a character into the buffer. This does still use the buffer.

Todo:
Replace this also with a direct call to od_disp_emu.
Parameters
cchar
Returns
int

◆ sleep_key()

signed int door::Door::sleep_key ( int  secs)

Waits secs seconds for a keypress.

returns key, or -1 on timeout (seconds passed). -2 hangup -3 out of time

Parameters
secs
Returns
signed int

◆ xsputn()

std::streamsize door::Door::xsputn ( const char *  s,
std::streamsize  n 
)
overrideprivate

Take given buffer and output it.

If debug_capture is enabled, we save everything to debug_buffer. This is used by the tests.

Parameters
sconst char *
nstd::streamsize
Returns
std::streamsize

Member Data Documentation

◆ previous

ANSIColor door::Door::previous

Previous ANSI-BBS colors and attributes sent. This is used to optimize our output.

See also
ANSIColor::output()

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