Skip to content

Add support for 256 colours in curses window port#1561

Open
ars3niy wants to merge 5 commits into
NetHack:NetHack-5.0from
ars3niy:curses256
Open

Add support for 256 colours in curses window port#1561
ars3niy wants to merge 5 commits into
NetHack:NetHack-5.0from
ars3niy:curses256

Conversation

@ars3niy

@ars3niy ars3niy commented May 30, 2026

Copy link
Copy Markdown

Only glyphs that are customised via config can have colours different
from the basic 16. For such glyphs, when curses supports 256 colours,
use them.

@ars3niy

ars3niy commented May 30, 2026

Copy link
Copy Markdown
Author

To show how it works for me (and what existing features I tested so they do not break), here is a screenshot containing:

  • An erinys with custom extended colour (OPTIONS=glyph:G_female_erinys:&/light-coral)
  • A barbed devil with default colour
  • A fox with custom basic colour (OPTIONS=glyph:G_male_fox:d/blue)
  • A highlighted pet
  • A highlighted item pile
nhcolour

@nhmall

nhmall commented May 30, 2026

Copy link
Copy Markdown
Contributor

Have the changes in win/curses been tested on pdcurses as well as ncurses?

@ars3niy

ars3niy commented May 30, 2026

Copy link
Copy Markdown
Author

ncurses (version 6.5 on Linux) is what I tested it on. pdcurses I have not tried but it would just be a matter of checking for regressions, as these commits in their current form cannot enable 256-colour support when only 256 colour pairs are available (which seems to be the case with pdcurses according to its documentation).

It would theoretically be possible to work even with 256 colour pairs because right now there are 16 character colours and 8 background colours, leaving 128 colour pairs to be used for a subset of extended colours with the help of some kind of colour pair allocator. I don't know if that would be worth the complexity, however.

@ars3niy

ars3niy commented May 30, 2026

Copy link
Copy Markdown
Author

The way 256 colours works in this merge request at the moment is, during initialisation 2048 colour pairs will be created for each of 256 colours and 8 background colours, without any regard for which combinations would be in use.

@ars3niy

ars3niy commented May 31, 2026

Copy link
Copy Markdown
Author

This is with pdcurses (SDL2 of Linux). The library indeed reports 256 available colour pairs so the game sticks to 16 colours.

nhcolour_pdcurses

Doktor L added 5 commits June 3, 2026 11:55
The blue background colour for piles was implemented by changing glyph
colour to curses colour pair with the desired background, and then
passed to curses_putch which takes character and background colour and
makes curses colour pair out of them once again.

Pass blue background to curses_putch instead and let it create curses
colour pair just once.
It will need another parameter for 256-colour support. To avoid having
too many arguments, put glyph colour, background colour and attributes
into a struct and, since to curses library all of that is attributes
that are handled by same function, call the struct "gryph attributes".

curses_putch was also declared in two different headers, remove one of
those declarations.
And to its inner function write_char
Keep only 8 background colours but if curses supports 256 colours and
256*8 colours pairs, create colours pairs for 256 foregrounds rather
than just 16.
Only glyphs that are customised via config can have colours different
from the basic 16. For such glyphs, when curses supports 256 colours,
use them.
@nhmall

nhmall commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

The plan is to review this pull request over the next two weeks (June 14-28). It requires testing on a few different platforms.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants