Fix cursor position on the input prompt

First part of cursor position fix.

This will fix the basic behavior. But more elaborate prompt (password, expand, etc) directly write some output and by doing this, the cursor is moved around the page and the initial position is lost. That'll require more work.