ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/perl/selection-autotransform
Revision: 1.5
Committed: Tue Jan 17 16:22:41 2006 UTC (18 years, 4 months ago) by root
Branch: MAIN
Changes since 1.4: +1 -6 lines
Log Message:
*** empty log message ***

File Contents

# Content
1 #! perl
2
3 sub msg {
4 my ($self, $msg) = @_;
5
6 my $overlay = $self->overlay (0, 0, $self->strwidth ($msg), 1);
7 $overlay->set (0, 0, $msg);
8 my $iow; $iow = urxvt::timer->new->start (urxvt::NOW + 2)->cb (sub {
9 undef $overlay;
10 undef $iow;
11 });
12 }
13
14 sub on_init {
15 my ($self) = @_;
16
17 for (my $idx = 0; defined (my $res = $self->x_resource ("selection-autotransform.$idx")); $idx++) {
18 $res = $self->locale_decode ($res);
19 my $transform = eval "sub { $res }";
20
21 if ($transform) {
22 push @{ $self->{transforms} }, $transform;
23 } else {
24 warn "$res: $@";
25 }
26 }
27
28 ()
29 }
30
31 sub on_sel_grab {
32 my ($self) = @_;
33
34 my $text = $self->selection;
35 local $_ = $text;
36
37 for my $transform (@{ $self->{transforms} }) {
38 $transform->();
39 if ($text ne $_) {
40 $self->selection ($_);
41 s/[\x00-\x1f\x80-\x9f]/ยท/g;
42 $self->msg ($self->special_encode ("auto-transformed to $_"));
43 last;
44 }
45 }
46
47 ()
48 }
49