Styled text is not supposed to "inherit" the current SGR styling context when
written to the terminal. This has always been the intention, but not correctly
implemented. This commit fixes that for both styled segments and styled texts.
Tests are amended to account for the difference in the output.
With context insensitivity correctly implemented, there is now no need for a
"default" color. It is functionally equivalent to a lack of color.
The parsing of SGR still needs to be aware of the codes 39 (default foreground)
and 49 (default background), but these codes are now translated into FgDefault
and BgDefault, which resets the foreground and background color fields.
The main benefits of this change are:
1) It uses a hermetic "home" directory with a known command and location
history. Which means it no longer depends on the interactive history
and directory layout of the person creating the ttyshot. Which also
means it no longer leaks the private history of anyone creating a
ttyshot. This produces reproducible results when updating ttyshots.
2) The user no longer has to augment the ttyshot by manually adding the
output of the commands to the generated HTML file. A process that is
error prone. The output of the commands that generate the ttyshot is
now captured and automatically included in the resulting HTML.
3) It makes it trivial to recreate every ttyshot. Simply execute these
commands:
```
make ttyshot
for f [website/ttyshot/**.spec] { put $f; ./ttyshot $f }
```
4) It makes it easy to introduce new "ttyshot" images by creating a
shell session "spec" file. This makes it easy to replace the existing
"```elvish-transcript...```" examples with ttyshots in order to
ensure a consistent representation and visual consistency with the
transcripts that are currently generated as ttyshots.
The downside of this change is the introduction of a dependency on the
Tmux application. But that seems reasonable since Tmux is a mature
application available on Linux, macOS, BSD, and probably every other
UNIX like OS we care about. Note that generating the Elvish
documentation already depends on similar apps such as Pandoc.
Related #1459