|
Next: 8.9 Clear Window and Up: 8.8 Options Previous: 8.8.2 Terminal Attributes
8.8.3 Use OptionsNow 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.
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 |
|||||||||||||||||
With any suggestions or questions please feel free to contact us |