From 43a175678395dd6f3746de2987b388abce309125 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Sat, 13 Jun 2020 14:10:25 +0200 Subject: [PATCH] tweaks: call init_pair() just once for each pair number --- src/color.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/color.c b/src/color.c index 09dc2a4b..f86f921f 100644 --- a/src/color.c +++ b/src/color.c @@ -108,11 +108,14 @@ void set_interface_colorpairs(void) /* Initialize the color pairs for the current syntax. */ void prepare_palette(void) { - const colortype *ink; + short number = NUMBER_OF_ELEMENTS; - /* For each coloring expression, initialize the color pair. */ - for (ink = openfile->syntax->color; ink != NULL; ink = ink->next) - init_pair(ink->pairnum, ink->fg, ink->bg); + /* For each unique pair number, tell ncurses the combination of colors. */ + for (colortype *ink = openfile->syntax->color; ink != NULL; ink = ink->next) + if (ink->pairnum > number) { + init_pair(ink->pairnum, ink->fg, ink->bg); + number = ink->pairnum; + } have_palette = TRUE; }