/usr/lib/urxvt/perl/selection-autotransform is in rxvt-unicode 9.14-1.
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 | #! perl
sub msg {
my ($self, $msg) = @_;
my $overlay = $self->overlay (0, 0, $self->strwidth ($msg), 1);
$overlay->set (0, 0, $msg);
my $iow; $iow = urxvt::timer->new->after (2)->cb (sub {
undef $overlay;
undef $iow;
});
}
sub on_init {
my ($self) = @_;
for (my $idx = 0; defined (my $res = $self->x_resource ("selection-autotransform.$idx")); $idx++) {
$res = $self->locale_decode ($res);
my $transform = eval "sub { $res }";
if ($transform) {
push @{ $self->{transforms} }, $transform;
} else {
warn "$res: $@";
}
}
$self->{enabled} = 1;
push @{ $self->{term}{option_popup_hook} }, sub {
("autotransform" => $self->{enabled}, sub { $self->{enabled} = shift })
};
()
}
sub on_sel_grab {
my ($self) = @_;
$self->{enabled}
or return;
my $text = $self->selection;
local $_ = $text;
for my $transform (@{ $self->{transforms} }) {
$transform->();
if ($text ne $_) {
$self->selection ($_);
s/[\x00-\x1f\x80-\x9f]/ยท/g;
$self->msg ($self->special_encode ("auto-transformed to $_"));
last;
}
}
()
}
|