Allows us to interpret ^C through ^Z as control codes and handle them
properly.
Also fixes resetting termios after ^C
| ... | ... |
@@ -153,6 +153,10 @@ void run(tty_t *tty, choices_t *choices){
|
| 153 | 153 |
strncpy(search, choices_get(choices, choices->selection), SEARCH_SIZE_MAX); |
| 154 | 154 |
search_size = strlen(search); |
| 155 | 155 |
choices_search(choices, search); |
| 156 |
+ }else if(ch == 3 || ch == 4){ /* ^C || ^D */
|
|
| 157 |
+ clear(tty); |
|
| 158 |
+ tty_close(tty); |
|
| 159 |
+ exit(EXIT_FAILURE); |
|
| 156 | 160 |
}else if(ch == 10){ /* Enter */
|
| 157 | 161 |
clear(tty); |
| 158 | 162 |
|
| ... | ... |
@@ -33,8 +33,9 @@ void tty_init(tty_t *tty, const char *tty_filename){
|
| 33 | 33 |
* Disable both of |
| 34 | 34 |
* ICANON Canonical input (erase and kill processing). |
| 35 | 35 |
* ECHO Enable echo. |
| 36 |
+ * ISIG Disable signals from control characters |
|
| 36 | 37 |
*/ |
| 37 |
- new_termios.c_lflag &= ~(ICANON | ECHO); |
|
| 38 |
+ new_termios.c_lflag &= ~(ICANON | ECHO | ISIG); |
|
| 38 | 39 |
|
| 39 | 40 |
if(tcsetattr(tty->fdin, TCSANOW, &new_termios)) |
| 40 | 41 |
perror("tcsetattr");
|