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

consider treating ANSI/CSI/OSC sequences as zero width #511

Open
samliddicott opened this issue Jun 13, 2023 · 1 comment
Open

consider treating ANSI/CSI/OSC sequences as zero width #511

samliddicott opened this issue Jun 13, 2023 · 1 comment

Comments

@samliddicott
Copy link

When wrapping, consider skipping over escape sequences such as those used for color control.

This way colorized messages can be wrapped.

Maybe https://docs.rs/strip-ansi-escapes/latest/strip_ansi_escapes/ has suitable code to steal.

@mgeisler
Copy link
Owner

Hi @samliddicott,

Thanks for looking at Textwrap and opening issues. What is your use-case for Textwrap?

When wrapping, consider skipping over escape sequences such as those used for color control.

This way colorized messages can be wrapped.

We already do this: the display_width function will unconditionally skip across such escape sequences. The function is used for all width computations in the library.

Did you run into a problem using the wrapping functions on colored terminal text?

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