Beispiel #1
0
/* Tries to find pair with specified colors among already allocated pairs.
 * Returns -1 when search fails. */
static int
find_pair(int fg, int bg)
{
	int i;

	for(i = 0; i < DCOLOR_BASE + MAXNUM_COLOR; i++)
	{
		if(color_pair_matches(i, fg, bg))
		{
			return i;
		}
	}

	for(i = 0; i < avail_pairs; i++)
	{
		if(get_bit(color_pair_map, i))
		{
			if(color_pair_matches(FCOLOR_BASE + i, fg, bg))
			{
				break;
			}
		}
	}
	return (i < avail_pairs) ? (FCOLOR_BASE + i) : -1;
}
/* Tries to find pair with specified colors among already allocated pairs.
 * Returns -1 when search fails. */
static int
find_pair(int fg, int bg)
{
	int i;

	for(i = PREALLOCATED_COUNT; i < used_pairs; ++i)
	{
		if(color_pair_matches(i, fg, bg))
		{
			return i;
		}
	}

	return -1;
}