-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
multiple unicode version support #1714
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just tested it, works really well - finally I can use emojis in my prompt again! I've left a small note about the registeredVersions function name, apart from that it LGTM.
@mofux: Thx! Im abit concerned about the package size, might try to get the new data in a more packed representation (The old one isnt even half as big, also zips further down). |
Reminder to myself: A provider instance needs to be disposable from the callback register (maybe simply remove it from the arguments). |
I wouldn't bee too concerned about the extra 32KB 😅 |
Yeah, also zipped the difference is 7.8 vs 2.5 kB, imho nothing to worry about. |
Made the provider disposable and added some tests. Ready for next review round 😸 |
src/UnicodeProvider.ts
Outdated
* Gets the newly registered version and | ||
* the `UnicodeProvider` instance as arguments. | ||
*/ | ||
public addRegisterListener(callback: (version: number, provider: UnicodeProvider) => void): void { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are all these listener functions needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They are in preparation for adding unicode versions at runtime by addons or such. The listener will inform about new versions, so any terminal instance can switch if needed.
Up for next review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests failing after merge? Also I think this is blocked on #1789 now
Ah thats weird, have to check if there is some high char hidden in the test, that might change width with a different unicode version. |
Reminder: Initialize wcwidth lookup table on first version request in |
Currently blocked by #1789. |
@dnfield May I ask you to have a look at the new code, in particular here: Line 335 in a1257a1
As you can see I extracted the BMP plane codepoints from the others to create the lookup table from it and shortcut the bisect for higher abit too (no magic here, I have simply split your lists). The problem: A closer look at your code revealed that you are not using the |
I didn't have any good test cases for the wide East Asian, and so I just left it as is, which I suppose is incorrect. |
@dnfield |
The new iOS release and Mojave claim to be Unicode v11, Ubuntu still ships ICU v60 in 18.10 which is still v10. Ubuntu 19.04 has ICU v63 linked which is v11. Not sure if the latter is already useable, guess the tests have to be done on Mojave. So I did a quick test in Mojave with the first codepoint that differs in v6 and v11: U+231A (watch) |
🤷♂️ |
Hmm it seems macOS' Guess I gonna start with v10 on ubuntu to check which wide definitions can be pulled in. |
Made some progress and queried wcwidths from different systems I have access to with these results:
I will try to get better results for v11 by extracting the values from the upcoming Ubuntu LTS (claims to be v11) and comparing it with the results from here https://github.com/jquast/wcwidth (they have several extractors to get the values). If this all fails we could still provide system dependent maps extracted from the default terminal, but I see this only as a last resort. From the differences of the extracted maps I conclude that we will have to bundle at least 3 versions (6.3 + 10 + 11, 11 contains much more changes than any other major release before) which raises the question whether we should go with an addon solution from the beginning. |
I had an idea yesterday which would probably be a good fix for this. Once we have addons, the unicode definitions can be "bundled" addons, so they will remain in xtermjs/xterm.js and ship in the // Loads the default unicode addon version using dynamic imports such
// that all unicode definitions are not loaded when a terminal is created
const t1 = new Terminal();
// Loads only the v11 unicode addon via dynamic import
const t2 = new Terminal({
unicodeVersion: 11
}); |
@Tyriar Stumbled myself over the question what to do with at least 3 versions to support. For local applications (like electron based) 50kB more or less dont really hurt, for remote browser based scenarios this is nasty, since a user only needs one particular version. My idea was to offer 2 ways to integrate the data:
|
Closing as the eventual addon solution will look pretty different to this, see #1709 (comment) |
First version of multiple unicode version support. Shall fix #1709, partly copied over from #1707 (thx to @dnfield).
The class
UnicodeProvider
currently holds registered versions at the global object. An instance of that class carries the active version info for a single terminal instance and returns the correctwcwidth
impl. The statically provided versions currently reside underunicode
in the codebase and get added inUnicodeProvider.ts
. More versions can be added at runtime (maybe in the future by addons), there is a callback slotonRegister
to get notified about newly registered versions.Still very hacky, would be good to get some conceptual feedback first before doing tests and such.
Edit: Currently adds ~20kB to the package size uncompressed (now at ~385kB).
/cc @Tyriar, @mofux, @bgw, @dnfield