#pragma once #include using namespace std; class ScreenBuffer{ struct Style{ int fg=9,bg=9; }; struct Cell{ char c=' '; Style style; }; int W,H; Cell *prevscreen,*screen; int curx=0,cury=0; Style curstyle; void printstr(const char *buf); int printf_varargs(const char *format,va_list ap); friend bool operator!=(const ScreenBuffer::Style &a,const ScreenBuffer::Style &b); friend bool operator!=(const ScreenBuffer::Cell &a,const ScreenBuffer::Cell &b); public: ScreenBuffer(int W,int H); ~ScreenBuffer(); void moveto(int x,int y); int printf(const char *format,...) __attribute__((format (printf, 2, 3))); int mvprintf(int x,int y,const char *format,...) __attribute__((format (printf, 4, 5))); void setfg(int fg); void setbg(int bg); void draw(); void emergencyDeinit(); };