wcwidth calculation#144
Conversation
|
Hi @jerch, thanks for your contribution! Before moving on with testing this out, could you please mention the particular GitHub issues that this PR is supposed to fix? |
| * wcwidth | ||
| */ | ||
| var wcswidth = (function() { | ||
| var _WIDTH_COMBINING = [ |
There was a problem hiding this comment.
Where was this list sourced from?
There was a problem hiding this comment.
Extracted from here https://www.cl.cam.ac.uk/%7Emgk25/ucs/wcwidth.c
|
I have cleaned up the code and fixed the indentation. |
|
Thanks @jerch! I'll have to take a chunk of time to look at this in detail, can you think of some test cases that could be added for |
|
yes I have some test cases, gonna try to apply them to xterm.js. There are some edge cases that need proper testing:
Offtopic: |
|
One test case fails - I commented it out since the it refers to a missing feature in default state (wrap true/false is not handled there at all). --> see #147 |
|
Okay, just found the chance to take a deeper look into this. #72 does not seem to be closed by this (still weird characters appear, but different than the ones mentioned in this issue). This PR closes #70 and closes #62 successfully though. I will move on with merging this PR, since it great steps forward have been done here. I also believe that #72 can be tackled autonomously, since it appears only when moving the cursor. Thanks a lot! |
Quick replacement of
isWide()withwcwidth. Since xterm.js has no frontend packaging atm I just copied my version into the source file.wcwidth fixes several issues:
Misaligned glyphs are not fixed by this pull request. This would need a way to introspect the current font and glyph widths. This could be done by prerendering faulty glyphs onto a canvas, getting their width with
measureTextand aligning them with a CSS rule. I played with this approach here https://github.com/netzkolchose/jquery.browserterminal/blob/master/dist/js/jquery.browserterminal.js#L289, the glyph width calculation is pretty slow but is only needed once.