ttx 0.1.0
Loading...
Searching...
No Matches
ttx::terminal::ScrollBack Class Reference

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 find_row (u64 row) const -> di::Tuple< u32, RowGroup const & >
 

Detailed Description

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.

Member Function Documentation

◆ absolute_row_end()

auto ttx::terminal::ScrollBack::absolute_row_end ( ) const -> u64
inline

◆ absolute_row_start()

auto ttx::terminal::ScrollBack::absolute_row_start ( ) const -> u64
inline

◆ add_rows()

void ttx::terminal::ScrollBack::add_rows ( RowGroup & from,
usize row_index,
usize row_count )

Add rows to the scroll back buffer.

Parameters
fromRow group to take from
row_indexRow index within the group to take from
row_countNumber of rows to take

The taken rows will be deleted after this call.

◆ clear()

void ttx::terminal::ScrollBack::clear ( )

Clear the scroll back history.

◆ find_row()

auto ttx::terminal::ScrollBack::find_row ( u64 row) const -> di::Tuple<u32, RowGroup const&>

◆ take_rows()

void ttx::terminal::ScrollBack::take_rows ( RowGroup & to,
u32 desired_cols,
usize row_index,
usize row_count )

Remove rows from the scroll back buffer.

Parameters
fromRow group to tranfer to
desired_colsNumber of columns to force in the output
row_indexRow index within the group to insert
row_countNumber 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.

◆ total_rows()

auto ttx::terminal::ScrollBack::total_rows ( ) const -> usize
inline

The documentation for this class was generated from the following files: