1
1

curseSplitOutput.hh 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. void computeDiff();
  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. std::map<const JSonElement *, ePath> diffResult;
  67. /**
  68. * Viewport start
  69. **/
  70. std::deque<int> scrollTop;
  71. WINDOW *currentWin;
  72. short nbInputs, selectedWin, workingWin;
  73. };