Skip to content
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

Option to use system's widths in GTK3 GUI #4380

Closed
robert-ross opened this issue May 16, 2019 · 15 comments
Closed

Option to use system's widths in GTK3 GUI #4380

robert-ross opened this issue May 16, 2019 · 15 comments

Comments

@robert-ross
Copy link

GVim uses its own version of functions such as wcwidth. In many cases that's better but sometimes it's more important to be consistent with other programs such as VTE3 which is commonly used by several terminals. In particular, some text files that are properly aligned when using Vim in a terminal become messed up in GVim and vice-versa. Please add an option such as "systemwidth" that can be enabled on a modline to avoid disruption.

@robert-ross
Copy link
Author

Oops, s/modline/modeline/.

@brammool
Copy link
Contributor

brammool commented May 16, 2019 via email

@chrisbra
Copy link
Member

This is possible, but the choice has to be made at runtime.

you mean compile-time?

@brammool
Copy link
Contributor

brammool commented May 17, 2019 via email

@robert-ross
Copy link
Author

Thanks for the fast response. This request is for being able to choose at runtime since the default (without USE_WCHAR_FUNCTIONS) is usually a good thing. I could switch off between two gvim binaries on my own machines but requiring that would be onerous for other people to read the text files.

@brammool
Copy link
Contributor

brammool commented May 17, 2019 via email

@robert-ross
Copy link
Author

Will do.

@robert-ross
Copy link
Author

It didn't have the desired effect but it did help me determine why GVim and terminal Vim had different widths. In my case, characters that were introduced in Unicode 12 differed since I'm using the latest stable glibc release and glibc 2.29 only supports Unicode 11. Thus characters such as U+1F6D5 appear narrower in terminal Vim than GVim. A workaround could append a filler or space when wcwidth(c) is -1 yet c is in Vim's doublewidth. I also found differences in older characters but only in scripts that I'm not qualified to assess. For example the sequences U+0020 U+093F and U+0915 U+093F both appear wider in terminal Vim than GVim but I have no idea which rendering is preferable or how to make the widths consistent. I could attach an example text file if that would help.

@robert-ross
Copy link
Author

After updating locale data files and running locale-gen, I'm getting excellent results from wcwidth, iswprint, etc. Now, USE_WCHAR_FUNCTIONS fixes issues with U+3248 to U+324F, U+32FF, and U+4DC0 to U+4DFF where the width should be 2 but commands such as 'echo strwidth("\u32FF")' return 1. Please update Vim's internal tables so USE_WCHAR_FUNCTIONS isn't necessary. U+32FF was a recent addition from Unicode 12.1 so it was probably going to be corrected eventually anyway. The other ranges don't satisfy Markus Kuhn's comments in http://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c but his mk_wcwidth and GNU's wcwidth return 2 for them.

@chrisbra
Copy link
Member

chrisbra commented Jun 4, 2019

Unicode 12.1 is very recent, and hasn't been applied to Vim yet. However patch 8.1.1157 added support for Unicode 12. So what exactly are you missing?

@k-takata
Copy link
Member

k-takata commented Jun 4, 2019

Unicode 12.1 added only one character U+32FF SQUARE ERA NAME REIWA.
I don't know about the rest of the characters: U+3248 to U+324F and U+4DC0 to U+4DFF.

@robert-ross
Copy link
Author

The first range was added to Unicode 5.2 based on ARIB STD B24 (the Japanese Association of Radio Industries and Businesses). The last range was added to Unicode 4 to encode Yijing (the ancient Chinese text known as I Ching). It's reasonable to assign these characters a width of 1 but that's a misfit, at least on GNU/Linux systems.

@brammool
Copy link
Contributor

brammool commented Jun 5, 2019 via email

@robert-ross
Copy link
Author

Agreed. There are some minor issues with defining USE_WCHAR_FUNCTIONS (need to #define _XOPEN_SOURCE on Linux before #include <wchar.h>, compiler warning about the doublewidth variable being unused, etc.) but nothing major. If desired, I'll write another ticket.

@chrisbra
Copy link
Member

chrisbra commented Jun 6, 2019

okay, closing then.

@chrisbra chrisbra closed this as completed Jun 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants