Fix qtconsole input prompt accounting

- Ensure prompt text is flushed after showing
- Ensure prompt position is adjusted when reading input
- Keep pending text to insert only when inserting at end

This fixes `ipdb>` input prompts when debugging a file
in qtconsole.