From 47c52ae7bbfec87a80fb583fb0753b4d77b0ba1d Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Sun, 20 May 2012 17:14:10 +0200 Subject: src/utils.c: Disable canonical mode in press_any_key() Use tcsetattr() to disable canonical mode in press_any_key() before waiting for a key press. This makes sure that input is available immediately (instead of line by line). Also, disable echoing until a key is pressed. Signed-off-by: Lukas Fleischer --- src/utils.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src') diff --git a/src/utils.c b/src/utils.c index 36abb30..a77bbb6 100644 --- a/src/utils.c +++ b/src/utils.c @@ -44,6 +44,7 @@ #include #include #include +#include #include "calcurse.h" @@ -1077,12 +1078,21 @@ child_wait (int *pfdin, int *pfdout, int pid) void press_any_key (void) { + struct termios t_attr_old, t_attr; + + tcgetattr (STDIN_FILENO, &t_attr_old); + memcpy (&t_attr, &t_attr_old, sizeof (struct termios)); + t_attr.c_lflag &= ~(ICANON | ECHO | ECHONL); + tcsetattr (STDIN_FILENO, TCSAFLUSH, &t_attr); + fflush (stdout); fputs (_("Press any key to continue..."), stdout); fflush (stdout); fgetc (stdin); fflush (stdin); fputs ("\r\n", stdout); + + tcsetattr (STDIN_FILENO, TCSAFLUSH, &t_attr_old); } /* -- cgit v1.2.3-70-g09d2