Open qiu8310 opened 9 years ago
For example: sindresorhus/time-grunt#52
Thanks for the information.
I had never heard that a terminal client could change the printing width of ambiguous-width characters before you told me.
Is there any good way to generally detect users' configuration other than providing an option to specify how to handle those characters?
We can use ansi escape to get Device Status Report.
By using ansi escape technology I write a package called tty-detect which can async detect any character's length on terminal, but it only work on my MAC, not work on Windows. If you have any better way, please let me know.
On the other hand, I don't think we should detect the ternimal's Double-Width Characters
setting, ternimal should export this setting to the environment.
My apologies for the late reply. It took more time than I expected to make progress on other projects and to figure out a way to employ the method you used in tty-detect
.
Considering wcwidth.js
's table-based approach, it seems difficult to adopt an empirical method to detect the width of ambiguous characters; wcwidth.js
should work when there are no attached terminals. The best way I can think of is to provide an option for the predefined width, hoping that, as you said, terminals will export their setting in the future.
wcwidth
will always return 1, but it should be 2 when enabledTreat ambiguous-width characters as double width
in iTerm2