<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">
i have a client who i'm trying to convince to use perl for general programming
tasks inside their office. they are stranded in the world of MSDOS so i've
had to be creative about making perl visually attractive.

this code should work on any VT-100 or similar terminal for UNIX boxes, or
with ANSI.SYS loaded on MSDOS. 

&lt;-- snip snip ---- cur.pl ------------------------------------------------&gt;
# curses-style cusror control for ANSI screens
# window-like primatives
# april 1993, vic spicer (vspicer@ccu.umanitoba.ca)

# clear screen
sub CLS { print "\e[;H\e[2J"; }

# inverse screen
sub INVERSE { print "\e[7m"; }

# normal screen
sub NORMAL { print "\e[0m"; }

# erase line
sub EL { print "\e[K"; }

# position cursor (y,x) 
sub CPOS { local($y,$x)=@_; print "\e[$y;$x"; print "H"; }

# make box (upper left y, upper left x, lower right y, lower right x,
#		title)
sub BOX
{
	local($y1,$x1,$y2,$x2,$title)=@_;
	local($lines)=$x2-$x1;	
	local($j);	
	&amp;CPOS($y1,$x1); &amp;INVERSE; 
	print "["; print "-" x ($lines-1); print "]";
	for ($j=$y1+1;$j&lt;$y2;$j++)
	{ &amp;CPOS($j,$x1); print "|"; &amp;NORMAL;
	print " " x ($lines-1) ; &amp;INVERSE; print "|"; }
	&amp;CPOS($y2,$x1); print "["; print "-" x ($lines-1); print "]";
	&amp;NORMAL;
	&amp;CPOS($y1,$x1+5); print $title;
}

# erase box (upper left y, upper left x, lower right y, lower right x)
sub UNBOX
{
	local($y1,$x1,$y2,$x2)=@_;
	local($j);
	for ($j=$y1;$j&lt;=$y2;$j++)
	{ &amp;CPOS($j,$x1); print " " x ($x2-$x1); }
}

# put message (upper left y, upper left x, message);
sub MSG
{
	local($y1,$x1,$mess)=@_;
	&amp;BOX($y1,$x1,$y1+2,$x1+length($mess)+1);
	&amp;CPOS($y1+1,$x1+1); print $mess;
}

# put many lines to window (upper left y, upper left x, x-width, 
#	array of lines)
sub TEXT
{
	local($y1,$x1,$wide,@mess)=@_;
	local($j);
	&amp;BOX($y1,$x1,$y1+2+$#mess,$x1+$wide);
	for ($j=0;$j&lt;=$#mess;$j++)
	{
		&amp;CPOS($y1+1+$j,$x1+1); print $mess[$j];
	}
}

# get many lines from window (upper left y, upper left x, x-width, lines)
sub MLINES
{
	local($y1,$x1,$wide,$lin,$title)=@_;
	local($j,@line);
	&amp;BOX($y1,$x1,$y1+2+$lin,$x1+$wide,$title);
	for ($j=0;$j&lt;=$lin;$j++)
	{
		&amp;CPOS($j+$y1+1,$x1+1); print "&gt;"; $moo=&lt;&gt;; chop($moo);
		$line[$j]=$moo;
	}
	return @line;
}

# get input in window (upper left y, upper left x, prompt, length of input,
#		default input)
sub INPUT
{
	local($y1,$x1,$mess,$length,$default)=@_;
	local($mess2)=$mess . $default . (" " x ($length-length($default)));
	&amp;MSG($y1,$x1,$mess2);
	&amp;CPOS($y1+1,$x1+length($mess)+1);
	local($d);	
	$d=&lt;&gt;; chop($d);
	if ($d eq "") { $d=$default; }
	return $d;
}

# select from options in window (upper left y, upper left x, width-x, title,
#		array of options)
# returns number for selected option, -1 for abort
sub SELECT
{
	local($y1,$x1,$wide,$title,@prompts)=@_;
	local($lls)=$#prompts;
	&amp;BOX($y1,$x1,$y1+$lls+3,$x1+$wide,$title);
	local($j,$letter); $letter="1";
	local($option);

	for ($j=0;$j&lt;=$lls;$j++)
	{
		&amp;CPOS($y1+$j+1,$x1+1); print "$letter: $prompts[$j]";
		$letter++;
	}
	
	$option=0;
	while (($option&lt;1 | $option&gt;$lls+1) &amp; $option ne "q") 
		{ 
			&amp;CPOS($y1+$lls+2,$x1+1);
			print "SELECT:     ";
			&amp;CPOS($y1+$lls+2,$x1+8);
			$option=&lt;&gt;; chop($option); 
	}

	if ($option eq "q") { $option=-1; }
	return $option;
}

1;

&lt;---- snip snip... demo.pl -----------------------------------------------&gt;

require "cur.pl";

&amp;CLS;
&amp;MSG(1,1,"hello world");
&amp;INPUT(5,1,"Enter File: ",25,"");

$what=&amp;SELECT(10,12,20,"select animal","cat","dogs","iguanna");

if ($what==1) { $msg="you picked a cat"; } elsif
($what==2) { $msg="you picked a dog"; } elsif
($what==3) { $msg="you picked an igunna"; } elsif
($what==-1) { $msg="entry aborted"; }

&amp;MSG(20,30,$msg);


&amp;TEXT(6,45,30,"this is a demo","of multiple line","text output");

&amp;UNBOX(1,1,3,20);

@text=&amp;MLINES(1,1,30,5,"enter captain's log");

&amp;MSG(20,1,"end of demo");
&amp;CPOS(23,1);

------
vic spicer, recent PERL convert/ data systems,instrument electronics and
software person with the Time of Flight Mass Spec. Lab
at the University of Manitoba Dept. of Physics


</pre></body></html>