JODA  0.13.1 (59b41972)
JSON On-Demand Analysis
ResultInterface.h
Go to the documentation of this file.
1 //
2 // Created by Nico on 13/03/2019.
3 //
4 
5 #ifndef JODA_INTERFACE_H
6 #define JODA_INTERFACE_H
7 
8 #include <curses.h>
11 #include <mutex>
12 #include "CursesFWD.h"
13 
14 namespace joda::cli {
16  public:
17  explicit ResultInterface();
18  virtual ~ResultInterface();
19 
20  void interact();
21  void updateStorage(std::shared_ptr<JSONStorage>& storage);
22 
23  void setStatus1(std::string& str);
24  void setStatus2(std::string& str);
25  void setStatus3(std::string& str);
26 
27  private:
28  std::vector<std::string> cache{};
29 
30  std::shared_ptr<JSONStorage> storage;
31 
32  size_t storageSize = 0;
33 
34  int maxRows{}, maxCols = 0;
35  /*
36  * Windows
37  */
38  WINDOW* status = nullptr;
39  WINDOW* status_1 = nullptr;
40  WINDOW* status_2 = nullptr;
41  WINDOW* status_3 = nullptr;
42 
43  WINDOW* results = nullptr;
44  WINDOW* resultborder = nullptr;
45  size_t maxResults{};
46  int maxLineLen{};
47  size_t currResult = 0;
48  size_t minResultI = 0;
49  size_t maxResultI = 0;
50  void scrollResults(bool down = true);
51 
52  void buildStatusBar();
53  void createWindows();
54  void refreshAll();
55  void destroyWindows();
56  void destroyWindow(WINDOW* local_win);
57  void updateContent();
58 
59  void initCache();
60  void addCache(size_t i, bool back);
61 
62  void forceRefresh();
63  void startJSONViewer() const;
64 
65  static std::wstring getWString(std::string& str);
66 };
67 } // namespace joda::cli
68 
69 #endif // JODA_INTERFACE_H
Definition: ResultInterface.h:15
void setStatus1(std::string &str)
Definition: ResultInterface.cpp:211
void setStatus2(std::string &str)
Definition: ResultInterface.cpp:216
ResultInterface()
Definition: ResultInterface.cpp:167
void interact()
Definition: ResultInterface.cpp:124
void updateStorage(std::shared_ptr< JSONStorage > &storage)
Definition: ResultInterface.cpp:187
virtual ~ResultInterface()
Definition: ResultInterface.cpp:12
void setStatus3(std::string &str)
Definition: ResultInterface.cpp:221
Definition: CLI.h:19