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

enable_colors=True

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

colstyle=$(ini_get color_style)

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

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

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

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

eval usercolor=$(ini_get color_user)
eval hostcolor=$(ini_get color_host)
eval datecolor=$(ini_get color_date)
eval timecolor=$(ini_get color_time)
eval wdircolor=$(ini_get color_wdir)
eval fontcolor=$(ini_get color_font)
eval sepacolor=$(ini_get color_separator)
eval upcolor=$(ini_get color_uptime)
eval pscolor=$(ini_get color_ps)
eval ps2color=$(ini_get color_ps2)
eval ps3color=$(ini_get color_ps3)
eval ps4color=$(ini_get color_ps4)

eusercolor=$(echo ${usercolor}| sed -e 's/\\\[//g;s/\\\]//g')
ehostcolor=$(echo ${hostcolor} | sed -e 's/\\\[//g;s/\\\]//g')
edatecolor=$(echo ${datecolor} | sed -e 's/\\\[//g;s/\\\]//g')
etimecolor=$(echo ${timecolor} | sed -e 's/\\\[//g;s/\\\]//g')
ewdircolor=$(echo ${wdircolor} | sed -e 's/\\\[//g;s/\\\]//g')
efontcolor=$(echo ${fontcolor} | sed -e 's/\\\[//g;s/\\\]//g')
esepacolor=$(echo ${sepacolor} | sed -e 's/\\\[//g;s/\\\]//g')
eupcolor=$(echo ${upcolor} | sed -e 's/\\\[//g;s/\\\]//g')
epscolor=$(echo ${pscolor} | sed -e 's/\\\[//g;s/\\\]//g')
eps2color=$(echo ${ps2color} | sed -e 's/\\\[//g;s/\\\]//g')
eps3color=$(echo ${ps3color} | sed -e 's/\\\[//g;s/\\\]//g')
eps4color=$(echo ${ps4color} | sed -e 's/\\\[//g;s/\\\]//g')
