Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Is it possible to use select with ncurses input?

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?

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading