/usr/lib/perl5/Tk/Clipboard.pm is in perl-tk 1:804.031-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | # Copyright (c) 1995-2003 Nick Ing-Simmons. All rights reserved.
# This program is free software; you can redistribute it and/or
# modify it under the same terms as Perl itself.
package Tk::Clipboard;
use strict;
use vars qw($VERSION);
$VERSION = '4.009'; # sprintf '4.%03d', q$Revision: #8 $ =~ /\D(\d+)\s*$/;
use AutoLoader qw(AUTOLOAD);
use Tk qw(catch);
sub clipEvents
{
return qw[Copy Cut Paste];
}
sub ClassInit
{
my ($class,$mw) = @_;
foreach my $op ($class->clipEvents)
{
$mw->Tk::bind($class,"<<$op>>","clipboard$op");
}
return $class;
}
sub clipboardSet
{
my $w = shift;
$w->clipboardClear;
$w->clipboardAppend(@_);
}
sub clipboardCopy
{
my $w = shift;
my $val = $w->getSelected;
if (defined $val)
{
$w->clipboardSet('--',$val);
}
return $val;
}
sub clipboardCut
{
my $w = shift;
my $val = $w->clipboardCopy;
if (defined $val)
{
$w->deleteSelected;
}
return $val;
}
sub clipboardGet
{
my $w = shift;
$w->SelectionGet('-selection','CLIPBOARD',@_);
}
sub clipboardPaste
{
my $w = shift;
local $@;
catch
{
## Different from Tcl/Tk version:
# if ($w->windowingsystem eq 'x11')
# {
# catch
# {
# $w->deleteSelected;
# };
# }
$w->insert("insert", $w->clipboardGet);
$w->SeeInsert if $w->can('SeeInsert');
};
}
sub clipboardOperations
{
my @class = ();
my $mw = shift;
if (ref $mw)
{
$mw = $mw->DelegateFor('bind');
}
else
{
push(@class,$mw);
$mw = shift;
}
while (@_)
{
my $op = shift;
$mw->Tk::bind(@class,"<<$op>>","clipboard$op");
}
}
# These methods work for Entry and Text
# and can be overridden where they don't work
sub deleteSelected
{
my $w = shift;
catch { $w->delete('sel.first','sel.last') };
}
1;
__END__
sub getSelected
{
my $w = shift;
my $val = Tk::catch { $w->get('sel.first','sel.last') };
return $val;
}
|