// vim:fileencoding=utf-8:foldmethod=marker

#include "../../../../common/aliases/aliases.h"
#include "../../../../common/platform/platform.h"
#include "../../../../base/strings/str8/str8.h"

#ifdef WP_PLATFORM_POSIX

#include "../terminal_colours.h"
#include <stdio.h>

wp_intern WpStr8RO colours[COUNT_TERM_COLOUR] = {
	[WP_TERM_COLOUR_FG_BLACK]      = wpStr8LitRoInitialiserList("\033[30m"),
	[WP_TERM_COLOUR_FG_RED]        = wpStr8LitRoInitialiserList("\033[31m"),
	[WP_TERM_COLOUR_FG_GREEN]      = wpStr8LitRoInitialiserList("\033[32m"),
	[WP_TERM_COLOUR_FG_BLUE]       = wpStr8LitRoInitialiserList("\033[34m"),
	[WP_TERM_COLOUR_FG_CYAN]       = wpStr8LitRoInitialiserList("\033[36m"),
	[WP_TERM_COLOUR_FG_MAGENTA]    = wpStr8LitRoInitialiserList("\033[35m"),
	[WP_TERM_COLOUR_FG_YELLOW]     = wpStr8LitRoInitialiserList("\033[33m"),
	[WP_TERM_COLOUR_FG_WHITE]      = wpStr8LitRoInitialiserList("\033[37m"),
	[WP_TERM_COLOUR_FG_BR_BLACK]   = wpStr8LitRoInitialiserList("\033[90m"),
	[WP_TERM_COLOUR_FG_BR_RED]     = wpStr8LitRoInitialiserList("\033[91m"),
	[WP_TERM_COLOUR_FG_BR_GREEN]   = wpStr8LitRoInitialiserList("\033[92m"),
	[WP_TERM_COLOUR_FG_BR_BLUE]    = wpStr8LitRoInitialiserList("\033[94m"),
	[WP_TERM_COLOUR_FG_BR_CYAN]    = wpStr8LitRoInitialiserList("\033[96m"),
	[WP_TERM_COLOUR_FG_BR_MAGENTA] = wpStr8LitRoInitialiserList("\033[95m"),
	[WP_TERM_COLOUR_FG_BR_YELLOW]  = wpStr8LitRoInitialiserList("\033[93m"),
	[WP_TERM_COLOUR_FG_BR_WHITE]   = wpStr8LitRoInitialiserList("\033[97m"),
	[WP_TERM_COLOUR_CLEAR]         = wpStr8LitRoInitialiserList("\033[0m"),
};

void _printColouredText(WpStr8RO *text, WpTerminalColour colour) {
	printf(WP_STR8_SPEC WP_STR8_SPEC, wpStr8Varg(colours[colour]), wpStr8Varg((*text)));
}

#endif // !WP_PLATFORM_POSIX
