|
ttx 0.1.0
|
Represents the terminal scroll back. More...
#include <ttx/terminal/scroll_back.h>
Public Member Functions | |
| auto | absolute_row_start () const -> u64 |
| auto | absolute_row_end () const -> u64 |
| auto | total_rows () const -> usize |
| void | clear () |
| Clear the scroll back history. | |
| void | add_rows (RowGroup &from, usize row_index, usize row_count) |
| Add rows to the scroll back buffer. | |
| void | take_rows (RowGroup &to, u32 desired_cols, usize row_index, usize row_count) |
| Remove rows from the scroll back buffer. | |
| auto | take_rows_for_reflow (RowGroup &to) -> u64 |
| Take rows so that to.reflow() will produce correct results. | |
| auto | reflow_visual_rows (u64 absolute_row_start, usize row_count, u32 desired_cols) -> di::Optional< ReflowResult > |
| Reflow scroll back for displaying a range of visual lines. | |
| auto | find_row (u64 row) const -> di::Tuple< u32, RowGroup const & > |
Represents the terminal scroll back.
The scroll back is effectively immutable and optimized to minimize the memory needed per cell. Blank cells are not stored but still accessible when iterating over a row.
The scroll back is unaffected by resize operations (until rewrap is supported), so rows can be over or under sized depending on the actual screen size when the scroll back is being rendered.
For efficiency, the scroll back is divided into chunks which target a particular number of cells, and represent a collection of visual terminal lines. The memory limit for the scroll back buffer is specified by the total number of cells allowed, which is used to determine the number of chunks.
|
inline |
|
inline |
| void ttx::terminal::ScrollBack::add_rows | ( | RowGroup & | from, |
| usize | row_index, | ||
| usize | row_count ) |
| void ttx::terminal::ScrollBack::clear | ( | ) |
Clear the scroll back history.
| auto ttx::terminal::ScrollBack::find_row | ( | u64 | row | ) | const -> di::Tuple<u32, RowGroup const&> |
| auto ttx::terminal::ScrollBack::reflow_visual_rows | ( | u64 | absolute_row_start, |
| usize | row_count, | ||
| u32 | desired_cols ) -> di::Optional<ReflowResult> |
Reflow scroll back for displaying a range of visual lines.
| absolute_row_start | The absolute for of the first visible row |
| row_count | The number of visible rows |
| desired_cols | The desired display width |
Rather than reflow the entire scrollback all at once, reflowing happens lazily during render based on what part of the screen is visible. The scrollback remembers the last size each row group was reflowed to in order to avoid redundant computation. Depending the the absolute row start, it may be required to reflow more than 1 row group, in which case all reflow results are merged together.
| void ttx::terminal::ScrollBack::take_rows | ( | RowGroup & | to, |
| u32 | desired_cols, | ||
| usize | row_index, | ||
| usize | row_count ) |
Remove rows from the scroll back buffer.
| from | Row group to tranfer to |
| desired_cols | Number of columns to force in the output |
| row_index | Row index within the group to insert |
| row_count | Number of rows to take |
This function requires: row_count >= total rows in scroll back.
The desired_cols value ensures that the inserted rows will have the correct number of cells per row. The row from scrollback will either be truncated or padded with empty cells to meet this constraint.
| auto ttx::terminal::ScrollBack::take_rows_for_reflow | ( | RowGroup & | to | ) | -> u64 |
Take rows so that to.reflow() will produce correct results.
| to | Row group to transfer to |
This function takes as many rows as necessary from the scrollback so that the last row in the scrollback buffer wasn't overflowed. This means that calling reflow() on the resulting group produces the correct results. Note that because row group boundaries should already be segmented into such boundaries, this function is only best effort. In extreme cases where we have 10 of thousands of lines of next that have overflowed reflow() everything isn't computationally practical, so we impose a limit on how far back we go.
|
inline |