static int this_try_alloc_color_pair (const char *fg, const char *bg) { char f[80], b[80], *p; if (bg) if (!*bg) bg = 0; if (fg) if (!*fg) fg = 0; if (fg) { g_strlcpy (f, fg, sizeof (f)); p = strchr (f, '/'); if (p) *p = '\0'; fg = f; } if (bg) { g_strlcpy (b, bg, sizeof (b)); p = strchr (b, '/'); if (p) *p = '\0'; bg = b; } return try_alloc_color_pair (fg, bg); }
int colorer_convert_color(const StyledRegion *region) { int fg = region->bfore ? region->fore : def_fore; int bg = region->bback ? region->back : def_back; int ret = colorer_color_map[bg + (fg<<4)]; if (ret == -1){ ret = try_alloc_color_pair(win_colors[fg], win_colors[bg]); colorer_color_map[bg+(fg<<4)] = ret; CLR_TRACE("MC", "map[%s:%s - %d]=%d", win_colors[fg], win_colors[bg], bg + (fg<<4), colorer_color_map[bg + (fg<<4)]); } return ret; }