TermOx
log.hpp
1 #ifndef TERMOX_WIDGET_WIDGETS_LOG_HPP
2 #define TERMOX_WIDGET_WIDGETS_LOG_HPP
3 #include <memory>
4 
5 #include <termox/painter/glyph_string.hpp>
6 #include <termox/system/key.hpp>
7 #include <termox/widget/widgets/text_view.hpp>
8 #include <termox/widget/widgets/textbox.hpp>
9 
10 namespace ox {
11 
13 
14 class Log : public Textbox {
15  public:
16  void post_message(Glyph_string message);
17 
18  protected:
19  auto key_press_event(Key k) -> bool override;
20 
21  private:
22  using Text_view::append;
23  using Text_view::erase;
24  using Text_view::insert;
25  using Text_view::pop_back;
26  using Text_view::set_text;
27 };
28 
30 [[nodiscard]] auto log() -> std::unique_ptr<Log>;
31 
32 } // namespace ox
33 #endif // TERMOX_WIDGET_WIDGETS_LOG_HPP
Holds a collection of Glyphs with a similar interface to std::string.
Definition: glyph_string.hpp:19
A scrollable list of logged messages.
Definition: log.hpp:14
auto key_press_event(Key k) -> bool override
Handles Key_press_event objects.
Definition: log.cpp:27
void pop_back()
Remove the last Glyph from the current contents. No-op if this->empty();.
Definition: text_view.cpp:101
void insert(Glyph_string text, int index)
Inserts text starting at index into the current contents.
Definition: text_view.cpp:63
void append(Glyph_string text)
Inserts text to the end of the current contents.
Definition: text_view.cpp:79
void erase(int index, int length=Glyph_string::npos)
Remove Glyphs from contents starting at index, for length Glyphs.
Definition: text_view.cpp:88
void set_text(Glyph_string text)
Replace the current contents with text.
Definition: text_view.cpp:34
Interactive Glyph_string display with text wrapping, alignment, etc...
Definition: textbox.hpp:15