Had to reopen stdin to get keyboard input back when piped data is used
modified: src/nms.c
This commit is contained in:
parent
ed59cb1070
commit
39390b673c
14
src/nms.c
14
src/nms.c
@ -125,9 +125,13 @@ void nmsexec(char *src) {
|
||||
usleep(ms * 1000);
|
||||
}
|
||||
|
||||
// TODO: pause with getchar() - something about the input stream being redirected
|
||||
// to a file is causing getchar() to immediately return here.
|
||||
// Reopen stdin for interactive input (keyboard), then require user
|
||||
// to press a key to continue.
|
||||
if (!isatty(STDIN_FILENO))
|
||||
if (!freopen ("/dev/tty", "r", stdin))
|
||||
sleep(1);
|
||||
else
|
||||
getch();
|
||||
|
||||
// Jumble loop
|
||||
ms = 35; // miliseconds, used for usleep()
|
||||
@ -206,6 +210,12 @@ void nmsexec(char *src) {
|
||||
attroff(COLOR_PAIR(1));
|
||||
}
|
||||
|
||||
// If stdin is set to the keyboard, user must press a key to continue
|
||||
if (isatty(STDIN_FILENO))
|
||||
getch();
|
||||
else
|
||||
sleep(2);
|
||||
|
||||
// End curses mode
|
||||
endwin();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user