Processing keyboard inputs and scrolling
In the previous section, we built the first iteration of our text viewer terminal-oriented application. We were able to display a file with fewer than 24 lines and see the header and footer bar containing some information. Finally, we were able to exit the program with Ctrl + Q.
In this section, we will add the following features to the text viewer:
- Provide the ability to display files of any size.
- Provide the ability for the user to scroll through the document using arrow keys.
- Add cursor position coordinates to the footer bar.
Let's begin by creating a new version of the code.
Copy the original code to a new file, as shown:
cp src/bin/text-viewer1.rs src/bin/text-viewer2.rs
This section is organized into three parts. First, we'll implement the logic to respond to the following keystrokes from a user: up, down, left, right, and backspace. Next, we'll implement the functionality to update the...