Skip to content

Support XTPUSHSGR / XTPOPSGR #2570

@jazzdelightsme

Description

@jazzdelightsme

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type/proposalA proposal that needs some discussion before proceeding

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions