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

don't count invisible characters when calculating column width #1

Open
masukomi opened this issue Nov 6, 2022 · 4 comments
Open

don't count invisible characters when calculating column width #1

masukomi opened this issue Nov 6, 2022 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@masukomi
Copy link
Owner

masukomi commented Nov 6, 2022

If you include ANSI escape sequences to format your text (bold, colored, etc.) then the code includes those escape characters in the calculation of how wide the text is, but when it's actually displayed those characters are not providing any width, so the columns are all misaligned.

@masukomi masukomi added the bug Something isn't working label Nov 6, 2022
@masukomi masukomi self-assigned this Nov 6, 2022
@masukomi
Copy link
Owner Author

masukomi commented Nov 6, 2022

with formatting (bolded text)
CleanShot 2022-11-06 at 17 57 01@2x

without formatting
CleanShot 2022-11-06 at 17 57 08@2x

@masukomi masukomi changed the title counts invisible characters when calculating column width don't count invisible characters when calculating column width Nov 6, 2022
@2colours
Copy link

It seems to me this is where things get very complicated suddenly. I would think twice whether planning for non-character content is worth it for this module at all.

@masukomi
Copy link
Owner Author

masukomi commented Nov 29, 2022

It seems to me this is where things get very complicated suddenly. I would think twice whether planning for non-character content is worth it for this module at all.

writing the following because i want to be sure i'm not missing something obvious @2colours:

I've got a lot of experience working with escape characters (see oho ) and this doesn't really seem like a big deal to me.

To be clear, i'm not intending to deal with the consequences of things like emoji and anything else that has issues with fitting into a monospace layout because emoji + terminal == layout nightmare.

BUT I think invisible content should be pretty straightforward. Well... invisible terminal escape characters should be pretty straightforward. ALL the invisible characters in Unicode, may be another issue. Not sure how many there are like "zero width space".

EDIT: looks like it's a pretty small set, if this list is to be trusted.

@2colours
Copy link

It seems to me you explained perfectly why it's a nightmare to work with. :P Besides, terminal escapes are ad-hoc and incompatible with unicode - been there, (not) done that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants