Replies: 1 comment 2 replies
-
Nice detailed analysis.
This seems like a huge leap through. a. This requires the user to go through some pretty convoluted steps to get icons working Problem |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello guys,
Stuck on this bug:
~ 1 year ago MacOS icon hack was added here #1711
But as you see it fixes only half of the problem (selections are still broken).
I've found a proper way how to solve all this nasty MacOS icon problems without using ANY dirty hacks.
Story
Some time ago Nerd icons Material Design icon set was moved to
0xf0000
-0xf1af0
character range (https://github.com/ryanoasis/nerd-fonts/wiki/Glyph-Sets-and-Code-Points)This completely screws ncurses and strange things starts to happen:
Locale definitions are located in
/usr/share/locale
dir.Depending on user configuration some of this predefined locales is selected, and all locales ending with
.UTF-8
has symlink forLC_CTYPE
pointing to../UTF-8/LC_CTYPE
.So character widths are baked into binary locale definition file:
/usr/share/locale/UTF-8/LC_CTYPE
.UTF-8/LC_CTYPE
file shipped with MacOS makes all characters in0xf0000
-0xf000e
range to be 2 character wide.Which is a root cause of all those MacOS icon issues.
I've checked
ncurses
code and he is relies solely onwcwidth
calls (notwcswidth
) to get character widths.wcwidth
itself relies onLC_CTYPE
locale category.So to fix icon problems we need to create a proper
LC_CTYPE
file.Locale building
To build correct UTF-8
LC_CTYPE
on*BSD
systems there is a tool calledmklocale
And luckily OpenBSD project shares pretty good UTF-8
LC_CTYPE
source file: https://github.com/openbsd/src/blob/master/share/locale/ctype/en_US.UTF-8.srcMacOS requires only a single modification to this file -
ENCODING "UTF8"
->ENCODING "UTF-8"
(additional dash).After that this file can be converted to binary form using:
Installation
There are many ways about how to install it.
According to
setlocale
Apple libc will look up next directories (in this order) for locale definition files:Modification of
/usr/share/locale
requires SIP disabling (https://developer.apple.com/documentation/security/disabling_and_enabling_system_integrity_protection) and probably might break some system update in future, so its a bad way and generally should be avoided.So to install:
sudo mkdir -p /usr/local/share/locale/UTF-8
sudo cp <path to binary LC_TYPE> /usr/local/share/locale/UTF-8
~/.zshrc
addexport PATH_LOCALE=/usr/local/share/locale
andexport LC_CTYPE=UTF-8
After this steps icons in
nnn
will just work without any hacks.So i think
macos_icon_hack()
can be completely removed and replaced with this little guide about how to make a proper locale on MacOS.What do u think?
Beta Was this translation helpful? Give feedback.
All reactions