I'm using select
to do non-blocking reads from a socket and STDIN. In pseudo-code:
loop
readable = select(socket, STDIN)
foreach input in readable
if input == STDIN
handle_keyboard_input(read(STDIN))
else
handle_socket_input(read(socket))
The above works great. But now I'd like to start using libncurses to build a more sophisticated text-based UI. (I'll probably have two windows: A large log window and a smaller one for the prompt.)
Presumably, the socket handling will remain the same. But I'm unclear on how libncurses abstracts away STDIN. What is the correct idiom for doing non-blocking reads in a libncurses window?
In truth this is in Ruby, but I'm just using thin wrappers around the C APIs, so I felt this was more appropriately tagged as a C problem.