You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We know that Elvish parses CSI sequences in a prompt into Text objects instead of writing raw output. It's cool, though introducing a defect. There are many CSI sequences (e.g., a \x1b[21m sequence that typically means disabling bold intensity text style on several terminals) being ignored (discarded) during the parsing via ui.ParseSGREscapedText. However, prompt engines like Oh My Posh, depend on utilizing these control sequences to construct flexible and awesome prompts. The drawback leads to incomplete or unexpected styled text rendered on a terminal.
Notice that quite a few of the SGR parameters documented at Wikipedia ANSI SGR parameters, including 21, are not handled by that function. Some of the known SGR parameters can be ignored because they are unlikely to ever be relevant for Elvish; e.g., 20, 26, 50, etc. It's also not clear how to support some parameters, such as 11 thru 19 which select an alternative font, but it seems unlikely those SGR parameters need to be supported by Elvish.
SGR parameter 21 (the focus of this issue) is interesting in that its official meaning (double-underline) is different from its de-facto meaning (disable bold intensity). But there is a more general issue since none of the negative SGR parameters are currently supported. For example, 22 (not bold or faint intensity), 23 (not italic), 24 (not underlined), etc. are also not currently supported by Elvish. But it should be straightforward to enhance ui.StylingFromSGR to support the negative parameters since the core Elvish text styling code supports the concept. See
> put (styled b bold) (styled (styled x bold red) no-bold)
▶ (ui:text (ui:text-segment b &bold=$true))
▶ (ui:text (ui:text-segment x &fg-color=red))
Someone just needs to write the code and add appropriate unit tests. It might also be useful if a command similar to styled was added that allows Elvish programs to explicitly convert strings containing SGR sequences to styled sequences. If nothing else that would make interactive testing easier of how SGR sequences are converted implicitly by the Elvish prompt code.
What happened, and what did you expect to happen?
We know that Elvish parses CSI sequences in a prompt into
Text
objects instead of writing raw output. It's cool, though introducing a defect. There are many CSI sequences (e.g., a\x1b[21m
sequence that typically means disabling bold intensity text style on several terminals) being ignored (discarded) during the parsing viaui.ParseSGREscapedText
. However, prompt engines like Oh My Posh, depend on utilizing these control sequences to construct flexible and awesome prompts. The drawback leads to incomplete or unexpected styled text rendered on a terminal.Output of "elvish -version"
0.21.0+official
Code of Conduct
The text was updated successfully, but these errors were encountered: