Fix cursor drawing.
Fix rendering.
Fix output of the last line of the screen buffer.
Draw selection.
Fix cursor blinking.
Simplify.