O'Reilly logo

Perl Cookbook by Nathan Torkington, Tom Christiansen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 15. User Interfaces

Introduction

And then the Windows failed—and then I could not see to see—

Emily Dickinson“I heard a Fly buzz—when I died”

Everything we use has a user interface: VCRs, computers, telephones, even books. Our programs have user interfaces: do we have to supply arguments on the command line? Can we drag and drop files into the program? Do we have to press Enter after every response we make, or can the program read a single keystroke at a time?

This chapter won’t discuss designing user interfaces: entire bookshelves are filled with books written on the subject. Instead, we’ll focus on implementing user interfaces—parsing command-line arguments, reading a character at a time, writing anywhere on the screen, and writing a graphical user interface.

The simplest user interface is what we’ll call line mode interfaces. Line mode programs normally read lines at a time and write characters or entire lines. Filters like grep and utilities like mail exemplify this type of interface. We don’t really talk much about this type of interface in this chapter, because so much of the rest of the book does.

A more complex interface is what we’ll call full-screen mode . Programs like vi, elm, and lynx have full-screen interfaces. They read single characters at a time and can write to any character position on the screen. We address this type of interface in Section 15.4, Section 15.6, Section 15.9, Section 15.10, and Section 15.11.

The final class of interface is the GUI (graphical ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required