mirror of
https://github.com/VARCem/PDCurses.git
synced 2026-09-23 15:25:01 +00:00
No reason now for pair_set[] to remain separate.
This commit is contained in:
@@ -103,11 +103,8 @@ int COLOR_PAIRS = PDC_COLOR_PAIRS;
|
||||
|
||||
/* COLOR_PAIR to attribute encoding table. */
|
||||
|
||||
static struct {short f, b;} atrtab[PDC_COLOR_PAIRS];
|
||||
static struct {short f, b; bool set;} atrtab[PDC_COLOR_PAIRS];
|
||||
|
||||
/* pair_set[] tracks whether a pair has been set via init_pair() */
|
||||
|
||||
static bool pair_set[PDC_COLOR_PAIRS];
|
||||
static bool default_colors = FALSE;
|
||||
static short first_col = 0;
|
||||
|
||||
@@ -127,8 +124,6 @@ int start_color(void)
|
||||
|
||||
PDC_init_atrtab();
|
||||
|
||||
memset(pair_set, 0, PDC_COLOR_PAIRS);
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
@@ -141,6 +136,25 @@ static void _normalize(short *fg, short *bg)
|
||||
*bg = SP->orig_attr ? SP->orig_back : COLOR_BLACK;
|
||||
}
|
||||
|
||||
static void _init_pair_core(short pair, short fg, short bg)
|
||||
{
|
||||
_normalize(&fg, &bg);
|
||||
|
||||
/* To allow the PDC_PRESERVE_SCREEN option to work, we only reset
|
||||
curscr if this call to init_pair() alters a color pair created by
|
||||
the user. */
|
||||
|
||||
if (atrtab[pair].set)
|
||||
{
|
||||
if (atrtab[pair].f != fg || atrtab[pair].b != bg)
|
||||
curscr->_clear = TRUE;
|
||||
}
|
||||
|
||||
atrtab[pair].f = fg;
|
||||
atrtab[pair].b = bg;
|
||||
atrtab[pair].set = TRUE;
|
||||
}
|
||||
|
||||
int init_pair(short pair, short fg, short bg)
|
||||
{
|
||||
PDC_LOG(("init_pair() - called: pair %d fg %d bg %d\n", pair, fg, bg));
|
||||
@@ -149,21 +163,7 @@ int init_pair(short pair, short fg, short bg)
|
||||
fg < first_col || fg >= COLORS || bg < first_col || bg >= COLORS)
|
||||
return ERR;
|
||||
|
||||
_normalize(&fg, &bg);
|
||||
|
||||
/* To allow the PDC_PRESERVE_SCREEN option to work, we only reset
|
||||
curscr if this call to init_pair() alters a color pair created by
|
||||
the user. */
|
||||
|
||||
if (pair_set[pair])
|
||||
{
|
||||
if (atrtab[pair].f != fg || atrtab[pair].b != bg)
|
||||
curscr->_clear = TRUE;
|
||||
}
|
||||
|
||||
atrtab[pair].f = fg;
|
||||
atrtab[pair].b = bg;
|
||||
pair_set[pair] = TRUE;
|
||||
_init_pair_core(pair, fg, bg);
|
||||
|
||||
return OK;
|
||||
}
|
||||
@@ -241,20 +241,7 @@ int assume_default_colors(int f, int b)
|
||||
return ERR;
|
||||
|
||||
if (SP->color_started)
|
||||
{
|
||||
short fg, bg;
|
||||
|
||||
fg = f;
|
||||
bg = b;
|
||||
|
||||
_normalize(&fg, &bg);
|
||||
|
||||
if (atrtab[0].f != fg || atrtab[0].b != bg)
|
||||
curscr->_clear = TRUE;
|
||||
|
||||
atrtab[0].f = fg;
|
||||
atrtab[0].b = bg;
|
||||
}
|
||||
_init_pair_core(0, f, b);
|
||||
|
||||
return OK;
|
||||
}
|
||||
@@ -299,5 +286,6 @@ void PDC_init_atrtab(void)
|
||||
{
|
||||
atrtab[i].f = fg;
|
||||
atrtab[i].b = bg;
|
||||
atrtab[i].set = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user