ttcdt / mp-5.x

The Minimum Profit Text Editor
The Unlicense
23 stars 4 forks source link

Fix mix between bold and bright #16

Closed X-Ryl669 closed 3 years ago

X-Ryl669 commented 3 years ago

There is a (common) misbehavior in the color handling process for terminals (both ncurses and ansi).

In effect, one mix bold with brighter, so for terminal that handle bold font correctly (like Kitty for one, but many other do), asking for a brighter font results in a bold font instead.

In reality, a bright font should use an escape code of \e[90+color m; and not \e[30+color;1m` since the latter is for bold attribute (see here).

So this PR fixes this for ANSI driver. For ncurses, since it's an arcane library, there is no A_BRIGHT attribute (yet?) but a A_DIM attribute instead. However, it does not seem to work (why???)

So in order to fix it for ncurses, I've taken a different approach, and I'm using the facility to reconfigure the color palette instead for a color index. So, it's better since the code is now able to load the theme set in MP and assign a color index of the terminal palette to the exact RGB value in the theme (so no more brighter requirement here).

If the terminal does not support 256 colors (or more), then the default behavior is kept even if it's ugly.

ttcdt commented 3 years ago

I've found several issues with this patch under OpenBSD:

. In the console, the ANSI driver is severely broken (only a small set of colors are shown, the rest is B/W) . The curses driver does not compile because A_ITALIC is not defined.

Regards, Claire

X-Ryl669 commented 3 years ago

What is the version of ncurses you are using ? Since version 3.7, A_ITALIC was added and it was released in 2013. Maybe you should upgrade the library to a more recent version.

Concerning the small set of colors in ANSI, I wonder if your terminal supports the brighter color code [90m. This is supported by VT500 series (released in 1993), see here search for Ps = 9 0.

I guess I'll have to add a configure switch/macro to disable "advanced" feature for very antique terminal and/or console, but, on the other side, recent terminal implements these code correctly. And using bold code instead of bright gives a very ugly output (since everything is in dark color, only the font weight if changing, and it's not very obvious).

So, I don't know what to do, the current code (without this patch) is not usable for me in the terminal I've used (Terminology, Kitty, Konsole), and with this patch it's not usable with your probably old console and ncurses version.

Can you assert if you can upgrade ncurses version and if you can test in a more recent terminal ?

X-Ryl669 commented 3 years ago

See PR #17 for a fix for your issue and please comment if it worked for you. Thanks!