[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Clearing console window



At 11:39 -0300 2000.07.28, Paul Williams wrote:
>Is there a way to clear/reset the MacPerl console window similar to
>system("clear")?

There is no good built-in method.  With Mac::AppleEvents::Simple it is
pretty "simple":

#!perl -w
use Mac::AppleEvents::Simple qw(:all);
$|++;

print "Getting ready to close ... ";
for (reverse(1..3)) {
    print "$_ ";
    sleep 1;
}

close_macperl_window();
sleep 1;

print "Pretty cool, eh?";

sub close_macperl_window {
    my $evt = build_event(qw/core clos McPL/,
      "'----':obj {form:name, want:type(cwin), " .
      "seld:TEXT(\@), from:'null'()}", 'MacPerl');
    $evt->send_event(kAENoReply());
}

__END__

Note that the third through ninth lines are to print something to the
window, before closing.  After calling the close function, we need to sleep
before printing right away, because we send the event with kAENoReply.
MacPerl will not wait for the event to finish before going on to the next
thing (printing again), because when MacPerl waits for a reply to an evend
it sends to itself in this manner, it pukes.

-- 
Chris Nandor       |     pudge@pobox.com      |     http://pudge.net/
Andover.Net        | chris.nandor@andover.net | http://slashcode.com/

# ===== Want to unsubscribe from this list?
# ===== Send mail with body "unsubscribe" to macperl-request@macperl.org