-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Description
The XTPUSHSGR
/ XTPOPSGR
control sequences (from xterm are really handy for composition of text that uses SGR sequences to colorize it.
The way it works is that XTPUSHSGR
saves the current text attributes (fg color, bg color, underline, etc.) to an internal stack. Then later, an XTPOPSGR
restores them--pops the attributes off the internal stack and sets the current text attributes back.
This capability allows you to use SGR sequences (which change text attributes like color) in a much more modular manner, because you are not required to have global awareness of the current text attributes. I.e. I can do something like:
printf( "The <xtpushsgr><fg blue><bg white>xterm.js<xtpopsgr> project is really cool." )
The phrase "xterm.js" will appear as blue on a white background... and the text after will be the same color as the text before. It's the semantic equivalent of an "end tag", and opens up all sorts of new possibilities for how text attributes are handled by programs. I'd love to see these sequences supported in xterm.js.
The xterm implementation allows supplying parameters to the sequence, to specify that only certain portions of the current text attributes should be saved (like "just save the underline state only"). But even only supporting a no-parameters form of the sequence would support the most common and useful (IMO) scenarios.