next up previous contents
Next: 8.9 Clear Window and Up: 8.8 Options Previous: 8.8.2 Terminal Attributes

8.8.3 Use Options

Now we have seen the window options and terminal modes it is time to describe their use.

First, on Linux you should enable the keypad. This will allow use of the cursor keys and the numeric block on the PC keyboard.

Now, there are two main types of input.

  1. The program wants the user to enter a key and then will call a function depend on this key. (For example, something like "press 'q' for quit" and wait for q)
  2. The program wants a string of characters typed by the user in a mask on the screen. For example: a directory or an address in a database.

For the first we use the following options and modes and the while loop will work correctly.

The program will hang until a key is pressed. If the key was q we call our quit function else we wait for other input.

The switch statement can be expanded until we have an input function that fits our wishes. Use the KEY_* macros to check special keys, for instance

for the cursor keys on the keyboard. For a file viewer the loop can look like this:

For the second, we only need to set echo() and the characters typed by the user will be printed to the screen. To have the characters printed on the position you want, use move(...) or wmove(...).

Or, we could open a window with a mask in it (some other colors than those of the window will do this) and ask the user to input a string:

See .c in the example directory for more explanation.



Converted on:
Fri Mar 29 14:43:04 EST 1996

Hosting by: Hurra Communications Ltd.
Generated: 2007-01-26 17:57:42