I had some issues working with some VT100 escape sequences:
Usually, a VT100 terminal should save the cursor position but also characters attributes when writing a save cursor escape sequence
The characters attributes should be restored when writing a restore cursor.
Currently, the position of the cursor is saved and restored but not the characters attributes.
I've tested the behavior of the save/restore escape sequences on other VT100 implementations to ensure they were handling it:
I'll give some details below, and will start working on a solution since I need it for myself.
Keep up the great work!
Here's the VT100 escape sequences used for testing:
\x1b[0m (attributes off)
\x1b[1;1f (reset origin)
\x1b[2J (clear)
\x1b7 (save cursor state)
\x1b[7m (set negative color)
<colored> (just some output)
\x1b8 (restore cursor state)
<should not be colored>\n\r (another output - will be printed in negative color in xtermjs)
With xtermjs, "should not be colored" is colored
xterm.write('\x1b[0m\x1b[1;1f\x1b[2J\x1b7\x1b[7m <colored>\x1b8<should not be colored>\n\r');
// will print:
// "<should not be colored> <colored>"
In a bash, "should not be colored" won't be colored
printf '\x1b[0m\x1b[1;1f\x1b[2J\x1b7\x1b[7m <colored>\x1b8<should not be colored>\n\r'
# will print
# "<should not be colored> <colored>"
Seems to me that text attributes should be saved and restored along with the position, here.
Here is how hterm is handling the save/restore cursor
edit:
All the characters attributes (fg color, bg color, and the special flag modes: bold, italic, negative, ..) are stored in the 'curAttr' attribute of the 'Terminal' class. Saving a copy of this attribute should be enough to restore all the characters attributes at once.
VTE used to be buggy too; perhaps you can find a few interesting bits in VTE 731205.
@7PH Since you are modifying DECSC anyways maybe you can have a look at https://vt100.net/docs/vt510-rm/DECSC.html, there are some more terminal attributes still missing, that should be handled as well.
If not we should create a separate issue for it. Capturing all these should probably be done in something like an ICursorState state object to keep things organized.
Merged in the PR and forked off the rest of the properties to https://github.com/xtermjs/xterm.js/issues/1526
Most helpful comment
If not we should create a separate issue for it. Capturing all these should probably be done in something like an
ICursorStatestate object to keep things organized.