The \b
control character, as I understand it, is not supposed to erase the previous character (this would be \b
+ a del character as well), so something like this works:
>>> print 'pototo\b\b\ba'
potato
Is there a character for moving forwards, like a non-overwriting space? Expected usage would be something like (I've called this character \x
):
>>> print 'pototo\r\x\x\xa'
potato
Obviously on a typewriter a normal space would do this just fine. But on a terminal a space erases the letter underneath.
My use case is a pexpect matching kind of scenario where I want to retrospectively go back and decorate certain parts of the output of a character stream with colours, and I'm wondering whether keeping a cache of the whole current line in memory will be necessary or not.