|
C-Menu 0.2.9
A User Interface Toolkit
|
Enter a single character from keyboard. More...
#include <cm.h>#include <fcntl.h>#include <stdbool.h>#include <string.h>#include <sys/ioctl.h>#include <termios.h>#include <unistd.h>Go to the source code of this file.
Functions | |
| int | main (int argc, char **argv) |
| Capture the current terminal settings for later restoration. | |
| int main | ( | int | argc, |
| char ** | argv ) |
Capture the current terminal settings for later restoration.
can be used in scripts to get a single character response from a user. For example: response=$(./enterchr "Enter Y or N: ") if [ "$response" = "Y" ]; then echo "You entered Yes" else echo "You entered No" fi This function saves the current terminal settings into a global variable so that they can be restored later. It should be called before modifying the terminal settings to ensure that the original settings can be restored when the program exits or is interrupted.
Definition at line 38 of file enterchr.c.
References capture_shell_tioctl(), mk_raw_tioctl(), restore_shell_tioctl(), and shell_tioctl.