-
-
Notifications
You must be signed in to change notification settings - Fork 442
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
Migrate away from legacy ncurses functions attrset
, attron
,attroff
, ...
#1541
Comments
attrset
, attron
and attroff
attrset
, attron
and attroff
attrset
, attron
and attroff
attrset
, attron
,attroff
, ...
If I'm reading your issue correctly, this, together with the comment in #243, would allow for proper preservation of the bold attribute without also introducing brightened-up colors if we were to update the mentioned API calls? Natural questions that come to mind are:
|
The problem in #243 should be able to be tackled without this, however, were that to add more code dependent on the legacy APIs, it would just needlessly be making it more complex to switch away from them later.
init_extended_pair was added to library on 2017.04.01, and released in version 6.1 January 27, 2018 htop currently specifies 6.0 as minimum, defined in 2021 (unless it was required even earlier than this readme commit), that would need to be bumped to 6.1.
For this issue for the non-W switchover, that should not matter. For #243, I do not believe anything new is necessary either, it is mainly a problem with how ncurses handles setting FG+BG color, otherwise we could just edit the original PR #434 to simply only apply the BG color we're passing through and preserve everything else, but ncurses does not work that way. For the possible W switchover, which from my understanding is needed for unicode:
ncurses|ncursesw is still split on the latest released Debian, so that stilll makes sense with the current codebase that does not hard depend on Wide char support.
Unsure, that sounds like something that'd be great to know, I suppose figuring out why VSC terminal differs from for example Konsole on this front would help reveal if that's possible.
This should be an internal ncurses thing and I don't suppose anything beyond 6.1 + code changes in htop for the newer API would be needed to migrate to it. At least one problem with the legacy APIs is that they limit ColorPairs to
Not from me unfortunately, I am not a designer, nor a C/C++ programmer, and my experience with ncurses starts yesterday to boot. |
This makes updating the codebase for ncurses 6.1 a reasonable way to go forward.
Given the wide availability of htop even on non-Linux systems, those should be considered to. There should be at least one LTS-style version for each platform that meets that new baseline, though this isn't necessary a hard requirement depending on the platform (no hard feelings for Darwin or Solaris ;-)). If most platforms provide ncurses 6.2 (Feb 2020), 6.3 (Oct 2021) or 6.4 (Dec 2022), even that would be an option, if we already are at increasing the baseline anyway.
We will need to keep htop compatible with ncurses versions that do not support Unicode; one example is NetBSD AFAIR.
Also consider the non-Linux platforms like all the *BSDs.
Current NetBSD if running their native curses implementation …
The libncursesw related ifdefs serve mostly two purposes:
NetBSD is a bit special there too, cf. this recent issue/PR
ACK. Also a great plus if we knew on the side of advancing with the issue in #243 that kickstarted this thread.
Seems reasonable.
I'm quite positive this ain't a problem even right now. ;-) And while I also don't see much reason to stick to the past for too much, given the existing deployments we shouldn't rush things to far into the future either.
I was asking because as far as I have skimmed over the manpage links I noticed the new APIs usually take the attributes and colors as two separate arguments, but our existing themes combine these two parameters in one value. There seems to be a macro to split this, but if code can be simplified or made more readable by splitting some of our internal definitions, I think this might be worth a shot. |
I have thought of a reasonable midway solution to #243 in #1542 with just the attributes. EDIT:
Actually, it looks like the current code is much more limited than just the 35k short values? EDIT2: Very good read about 24-bit terminal colors which have started being supported in recent years here - mawww/kakoune#1807 That also requires ncurses 6.1 at minimum. |
OpenBSD curses_attributes(3) man page So it's safe to assume NetBSD curses supports Also it's good to implement the function availability test in the configure script first. |
What are the benefits of supporting both the limited NetBSD https://github.com/htop-dev/htop/blob/main/netbsd/README.md only describes this situation as NetBSD being one of the last holdouts with their own curses implementation, and htop having support for both. What I can see from my end is having to write the code twice, in different ways, with caveats, limitations, and having to carefully ifdef everything and having to consider all of that while trying to plumb up the existing codebase or adding new features. This complex duplication makes it very unappealing to make such contributions. |
Ran into this while trying to fix #243
Fixing these will allow htop to correctly handle the 65k available colors and the necessary version bump enables 8-bit RGB colors (24-bit).
Maybe migrate to wide chars where doable ->
wattr_on
/wattr_off
/wattr_set
?In which case other things also have to be migrated, see the docs.
Here's picmap source from ncurses test examples - https://github.com/ThomasDickey/ncurses-snapshots/blob/master/test/picsmap.c
With the 6.1+ bump:
init_pair -> init_extended_pair
attron -> attr_on
attroff -> attr_off
attrset -> attr_set
Moreover it looks like htop is written with the 16 (8+8bold) colors of the ancient past in mind, rather than the 256 color standard of yesterday, or the 8-bit RGB of today.
Any arguments about old distributions can rest, as those distributions will simply use old htop, even Ubuntu 20.04 from 2020 has ncurses 6.2... and htop 2.2.0.
The text was updated successfully, but these errors were encountered: