I don't understand why the getch() function returns ERR all the time if I have an application set up in this manner (stripped to the bones):
static char data[DATA_SIZE]; // Very big - covers all input for sure
int main(int argn, char ** argv)
{
// Slurp the file in
int length = read(0, &data[0], DATA_SIZE);
if (length == 0)
{
fprintf(stderr, "Nothing to read\n");
return 0;
}
initscr();
cbreak();
refresh();
WINDOW * woutput = newwin(LINES - 1, COLS, 0, 0);
WINDOW * winput = newwin(1, COLS, LINES - 1, 0);
wattron(winput, A_REVERSE);
keypad(winput, TRUE);
//print the data buffer into a window
int c;
while ((c = wgetch(winput)) != 'q')
{
}
}
I run the application in this manner:
./application < path/to/file
But the result of wgetch is always 'ERR'
.