#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: typedef Optional, const JSonElement *> > t_nextKey; 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&, const JSonElement *, const JSonContainer *); bool readInput(); void getScreenSize(std::pair &, std::pair &); static CurseOutput::t_nextKey findPrev(const JSonElement *); static CurseOutput::t_nextKey findNext(const JSonElement *); void checkSelection(const JSonElement *item, const JSonElement *parent, const std::pair&); void write(const int &x, const int &y, const JSonElement *item, bool selected =false); void write(const int &x, const int &y, const std::string &item, bool selected =false); void write(const int &x, const int &y, const char item, bool selected =false); void write(const int &x, const int &y, const char *item, bool selected =false); bool writeKey(const std::string &key, std::pair &cursor, const int maxHeight, bool selected); bool writeContainer(std::pair &, const std::pair&, const JSonContainer *); bool writeContent(std::pair &cursor, const std::pair &maxSize, const JSonArray * obj); bool writeContent(std::pair &cursor, const std::pair &maxSize, const JSonObject * obj); std::set collapsed; const JSonElement *data, *selection; SCREEN *screen; FILE *screen_fd; bool breakLoop; int topleft; const unsigned int indentLevel; //FIXME optimize const JSonElement *select_up, *select_down; bool selectFound, selectIsLast, selectIsFirst; };