#define _GNU_SOURCE #include #include #include #include #include #include #include "screenbuffer.h" using namespace std; bool operator!=(const ScreenBuffer::Style &a,const ScreenBuffer::Style &b){ return memcmp(&a,&b,sizeof(ScreenBuffer::Style))!=0; } bool operator!=(const ScreenBuffer::Cell &a,const ScreenBuffer::Cell &b){ return memcmp(&a,&b,sizeof(ScreenBuffer::Cell))!=0; } static void initTerminal(){ cout<<"\x1B[?1049h" // start alternate screen "\x1B[2J" // clear screen "\x1B[H" // move to top left <=0&&x=0&&y=0&&fg<=7)||fg==9); curstyle.fg=fg; } void ScreenBuffer::setbg(int bg){ assert((bg>=0&&bg<=7)||bg==9); curstyle.bg=bg; } void ScreenBuffer::draw(){ bool changed[W*H]; for(int i=0;i