Refactor input handling into a state machine
Enable non-blocking usage within an event loop

Includes a complete example using poll(2) showing the effect of other
asynchronous activity intermixed with line editing.