Expand description
This module contains the code needed for the implementation of a stateful buffer that holds a history of the lines/data received from the serial connection and the rendering/updating of the buffer to the terminal screen (stdout).
Simply writing the data received from the serial connection directly to stdout creates one main issue: there is no history of previous lines that were received from the serial connection. Without a screen buffer, lines would simply be wiped from existence as they exit the terminal’s screen.
As a result, there would be no way to implement features like scrolling, highlighting text (for UI purposes), and getting characters at specific locations within the screen for things like copying to a clipboard.
The screen buffer solves these issues by storing each line received from the
connection in a VecDeque. It is important to note that
currently, the capacity of the VecDeque is hardcoded with a value of 10,000
lines with MAX_SCROLLBACK.
Structs§
- Cell
Cellrepresents a cell within the terminal’s window/frame.- Line
- Line is a wrapper around
Vec<Cell>and represents a line within theScreenBuffer. - Position
- Represent’s the cursor’s position within the
ScreenBuffer. - Screen
Buffer - The
ScreenBufferholds rendering state for the entire terminal’s window/frame.
Enums§
- UICommand
UICommandis used for communication between stdin and theScreenBuffer.
Constants§
- MAX_
SCROLLBACK - The maximum number of lines stored in memory in
ScreenBuffer.