Instead of waking up regularly WaitEventsTimeout, WaitEvents and
PostEmptyEvent are used to make the main loop purely event driven. The
rate of redraws due to terminal activity can be tweaked via the new
wakePeriod const.
This leads to some significant performance improvements: Aminal now consumes:
- no CPU when idle (previously ~2.7% on my laptop)
- ~8.5% CPU on my machine when running htop full screen on a large
monitor (previously ~18.5% on my laptop)
- scrolling large amounts of output is an order of magnitude faster
This change also incidentally fixes data races around the terminal
dirty flag (which is now gone).