+
+static void upd_color(void)
+{
+ int i;
+
+ for(i=0; i<num_colors; i++) {
+ if(fgcol == colors[i].fg && bgcol == colors[i].bg) {
+ cur_pair = colors[i].pair;
+ return;
+ }
+ }
+
+ /* not found, allocate a new color pair */
+ if(num_colors >= COLORS) {
+ return;
+ }
+ i = num_colors++;
+ cur_pair = num_colors;
+
+ colors[i].fg = fgcol;
+ colors[i].bg = bgcol;
+ colors[i].pair = cur_pair;
+ init_pair(cur_pair, fgcol, bgcol);
+}