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

Should wcwidth provide rjust, ljust, center and textwrap? #93

Open
jquast opened this issue Oct 21, 2023 · 2 comments
Open

Should wcwidth provide rjust, ljust, center and textwrap? #93

jquast opened this issue Oct 21, 2023 · 2 comments

Comments

@jquast
Copy link
Owner

jquast commented Oct 21, 2023

In the readme, we talk about the example of writing our own custom rjust function. If the most common use case is text alignment, let's just offer it as a public API. They would be the same name and signature as python's,

And text-wrapping interface,

I have previously added support of these (with terminal sequences) in blessed, https://github.com/jquast/blessed/blob/a34c6b1869b4dd467c6d1ab6895872bb72db7e0f/blessed/sequences.py#L141-L239

@jquast jquast changed the title Should wcwidth provide rjust, ljust, and center? Should wcwidth provide rjust, ljust, center and textwrap? Oct 21, 2023
@dscrofts
Copy link

Definitely! I have implemented the ljust function as per the readme but it would be super convenient to have this already included.

@jquast
Copy link
Owner Author

jquast commented Jun 26, 2024

On textwrap, there is a pretty strange edge-case found in downstream blessed library jquast/blessed#275 -- what should be done when wrapping wide characters to a column length of 1? We have no choice but to flow beyond column width. A width of "1" may not even be allowed, or allowed with caveats.

We must also be very careful not to split ZWJ and VS-16 sequences apart.

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

No branches or pull requests

2 participants