#!/bin/sh
# interface script
# by M.A.


#set -x

#-----------------
# local variables
#-----------------


#--------------------
# Select : $1=item
#--------------------

Select()
{
case $1 in
*all*) ls .. | muless;;
*)
	muless -e $0 -t $1 -b "[q]quit" $1
	;;
esac
}

#-----------------------
# reload: $1=dir $2=mesg
#-----------------------

Reload()
{
link=$1; shift
cat > /tmp/cnt <<END
:T: hypertext demo -- $link
:B: $menu 
:S: $@
END

cat $link >> /tmp/cnt

kill -10 $pid

}

#--------------
# Main
#--------------


# initialization

if [ -z "$1" ] ; then
Reload br.txt 
muless -e $0  -t "hypertext demo" -b "-enter- select the link" -x br.txt
exit
fi

# passed from muless 


pid=$2
set -- $1
key=$1; shift; shift; link="$@"
# main switch


case $key in
h)
	;;
q)
	exit
	;;

|ENTER)

	Select "$link"
	;;
esac


