#!/usr/bin/zsh
# Display all available color combinations
# (bold/non-bold foreground on backgrounds)

autoload -U colors && colors

local -a bgs
if [[ $1 != "" ]]; then
	bgs=($1)
else
	# bgs=(${(k)bg})
	bgs=("-" 0 1 2 3 4 5 6 7)
fi


for b in $bgs; do
	if (( $#bgs > 1 )); then
		echo "bg: $b"
	fi
	for c in {0..7}; do
		[[ $b != "-" ]] && tput setab $b
		print -n "\x1b[$((c+30))m"   ${(l.$((COLUMNS/2-1)).):-"$c:${color[$((c+30))]}"}
		print -n "\x1b[$((c+30));1m" ${(r.$((COLUMNS/2-1)).):-"$((c+8)):${color[$((c+30))]}"}
		print -P %{${reset_color}%}
	done

	echo "== EXTENDED (base16) =="
	for c in {16..18}; do
		[[ $b != "-" ]] && tput setab $b
		tput setaf $c
		print -n " ${(l.$((COLUMNS/2-1)).):-"$c:base16-$c"} "
		tput setaf $((c+3))
		print -n ${(r.$((COLUMNS/2-1)).):-"$((c+3)):base16-$((c+3))"}
		print -P %{${reset_color}%}
	done
done