#!/bin/bash
#########################################################
# 							#
# This is BashStyle-NG  				#
#							#
# Licensed under GNU GENERAL PUBLIC LICENSE v3    	#
#							#
# Copyright 2007 - 2016 Christopher Bratusek		#
#							#
#########################################################

dbg_msg $"BashStyle-NG Setting:" Colors $"On"
dbg_msg $"BashStyle-NG Setting:" Color-Style $(ini_get color_style)

colors=(black red green yellow blue magenta cyan grey white coldblue
	smoothblue iceblue turqoise smoothgreen winered brown silver ocher
	orange purple pink cream)

ecolors=(eblack ered egreen eyellow eblue emagenta ecyan egrey ewhite ecoldblue
	esmoothblue eiceblue eturqoise esmoothgreen ewinered ebrown esilver eocher
	eorange epurple epink ecream)

color_style=$(ini_get color_style)

if [[ ${color_style} == bright ]]; then
	style="01"
elif [[ ${color_style} == normal ]]; then
	style="0"
elif [[ ${color_style} == inverted ]]; then
	style="7"
elif [[ ${color_style} == dimmed ]]; then
	style="02"
elif [[ ${color_style} == underlined ]]; then
	style="04"
fi

if [[ ${TERM} != *xterm* ]]; then
	black="\[\033[${style};30m\]"
	red="\[\033[${style};31m\]"
	green="\[\033[${style};32m\]"
	yellow="\[\033[${style};33m\]"
	blue="\[\033[${style};34m\]"
	magenta="\[\033[${style};35m\]"
	cyan="\[\033[${style};36m\]"
	grey="\[\033[${style};37m\]"
	white="\[\033[${style};97m\]"
	coldblue=${blue}
	smoothblue=${blue}
	iceblue=${blue}
	turqoise=${cyan}
	smoothgreen=${green}
	winered=${red}
	brown=${yellow}
	silver=${white}
	ocher=${yellow}
	orange=${yellow}
	purple=${magenta}
	pink=${magenta}
	cream=${magenta}

	eblack="\033[${style};30m"
	ered="\033[${style};31m"
	egreen="\033[${style};32m"
	eyellow="\033[${style};33m"
	eblue="\033[${style};34m"
	emagenta="\033[${style};35m"
	ecyan="\033[${style};36m"
	egrey="\033[${style};37m"
	ewhite="\033[${style};97m"
	ecoldblue=${eblue}
	esmoothblue=${eblue}
	eiceblue=${eblue}
	eturqoise=${ecyan}
	esmoothgreen=${egreen}
	ewinered=${ered}
	ebrown=${eyellow}
	esilver=${ewhite}
	eocher=${eyellow}
	eorange=${eyellow}
	epurple=${emagenta}
	epink=${emagenta}
	ecream=${emagenta}
else
	black="\[\033[${style};38;5;0m\]"
	red="\[\033[${style};38;5;1m\]"
	green="\[\033[${style};38;5;2m\]"
	yellow="\[\033[${style};38;5;3m\]"
	blue="\[\033[${style};38;5;4m\]"
	magenta="\[\033[${style};38;5;129m\]"
	cyan="\[\033[${style};38;5;6m\]"
	grey="\[\033[${style};38;5;7m\]"
	white="\[\033[${style};38;5;999m\]"
	coldblue="\[\033[${style};38;5;33m\]"
	smoothblue="\[\033[${style};38;5;111m\]"
	iceblue="\[\033[${style};38;5;45m\]"
	turqoise="\[\033[${style};38;5;50m\]"
	smoothgreen="\[\033[${style};38;5;42m\]"
	winered="\[\033[${style};38;5;637m\]"
	brown="\[\033[${style};38;5;684m\]"
	silver="\[\033[${style};38;5;761m\]"
	ocher="\[\033[${style};38;5;690m\]"
	orange="\[\033[${style};38;5;714m\]"
	purple="\[\033[${style};38;5;604m\]"
	pink="\[\033[${style};38;5;213m\]"
	cream="\[\033[${style};38;5;5344m\]"

	eblack="\033[${style};38;5;0m"
	ered="\033[${style};38;5;1m"
	egreen="\033[${style};38;5;2m"
	eyellow="\033[${style};38;5;3m"
	eblue="\033[${style};38;5;4m"
	emagenta="\033[${style};38;5;129m"
	ecyan="\033[${style};38;5;6m"
	egrey="\033[${style};38;5;7m"
	ewhite="\033[${style};38;5;999m"
	ecoldblue="\033[${style};38;5;33m"
	esmoothblue="\033[${style};38;5;111m"
	eiceblue="\033[${style};38;5;45m"
	eturqoise="\033[${style};38;5;50m"
	esmoothgreen="\033[${style};38;5;42m"
	ewinered="\033[${style};38;5;637m"
	ebrown="\033[${style};38;5;684m"
	esilver="\033[${style};38;5;761m"
	eocher="\033[${style};38;5;690m"
	eorange="\033[${style};38;5;714m"
	epurple="\033[${style};38;5;604m"
	epink="\033[${style};38;5;213m"
	ecream="\033[${style};38;5;5344m"
fi

if [[ $(ini_get dark_terminal) == True ]]; then
	black=${white}
	eblack=${ewhite}
else	white=${black}
	ewhite=${eblack}
fi

pcolors=(user host date time wdir font separator uptime ps ps0 ps2 ps3 ps4)

for color in ${pcolors[@]}; do
	eval color_${color}=$(ini_get color_${color})
	temp=$(ini_get color_${color})
	eval ecolor_${color}=${temp/\$/\$e}
done

for color in banner mkdir empty; do
	temp=$(ini_get color_cd_${color})
	eval ccolor_${color}=${temp/\$/\$e}
done

for color in ${ecolors[@]}; do
	export ${color}
done

unset temp colors ecolors pcolors color_style
