Rewrite printing the current input in the string input function.

This avoid some pitfalls with UTF-8 by:
1. clearing the line
2. printing the (visible part of the) input string (using utf8_wrapper::substr to remove the part that is scrolled out of view).
3. printing the cursor (in special color), possibly overriding the already printed strings.
4. printing the trailing newlines.