ttx 0.1.0
Loading...
Searching...
No Matches
scroll_back.h
Go to the documentation of this file.
1#pragma once
2
3#include "di/container/ring/prelude.h"
5
6namespace ttx::terminal {
23 // TODO: optimize!
24 constexpr static auto cells_per_group = usize(di::NumericLimits<u16>::max / 2);
25
26 // TODO: make this configurable.
27 constexpr static auto max_cells = usize(cells_per_group * 100);
28
29 constexpr static auto max_groups = di::divide_round_up(max_cells, cells_per_group);
30
31 struct Group {
32 RowGroup group;
33 usize cell_count { 0 };
34 };
35
36public:
37 auto absolute_row_start() const -> u64 { return m_absolute_row_start; }
38 auto absolute_row_end() const -> u64 { return m_absolute_row_start + total_rows(); }
39 auto total_rows() const -> usize { return m_total_rows; }
40
42 void clear();
43
51 void add_rows(RowGroup& from, usize row_index, usize row_count);
52
65 void take_rows(RowGroup& to, u32 desired_cols, usize row_index, usize row_count);
66
67 auto find_row(u64 row) const -> di::Tuple<u32, RowGroup const&>;
68
69private:
70 auto is_last_group_full() const -> bool;
71 auto add_group() -> Group&;
72
73 di::Ring<Group> m_groups;
74 usize m_total_rows { 0 };
75 u64 m_absolute_row_start { 0 };
76};
77}
Represents a group of terminal rows.
Definition row_group.h:23
Represents the terminal scroll back.
Definition scroll_back.h:22
auto find_row(u64 row) const -> di::Tuple< u32, RowGroup const & >
Definition scroll_back.cpp:58
auto absolute_row_start() const -> u64
Definition scroll_back.h:37
auto total_rows() const -> usize
Definition scroll_back.h:39
auto absolute_row_end() const -> u64
Definition scroll_back.h:38
void add_rows(RowGroup &from, usize row_index, usize row_count)
Add rows to the scroll back buffer.
Definition scroll_back.cpp:6
void clear()
Clear the scroll back history.
Definition scroll_back.cpp:74
void take_rows(RowGroup &to, u32 desired_cols, usize row_index, usize row_count)
Remove rows from the scroll back buffer.
Definition scroll_back.cpp:35
Definition capability.h:8