Add support for 256 colours in curses window port#1561
Conversation
|
Have the changes in win/curses been tested on pdcurses as well as ncurses? |
|
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. |
|
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. |
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.
|
The plan is to review this pull request over the next two weeks (June 14-28). It requires testing on a few different platforms. |


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.