Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Control sequences should end with \STX code #225

Open
Telpenarmo opened this issue May 27, 2022 · 1 comment
Open

Control sequences should end with \STX code #225

Telpenarmo opened this issue May 27, 2022 · 1 comment

Comments

@Telpenarmo
Copy link

Now rendering AnsiStyle-annotated docs generates escape sequence starting with \ESC code before actual text, and similar sequence applying previous style at its end. This almost always works well, but for example in Haskeline, all escape sequences are required to end with \STX byte for text to display properly (as explained in Haskeline wiki).

I think the fix would be just to change styleToRawText from T.pack . ANSI.setSGRCode . [stylesToSgrs] to T.pack . (++ "\STX") . ANSI.setSGRCode . [stylesToSgrs]. I would be happy to provide a tiny PR with this, if it's OK.

To be honest, I did not found any other cases, but probably other readline-like libraries are also affected by this. On the other hand, I don't think there are any drawbacks of this change.

@sjakobi
Copy link
Collaborator

sjakobi commented May 27, 2022

This almost always works well, but for example in Haskeline, all escape sequences are required to end with \STX byte for text to display properly (as explained in Haskeline wiki).

Could you possibly give an example that demonstrates how the missing \STX byte breaks things?

I think the fix would be just to change styleToRawText from T.pack . ANSI.setSGRCode . [stylesToSgrs] to T.pack . (++ "\STX") . ANSI.setSGRCode . [stylesToSgrs]. I would be happy to provide a tiny PR with this, if it's OK.

Have you considered changing setSGRCode so it always appends the \STX byte, or integrating functionality to generate the \STX byte into ansi-terminal in another way? I'm slightly hesitant about doing this change in prettyprinter-ansi-terminal because so far the actual escape code generation has been left to ansi-terminal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants