22 #define XKEY_START 0x1000
24 #define XKEY_UP_ARROW 0x1001
25 #define XKEY_DOWN_ARROW 0x1002
26 #define XKEY_RIGHT_ARROW 0x1003
27 #define XKEY_LEFT_ARROW 0x1004
29 #define XKEY_HOME 0x1010
30 #define XKEY_END 0x1011
31 #define XKEY_PGUP 0x1012
32 #define XKEY_PGDN 0x1023
33 #define XKEY_INSERT 0x1024
34 #define XKEY_DELETE 0x7f
36 #define XKEY_F1 0x1021
37 #define XKEY_F2 0x1022
38 #define XKEY_F3 0x1023
39 #define XKEY_F4 0x1024
40 #define XKEY_F5 0x1025
41 #define XKEY_F6 0x1026
42 #define XKEY_F7 0x1027
43 #define XKEY_F8 0x1028
44 #define XKEY_F9 0x1029
45 #define XKEY_F10 0x102a
46 #define XKEY_F11 0x102b
47 #define XKEY_F12 0x102c
49 #define XKEY_UNKNOWN 0x1111
59 extern bool full_cp437;
60 extern bool debug_capture;
70 void cp437toUnicode(std::string input, std::string &out);
71 void cp437toUnicode(
const char *input, std::string &out);
84 enum class COLOR : std::int8_t {
108 enum class ATTR : std::int8_t {
169 std::string
output(
void)
const;
171 std::string debug(
void);
193 class Door :
public std::ostream,
private std::streambuf {
196 std::streamsize
xsputn(
const char *s, std::streamsize n)
override;
198 std::string doorname;
199 void parse_dropfile(
const char *filepath);
202 struct termios tio_default;
204 signed int getch(
void);
211 std::string dropfilename;
212 vector<std::string> dropfilelines;
214 void detect_unicode_and_screen(
void);
217 std::promise<void> stop_thread;
222 void time_thread_run(std::future<void> future);
223 std::thread time_thread;
230 Door(std::string dname,
int argc,
char *argv[]);
237 std::string debug_buffer;
251 std::string username;
253 std::string location;
257 atomic<int> time_left;
258 atomic<int> time_used;
260 signed int getkey(
void);
309 Render(
const std::string txt);
315 void output(std::ostream &os);
403 enum class Justify { NONE, LEFT, RIGHT, CENTER };
418 Goto(
int xpos,
int ypos);
423 void set(
int xpos,
int ypos);
427 extern const char SaveCursor[];
428 extern const char RestoreCursor[];
437 virtual ~LineBase() =
default;
438 virtual bool update(
void) = 0;
453 BasicLine(std::string txt);
454 BasicLine(std::string txt, ANSIColor c);
455 BasicLine(
const BasicLine &rhs) =
default;
456 virtual ~BasicLine() =
default;
458 bool hasRender(
void);
459 void setText(std::string txt);
460 void setColor(ANSIColor c);
465 friend std::ostream &
operator<<(std::ostream &os,
const BasicLine &l);
470 std::vector<std::shared_ptr<BasicLine>> lines;
474 void append(std::shared_ptr<BasicLine> bl);
477 friend std::ostream &
operator<<(std::ostream &os,
const MultiLine &l);
515 Line(
const std::string &txt,
int width = 0);
516 Line(
const char *txt,
int width = 0);
538 void setText(std::string &txt);
540 const char *getText(
void) {
return text.c_str(); };
546 std::string debug(
void);
598 std::vector<std::unique_ptr<Line>>
lines;
603 std::unique_ptr<Line> title;
607 Panel(
int x,
int y,
int width);
614 void set(
int x,
int y);
620 void setTitle(std::unique_ptr<Line> T,
int off = 1);
623 int getWidth(
void) {
return width; };
624 int getHeight(
void) {
628 return lines.size() + 2;
632 void addLine(std::unique_ptr<Line> l);
649 bool update(Door &d);
650 void update(Door &d,
int line);
655 friend std::ostream &operator<<(std::ostream &os,
const Panel &p);
675 std::vector<char> options;
691 Menu(
int x,
int y,
int width);
697 void addSelection(
char c,
const char *line);
699 void defaultSelection(
int d);
712 std::vector<std::unique_ptr<Panel>> panels;
717 void addPanel(std::unique_ptr<Panel> p);
724 bool update(
Door &d);
727 friend std::ostream &operator<<(std::ostream &os,
const Screen &s);
ANSI Goto X, Y position.
Definition: door.h:411
int length(void)
Definition: lines.cpp:203
void fit(void)
Definition: lines.cpp:225
CR+LF.
Definition: door.h:384
ANSIColor paddingColor
Padding color.
Definition: door.h:500
void output(std::ostream &os)
Definition: door.cpp:1071
ColorOutput()
Definition: door.cpp:1039
ANSIColor & Attr(ATTR a)
Definition: ansicolor.cpp:111
updateFunction updater
updateFunction to use when updating.
Definition: door.h:505
@ BOLD
BOLD is the same as BRIGHT.
ofstream & log(void)
Give ofstream handle for logging.
Definition: door.cpp:507
Clrscr(void)
Definition: door.cpp:1114
ANSIColor c
Color to use for this fragment.
Definition: door.h:285
Door(std::string dname, int argc, char *argv[])
Definition: door.cpp:139
bool operator==(const ANSIColor &c) const
Definition: ansicolor.cpp:137
int x
X-Position.
Definition: door.h:413
void append(ANSIColor color, int len=1)
Definition: door.cpp:1086
ANSIColor previous
Definition: door.h:244
@ INVERSE
INVERSE is Background on Foreground.
COLOR fg
Foreground color.
Definition: door.h:133
signed int sleep_key(int secs)
Waits secs seconds for a keypress.
Definition: door.cpp:864
unsigned int inverse
inverse
Definition: door.h:144
std::vector< ColorOutput > outputs
Vector of ColorOutput object.
Definition: door.h:313
@ BRIGHT
BRIGHT is the same as BOLD.
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:1148
std::ostream & operator<<(std::ostream &os, const ANSIColor &c)
Definition: ansicolor.cpp:339
bool operator!=(const ANSIColor &c) const
Definition: ansicolor.cpp:150
int pos
Starting position of Render.text.
Definition: door.h:287
friend std::ostream & operator<<(std::ostream &os, const Goto &g)
Definition: door.cpp:1199
COLOR
The colors available under ANSI-BBS.
Definition: door.h:84
Foreground, Background and Attributes.
Definition: door.h:131
std::string input_string(int max)
Input a string of requested max length.
Definition: door.cpp:913
int get_one_of(const char *keys)
Get one of these keys.
Definition: door.cpp:964
Definition: anyoption.h:35
renderFunction render
renderFunction to use when rendering Line.
Definition: door.h:503
int y
Y-Position.
Definition: door.h:415
std::function< Render(const std::string &)> renderFunction
Render output function.
Definition: door.h:341
@ DOUBLE_SINGLE
DOUBLE top SINGLE side (4)
ANSIColor color
Line color.
Definition: door.h:496
Render(const std::string txt)
Definition: door.cpp:1060
std::unique_ptr< Line > spacer_line(bool single)
Create a spacer line using block drawing characters.
Definition: panel.cpp:332
unsigned int blink
blink slow blinking text
Definition: door.h:142
Clrscr cls
Definition: door.cpp:1142
void setPadding(std::string &padstring, ANSIColor padColor)
Definition: lines.cpp:256
unsigned int reset
reset flag / always send color and attributes
Definition: door.h:138
Text and ANSIColor.
Definition: door.h:488
friend std::ostream & operator<<(std::ostream &os, const Line &l)
Definition: lines.cpp:354
const std::string text
Complete text to be rendered.
Definition: door.h:311
friend std::ostream & operator<<(std::ostream &os, const Clrscr &clr)
Definition: door.cpp:1126
@ RESET
RESET forces all attributes (and Colors) to be sent.
std::vector< std::unique_ptr< Line > > lines
Definition: door.h:598
std::function< std::string(void)> updateFunction
Definition: door.h:360
NewLine nl
Definition: door.cpp:1170
bool update(Door &d)
Updates a panel.
Definition: panel.cpp:248
@ SINGLE_DOUBLE
SINGLE top DOUBLE side (3)
bool hasRender(void)
Definition: lines.cpp:188
std::string output(void) const
Definition: ansicolor.cpp:180
renderFunction rBlueYellow
BlueYellow Render example function.
Definition: door.cpp:1227
std::string text
Text of the line.
Definition: door.h:491
ATTR
ANSI-BBS text attributes.
Definition: door.h:108
void set(int x, int y)
Set the panels X and Y screen position.
Definition: panel.cpp:80
ANSIColor reset(ATTR::RESET)
reset colors to normal
Definition: door.h:400
ANSIColor()
Definition: ansicolor.cpp:16
bool update(void)
Definition: lines.cpp:319
void lineSetBack(ANSIColor back)
Set background of all lines in the panel.
Definition: panel.cpp:319
std::string padding
Padding characters.
Definition: door.h:498
std::streamsize xsputn(const char *s, std::streamsize n) override
Definition: door.cpp:992
BorderStyle
Definition: door.h:570
friend std::ostream & operator<<(std::ostream &os, const ANSIColor &c)
Definition: ansicolor.cpp:339
The BBS door project. This is an attempt at writing a C++ BBS door toolkit.
Definition: ansicolor.cpp:9
int overflow(int c) override
Definition: door.cpp:1019
int len
Length.
Definition: door.h:289
Justify
Definition: door.h:403
Clear the screen.
Definition: door.h:367
void reset(void)
Definition: door.cpp:1047
COLOR bg
Background color.
Definition: door.h:135
Goto(int xpos, int ypos)
Definition: door.cpp:1178
void setText(std::string &txt)
Definition: lines.cpp:243
Rendering a string with ANSIColor.
Definition: door.h:307
bool hasColor
Do we have color?
Definition: door.h:494
friend std::ostream & operator<<(std::ostream &os, const NewLine &nl)
Definition: door.cpp:1156
void setUpdater(updateFunction uf)
Definition: lines.cpp:298
This holds an ANSIColor and text position + length.
Definition: door.h:279
unsigned int bold
bold / bright flag
Definition: door.h:140
void setRender(renderFunction rf)
Definition: lines.cpp:289