-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix unicode display: CJK, powerline, tmux #1536
Conversation
Wow, this is awesome! Will try it tonight 👍 |
Also, since other Terminals limit the width of Emojis, I worry that we'd be displaying them not as nicely in Hyper, because they'd essentially have an extra space (think Yarn) |
@rauchg: great point about emojis, one important breaking UI is the cursor position. However we need to address at least powerline unicode characters (e.g. #1336 (comment)), which is handled properly by iTerm as well. Emojis being spread over codepoints, it would be easier to isolate the powerline glyphs and give them more space. We can choose to apply flexible or double spacing, I would suggest double to keep the cursor position in check. From what I can see, this is the way iTerm handles it too. After that, I think I should remove css decoration for braille, since it will fall in the normal unicode styling (?). Sidenote: This is getting interesting, powerline glyphs are stored in the Unicode Private Use Area, along with medieval scripts, Klingon, and various languages of the Middle-earth... Should we display that with fix width or double width like powerline glyphs? 😂 |
@tibotiber that's a very good question. I think ultimately it would depend on each glyph in the private use area whether they want double or single width. Let's do this: for now, let's give all private use area double (which would encompass Powerline glyphs), and then if a request comes up, we can think about adding a config flag for specifying ranges that you want to be double width |
OK, I'll push changes today (it's Saturday here already). I'll remove the braille part then. |
Update: The issue with powerline glyphs is not a width issue. I couldn't get this to work in a way that supports basic powerline glyphs as well as user defined ones, so I checked iTerm a bit more and realised they do not treat powerline glyphs (new or old) as wide chars. What happens is wide unicode simply overflows on the next char. See screenshots for iTerm and Hyper: I removed my previous changes and only left the low hanging fruit: fixing of CJK wide chars. Still trying to find a way around the powerline issue. Summary of issues i'm trying to address and the ones fixed:
|
As explained above, without the
That's not true for Emojis it seems? Or emojis are not "wide unicode" (why not?) Another thing I'd like to add to your list: ensure chinese characters render correctly |
More food for thought: how should |
OK, that's what I had gathered about the encapsulation, just wanted to make sure there were no other reasons.
I don't understand. Emojis are wide unicode, and they do overflow on the next char in iTerm, don't they? This is what your screenshot shows with the heart overflowing from its span onto the next (behind the Good job finding ﷽ 😂, I'll target full overflow, like in Terminal.app.
Which part exactly? The |
Just wanted to be 100% sure! Seems like we're on the same page @tibotiber. Next up once we merge this PR is to fix backspace (the behavior of the ANSI escape that is) for surrogate pairs and caret position |
Yep I was referring to the report by @BirkhoffLee |
Also not a priority for now considering our broken backspace, but thought I'd mention it |
b6bba15
to
9d3195a
Compare
Took a while to get back to this, sorry. I pushed new changes to try and fix the display of unicode in powerline prompts:
This is partially working and I can't figure out why only "partially". It basically works for general unicode display such as I think it has something to do with the way hterm handles data decoding in I left some debug logs that help to understand what the new |
Reverting |
I'll have a look for a fix |
Hey, sorry about this, didn't try to |
I use https://github.com/brandonweiss/pure.fish and i think rauch is using https://github.com/sindresorhus/pure @tibotiber |
Mmmmh, I'm on sindresorhus pure as well actually. I tried a few other prompts (antigen themes) and I'm getting no error. Not understanding this. |
🤔 I'll diag & give you something to reproduce with tomorrow, need to get some 💤 |
Why don't we just let the webkit do this work instead of calculate the width of the char? |
@mengzhuo I'm sad to say it's a bit more complicated than that... Sorry for not coming back yet, I'll get this sorted tomorrow 👼 |
I use font "Cousine for Powerline", this screenshot is after I remove all unicode-node style. You can compare with gnome-terminal at the background. I think it's a "web-based" app, we should due with it more "web-way" by using more css instead of messing with DOM. |
@mengzhuo, the issue with this approach is that you break the rendering for unicode that is not monospaced (see this comment). You can observe a bad example by running |
Sorry for the delay @tibotiber the problem is that not all nodes has I tried two things:
here's what's in my console when entering one emoji: (fish) After testing some more, it seems to be an issue with because if i print emojis (cat a file with emojis in it for example), they work as expected |
@albinekb thanks for posting more details. I looked into it and here are some thoughts:
|
…" (vercel#1847)" This reverts commit edd8667.
Quite honestly, |
I stumbled upon this PR and wanted to ask here before creating an issue first, so sorry in advance for posting this here. By any chance is this rendering issue related to the problem produced in this screenshot: On the left is Terminal and on the right is Hyper. I'm speaking of course about the box side which seems to warp as well as contain some overlap between the characters. |
@LeonBlade this will need to be checked once the follow up PR #1873 lands, but it should fix your issue. |
Hi! I don't necessarily have a horse in this race, besides the ones that the contributors above have (Pretty Unicode Interfaces [for english text] And Maybe Sometimes Emoji) — but I want to point out that this heavily affects users from other countries and cultures? This seems like a question that's ideal for a ‘reach out and ask users’ kind of moment. Maybe a request-for-comments notice in the README for six months, or something like that? (Also, a great way for beginners to contribute: “What does your language need from a terminal emulator?) If nothing else, I suspect we need to get a ~Unicode expert~ to come in and answer some questions about character ranges to treat as ‘wide’ (our implementation gives them double width, automatically consuming an extra column) versus ones to ignore, treat as single-wide, and leave for userspace handling (“What? This emoji looks funny? I guess I'd better spit out an extra space after it.” aka The Yarn Approach). |
An aside — copied from a friend, as examples of why the emoji in particular are A Hard Problem, and “display all private-use-area characters as two columns” isn't enough:
|
@tibotiber Great!! You saved my life. Thank you. I'll looking forward to be released 👍 |
Hi! This is a follow up PR from #1376, taking 2e58e56 into consideration. I have isolated the issue with braille characters for
vtop
by decorating the corresponding nodes with abraille-node
class additionally to the existingunicode-node
class. It is ready to merge to the best of my knowledge.Cc @rauchg
WIP summary:
wc-node
css