Backstory (You can skip)
Awhile back I was developing a console toolkit for displaying debug messages and the like:
It gives me colour coding, blinking, underlines, bold, italic, etc.
While developing this library, I quickly learned that nesting with ANSI escape sequences was impossible, but assumed that good reasons existed why this was the case.
Of course working with other document types, nesting is more or less trivial:
<foo> the <bar> quick </bar> brown </foo>
or with JSON
{
type=foo,
text=[
"the",
{type=bar, text="quick",},
"brown",
]
}
But with Ansi, its something like this:
\e[1m the \e[2m quick \e[1m brown
giving an output like this:
Basically meaning that you would need to manually track the formatting, and explicitly construct escape sequences to represent all output moving forward. You can obviously make due, but it complicates things. Before complaining about this, I'd like to clarify what reasons exist that would necessitate an escape sequence model over say, a structured document style.
Questions:
Is it purely due to legacy reasons why displaying text on our video terminals is done with ANSI escape sequences and not another framework such as JSON, Yaml, XML, or something else?
Is ANSI escape sequences in video terminal, simply an old technology similar to say, X11
that sticks around solely due to how embedded it is within the computing paradigm?
If not, why don't developers switch from an escape sequence style to something that would support nesting?
Are there any proposals to do away with ANSI escapes in terminals and replace it with something else?