#pragma once #include #include #include #include #include #include "outputFlag.hh" #include "params.hh" class JSonElement; class JSonContainer; class JSonArray; class JSonObject; template class Optional; class CurseOutput { public: CurseOutput(JSonElement *rootData, const Params &); 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); const OutputFlag getFlag(const JSonElement *item) const; void write(const char *str, unsigned int maxWidth, const OutputFlag flags) const; unsigned int write(const int &x, const int &y, const JSonElement *item, unsigned int maxWidth, const OutputFlag); unsigned int write(const int &x, const int &y, const std::string &item, unsigned int maxWidth, const OutputFlag); unsigned int write(const int &x, const int &y, const char item, unsigned int maxWidth, const OutputFlag); unsigned int write(const int &x, const int &y, const char *item, unsigned int maxWidth, const OutputFlag); bool writeKey(const std::string &key, std::pair &cursor, const std::pair &maxWidth, OutputFlag, unsigned int extraLen =0); bool writeKey(const std::string &key, const std::string &after, std::pair &cursor, const std::pair &maxWidth, OutputFlag); 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; const Params ¶ms; SCREEN *screen; FILE *screen_fd; bool breakLoop; int topleft; std::set colors; const JSonElement *select_up, *select_down; bool selectFound, selectIsLast, selectIsFirst; };