spectre.console icon indicating copy to clipboard operation
spectre.console copied to clipboard

Using Wide Character compatibility renders double table columns in gnome-terminal

Open AdmiringWorm opened this issue 5 years ago • 9 comments

When using gnome-terminal, and have the option Ambiguous-width character set to Wide causes spectre.console to render all tables with the double amount of table columns (Setting the option to narrow fixes this issue though).

image

Reproducible in gnome-terminal by setting the following option: Edit --> Preferences --> Compatibility --> Ambiguous-width character = Wide. image

AdmiringWorm avatar Oct 27 '20 16:10 AdmiringWorm

@AdmiringWorm Yeah, not sure what to do about something like this, to be honest. Is there an environment variable or something that this setting is reflected via? In that case, we might not use wcwidth when calculating character width and multiply the number of characters with 2. That would fix your problem. That is, if there is a way of detecting this.

patriksvensson avatar Oct 27 '20 16:10 patriksvensson

Honestly, I got no idea if it is possible to detect it through an environment variable, I believe the only way to find out is to query gsettings (but I do not know what the settings name would be).

Best bet would probably to document the issue instead, maybe allow the settings to be overridden? Personally, I fixed the issue on my end by just setting the ambiguous-width character to narrow instead of wide, but that is something that would need to be done per user.

AdmiringWorm avatar Oct 27 '20 17:10 AdmiringWorm

@AdmiringWorm Can you check what VTE_CJK_WIDTH environment variable is when "Ambiguous-width character" is set to Wide and Narrow?

patriksvensson avatar Oct 27 '20 17:10 patriksvensson

@patriksvensson I just checked, it is undefined (or at least empty) both for Wide and for Narrow.

AdmiringWorm avatar Oct 27 '20 17:10 AdmiringWorm

@AdmiringWorm Out of curiosity. If you set your terminal to have "Ambiguous-width character" is set to Wide, then launch the table example with VTE_CJK_WIDTH=1, VTE_CJK_WIDTH=0 and VTE_CJK_WIDTH=2, do you see any difference in the output?

patriksvensson avatar Oct 27 '20 17:10 patriksvensson

@patriksvensson no, there is no difference in the output with either one of the values of the variable. All of them produces the same output (both using Wide and for Narrow compatibility set).

AdmiringWorm avatar Oct 27 '20 17:10 AdmiringWorm

To check if it was something that changes that causes this, I traced back to the earliest version of spectre.console the showed the same symptoms.

I found that since v0.4.0 (the introduction of panels I believe), the same issue occurs.

I also compared all environment variables set between the Wide and Narrow compatibility layer, and unfortunately, there are no changes between them.

AdmiringWorm avatar Oct 27 '20 17:10 AdmiringWorm

@AdmiringWorm I see. Sadly this has nothing really to do with Spectre.Console, it's the Gnome terminal which behaves in a way that's kind of unorthodox, so the best we can do is document the behavior if we can't detect it.

patriksvensson avatar Oct 27 '20 17:10 patriksvensson

This might come up again for windows terminal, if https://github.com/microsoft/terminal/issues/153 is being implemented.

nils-a avatar Oct 15 '21 21:10 nils-a