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

Re: [MacPerl] system( 'clear' ) for interfaces



The following script is a small elaboration of my previous post (10 SEP 98)
which allows the MacPerl window to be cleared even if it is not the
frontmost window.

Three events are sent: the first brings the MacPerl window to the front,
the second selects all the text in the window, and the third deletes all
the selected text.

I hope it might be a useful addition to the Anarchist's Cookbook.

Alan Fry

#----------

#!perl -w
use Mac::AppleEvents;
use strict;

$|=1;
print "hello\n";
sleep(1);

clear_window();

sub clear_window {
    my $win = "obj {want:type(cwin), from:'null'(), form:name,
seld:'TEXT'(\@)}";
    my $txt = "obj {want:type(ctxt), from:$win,     form:indx,
seld:abso(all )}";
    my $sel = "obj {want:type(prop), from:'null'(), form:prop,
seld:type(sele)}";
    my $del = "obj {want:type(ctxt), from:$sel,     form:indx,
seld:abso(all )}";


    my $evt = AEBuildAppleEvent(
        'misc', 'slct', 'sign', 'McPL', 0, 0, "'----':$win", "MacPerl",
    ) or die $^E;

    AESend($evt, kAENoReply) or die $^E;
    AEDisposeDesc $evt;

    $evt = AEBuildAppleEvent(
        'misc', 'slct', 'sign', 'McPL', 0, 0, "'----':$txt", "MacPerl"
    ) or die $^E;

    AESend($evt, kAENoReply) or die $^E;
    AEDisposeDesc $evt;

    $evt = AEBuildAppleEvent(
        'core', 'delo', 'sign', 'McPL', 0, 0, "'----':$del",
    ) or die $^E;

    AESend($evt, kAENoReply) or die $^E;
    AEDisposeDesc $evt;
}

#----------



***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch