In my experience, applications treat the first character in a sequence as 'belonging' to the style, so if you had:
<grey>This is <blue>Fred\b\b\b\bWilma.\n
What you finally end up with is:
<grey>This is Wilma.\n
All in grey. You don't erase the style seperately, it is 'attached' to the first character in the line it effects. This, again, would be do to the transition from teletype to eventually Ansi and telnet. In the first terminals that allowed any sort of style or even color, they where literally physically coded into the display memory like:
@4This like is color 4$
Though, the @ and $ would have been unprintable characters. When Ansi emerged, the 'end of style' part got dropped, but the @4 like part remained. The reason being that each individual character was stored as two bytes, one to define the style, the second to define the letter. When you sent '^[[32m' to it, it automatically set each following characters 'style' to that color. So, when you used \b, it erased 'both' the letter and the style that was defined for the last memory address. Since Ansi was specifically developed to be used this way on such terminals, as was VT-52, VT-100, et al, the 'expected' behaviour is for the color/style information to be removed at the same time the letter you erase is. This is also why I am fairly sure backspace can't span lines, the terminals the standard was developed for wouldn't have likely allowed it. \b past the first part of the line and you would end up at the 80th column on the right of the display, not the 'end of line', since no special character was likely used in to designate where that was.
The newline would not likely, if used at all have been treated as a character itself, but merely the end of the 'visible' and thus erasable characters. However, that doesn't mean I am right about it. I am 99.9% sure of the color/style issue, but only about 70% sure of the newline one. |