Modulo colors before comparing pairs
Otherwise a new pair is allocated every time a high color is requested.master
parent
1cf6e29fc4
commit
6e679bdf26
4
ui.c
4
ui.c
|
@ -135,12 +135,14 @@ static attr_t colorAttr(short fg) {
|
||||||
|
|
||||||
static short colorPair(short fg, short bg) {
|
static short colorPair(short fg, short bg) {
|
||||||
if (bg == -1) return 1 + fg;
|
if (bg == -1) return 1 + fg;
|
||||||
|
fg %= COLORS;
|
||||||
|
bg %= COLORS;
|
||||||
for (short pair = 17; pair < colorPairs; ++pair) {
|
for (short pair = 17; pair < colorPairs; ++pair) {
|
||||||
short f, b;
|
short f, b;
|
||||||
pair_content(pair, &f, &b);
|
pair_content(pair, &f, &b);
|
||||||
if (f == fg && b == bg) return pair;
|
if (f == fg && b == bg) return pair;
|
||||||
}
|
}
|
||||||
init_pair(colorPairs, fg % COLORS, bg % COLORS);
|
init_pair(colorPairs, fg, bg);
|
||||||
return colorPairs++;
|
return colorPairs++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue