#!/bin/bash
##################################################################################
## Bashish, a console theme engine
## Copyright (C) 2010 Thomas Eriksson
##
## This program is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public License
## as published by the Free Software Foundation; either version 2
## of the License, or (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
## GNU General Public License for more details.
## 
##
## along with this program; if not, write to the Free Software
## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
##################################################################################
##
## _bashish_prompt_parsecolors is a theme helper
## translate color names to ansi color numbers (not foreground, background nor attributes)
##
## BASHISH_COLOR0
## ..
## BASHISH_COLORn
##
## where n is an arbitary number of colors
##
##################################################################################

function _bashish_prompt_parsecolors
{
	local i=0 c=""
	for ARG in "$@"
	do
		test $i -gt 0 && printf ";"
		case "${ARG}" in
		black) c=0;;
		red) c=1;;
		green) c=2;;
		yellow) c=3;;
		blue) c=4;;
		magenta) c=5;;
		cyan) c=6;;
		white) c=7;;
		esac
		eval printf \"local BASHISH_COLOR${i}=$c\";let i++
	done
}

test x$BASHISH_FNLOAD != x1 && _bashish_prompt_parsecolors "$@"
