#!/bin/sh

# clear screen
# gets size of the region to be cleared from an stty call
# so as not to interfere with status lines and the like.

function parse()
{
	ROWS=$1
	COLS=$2
}

parse `stty size`

if [ ${ROWS} -eq 25 ]
then
	# optimization: assume entire screen if rows equals 25, ergo ...
	# quick clear screen
	echo -en "\033c"		 # or tput clear, etc.
else
	# clear screen as a scroll region
	echo -en "\033[${ROWS};${COLS}H" # position cursor at end scroll region
	echo -en "\033[1J"		 # clear from start of screen to cursor
	echo -en "\033[H"		 # home cursor
fi
