#!/usr/bin/env bash

# Test the bash color library

# source in the color library
# place libcolor.bash file in your $PATH or put the full path to the file here
#
  . $HOME/bin/library.bash/libcolor.bash
  
  # show the version of this library
  echo
  _libcolor_version
  echo
  
  #access colors directly
  echo -e "Hi my name is ${magenta}magenta!${resetall}"
  echo -e "Hello ${magenta}magenta${resetall}, my name is ${green}green${resetall}."
  echo -e "${bold}I am bold.${resetall}I am NOT bold"
  echo -e "${italics}Italics here.${resetitalics}But no italics now"

  
  echo
  
    # mix a function and direct text effects
  _colortext16 green  "${bold}Bold green.${resetall}${green}Not bold green"
  _colortext16 "blue" "${bold}${underline}Blue bold underlined"
  _colortext16 red    "${underline}Underline red. ${resetunderline}No underline but still red"
  _colortext16 cyan   "${blink}Blinking${resetblink} Not blinking."
  _colortext16 yellow "${dim}I am dim. Ha ha.${resetdim}I am NOT dim."
  _colortext16 lgrey  "${reverse}Reversed${resetreverse}. But not now."
  _colortext16 blue   "My password is: ${hidden}1234${resethidden}5678"
  
  echo

  # use a function for the first 8 colors
  _colortext16 black    "Hello black"
  _colortext16 red      "Hello red"
  _colortext16 green    "Hello green"
  _colortext16 yellow   "Hello yellow"
  _colortext16 blue     "Hello blue"
  _colortext16 magenta  "Hello magenta"
  _colortext16 cyan     "Hello cyan"
  _colortext16 "cyan"   "Hellow cyan again"
  _colortext16 lgrey    "Hello light grey"
  _colortext16 dgrey    "Hello dark grey"
  _colortext16 lred     "Hello light red"
  _colortext16 lgreen   "Hello light green"
  _colortext16 lyellow  "Hello light yellow"
  _colortext16 lblue    "Hello light blue"
  _colortext16 lmagenta "Hello light magenta"
  _colortext16 lcyan    "Hello light cyan"
  _colortext16 white    "Hello white"
  
  _colortext16 red     "Red text, ${resetfg}but now white"
  
  echo
  
  _colorbackground16 black    "Black background"
  _colorbackground16 red      "Red background"
  _colorbackground16 "red"    "Red background again"
  _colorbackground16 green    "Green background"
  _colorbackground16 yellow   "Yellow background"
  _colorbackground16 blue     "Blue background"
  _colorbackground16 magenta  "Magenta background"
  _colorbackground16 cyan     "Cyan background"
  _colorbackground16 lgrey    "Lightgrey background"
  _colorbackground16 dgrey    "Dark grey background"
  _colorbackground16 lred     "Light red background"
  _colorbackground16 lgreen   "Light green background"
  _colorbackground16 lyellow  "Light yellow background"
  _colorbackground16 lblue    "Light blue background"
  _colorbackground16 lmagenta "Light magenta background"
  _colorbackground16 lcyan    "Light cyan background"
  _colorbackground16 white    "White background"
  
  _colorbackground16 blue    "Blue background,${resetbg} but not blue now"  
  
  echo
  
  _colorfgbg256 blue lgreen   "Hello blue text with light green background"
  _colorfgbg256 green lblue   "Green text with light blue background"
  _colorfgbg256 "lred" white  "Light red text with white background"
  _colorfgbg256 lblue "dgrey" "Light blue text with dark grey background"
  _colorfgbg256 "red" "green" "Ugly Colors" #yes they are ugly
  
  echo
  
  echo "Lets check some error conditions..."
  
  echo "Uncomment to see _colorfgbg256 errors"
  
  #_colorfgbg256 red "hello there"           #error, unknown background
  #_colorfgbg256 "hi there" blue             #error, unknown foreground and no background
  #_colorfgbg256 red blue                    #echo 1 line
  
  echo "Uncomment to see _colortext16 errors"
  
  # check the case catchall for text colors
  #_colortext16               #function will return
  #_colortext16 ugly ""       #error
  #_colortext16 red           #echo 1 line
  #_colortext16 blue ""       #echo 1 line
  #_colortext16 "" scary      #error
  #_colortext16 one two three #function will return

  echo "Uncomment to see _colorbackground16 errors"
  
  # check the case catchall for background colors
  #_colorbackground16               #function will return
  #_colorbackground16 uglybg ""     #error
  #_colorbackground16 red           #echo 1 line
  #_colorbackground16 blue          #echo 1 line
  #_colorbackground16 "" scarybg    #error
  #_colorbackground16 one two three #function will return

  echo
  
  # check tput colors. tput colors don't need -e with echo command
  echo "${tblue}tput blue text"
  echo "${tblue_bold}tput bold tput blue text${tresetall}"
  echo "${tgreen}tput green text"
  echo "${tgreen_bold}tput bold tput green text${tresetall}"
  echo "${tlightblue}tput lightblue text"
  echo "${tpurple}tput purple text"
  echo -e "${underline}This text should be purple${torange}tput orange text${resetall}"
  echo "${tbold}${torange}tput bold tput orange text${tresetall}"
  echo "${tred}tput red text"
  echo "${tred_bold}tput bold tput red text${tresetall}"
  echo "${tyellow}tput yellow text"
  echo "${tbold}${tyellow}tput bold tput yellow text${tresetall}"
  echo "${twhite}tput white text"
  echo "${twhite_bold}tput bold tput white text${tresetall}"
  
  echo
  
  echo "${tblue_bg}tput blue background${tresetall}"
  echo "${tgreen_bg}tput green background${tresetall}"
  echo "${twhite_bold}${tred_bg}tput white bold text with tput red background${tresetall}"
  echo "${tmagenta_bg}tput magenta background${tresetall}"
  
  echo
  
  # if mixing regular colors with tput you still need -e for 
  # echo to process the escape sequence. If all colors used
  # are tput colors, you don't need the -e
  echo -e "${red}Red${resetall} and ${tblue}tput blue${tresetall}."
  echo "${tpurple}${twhite_bg}tput purple and tput white background${tresetall}"
  echo "${tblue_bg}${tgold}Nice Comination.${tresetall}" 
  
  echo
  
  echo "Use _colortable function to see color chart"
  #_colortable
  echo
  _howmanycolors

