Is it possible to use select with ncurses input?

Viewed 52

Does ncurses use some file descriptors? Is it possible to use system call select(int n, fd_set *, fd_set *, fd_set *, struct timeval *) with ncurses library? If so how could I manage stdin in ncurses?

1 Answers

When initializing, initscr uses stdin and stdout. Using newterm lets you use some other choice. Internally, ncurses just uses the file descriptors for the corresponding streams.

A program using select would check if the file descriptor for stdin (or whatever input is used via newterm) and call wgetch, etc., when there is data ready.

If there's some concern about wgetch reading multiple bytes (and blocking too long), there are various options controlling how to timeout, etc.

Related