#!./perl
BEGIN { push(@INC, qw(../../../lib ../../lib ../lib lib)) }
use Tk;

# A minimal tkperl "shell".
# Typed commands to stdin are executed as soon as a trailing ; is seen.

$name = @ARGV ? $ARGV[0] : "tkpsh";
$top = tkinit($name);
addasyncio(STDIN, "r", \&gotinput);
tkmainloop;

sub gotinput {
    my ($slave, $toread) = @_;
    return unless defined $toread;
    exit unless $toread;
    sysread(STDIN, $command, $toread, length($command));
    if ($command =~ /;$/) {
	eval $command;
	warn $@ if $@;
	$command = "";
    }
}
