#!/vsta/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"

case "$TERM" in
mgr) : ;;
*) echo "$0 only works on mgr terminals" ; exit 1 ;;
esac

#	pop the environment stack a few times
echo -n "${ESC}p${ESC}p${ESC}p${ESC}p${ESC}p"

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

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

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

#	reset the window modes (except 8 - bury, and 3 - set)
for i in $TWENTY; do
	case $i in
	3) echo -n "${ESC}${i}S" ;;
	8) : ;;
	*) echo -n "${ESC}${i}s" ;;
	esac
done

# reset the cursor
echo -n "${ESC}0h"

# reset the font
# echo -n "${ESC}F"

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

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

#	clear the text region
echo -n "${ESC}t"

#	clear the window and home the cursor
echo -n "$CLEAR"

exit 0
