Combine three arguments of curses_putch into one

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.
This commit is contained in:
Doktor L
2026-06-19 16:36:27 +02:00
committed by Patric Mueller
parent 24adb1c592
commit f3d292e111
4 changed files with 26 additions and 30 deletions
+13 -14
View File
@@ -7,6 +7,7 @@
#include "hack.h"
#include "color.h"
#include "wincurs.h"
#include "curswins.h"
#ifdef CURSES_UNICODE
#include <locale.h>
#endif
@@ -939,17 +940,16 @@ curses_print_glyph(
{
int glyph;
int ch;
int color;
int framecolor;
struct glyph_attributes attr;
int nhcolor = 0;
unsigned int special;
int attr = -1;
attr.attribute_flags = -1;
glyph = glyphinfo->glyph;
special = glyphinfo->gm.glyphflags;
ch = glyphinfo->ttychar;
color = glyphinfo->gm.sym.color;
framecolor = bkglyphinfo->framecolor;
attr.color = glyphinfo->gm.sym.color;
attr.framecolor = bkglyphinfo->framecolor;
/* Extra color handling
* FIQ: The curses library does not support truecolor, only the more limited 256
* color mode. On top of this, the windowport only supports 16 color mode.
@@ -958,7 +958,7 @@ curses_print_glyph(
if (glyphinfo->gm.customcolor != 0
&& (curses_procs.wincap2 & WC2_EXTRACOLORS) != 0) {
if ((glyphinfo->gm.customcolor & NH_BASIC_COLOR) != 0) {
color = COLORVAL(glyphinfo->gm.customcolor);
attr.color = COLORVAL(glyphinfo->gm.customcolor);
#if 0
} else {
/* 24-bit color, NH_BASIC_COLOR == 0 */
@@ -967,10 +967,10 @@ curses_print_glyph(
}
}
if ((special & MG_PET) && iflags.hilite_pet) {
attr = curses_convert_attr(iflags.wc2_petattr);
attr.attribute_flags = curses_convert_attr(iflags.wc2_petattr);
}
if ((special & MG_DETECT) && iflags.use_inverse) {
attr = A_REVERSE;
attr.attribute_flags = A_REVERSE;
}
if (SYMHANDLING(H_DEC))
ch = curses_convert_glyph(ch, glyph);
@@ -983,9 +983,9 @@ curses_print_glyph(
*/
if ((special & MG_OBJPILE) && iflags.hilite_pile) {
if (iflags.wc_color)
framecolor = CLR_BLUE;
attr.framecolor = CLR_BLUE;
else /* if (iflags.use_inverse) */
attr = A_REVERSE;
attr.attribute_flags = A_REVERSE;
}
/* water and lava look the same except for color; when color is off
(checked by core), render lava in inverse video so that it looks
@@ -994,11 +994,11 @@ curses_print_glyph(
if ((special & (MG_BW_LAVA | MG_BW_ICE | MG_BW_SINK | MG_BW_ENGR))
!= 0 && iflags.use_inverse) {
/* reset_glyphmap() only sets MG_BW_foo if color is off */
attr = A_REVERSE;
attr.attribute_flags = A_REVERSE;
}
/* highlight female monsters (wizard mode option) */
if ((special & MG_FEMALE) && wizard && iflags.wizmgender) {
attr = A_REVERSE;
attr.attribute_flags = A_REVERSE;
}
}
@@ -1008,8 +1008,7 @@ curses_print_glyph(
&& glyphinfo->gm.u && glyphinfo->gm.u->utf8str)
? glyphinfo->gm.u : NULL,
#endif
(nhcolor != 0) ? nhcolor : color,
framecolor, attr);
&attr);
}