tweaks: move a function, to be in the order in which they are called

In addition, rename two variables and adjust the type of one of them.
This commit is contained in:
Benno Schulenberg 2020-06-13 17:14:57 +02:00
parent 43a1756783
commit 1c8c02f63b
1 changed files with 26 additions and 25 deletions

View File

@ -41,31 +41,6 @@
static bool defaults_allowed = FALSE;
/* Whether ncurses accepts -1 to mean "default color". */
/* Assign a pair number to each of the foreground/background color combinations
* in the given syntax, giving identical combinations the same number. */
void set_syntax_colorpairs(syntaxtype *sntx)
{
int new_number = NUMBER_OF_ELEMENTS + 1;
for (colortype *ink = sntx->color; ink != NULL; ink = ink->next) {
colortype *earlier = sntx->color;
if (!defaults_allowed) {
if (ink->fg == USE_THE_DEFAULT)
ink->fg = COLOR_WHITE;
if (ink->bg == USE_THE_DEFAULT)
ink->bg = COLOR_BLACK;
}
while (earlier != ink && (earlier->fg != ink->fg || earlier->bg != ink->bg))
earlier = earlier->next;
ink->pairnum = (earlier != ink) ? earlier->pairnum : new_number++;
ink->attributes |= COLOR_PAIR(ink->pairnum) | A_BANDAID;
}
}
/* Initialize the color pairs for nano's interface. */
void set_interface_colorpairs(void)
{
@ -105,6 +80,32 @@ void set_interface_colorpairs(void)
}
}
/* Assign a pair number to each of the foreground/background color combinations
* in the given syntax, giving identical combinations the same number. */
void set_syntax_colorpairs(syntaxtype *sntx)
{
short number = NUMBER_OF_ELEMENTS;
colortype *older;
for (colortype *ink = sntx->color; ink != NULL; ink = ink->next) {
if (!defaults_allowed) {
if (ink->fg == USE_THE_DEFAULT)
ink->fg = COLOR_WHITE;
if (ink->bg == USE_THE_DEFAULT)
ink->bg = COLOR_BLACK;
}
older = sntx->color;
while (older != ink && (older->fg != ink->fg || older->bg != ink->bg))
older = older->next;
ink->pairnum = (older != ink) ? older->pairnum : ++number;
ink->attributes |= COLOR_PAIR(ink->pairnum) | A_BANDAID;
}
}
/* Initialize the color pairs for the current syntax. */
void prepare_palette(void)
{