horeah / PyCmd

Improved interactive experience for Windows' cmd.exe
GNU Lesser General Public License v3.0
18 stars 4 forks source link

Use actual Unicode width when computing the cell-width of strings printed to the terminal #9

Open horeah opened 1 year ago

horeah commented 1 year ago

This was initially reported by @santagada in the context of the incremental history search (#1) but applies to several other places in the code: assuming that the number of terminal cells is equal to the number of characters in the printed string is incorrect for certain classes of Unicode characters!

The suggested solution is to use a package like wcwidth (https://pypi.org/project/wcwidth/) whenever terminal sizes and offsets are being computed.