From 24adb1c592a306b67fbb3fa928fbe2fb5497ae79 Mon Sep 17 00:00:00 2001 From: Doktor L Date: Sat, 30 May 2026 18:03:20 +0200 Subject: [PATCH] curses: use existing background parameter for pile 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. --- include/wincurs.h | 1 - win/curses/cursmain.c | 6 ++++-- win/curses/curswins.c | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/include/wincurs.h b/include/wincurs.h index 0911cf11c..aea0e9ebf 100644 --- a/include/wincurs.h +++ b/include/wincurs.h @@ -145,7 +145,6 @@ extern void curses_puts(winid wid, int attr, const char *text); extern void curses_clear_nhwin(winid wid); extern void curses_alert_win_border(winid wid, boolean onoff); extern void curses_alert_main_borders(boolean onoff); -extern int get_framecolor(int nhcolor, int framecolor); extern void curses_draw_map(int sx, int sy, int ex, int ey); extern boolean curses_map_borders(int *sx, int *sy, int *ex, int *ey, int ux, int uy); diff --git a/win/curses/cursmain.c b/win/curses/cursmain.c index 448d8c77d..ee45eb059 100644 --- a/win/curses/cursmain.c +++ b/win/curses/cursmain.c @@ -940,6 +940,7 @@ curses_print_glyph( int glyph; int ch; int color; + int framecolor; int nhcolor = 0; unsigned int special; int attr = -1; @@ -948,6 +949,7 @@ curses_print_glyph( special = glyphinfo->gm.glyphflags; ch = glyphinfo->ttychar; color = glyphinfo->gm.sym.color; + 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. @@ -981,7 +983,7 @@ curses_print_glyph( */ if ((special & MG_OBJPILE) && iflags.hilite_pile) { if (iflags.wc_color) - color = get_framecolor(color, CLR_BLUE); + framecolor = CLR_BLUE; else /* if (iflags.use_inverse) */ attr = A_REVERSE; } @@ -1007,7 +1009,7 @@ curses_print_glyph( ? glyphinfo->gm.u : NULL, #endif (nhcolor != 0) ? nhcolor : color, - bkglyphinfo->framecolor, attr); + framecolor, attr); } diff --git a/win/curses/curswins.c b/win/curses/curswins.c index 21e1bae09..50f8f171c 100644 --- a/win/curses/curswins.c +++ b/win/curses/curswins.c @@ -763,7 +763,7 @@ is_main_window(winid wid) coordinates without a refresh. Currently only used for the map. */ /* convert nhcolor (fg) and framecolor (bg) to curses colorpair */ -int +static int get_framecolor(int nhcolor, int framecolor) { /* curses_toggle_color_attr() adds the +1 and takes care of COLORS < 16 */