1
1

curseSplitOutput.hh 3.5 KB

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