#!/bin/sh
#                        Copyright (c) 1990 Bellcore
#                            All Rights Reserved
#       Permission is granted to copy or use this program, EXCEPT that it
#       may not be sold for profit, the copyright notice must be reproduced
#       on copies, and credit should be given to Bellcore where it is due.
#       BELLCORE MAKES NO WARRANTY AND ACCEPTS NO LIABILITY FOR THIS PROGRAM.

#	reset the mgr window state

ESC=""
CLEAR=""
TWENTY="0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20"

if [ `echo $TERM | sed 's/-.*//'` != mgr ]
then
   echo "$0 only works on mgr terminals"
   exit 1
fi

#	pop the environment stack a few times
echo "${ESC}p${ESC}p${ESC}p${ESC}p${ESC}p\\c"

# clear the events
for i in $TWENTY; do
	echo "${ESC}${i}e\\c"
done

# clear some menus
for i in $TWENTY; do
	echo "${ESC}${i}m\\c"
done

# clear some bitmaps
for i in $TWENTY; do
	echo "${ESC}${i}b\\c"
done

#	reset the window modes (except 8 - bury, and 3 - set)
for i in $TWENTY; do
	if /bin/test $i = 3 
		then
		echo "${ESC}${i}S\\c"
	elif /bin/test $i != 8 
		then
		echo "${ESC}${i}s\\c"
	fi
done

# reset the cursor
echo "${ESC}0h\\c"

# reset the font
# echo "${ESC}F\\c"

# reset the video mode
echo "${ESC}n\\c"

# reset the drawing mode (to OR)
echo "${ESC}14b\\c"

#	clear the text region
echo "${ESC}t\\c"

#	clear the window and home the cursor
echo "$CLEAR\\c"
