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

Re: [MacPerl-Toolbox] Oops (Getting/setting clipboard)



At 7:08 am -0400 14/04/00, Chris Nandor wrote:

>BTW, here is what I came up with:
>
>#!perl -w
># get
>use Mac::LowMem;
>my $lmh = LMGetScrapHandle();
>my $type = $lmh->get(0, 4);
>my $len = unpack 'l', $lmh->get(4, 8);
>print $lmh->get(8, $len) if $type eq 'TEXT';

Interesting -- in MPWrite the 'get' subroutine runs:

sub get_scrap {
     my $str = $lmh->get;
     my @clip = unpack("a4La*", $str);
     if ($clip[0] eq 'TEXT') {
         return substr($clip[2], 0, $clip[1])
     }
}

which boils down to pretty much the same thing I think?

>#!perl -w
># set
>use Mac::LowMem;
>my $lmh = LMGetScrapHandle();
>my $text = 'fooooo';
>my $hand = 'TEXT' . pack('l', length($text)) . $text;
>$lmh->set(0, length($hand), $hand);

In MPWrite it goes:

my $len = $lmh->size;
$lmh->set(0, $len, 'TEXT'.pack("L", length $str).$str);

which is not quite the same. It was some time ago and the details 
have got a bit hazy but I think $len should be an offset and not the 
length of the string being set.

There are some mysteries. For example LM will not always get the 
whole of a long string put on the clipboard by BBEdit for example. 
Then there is 'public' and 'private' scrap and I was never able to 
get to the bottom of, for example, how TE makes transfers from one to 
the other, or even where TE puts its private scrap.

Alan Fry


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