You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is an enhancement suggestion for supporting CJK wide characters.
Many CJK characters are two columns wide in terminals. For example, "人" is a Chinese character and appears as wide as "xx" in a terminal, though len("人")==1. Many calculations and codes are based on the assumption that each character take only occupies one column. This issue breaks many of the effects like in beams, the vertical beams break into segments and in print the rows are not cleaned correctly because the length of rows are miscalculated. It also breaks the shapes of spotlights etc.
I made some modification to fix the issue, main...tjwei:terminaltexteffects:main
It use unicodedata.east_asian_width(x) in ['W', 'F'] to determine whether a character is wide or not.
This is just a quick workaround for explaining the issue, and I believe there are many I am not aware of.
There are also issues related to each effect, like for waves or decrypt, the gradient or replacement characters should also be 2 columns wide for wide characters. synthgrid also needs some adjustment. Some effect may not even make much sense when considering some characters are two columns wide.
Update: synthgrid seems fine after I fixed my code. I failed to handle the situation that two current_character_visual may have same position.
The text was updated successfully, but these errors were encountered:
This is an enhancement suggestion for supporting CJK wide characters.
Many CJK characters are two columns wide in terminals. For example, "人" is a Chinese character and appears as wide as "xx" in a terminal, though
len("人")==1
. Many calculations and codes are based on the assumption that each character take only occupies one column. This issue breaks many of the effects like inbeams
, the vertical beams break into segments and inprint
the rows are not cleaned correctly because the length of rows are miscalculated. It also breaks the shapes ofspotlights
etc.I made some modification to fix the issue,
main...tjwei:terminaltexteffects:main
It use
unicodedata.east_asian_width(x) in ['W', 'F']
to determine whether a character is wide or not.This is just a quick workaround for explaining the issue, and I believe there are many I am not aware of.
There are also issues related to each effect, like for
waves
ordecrypt
, the gradient or replacement characters should also be 2 columns wide for wide characters.synthgrid
also needs some adjustment. Some effect may not even make much sense when considering some characters are two columns wide.Update:
synthgrid
seems fine after I fixed my code. I failed to handle the situation that twocurrent_character_visual
may have same position.The text was updated successfully, but these errors were encountered: