TermOx
screen_buffers.hpp
1 #ifndef TERMOX_TERMINAL_DETAIL_SCREEN_BUFFERS_HPP
2 #define TERMOX_TERMINAL_DETAIL_SCREEN_BUFFERS_HPP
3 #include <termox/terminal/detail/canvas.hpp>
4 #include <termox/widget/area.hpp>
5 
6 namespace ox::detail {
7 
9 
12  public:
13  Canvas current;
14  Canvas next;
15 
16  public:
18  Screen_buffers(ox::Area a);
19 
20  public:
22  void resize(ox::Area a);
23 
25  [[nodiscard]] auto area() const -> Area;
26 
28 
30  void merge();
31 
33 
35  [[nodiscard]] auto merge_and_diff() -> Canvas::Diff const&;
36 
38 
41  [[nodiscard]] auto generate_color_diff(Color c) -> Canvas::Diff const&;
42 
44  [[nodiscard]] auto current_screen_as_diff() -> Canvas::Diff const&;
45 
46  private:
47  Canvas::Diff diff_;
48 };
49 
50 } // namespace ox::detail
51 #endif // TERMOX_TERMINAL_DETAIL_SCREEN_BUFFERS_HPP
Color numbers [0 - 180] are valid.
Definition: color.hpp:16
A 2D field of Glyphs, useful as a screen buffer.
Definition: canvas.hpp:18
std::vector< std::pair< ox::Point, ox::Glyph > > Diff
Type used to model differences between two Canvas objects.
Definition: canvas.hpp:24
Holds the current and next screen buffers as Canvas objects.
Definition: screen_buffers.hpp:11
Screen_buffers(ox::Area a)
Construct with both Canvas objects having Area a.
Definition: screen_buffers.cpp:8
auto current_screen_as_diff() -> Canvas::Diff const &
Returns the entire current screen as a Diff. Used on Window Resize.
Definition: screen_buffers.cpp:32
auto merge_and_diff() -> Canvas::Diff const &
Merges the next Canvas into the current Canvas and returns the changes.
Definition: screen_buffers.cpp:20
auto area() const -> Area
Return the current size of the screen buffers.
Definition: screen_buffers.cpp:16
auto generate_color_diff(Color c) -> Canvas::Diff const &
Generates a Canvas::Diff, with every Glyph from current that has c.
Definition: screen_buffers.cpp:26
void resize(ox::Area a)
Resizes both current and next Canvas objects to a.
Definition: screen_buffers.cpp:10
void merge()
Merges the next Canvas into the current Canvas.
Definition: screen_buffers.cpp:18