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

[misc-] handle chars with screen width != 1, in unimportant cases #2666

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from

Conversation

midichef
Copy link
Contributor

@midichef midichef commented Jan 6, 2025

472953e - fixes behavior in several files. The effects are minor.
And I added this comment:
# textwrap.wrap does not handle variable-width characters #2416
because it seems I need the reminder, as I just looked into textwrap's handling of such characters, eventually discovering I looked into it several months ago but forgot.

5ae669b - should not change behavior of current visidata in any visible way. But in the future, if menus use variable-width characters, it would matter.
cb2bad3 - man/parse_options.py, it should not change current behavior.
1c707a1 - ddwplay.py for Animation.loadfrom(). I did not test this change, as I do not know how to test Animation.
066db54 - These changes are not strictly necessary, as the prompt strings are standard ASCII text. The fix is only for completeness, useful only if the code is copy/pasted or altered.

With this PR, my audit of len() vs dispwidth() is finished.

@midichef midichef changed the title Dispwidth misc [misc-] handle chars with screen width != 1, in unimportant cases Jan 6, 2025
@@ -32,7 +32,7 @@
BaseSheet.init('longname', lambda: '')

def fitWithin(s, n=10):
if len(s) > n:
if dispwidth(s) > n:
return s[:n//2-1] + '…' + s[-n//2+1:]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would need to use the same kind of partition() function that was mentioned in #2662.

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

Successfully merging this pull request may close these issues.

3 participants