1
1

curseOutput.hh 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #pragma once
  2. #include <fstream>
  3. #include <ios>
  4. #include <ncurses.h>
  5. class JSonElement;
  6. template<class T> class Optional;
  7. class CurseOutput
  8. {
  9. public:
  10. CurseOutput(JSonElement *rootData);
  11. virtual ~CurseOutput();
  12. void run();
  13. private:
  14. typedef Optional<std::pair<Optional<const std::string>, const JSonElement *> > t_nextKey;
  15. protected:
  16. void init();
  17. void shutdown();
  18. void redraw();
  19. void redraw(std::pair<int, int> &, const std::pair<int, int>&, const JSonElement *);
  20. bool readInput();
  21. void getScreenSize(std::pair<int, int> &);
  22. static CurseOutput::t_nextKey findNext(const JSonElement *);
  23. void write(const int &x, const int &y, JSonElement *item);
  24. void write(const int &x, const int &y, const std::string &item);
  25. void writeKey(const std::string &key, std::pair<int, int> &cursor);
  26. const JSonElement *data, *selection;
  27. const JSonElement *select_up, *select_down;
  28. SCREEN *screen;
  29. FILE *screen_fd;
  30. bool selectFound;
  31. bool selected;
  32. std::pair<std::pair<unsigned int, unsigned int>, const JSonElement *> topleft;
  33. const unsigned int indentLevel;
  34. };