xaizek / vifm (License: GPLv2+) (since 2018-12-07)
Vifm is a file manager with curses interface, which provides Vi[m]-like environment for managing objects within file systems, extended with some useful ideas from mutt.
<root> / tests / colmgr / suite.c (5860a577f6fdf24eea496570d5e3aacd37a71007) (1,168B) (mode 100644) [raw]
#include <stic.h>

#include "../../src/ui/color_manager.h"
#include "../../src/utils/macros.h"

#include "test.h"

static int init_pair(int pair, int f, int b);
static int pair_content(int pair, int *f, int *b);
static int pair_in_use(int pair);
static void pair_moved(int from, int to);

int colors[TOTAL_COLOR_PAIRS][3];

DEFINE_SUITE();

SETUP()
{
	colmgr_reset();
}

SETUP_ONCE()
{
	const colmgr_conf_t colmgr_conf =
	{
		.max_color_pairs = ARRAY_LEN(colors),
		.max_colors = 8,
		.init_pair = &init_pair,
		.pair_content = &pair_content,
		.pair_in_use = &pair_in_use,
		.pair_moved = &pair_moved,
	};
	colmgr_init(&colmgr_conf);
}

static int
init_pair(int pair, int f, int b)
{
	colors[pair][0] = f;
	colors[pair][1] = b;
	colors[pair][2] = (f == INUSE_SEED);
	return 0;
}

static int
pair_content(int pair, int *f, int *b)
{
	*f = colors[pair][0];
	*b = colors[pair][1];
	return 0;
}

static int
pair_in_use(int pair)
{
	return colors[pair][2];
}

static void
pair_moved(int from, int to)
{
	colors[to][2] = 1;
	colors[from][2] = 0;
}

/* vim: set tabstop=2 softtabstop=2 shiftwidth=2 noexpandtab cinoptions-=(0 : */
/* vim: set cinoptions+=t0 filetype=c : */
Hints

Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/vifm

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/vifm

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master