123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- #ifndef TERMINAL_H
- #define TERMINAL_H
- #include <string>
- #include <vector>
- class Terminal {
- private:
- int posx, posy;
- std::vector<std::pair<int, int>> saved_cursor_position;
- std::string ansi;
- int in_ansi;
- int fgcolor, bgcolor, status;
- int dcs_map;
- public:
- enum ANSI_TYPE { START, CURSOR, COLOR, CLEAR, DCS, OTHER };
- struct termchar {
- int in_ansi;
- Terminal::ANSI_TYPE ansi;
- };
- public:
- Terminal(void);
- Terminal(const Terminal &old);
- Terminal &operator=(Terminal &rhs);
- void init(void);
- std::string color_restore(void);
- termchar putchar(char ch);
- void putstring(std::string text);
- int getx(void);
- int gety(void);
- int getstatus(void);
- int inANSI(void);
- int fg(void);
- int bg(void);
- bool ansiempty(void);
- int dcs(void);
- private:
- void ansi_color(int color);
- ANSI_TYPE ansi_code(std::string ansi);
- };
- struct console_details {
- int posx, posy;
- int savedx, savedy;
- char ansi[20];
- int in_ansi;
- int fgcolor;
- int bgcolor;
- int status;
- };
- enum ANSI_TYPE { START, CURSOR, COLOR, CLEAR, OTHER };
- struct termchar {
- int in_ansi;
- ANSI_TYPE ansi;
- };
- void console_init(struct console_details *cdp);
- void ansi_color(struct console_details *cdp, int color);
- const char *color_restore(struct console_details *cdp);
- ANSI_TYPE console_ansi(struct console_details *cdp, const char *ansi);
- termchar console_char(struct console_details *cdp, char ch);
- void console_receive(struct console_details *cdp, std::string chars);
- #endif
|