ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/perl/overlay-osc
Revision: 1.2
Committed: Fri Oct 10 00:21:16 2008 UTC (15 years, 7 months ago) by root
Branch: MAIN
Changes since 1.1: +8 -4 lines
Log Message:
*** empty log message ***

File Contents

# Content
1 #! perl
2
3 # allows programs to open popups
4 # printf "\033]777;overlay;action;args\007"
5 #
6 # action "simple;<id>;<timeout>;<x>;<y>;<h|t>;<text>"
7 # printf "\033]777;overlay;simple;ov1;0;0;t;test\007"
8 #
9
10 # action "timeout;<id>;<seconds>"
11 # printf "\033]777;overlay;timeout;ov1;6\007"
12
13 # action "destroy;<id>"
14 # printf "\033]777;overlay;destroy;ov1\007"
15
16 # TODO:
17 ## action "complex;<id>;<timeout>;<x>;<y>;<width>;<height>;<rstyle>;<border>"
18 ## action "set;<id>;<x>;<y>;<h|t>;<hextext>;<rendition...>"
19
20 sub on_osc_seq_perl {
21 my ($self, $osc, $resp) = @_;
22
23 return unless $osc =~ s/^overlay;//;
24
25 $osc =~ s/^([^;]+)+;//
26 or return;
27
28 if ($1 eq "timeout") {
29 my ($id, $to) = split /;/, $osc, 2;
30 my $ov = $self->{ov}{$id}
31 or return;
32 if (length $to) {
33 $ov->{to}->start (urxvt::NOW + $to);
34 } else {
35 delete $ov->{to};
36 }
37
38 } elsif ($1 eq "simple") {
39 my ($id, $to, $x, $y, $t, $txt) = split /;/, $osc, 6;
40 if ($t eq "h") {
41 $txt = pack "H*", $txt;
42 utf8::decode $txt;
43 }
44 $self->{ov}{$id} = {
45 ov => $self->overlay_simple ($x, $y, $txt),
46 to => urxvt::timer
47 ->new
48 ->start (urxvt::NOW + $to)
49 ->cb(sub {
50 delete $self->{ov}{$id};
51 }),
52 };
53
54 } elsif ($1 eq "destroy") {
55 delete $self->{ov}{$osc};
56 }
57
58 1
59 }
60
61