Fixed an intermittent deadlock in MainTest:
FlushListener could receive more than the expected number of flushes
before the VirtualTerminalInteractor was given control. So by setting
the flush count to zero in waitForFlushes(), flushes could be lost. Now
it only reduces the number of flushes by the expected number.
A few issues still remain:
- Inserting text pushes the remainder of the input to a new line
at the end of the buffer.
- Resizing the terminal height causes numerous issues.