#!/bin/sh
 
 # g_palet
 # =======

 # This file is part of Gerolf Markup Shredder,
 # written by G. D. Brettschneider (1999-2006).
  
 GMSdateG_PALET=20060927
 
 # Prologue: ==================================================================
 
 # Not running:
 
 if [ "$GMS_SHELL" = "" ]; then
   echo "This is Gerolf Markup Shredder (g_palet)."
   exit
 fi 
 
 # Debug: ---------------------------------------------------------------------
   
 if [ "$GMS_DEBUG" = "X" -o "$GMS_DEBUG" = "Y" ]; then
   source "$GMS_SHELL/l_banner" -debug g_palet $1 $2 $3 $4
 elif  [ "$GMS_DEBUG" = "Z" ]; then
   echo " g_palet ($1) ($2) ($3) ($4) ($5) ($6) ($7) ($8) ($9)" >> "$Z"
 fi
 
 # Chapters: ==================================================================
   
 # Not defined:
 
 if [ "$1" = "" ]; then source "$GMS_SHELL/l_banner" -no_action g_palet
   
 # Build: ---------------------------------------------------------------------
   
 elif [ $1 = -build -o $1 = -rebuild ]; then
   source "$GMS_SHELL/g_palet" -handle \
   $REPLY_DESKTOP $REPLY_PATTERN $REPLY_BANNER \
   $REPLY_TEXT $REPLY_SHADE $REPLY_HOTKEY \
   $REPLY_LETTER
   source "$GMS_SHELL/l_desk" -build 
   if [ "$GMS_RETURN" = "" ]; then
     export REPLY_MODULE=g_wel 
     export REPLY_ACTION=-remove 
     source "$GMS_SHELL/g_wel" -resize 
     source "$GMS_SHELL/g_wel" -build 
     export GMS_RECEIVE=1 
   else
     GMS_RETURN=1     
     if [ "$GMS_FILE" = "" ]; then
       source "$GMS_SHELL/l_banner" -upper -first
     else
       source "$GMS_SHELL/l_banner" -upper -file
     fi
     source "$GMS_SHELL/l_banner" -lower -folder
     source "$GMS_SHELL/g_menu" -build
   fi
   
 # Handle: --------------------------------------------------------------------
   
 elif [ $1 = -handle ]; then
 
 # Check if color values are acceptable: --------------------------------------
   
 # 2) Background (desktop) color:
   BACKUP=$GMS_DESKTOP
   export GMS_DESKTOP="R"
   case "$BACKUP" in
     "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" )
       export REPLY_DESKTOP=$BACKUP
       export GMS_DESKTOP=$BACKUP;;
     "R" | "r" ) #export REPLY_DESKTOP=$2;;
       case "$2" in
         "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" )     
           export REPLY_DESKTOP=$2;;
       esac
   esac 
   
 # 3) Foreground (pattern) color:
   BACKUP=$GMS_PATTERN
   export GMS_PATTERN="R"
   case "$BACKUP" in
     "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | \
     "8" | "9" | "10" | "11" | "12" | "13" | "14" | "15" )
       export REPLY_PATTERN=$BACKUP
       export GMS_PATTERN=$BACKUP;;
   "R" | "r" ) # export REPLY_PATTERN=$3;;
       case "$3" in
         "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | \
         "8" | "9" | "10" | "11" | "12" | "13" | "14" | "15" )     
           export REPLY_PATTERN=$3;;
       esac
   esac 
   
 # 4) Banner color:
   BACKUP=$GMS_BANNER
   export GMS_BANNER="R"
   case "$BACKUP" in
     "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" )
       export REPLY_BANNER=$BACKUP
       export GMS_BANNER=$BACKUP;;
     "R" | "r" ) # export REPLY_BANNER=$4;;
       case "$4" in
         "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" )     
           export REPLY_BANNER=$4;;
       esac
   esac 
   
 # 5) Text color:
   BACKUP=$GMS_TEXT
   export GMS_TEXT="R"
   case "$BACKUP" in
     "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | \
     "8" | "9" | "10" | "11" | "12" | "13" | "14" | "15" )
       export REPLY_TEXT=$BACKUP
       export GMS_TEXT=$BACKUP;;
     "R" | "r" ) # export REPLY_TEXT=$5;;
       case "$5" in
         "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | \
         "8" | "9" | "10" | "11" | "12" | "13" | "14" | "15" )     
           export REPLY_TEXT=$5;;
       esac
   esac
   
 # 6) Shadow color:
   BACKUP=$GMS_SHADE 
   export GMS_SHADE="R"
   case "$BACKUP" in
     "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" )
       export REPLY_SHADE=$BACKUP
       export GMS_SHADE=$BACKUP;;
     "R" | "r" ) # export REPLY_SHADE=$6;;
       case "$6" in
         "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" )     
           export REPLY_SHADE=$6;;
       esac
   esac 
   
 # 7) Hotkey color:
   BACKUP=$GMS_HOTKEY
   export GMS_HOTKEY="R"
   case "$BACKUP" in
     "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | \
     "8" | "9" | "10" | "11" | "12" | "13" | "14" | "15" )
       export REPLY_HOTKEY=$BACKUP
       export GMS_HOTKEY=$BACKUP;;
     "R" | "r" ) # export REPLY_HOTKEY=$7;;
       case "$7" in
         "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | \
         "8" | "9" | "10" | "11" | "12" | "13" | "14" | "15" )     
           export REPLY_HOTKEY=$7;;
       esac
   esac 
   
 # 8) Fill pattern character:
   BACKUP=$GMS_LETTER
   export GMS_LETTER="R"
   case "$BACKUP" in
     "32" | "33" | "34" | "35" | "36" | "37" | "38" | "39" | \
     "40" | "41" | "42" | "43" | "44" | "45" | "46" | "47" | \
     "48" | "49" | "50" | "54" | "52" | "53" | "54" | "55" | \
     "56" | "57" | "58" | "59" | "60" | "61" | "62" | "63" | \
     "64" | "65" | "66" | "67" | "68" | "69" | "70" | "71" | \
     "72" | "73" | "74" | "75" | "76" | "77" | "78" | "79" | \
     "80" | "81" | "82" | "83" | "84" | "85" | "86" | "87" | \
     "88" | "89" | "90" | "91" | "92" | "93" | "94" | "95" | \
     "96" | "97" | "98" | "99" | "100" | "101" | "102" | "103" | \
     "104" | "105" | "106" | "107" | "108" | "109" | "110" | "111" | \
     "112" | "113" | "114" | "115" | "116" | "117" | "118" | "119" | \
     "120" | "121" | "122" | "123" | "124" | "125" | "126" )
       export REPLY_LETTER=$BACKUP
       export GMS_LETTER=$BACKUP;;
     "R" | "r" ) export REPLY_LETTER=$8;;
   esac 
   BACKUP=
   export GMS_RECEIVE=1
   
 # Not found: -----------------------------------------------------------------
 
 else
   source "$GMS_SHELL/l_banner" -no_action g_palet $1   
 fi
 
 # Background colors:
 
   # 0 black
   # 1 blue 
   # 2 green
   # 3 cyan
 
   # 4 red
   # 5 magenta
   # 6 brown
   # 7 lightgray
 
 # Additional foreground colors:
 
   # 8 darkgray
   # 9 lightblue
   # 10 lightgreen
   # 11 lightcyan
 
   # 12 lightred
   # 13 lightmagenta
   # 14 yellow
   # 15 white 
