TermControl: force all ambiguous glyphs to be narrow#2928
Conversation
From Egmont Koblinger: > In terminal emulation, apps have to be able to print something and keep track of the cursor, whereas they by design have no idea of the font being used. In many terminals the font can also be changed runtime and it's absolutely not feasible to then rearrange the cells. In some other cases there is no font at all (e.g. the libvterm headless terminal emulation library, or a detached screen/tmux), or there are multiple fonts at once (a screen/tmux attached from multiple graphical emulators). > The only way to do that is via some external agreement on the number of cells, which is typically the Unicode EastAsianWidth, often accessed via wcwidth(). It's not perfect (changes through Unicode versions, has ambiguous characters, etc.) but is still the best we have. > glibc's wcwidth() reports 1 for ambiguous width characters, so the de facto standard is that in terminals they are narrow. > If the glyph is wider then the terminal has to figure out what to do. It could crop it (newer versions of Konsole, as far as I know), overflow to the right (VTE), shrink it (Kitty I believe does this), etc. See Also: https://bugzilla.gnome.org/show_bug.cgi?id=767529 https://gitlab.freedesktop.org/terminal-wg/specifications/issues/9 https://www.unicode.org/reports/tr11/tr11-34.html Salient point from proposed update to Unicode Standard Annex #11: > Note: The East_Asian_Width property is not intended for use by modern terminal emulators without appropriate tailoring on a case-by-case basis. Fixes #2066 Fixes #2375
zadjii-msft
left a comment
There was a problem hiding this comment.
I'm okay with this, but I also really want #900 to get better in 0.6 if we're also making it aggressively worse.
|
@zadjii-msft i can produce a table of all the emoji that exist, and which ones are miscolumned. Would that be sufficient evidence to move #900 forward, do you reckon? |
|
@DHowett-MSFT Probably. I'm probably not going to be the one solving #900 though, that seems more like @miniksa's wheelhouse |
I'm fine with building such a table, @DHowett-MSFT and resolving the columns. It looks like in #900 that Fcharlie already did something like that |
| static bool _EnsureStaticInitialization() | ||
| { | ||
| // use C++11 magic statics to make sure we only do this once. | ||
| static bool initialized = []() { |
|
🎉 Handy links: |
* send alt/F10 through the control
We were not listening for WM_SYSKEY{UP,DOWN}
* extract the actual scancode during WM_CHAR, not the bitfield
We were accidentally sending some of the additional keypress data in with
the character event in Win32 Input Mode
* set default fg/bg to campbell
The WPF control starts up in PowerShell blue even though it's not typically used
in PowerShell blue.
* don't rely on the font to determine wideness
This is a cross-port of #2928 to the WPF control
* deterministic shutdown
In testing, I saw a handful of crashes on teardown because we were not shutting
down the render thread properly.
* don't pass 10 for the font weight ...
When Cascadia Code is set, it just looks silly.
* trigger render when selection is cleared, do it under lock
Fixes #6966.
* send alt/F10 through the control
We were not listening for WM_SYSKEY{UP,DOWN}
* extract the actual scancode during WM_CHAR, not the bitfield
We were accidentally sending some of the additional keypress data in with
the character event in Win32 Input Mode
* set default fg/bg to campbell
The WPF control starts up in PowerShell blue even though it's not typically used
in PowerShell blue.
* don't rely on the font to determine wideness
This is a cross-port of #2928 to the WPF control
* deterministic shutdown
In testing, I saw a handful of crashes on teardown because we were not shutting
down the render thread properly.
* don't pass 10 for the font weight ...
When Cascadia Code is set, it just looks silly.
* trigger render when selection is cleared, do it under lock
Fixes #6966.
(cherry picked from commit 76de2ae)
* send alt/F10 through the control
We were not listening for WM_SYSKEY{UP,DOWN}
* extract the actual scancode during WM_CHAR, not the bitfield
We were accidentally sending some of the additional keypress data in with
the character event in Win32 Input Mode
* set default fg/bg to campbell
The WPF control starts up in PowerShell blue even though it's not typically used
in PowerShell blue.
* don't rely on the font to determine wideness
This is a cross-port of #2928 to the WPF control
* deterministic shutdown
In testing, I saw a handful of crashes on teardown because we were not shutting
down the render thread properly.
* don't pass 10 for the font weight ...
When Cascadia Code is set, it just looks silly.
* trigger render when selection is cleared, do it under lock
Fixes #6966.
(cherry picked from commit 76de2ae)
This PR introduces `compatibility.ambiguousWidth` as a **global** compatibility setting (`narrow` default, `wide` optional). The default remains `narrow`. Why global-only in this PR: - Width detection is currently process-wide (`CodepointWidthDetector` singleton). - True profile-level ambiguous-width behavior would require broader architectural changes and is intentionally deferred to a follow-up design/PR. What this PR guarantees: - Terminal-side handling is consistent end-to-end for the selected ambiguous-width policy (rendering path + ConPTY/host propagation). Known limitation: - Some client applications (for example PSReadLine/readline-based apps) may still compute character widths independently. - In such cases, cursor movement or Backspace behavior can differ from visual cell width even when terminal-side policy is consistent. This is a compatibility/readability trade-off feature: - `narrow`: prioritize cross-application compatibility. - `wide`: prioritize readability with many CJK fonts. Closes #153 Closes #370 Refs #2928 Refs #2049, #2066, #2375, #900, #5910, #5914 Co-authored-by: Leonard Hecker <[email protected]>
From Egmont Koblinger:
See Also:
https://bugzilla.gnome.org/show_bug.cgi?id=767529
https://gitlab.freedesktop.org/terminal-wg/specifications/issues/9
https://www.unicode.org/reports/tr11/tr11-34.html
Salient point from proposed update to Unicode Standard Annex #11:
Fixes #2066
Fixes #2375
PR Checklist
Requires documentation to be updatedValidation Steps Performed
This one has some followup issues. I went wild on it, but it does still have some issues. It makes #900 worse, and introduces a debug break you hit when the renderer and the column counter disagree. It might make the renderer discard the rest of the line it was working on.