Commit Graph

7 Commits

Author SHA1 Message Date
Qi Xiao
42c6c3b1aa pkg/ui: Make styled text context-insensitive, and remove the "default" color.
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.
2022-07-24 14:31:02 +01:00
Qi Xiao
51e4d97568 interface{} -> any now that Elvish requires Go 1.18. 2022-03-20 16:17:19 +00:00
Qi Xiao
b6adbed317 pkg/ui: Implement StyleFromSGR in terms of a new StylingFromSGR.
Part of a reimplementation of #1038.
2020-08-25 21:17:14 +01:00
Qi Xiao
8374937a5f pkg/ui: Add more tests.
Also fix some small issues discovered by tests.

This addresses #944.
2020-04-01 22:39:46 +01:00
Qi Xiao
ccbad60ab9 pkg/ui: Test Style.SGR.
This addresses #944.
2020-04-01 00:46:29 +01:00
Qi Xiao
e9a2a9392d pkg/ui: Parse more SGR sequences in StyleFromSGR. 2019-12-31 11:51:39 +00:00
Qi Xiao
e45fdf7228 Move all libraries to new pkg/. 2019-12-23 20:00:59 +00:00