jerch / xterm-addon-image

Image addon for xterm.js
MIT License
51 stars 6 forks source link

reload default palette from XTSMGRAPHICS #12

Closed jerch closed 2 years ago

jerch commented 2 years ago

Currently default palette reloading is only coupled to RIS and DECSTR, which is rather intrusive to get initial colors back. Until we have something better, clamp "reload default palette" to XTSMGRAPHICS.registers.SET_DEFAULT.

j4james commented 2 years ago

@jerch I've been thinking about this recently, and I had another idea that might be workable. If you remember back when we were discussing this in https://github.com/hackerb9/vt340test/issues/22, there was the suggestion of using DECSTGLT to reset the palette, because that's what the VT340 does. However, I didn't think that was workable on a modern terminal because it also resets the text palette, and the color order isn't compatible with ANSI. However, I remembered recently that the VT525 has a third option for DECSTGLT that is ANSI-compatible, so that might be the ideal solution.

Basically if you execute DECSTGLT with the table number set to 3, we could reset the text palette to ANSI-compatible colors (assumedly the user's preferred palette), and reset the graphics palette to the modern default (i.e. the VT340 colors for the first 16 entries, and an XTerm palette for the rest). Although, given that table 3 doesn't need to be compatible with the VT340, I wouldn't be opposed to making the graphics palette ANSI-compatible too in that case.

That said, this is assuming the VT525 actually works the way I think it does (obviously it doesn't support sixel, but I mean the way the text palette is reset). So if you like this idea, I'm hoping you might do a bit of testing on your VT525 to confirm. For one thing, I'm curious whether we could get away with a single DECSTGLT call to reset the palette, or it needs to be toggled between two different values like on the VT340.

jerch commented 2 years ago

Thx for the reminder of those - yes it is prolly the better way in long term. Still have to do some tests to confirm, how thats supposed to work. It further gets complicated by the fact, that almost all xterm-like TEs implement OSC 4 for text palette changes, while the basics from the higher VT lines are missing. Prolly needs some thinking how to get things working nice together.