Refactor tio_wait()

This changes the function to accept a file descriptor, an event and
timeout parameter directly instead of a confusing flag.
Use normal timeout handling in tio_skipall()

Use the same mechanism in tio_skipall() as in tio_read(), except use a
different timeout value.