diff options
author | June McEnroe <june@causal.agency> | 2020-02-05 04:24:13 -0500 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2020-02-05 04:24:13 -0500 |
commit | 6e679bdf26fa4dae651aade985155bd424761a3a (patch) | |
tree | 92eb50e7ec420e7431144e6e5246a52a5aa5344f | |
parent | Send input as raw IRC in <debug> (diff) | |
download | catgirl-6e679bdf26fa4dae651aade985155bd424761a3a.tar.gz catgirl-6e679bdf26fa4dae651aade985155bd424761a3a.zip |
Modulo colors before comparing pairs
Otherwise a new pair is allocated every time a high color is requested.
-rw-r--r-- | ui.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/ui.c b/ui.c index 12205cc..894e04d 100644 --- a/ui.c +++ b/ui.c @@ -135,12 +135,14 @@ static attr_t colorAttr(short fg) { static short colorPair(short fg, short bg) { if (bg == -1) return 1 + fg; + fg %= COLORS; + bg %= COLORS; for (short pair = 17; pair < colorPairs; ++pair) { short f, b; pair_content(pair, &f, &b); if (f == fg && b == bg) return pair; } - init_pair(colorPairs, fg % COLORS, bg % COLORS); + init_pair(colorPairs, fg, bg); return colorPairs++; } |