23 #define XKEY_START 0x1000
25 #define XKEY_UP_ARROW 0x1001
26 #define XKEY_DOWN_ARROW 0x1002
27 #define XKEY_RIGHT_ARROW 0x1003
28 #define XKEY_LEFT_ARROW 0x1004
30 #define XKEY_HOME 0x1010
31 #define XKEY_END 0x1011
32 #define XKEY_PGUP 0x1012
33 #define XKEY_PGDN 0x1023
34 #define XKEY_INSERT 0x1024
35 #define XKEY_DELETE 0x7f
37 #define XKEY_F1 0x1021
38 #define XKEY_F2 0x1022
39 #define XKEY_F3 0x1023
40 #define XKEY_F4 0x1024
41 #define XKEY_F5 0x1025
42 #define XKEY_F6 0x1026
43 #define XKEY_F7 0x1027
44 #define XKEY_F8 0x1028
45 #define XKEY_F9 0x1029
46 #define XKEY_F10 0x102a
47 #define XKEY_F11 0x102b
48 #define XKEY_F12 0x102c
50 #define XKEY_UNKNOWN 0x1111
90 enum class COLOR : std::int8_t {
114 enum class ATTR : std::int8_t {
179 std::string
output(
void)
const;
180 std::string
debug(
void);
190 class Door :
public std::ostream,
private std::streambuf {
193 std::streamsize
xsputn(
const char *s, std::streamsize n)
override;
202 signed int getch(
void);
219 void time_thread_run(std::future<void> future);
224 Door(std::string dname,
int argc,
char *argv[]);
324 Render(
const std::string txt);
329 void output(std::ostream &os);
417 enum class Justify { NONE, LEFT, RIGHT, CENTER };
432 Goto(
int xpos,
int ypos);
437 void set(
int xpos,
int ypos);
451 virtual ~LineBase() =
default;
452 virtual bool update(
void) = 0;
467 BasicLine(std::string txt);
468 BasicLine(std::string txt, ANSIColor c);
469 BasicLine(
const BasicLine &rhs) =
default;
470 virtual ~BasicLine() =
default;
472 bool hasRender(
void);
473 void setText(std::string txt);
474 void setColor(ANSIColor c);
479 friend std::ostream &
operator<<(std::ostream &os,
const BasicLine &l);
484 std::vector<std::shared_ptr<BasicLine>> lines;
488 void append(std::shared_ptr<BasicLine> bl);
491 friend std::ostream &
operator<<(std::ostream &os,
const MultiLine &l);
529 Line(
const std::string &txt,
int width = 0);
530 Line(
const char *txt,
int width = 0);
552 void setText(std::string &txt);
554 const char *getText(
void) {
return text.c_str(); };
560 std::string debug(
void);
612 std::vector<std::unique_ptr<Line>>
lines;
617 std::unique_ptr<Line> title;
621 Panel(
int x,
int y,
int width);
628 void set(
int x,
int y);
629 void get(
int &x,
int &y) {
634 void setTitle(std::unique_ptr<Line> T,
int off = 1);
637 int getWidth(
void) {
return width; };
638 int getHeight(
void) {
642 return lines.size() + 2;
646 void addLine(std::unique_ptr<Line> l);
664 void update(Door &d,
int line);
669 friend std::ostream &
operator<<(std::ostream &os,
const Panel &p);
689 std::vector<char> options;
705 Menu(
int x,
int y,
int width);
711 void addSelection(
char c,
const char *line);
713 void defaultSelection(
int d);
729 std::vector<std::unique_ptr<Panel>>
panels;
734 void addPanel(std::unique_ptr<Panel> p);
741 bool update(
Door &d);
ANSI Goto X, Y position.
Definition: door.h:425
int length(void)
Definition: lines.cpp:203
void fit(void)
Definition: lines.cpp:225
signed int getkey_or_pushback(void)
Definition: door.cpp:769
CR+LF.
Definition: door.h:398
ANSIColor paddingColor
Padding color.
Definition: door.h:514
std::string username
Definition: door.h:257
std::string debug(void)
Output debug string for ANSIColor.
Definition: ansicolor.cpp:249
void output(std::ostream &os)
Definition: door.cpp:1281
ColorOutput()
Definition: door.cpp:1249
ANSIColor & Attr(ATTR a)
Definition: ansicolor.cpp:112
updateFunction updater
updateFunction to use when updating.
Definition: door.h:519
@ BOLD
BOLD is the same as BRIGHT.
ofstream & log(void)
Give ofstream handle for logging.
Definition: door.cpp:654
Clrscr(void)
Definition: door.cpp:1324
ANSIColor c
Color to use for this fragment.
Definition: door.h:297
Door(std::string dname, int argc, char *argv[])
Construct a new Door:: Door object.
Definition: door.cpp:231
bool operator==(const ANSIColor &c) const
Definition: ansicolor.cpp:138
int cx
Definition: door.h:242
std::string doorname
Definition: door.h:196
int x
X-Position.
Definition: door.h:427
atomic< int > time_used
Definition: door.h:270
void append(ANSIColor color, int len=1)
Definition: door.cpp:1296
ANSIColor previous
Definition: door.h:238
bool full_cp437
Was full CP437 detected?
Definition: door.cpp:216
friend std::ostream & operator<<(std::ostream &os, const Panel &p)
Output panel to stream.
Definition: panel.cpp:390
@ INVERSE
INVERSE is Background on Foreground.
void attr(ATTR a)
Set attribute.
Definition: ansicolor.cpp:194
COLOR fg
Definition: door.h:139
void cp437toUnicode(std::string input, std::string &out)
Convert from CP437 to unicode.
Definition: door.cpp:181
int node
Definition: door.h:266
signed int sleep_key(int secs)
Waits secs seconds for a keypress.
Definition: door.cpp:1028
unsigned int inverse
Definition: door.h:150
std::vector< ColorOutput > outputs
Vector of ColorOutput object.
Definition: door.h:327
@ BRIGHT
BRIGHT is the same as BOLD.
vector< std::string > dropfilelines
Definition: door.h:210
void setColor(ANSIColor c)
Definition: lines.cpp:277
Line(const std::string &txt, int width=0)
Definition: lines.cpp:121
NewLine(void)
Definition: door.cpp:1358
std::ostream & operator<<(std::ostream &os, const ANSIColor &c)
Definition: ansicolor.cpp:371
bool operator!=(const ANSIColor &c) const
Definition: ansicolor.cpp:151
int pos
Starting position of Render.text.
Definition: door.h:299
friend std::ostream & operator<<(std::ostream &os, const Goto &g)
Definition: door.cpp:1409
COLOR
The colors available under ANSI-BBS.
Definition: door.h:90
Foreground, Background and Attributes.
Definition: door.h:137
std::promise< void > stop_thread
Definition: door.h:215
std::string input_string(int max)
Input a string of requested max length.
Definition: door.cpp:1123
int get_one_of(const char *keys)
Get one of these keys.
Definition: door.cpp:1174
std::string location
Definition: door.h:261
COLOR getFg()
Definition: door.h:171
struct termios tio_default
Definition: door.h:201
renderFunction render
renderFunction to use when rendering Line.
Definition: door.h:517
void setFg(COLOR f)
Set foreground color.
Definition: ansicolor.cpp:161
int cy
Definition: door.h:244
std::string dropfilename
Definition: door.h:208
int y
Y-Position.
Definition: door.h:429
std::function< Render(const std::string &)> renderFunction
Render output function.
Definition: door.h:355
ofstream logf
Definition: door.h:212
@ DOUBLE_SINGLE
DOUBLE top SINGLE side (4)
ANSIColor color
Line color.
Definition: door.h:510
Render(const std::string txt)
Definition: door.cpp:1270
COLOR getBg()
Definition: door.h:176
std::unique_ptr< Line > spacer_line(bool single)
Create a spacer line using block drawing characters.
Definition: panel.cpp:357
unsigned int blink
Definition: door.h:148
Clrscr cls
Definition: door.cpp:1352
void setPadding(std::string &padstring, ANSIColor padColor)
Definition: lines.cpp:256
unsigned int reset
Definition: door.h:144
Text and ANSIColor.
Definition: door.h:502
friend std::ostream & operator<<(std::ostream &os, const Line &l)
Definition: lines.cpp:354
AnyOption opt
Definition: door.h:229
friend std::ostream & operator<<(std::ostream &os, const Clrscr &clr)
Definition: door.cpp:1336
std::thread time_thread
Definition: door.h:221
@ RESET
RESET forces all attributes (and Colors) to be sent.
friend std::ostream & operator<<(std::ostream &os, const Screen &s)
Outputs screen to stream.
Definition: panel.cpp:926
std::vector< std::unique_ptr< Line > > lines
Definition: door.h:612
std::function< std::string(void)> updateFunction
Definition: door.h:374
NewLine nl
Definition: door.cpp:1380
bool update(Door &d)
Updates a panel.
Definition: panel.cpp:273
@ SINGLE_DOUBLE
SINGLE top DOUBLE side (3)
bool hasRender(void)
Definition: lines.cpp:188
std::string output(void) const
Definition: ansicolor.cpp:207
renderFunction rBlueYellow
BlueYellow Render example function.
Definition: door.cpp:1443
std::string text
Text of the line.
Definition: door.h:505
ATTR
ANSI-BBS text attributes.
Definition: door.h:114
void set(int x, int y)
Set the panels X and Y screen position.
Definition: panel.cpp:79
ANSIColor reset(ATTR::RESET)
reset colors to normal
Definition: door.h:414
ANSIColor()
Definition: ansicolor.cpp:16
void detect_unicode_and_screen(void)
Detect unicode/CP437, and screen size.
Definition: door.cpp:457
void setBg(COLOR b)
Set background color.
Definition: ansicolor.cpp:185
bool update(void)
Definition: lines.cpp:319
int inactivity
Number of seconds before timing out.
Definition: door.h:255
bool track
Definition: door.h:240
bool has_dropfile
Definition: door.h:205
void lineSetBack(ANSIColor back)
Set background of all lines in the panel.
Definition: panel.cpp:344
std::vector< std::unique_ptr< Panel > > panels
vector of panels.
Definition: door.h:729
int height
Definition: door.h:248
std::string padding
Padding characters.
Definition: door.h:512
const char SaveCursor[]
ANSI Save Cursor position command.
Definition: door.cpp:1434
std::string handle
Definition: door.h:259
std::streamsize xsputn(const char *s, std::streamsize n) override
Definition: door.cpp:1202
BorderStyle
Definition: door.h:584
bool unicode
Was unicode detected?
Definition: door.cpp:208
friend std::ostream & operator<<(std::ostream &os, const ANSIColor &c)
Definition: ansicolor.cpp:371
The BBS door project. This is an attempt at writing a C++ BBS door toolkit.
Definition: ansicolor.cpp:9
std::string debug_buffer
Definition: door.h:231
int overflow(int c) override
Definition: door.cpp:1229
int len
Length.
Definition: door.h:301
Justify
Definition: door.h:417
int width
Definition: door.h:246
void parse_dropfile(const char *filepath)
Load dropfile into dropfilelines and parse.
Definition: door.cpp:576
std::list< char > pushback
pushback buffer for keys.
Definition: door.cpp:60
Clear the screen.
Definition: door.h:381
bool debug_capture
Capture the output for debugging.
Definition: door.cpp:222
void reset(void)
Definition: door.cpp:1257
COLOR bg
Definition: door.h:141
signed int getch(void)
low level read key.
Definition: door.cpp:714
signed int getkey(void)
Get a key routine.
Definition: door.cpp:790
Goto(int xpos, int ypos)
Definition: door.cpp:1388
bool haskey(void)
Are there any keys in STDIN?
Definition: door.cpp:672
int seconds_elapsed
Definition: door.h:218
void setText(std::string &txt)
Definition: lines.cpp:243
const char RestoreCursor[]
ANSI Restore Cursor position command.
Definition: door.cpp:1438
atomic< int > time_left
Definition: door.h:268
Rendering a string with ANSIColor.
Definition: door.h:319
bool hasColor
Do we have color?
Definition: door.h:508
std::string text
Complete text to be rendered.
Definition: door.h:321
std::string sysop
Definition: door.h:263
signed int sleep_ms_key(int msecs)
Waits miliseconds for a keypress.
Definition: door.cpp:1074
friend std::ostream & operator<<(std::ostream &os, const NewLine &nl)
Definition: door.cpp:1366
void setUpdater(updateFunction uf)
Definition: lines.cpp:298
This holds an ANSIColor and text position + length.
Definition: door.h:291
unsigned int bold
Definition: door.h:146
void setRender(renderFunction rf)
Definition: lines.cpp:289