curseSplitOutput.hh 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #pragma once
  2. #include <deque>
  3. #include "curseOutput.hh"
  4. class CurseSplitOutput: public CurseOutput
  5. {
  6. public:
  7. CurseSplitOutput(const Params &);
  8. virtual ~CurseSplitOutput();
  9. /**
  10. * Display data, and shutdown ncurses at the end
  11. **/
  12. void run(const std::deque<std::string> &, const std::deque<JSonElement *> &);
  13. void checkSelection(const JSonElement *item, const std::pair<int, int> &cursor);
  14. void loop();
  15. bool redraw();
  16. bool redraw(std::pair<int, int> &, const std::pair<unsigned int, unsigned int> &, JSonElement *);
  17. bool redrawCurrent(short);
  18. bool redrawCurrent(const std::pair<unsigned int, unsigned int> &screenSize);
  19. bool writeContainer(std::pair<int, int> &, const std::pair<unsigned int, unsigned int> &, const JSonContainer *);
  20. bool writeContent(std::pair<int, int> &cursor, const std::pair<unsigned int, unsigned int> &maxSize, std::list<JSonElement*> *_item);
  21. bool writeKey(const std::string &key, const size_t keylen, std::pair<int, int> &cursor, const std::pair<unsigned int, unsigned int> &maxSize, OutputFlag flags, unsigned int extraLen =0);
  22. bool writeKey(const std::string &key, const size_t keylen, const std::string &after, size_t afterlen, std::pair<int, int> &cursor, const std::pair<unsigned int, unsigned int> &maxSize, OutputFlag flags);
  23. unsigned int write(const int &x, const int &y, const char item, unsigned int maxWidth, OutputFlag flags);
  24. unsigned int write(const int &x, const int &y, const std::string &str, const size_t strlen, unsigned int maxWidth, const OutputFlag flags);
  25. void write(const std::string &str, const OutputFlag flags) const;
  26. bool jumpToNextSearch(const JSonElement *current, bool &selectFound);
  27. bool jumpToNextSearch();
  28. unsigned int search(const SearchPattern &search_pattern);
  29. unsigned int search(const SearchPattern &search_pattern, const JSonElement *current);
  30. /**
  31. * get the screen size
  32. **/
  33. const std::pair<unsigned int, unsigned int> getScreenSize() const;
  34. /**
  35. * Initialize ncurses
  36. **/
  37. void init();
  38. /**
  39. * Release ncurses
  40. **/
  41. void shutdown();
  42. void destroyAllSubWin();
  43. /**
  44. * get flags to be passed to write.
  45. * Contains indications on who to write item
  46. **/
  47. const OutputFlag getFlag(const JSonElement *item) const;
  48. const OutputFlag getFlag(const JSonElement *item, const JSonElement *selection) const;
  49. protected:
  50. inputResult selectUp();
  51. inputResult selectDown();
  52. inputResult selectPUp();
  53. inputResult selectPDown();
  54. inputResult expandSelection();
  55. inputResult collapseSelection();
  56. inputResult initSearch();
  57. inputResult nextResult();
  58. std::deque<std::string> fileNames;
  59. std::deque<JSonElement *> roots;
  60. std::deque<const JSonElement *> selection, select_up, select_down;
  61. std::deque<WINDOW *> subwindows, outerWin;
  62. /**
  63. * currently searching pattern and its results
  64. **/
  65. std::deque<std::list<const JSonElement*> > search_result;
  66. /**
  67. * Viewport start
  68. **/
  69. std::deque<int> scrollTop;
  70. WINDOW *currentWin;
  71. short nbInputs, selectedWin, workingWin;
  72. };