Working with the terminal UI (size, color, styles) and cursors
In this section, we will build the first iteration of the text viewer. At the end of this section, we will have a program that will accept a filename from the command line, display its contents, and display a header and footer bar. We will use a Termion crate to set the color and style, get the terminal size, position the cursor at specific coordinates, and clear the screen.
The code in this section is organized as follows:
- Writing data structures and the
main()
function - Initializing the text viewer and getting the terminal size
- Displaying a document and styling the terminal color, styles, and cursor position
- Exiting the text viewer
Let's start with data structures and the main()
function of the text viewer
Writing data structures and the main() function
In this section, we'll define the data structures needed to represent the text viewer in memory. We'll also write the...