curseSplitOutput.hh 3.5 KB

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