1
1

curseSplitOutput.hh 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. void writeTopLine(const std::string &currentBuffer, short color) const;
  27. bool jumpToNextSearch(const JSonElement *current, bool &selectFound);
  28. bool jumpToNextSearch();
  29. unsigned int search(const SearchPattern &search_pattern);
  30. unsigned int search(const SearchPattern &search_pattern, const JSonElement *current);
  31. /**
  32. * get the screen size
  33. **/
  34. const std::pair<unsigned int, unsigned int> getScreenSize() const;
  35. /**
  36. * Release ncurses
  37. **/
  38. void shutdown();
  39. void destroyAllSubWin();
  40. /**
  41. * get flags to be passed to write.
  42. * Contains indications on who to write item
  43. **/
  44. const OutputFlag getFlag(const JSonElement *item) const;
  45. const OutputFlag getFlag(const JSonElement *item, const JSonElement *selection) const;
  46. protected:
  47. inputResult selectUp();
  48. inputResult selectDown();
  49. inputResult selectPUp();
  50. inputResult selectPDown();
  51. inputResult expandSelection();
  52. inputResult collapseSelection();
  53. inputResult initSearch();
  54. inputResult nextResult();
  55. inputResult changeWindow(char, bool);
  56. std::deque<std::string> fileNames;
  57. std::deque<JSonElement *> roots;
  58. std::deque<const JSonElement *> selection, select_up, select_down;
  59. std::deque<WINDOW *> subwindows, outerWin;
  60. /**
  61. * currently searching pattern and its results
  62. **/
  63. std::deque<std::list<const JSonElement*> > search_result;
  64. /**
  65. * Viewport start
  66. **/
  67. std::deque<int> scrollTop;
  68. WINDOW *currentWin;
  69. short nbInputs, selectedWin, workingWin;
  70. };