use Tk; use strict; my $start ='1.0'; my $mw = new MainWindow(); my $ta = $mw->Text(-bg => 'black', -fg => 'green', -insertbackground=>'green')->pack(); $ta->focus(); $ta->bind('',[\&getText, \$start]); $ta->bind('',[\&setStart, \$start]); $ta->bind('',[\&setStart, \$start]); $ta->bind('',[\&setStart, \$start]); $ta->bind('',[\&setStart, \$start]); $ta->bind('',sub{exit}); startText(); MainLoop; sub startText{ insertText("Mainframe Monkey Version \'dev\' Oct 2004 - RJC Production\n"); insertText("\n USER: [ ]\n\n PASSWORD:[ ]"); #need to loop back to the USER input at this point setStart(); } sub setStart{ $start = $ta->index('insert'); } sub getText{ my @lp = split /\./,$start; my $com = $ta->get($start, "$lp[0].end"); chomp $com; $com =~ s/ //g; $com =~ s/_//g; doAction($com); $start = $ta->index('insert'); } sub doAction{ my $com = $_[0]; $com = uc $com; if ($com eq 'EXIT'){$mw->destroy} elsif ($com eq 'DIR'){my $dir = `dir`;insertText($dir);} elsif ($com eq 'CLS'){$ta->delete('1.0','end');setStart();} else {insertText("\nUnKown command or program\n")} } sub insertText{ my $text = $_[0]; $ta->delete('insert','end'); $ta->insert('insert',$text); $ta->see('insert'); }