#!/bin/bash
#
#  V1.0   20/08/2008  VK8SJ   File created to ease RSI (repeditive shell input)
#
#
##############################################################################
#
# Variable Definitions..
   ESC="\033"

#############################################################################
############################# Functions #####################################
#############################################################################
#
### CRSR and TXTCol
# 'crsr ln col'   - Cursor position (x,y)
# 'txtcol fg bg att'  - Colour of text, foreground, background, attribute
# these commands control the displays cursor via ANSI escape codes. The 
# codes control cursor position and colour, as well as screen colour.
# Errors handled by 'dummyspit 5'
#  It goes something like this....
function crsr () {
  LN=$1
  COL=$2
  if [ -z $LN ] || [ -z $COL ]; then dummyspit 5; fi
  echo -en $ESC"["$LN";"$COL"H"
}

function txtcol () {
  FG=$1
  BG=$2
  ATT=$3
#  Forground colour minimum requirement
  if [ -z $FG ]; then dummyspit 5; fi
  case $FG in
    def)      echo -en $ESC"[0m" ;;  # Default screen attributes
    red)      echo -en $ESC"[31m" ;;
    grn)      echo -en $ESC"[32m" ;;
    yel)      echo -en $ESC"[33m" ;;
    blu)      echo -en $ESC"[34m" ;;
    mag)      echo -en $ESC"[35m" ;;
    cyn)      echo -en $ESC"[36m" ;;
    wht)      echo -en $ESC"[37m" ;;
    ltred)    echo -en $ESC"[31;1m" ;;
    ltgrn)    echo -en $ESC"[32;1m" ;;
    ltyel)    echo -en $ESC"[33;1m" ;;
    ltblu)    echo -en $ESC"[34;1m" ;;
    ltmag)    echo -en $ESC"[35;1m" ;;
    ltcyn)    echo -en $ESC"[36;1m" ;;
    ltwht)    echo -en $ESC"[37;1m" ;;
    *)        echo "OH Nooooo..."
              dummyspit 5 ;;
  esac

  case $BG in
    blk)      echo -en $ESC"[40m" ;;
    red)      echo -en $ESC"[41m" ;;
    grn)      echo -en $ESC"[42m" ;;
    yel)      echo -en $ESC"[43m" ;;
    blu)      echo -en $ESC"[44m" ;;
    mag)      echo -en $ESC"[45m" ;;
    cyn)      echo -en $ESC"[46m" ;;
    wht)      echo -en $ESC"[47m" ;;
  esac

  case $ATT in
    blink)    echo -en $ESC"[5m" ;;
    bold)     echo -en $ESC"[1m" ;;
    italic)   echo -en $ESC"[3m" ;;
  esac
 
}

### End Functions
#########################################################################
