panel_interface.h
Go to the documentation of this file.
1 
28 #ifndef LOG_VIEW_PANEL_INTERFACE_H_
29 #define LOG_VIEW_PANEL_INTERFACE_H_
30 
31 #include <memory>
32 #include <string>
33 
34 #include <curses.h>
35 #include <panel.h>
36 
37 #define KEY_ENTER_VAL 10
38 
39 namespace log_view {
40 
42  public:
43  PanelInterface(int height, int width, int y, int x);
44  virtual ~PanelInterface();
45  virtual void refresh() = 0;
46  virtual void forceRefresh();
47  virtual void resize(int height, int width, int y, int x);
48  virtual bool handleInput(int key);
49  virtual bool handleNavigation(int key);
50  virtual bool handleMouse(const MEVENT& event) { return false; }
51  virtual bool handleKey(int key) { return false; }
52  virtual bool encloses(int y, int x);
53 
54  virtual void hide(bool enable);
55  virtual bool setFocus(bool enable);
56  virtual void toTop();
57  virtual bool setCursor();
58 
59  virtual int x() const;
60  virtual int y() const;
61  virtual int width() const;
62  virtual int height() const;
63  virtual bool hidden() const;
64  virtual bool visible() const;
65  virtual bool focus() const;
66  virtual bool scrollbar() const;
67 
68  protected:
69  virtual bool canFocus() const { return false; }
70  virtual void drawScrollBar(size_t count, int height, int y, int x);
71 
72  // text input
73  virtual bool canInput() const { return false; }
74  virtual void activate(bool enable) {}
75  virtual int inputOffset() const { return 0; }
76 
77  // navigation
78  virtual bool canNavigate() const { return false; }
79  virtual bool canSelect() const { return false; }
80  virtual size_t getContentSize() const { return 0; }
81  virtual int getContentHeight() const { return height_; }
82  virtual int getContentWidth() const { return width_; }
83  virtual void setCursor(int64_t cursor) {}
84  virtual int64_t getCursor() const { return 0; }
85  virtual void follow(bool enable);
86  virtual void pageUp();
87  virtual void pageDown();
88  virtual void move(int step);
89  virtual void moveTo(size_t index);
90  virtual void shift(int cols);
91  virtual void select() {};
92  virtual bool following() { return getCursor() < 0; }
93 
94  WINDOW* window_ = nullptr;
95  PANEL* panel_ = nullptr;
96  int x_;
97  int y_;
98  int width_;
99  int height_;
100  bool cleared_ = false;
101  bool hidden_ = false;
102 
103  // text input
104  bool focus_ = false;
105  std::string input_text_;
106  int input_loc_ = -1;
107 
108  // navigation
109  bool follow_ = true;
110  size_t last_content_size_ = 0;
111  int64_t last_cursor_ = 0;
112  size_t max_length_ = 0;
113  int shift_ = 0;
114 };
115 typedef std::shared_ptr<PanelInterface> PanelInterfacePtr;
116 
117 } // namespace log_view
118 
119 #endif // LOG_VIEW_PANEL_INTERFACE_H_
virtual bool handleMouse(const MEVENT &event)
virtual bool handleInput(int key)
virtual bool hidden() const
virtual void setCursor(int64_t cursor)
virtual int width() const
virtual int getContentHeight() const
std::shared_ptr< PanelInterface > PanelInterfacePtr
virtual bool encloses(int y, int x)
virtual bool canNavigate() const
virtual void resize(int height, int width, int y, int x)
virtual int inputOffset() const
virtual void refresh()=0
virtual bool canInput() const
virtual bool canSelect() const
virtual void moveTo(size_t index)
virtual bool scrollbar() const
virtual bool handleKey(int key)
virtual bool canFocus() const
virtual int64_t getCursor() const
virtual int height() const
virtual int getContentWidth() const
virtual void hide(bool enable)
virtual void move(int step)
virtual bool setFocus(bool enable)
virtual bool focus() const
virtual size_t getContentSize() const
virtual bool visible() const
virtual void shift(int cols)
virtual bool handleNavigation(int key)
virtual void activate(bool enable)
PanelInterface(int height, int width, int y, int x)
virtual void drawScrollBar(size_t count, int height, int y, int x)
virtual void follow(bool enable)


log_view
Author(s): Marc Alban
autogenerated on Sun Sep 18 2022 02:12:07