Viewing Text One Page at a Time
Now that we have a program that can display the contents of a file directly to the screen, it’s time to start adding pagination. In this section, we’ll update our program so that we can scroll forward through the contents of a file one page at a time. We need to let the user scroll at their own speed, so we’ll let them press the spacebar to advance one page forward through the document. When they scroll past the last page of the document we should exit the program. We also want to let the user exit the program earlier if they find what they are looking for, so we’ll let them press the q key at any point while they are scrolling through the document to quit immediately.
You probably already have an intuitive idea ...
Get Effective Haskell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.