[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Issue using more than 255 color pairs
From: |
David Unterwandling |
Subject: |
Re: Issue using more than 255 color pairs |
Date: |
Mon, 17 Jul 2023 21:38:30 +0200 |
#include <curses.h>
#define BRIGHT 8
void init_colorpairs(int);
unsigned int curses_color(unsigned char, unsigned char);
int main(void)
{
register int i;
initscr();
start_color();
use_default_colors();
for (i = 0; i < 8; i++)
init_colorpairs(i);
}
static void
init_bg(int n, int f, int b)
{
if (b == COLOR_BLACK || (b % p) > BRIGHT)
init_pair(n, f, b);
if (f == COLOR_BLACK)
n -= BRIGHT;
else
n += BRIGHT;
if (f == (b - BRIGHT))
init_pair(n, -1, b);
else
init_pair(n, f|BRIGHT, b);
}
void
init_colorpairs(int i)
{
int f, b, n, o, p = 16;
f = i;
n = i|BRIGHT;
if (COLORS < 16) {
p = 8;
/* later use bold */
init_pair(n, f, -1);
} else
init_pair(n, f|BRIGHT, -1);
n = i;
init_pair(n, f, -1);
for (i = 0; i < 8; i++) {
b = i;
if (b != COLOR_BLACK) {
if (b == f)
init_pair(n, -1, b);
else
init_pair(n, f, b);
if (COLORS >= 16) {
init_bg(n, f, b);
o = p * BRIGHT - p; n += o;
init_bg(n, f, b|BRIGHT);
n -= o;
}
} else if (COLORS >= 16) {
o = p * p - p; n += o;
init_bg(n, f, b);
n -= o;
}
n += p;
}
}
unsigned int
curses_color(unsigned char f, unsigned char b)
{
int p = 16;
if (COLORS < 16)
p = 8;
if (b > 0 && f == 0)
f = b;
return f + b * p;
}
- Re: Issue using more than 255 color pairs, David Unterwandling, 2023/07/15
- Re: Issue using more than 255 color pairs, David Unterwandling, 2023/07/15
- Re: Issue using more than 255 color pairs, Bill Gray, 2023/07/16
- Re: Issue using more than 255 color pairs, Thomas Dickey, 2023/07/16
- Re: Issue using more than 255 color pairs, Dennis Clarke, 2023/07/16
- Re: Issue using more than 255 color pairs, William McBrine, 2023/07/16
- Re: Issue using more than 255 color pairs, Bill Gray, 2023/07/16
- Re: Issue using more than 255 color pairs, Mike Gran, 2023/07/16
- Re: Issue using more than 255 color pairs, Bill Gray, 2023/07/17
- Re: Issue using more than 255 color pairs, Mike Gran, 2023/07/17
- Re: Issue using more than 255 color pairs, Bill Gray, 2023/07/19
Re: Issue using more than 255 color pairs, David Unterwandling, 2023/07/15