Comments (9)
Thanks for reporting. Will take a look at this along with the rest international character issues.
from xterm.js.
Seems like the weird line break is actually the div overflowing. This indeed happens because these are double byte characters, the terminal ignores this fact and counts them as single-byte ones.
Working on a fix.
Screenshot
from xterm.js.
@parisk To support this you gonna have to include the wcwidth calculation for any Unicode codepoint (see man wcwidth
) and adjust the taken space for fullwidth characters to 2 terminal cells (terminals are based on the idea that a single cell can hold one halfwidth character since all western characters are halfwidth).
Problem with Javascript and Unicode is - it is a total mess with the UTF-16 encoding (surrogates) and very expensive to calculate. This gets even more complicated if you plan to support stackable combining characters (wcwidth will report a width of zero for those). This might be easier to implement once the Unicode functions with real codepoints are widely adapted by the JS engines.
I tried to implement this according to the Unicode spec but well - it ended up as a total code mess in my own terminal emulator.
Original source of wcwidth: https://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c
from xterm.js.
I had a look at your line at cell abstraction - this is pretty much the same I did in my emulator. If you like I can extend your isWide and write functions with the wcwidth stuff in a PR.
Another problem is the rendering with Unicode. For higher BMP or non BMP codepoints the fonts might differ in the glyph width from wcwidth (if they have that glyph at all). You are likely to need a CSS class fixing misaligned glyphs into place to keep the output a well formed cell grid.
from xterm.js.
Interesting. Do you believe that this could be handy? http://code.woong.org/wcwidth.js
from xterm.js.
yes, it should do the trick, though it is not 100% xterm compatible (xterm uses a slightly different version of it). If xterm compatibility is a major concern for xterm.js, we'd have to strip the lookup tables from their sources.
from xterm.js.
You can look at a solution to this here chjj/term.js#97
from xterm.js.
That seems to work for BMP fullwidth characters. Surrogates are still failing in width and cursor positioning as you can test with these characters: 𝟙𝟚𝟛𝟜𝟝𝟞𝟟𝟠𝟡
No clue if any character set of the other planes is important enough to implement the dirty surrogate handling (see Polyfill here https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/codePointAt). At least apple uses some codepoints of the private planes for their emojies.
Also combining characters are not handled by this as you can test with 'cafe\u0301'. This would be a small fix to the existing code, since the combining char has no width and would simply end up in the last active terminal cell --> ['c', 'a', 'f', 'e\u0301']. It is still a mess at the last cell in row though.
from xterm.js.
Closed in #144.
from xterm.js.
Related Issues (20)
- invalid identity escape in regular expression HOT 1
- Unexpected issue regarding `addon-fit` when used in React
- Unable to clear terminal using clear method HOT 8
- Duplicate input when using Chinese input methods
- Vscode sending "\n" instead of "^J" with "\u000A"? HOT 1
- Fit-addon is not compatible with SSR/prerendering HOT 1
- Terminal Image display has low resolution HOT 2
- _smoothScroll seems to occur more than once per frame
- It is not possible to move the cursor outside the active buffer using ANSI commands
- RIS is undocumented in vt functions doc
- @xterm/addon-web-links doesn't support blob URL (URI)
- Support for wider color spaces? HOT 1
- Ctrl+c in terminal does not scroll to the very bottom HOT 1
- Xterm.onResize cannot receive correct data HOT 4
- Height keeps shrinking when using fitAddon.fit() HOT 1
- can't input Chinese Number
- xterm deletes content instead of wrapping HOT 4
- Terminals not accessible using nano, vim, etc. in Cloud Shell and likely elsewhere
- ptyProcess.kill() is error
- Line break bug HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from xterm.js.