1
1

curseOutput.hh 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. bool onsig(int signo);
  14. private:
  15. typedef Optional<std::pair<Optional<const std::string>, const JSonElement *> > t_nextKey;
  16. virtual void loop();
  17. protected:
  18. void init();
  19. void shutdown();
  20. void redraw();
  21. void redraw(std::pair<int, int> &, const std::pair<int, int>&, const JSonElement *);
  22. bool readInput();
  23. void getScreenSize(std::pair<int, int> &);
  24. static CurseOutput::t_nextKey findNext(const JSonElement *);
  25. void write(const int &x, const int &y, const JSonElement *item, bool selected);
  26. void write(const int &x, const int &y, const std::string &item, bool selected);
  27. void writeKey(const std::string &key, std::pair<int, int> &cursor, bool selected);
  28. const JSonElement *data, *selection;
  29. SCREEN *screen;
  30. bool breakLoop;
  31. FILE *screen_fd;
  32. std::pair<std::pair<unsigned int, unsigned int>, const JSonElement *> topleft;
  33. const unsigned int indentLevel;
  34. //FIXME optimize
  35. const JSonElement *select_up, *select_down;
  36. bool selectFound;
  37. };