#pragma once #include #include #include #include class JSonElement; class JSonContainer; class JSonArray; class JSonObject; template class Optional; class CurseOutput { public: CurseOutput(JSonElement *rootData); virtual ~CurseOutput(); void run(); bool onsig(int signo); private: virtual void loop(); protected: void init(); void shutdown(); /** * return false if bottom of screen is touched **/ bool redraw(); bool redraw(std::pair &, const std::pair &maxWidth, const JSonElement *, const JSonContainer *); bool readInput(); void getScreenSize(std::pair &, std::pair &) const; void checkSelection(const JSonElement *item, const JSonElement *parent, const std::pair&); static unsigned int getNbLines(float nbChar, unsigned int maxWidth); unsigned int write(const int &x, const int &y, const JSonElement *item, unsigned int maxWidth, bool selected =false); unsigned int write(const int &x, const int &y, const std::string &item, unsigned int maxWidth, bool selected =false); unsigned int write(const int &x, const int &y, const char item, unsigned int maxWidth, bool selected =false); unsigned int write(const int &x, const int &y, const char *item, unsigned int maxWidth, bool selected =false); bool writeKey(const std::string &key, std::pair &cursor, const std::pair &maxWidth, bool selected); bool writeContainer(std::pair &, const std::pair &maxSize, const JSonContainer *); bool writeContent(std::pair &cursor, const std::pair &maxSize, const std::list * obj); std::set collapsed; const JSonElement *data, *selection; SCREEN *screen; FILE *screen_fd; bool breakLoop; int topleft; const unsigned int indentLevel; const JSonElement *select_up, *select_down; bool selectFound, selectIsLast, selectIsFirst; };