ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/perl/overlay-osc
Revision: 1.6
Committed: Tue Sep 4 22:41:12 2012 UTC (11 years, 8 months ago) by root
Branch: MAIN
CVS Tags: rxvt-unicode-rel-9_26, rxvt-unicode-rel-9_25, rxvt-unicode-rel-9_22, rxvt-unicode-rel-9_20, rxvt-unicode-rel-9_21, rxvt-unicode-rel-9_19, rxvt-unicode-rel-9_18, rxvt-unicode-rel-9_17, rxvt-unicode-rel-9_16
Changes since 1.5: +1 -1 lines
Log Message:
*** empty log message ***

File Contents

# Content
1 #! perl
2
3 =head1 NAME
4
5 overlay-osc - implement OSC to manage overlays
6
7 =head1 DESCRIPTION
8
9 This extension implements some OSC commands to display timed popups on the
10 screen - useful for status displays from within scripts. You have to read
11 the sources for more info.
12
13 =cut
14
15 # allows programs to open popups
16 # printf "\033]777;overlay;action;args\007"
17 #
18 # action "simple;<id>;<timeout>;<x>;<y>;<h|t>;<text>"
19 # printf "\033]777;overlay;simple;ov1;5;0;0;t;test\007"
20 #
21
22 # action "timeout;<id>;<seconds>"
23 # printf "\033]777;overlay;timeout;ov1;6\007"
24
25 # action "destroy;<id>"
26 # printf "\033]777;overlay;destroy;ov1\007"
27
28 # TODO:
29 ## action "complex;<id>;<timeout>;<x>;<y>;<width>;<height>;<rstyle>;<border>"
30 ## action "set;<id>;<x>;<y>;<h|t>;<hextext>;<rendition...>"
31
32 sub on_osc_seq_perl {
33 my ($self, $osc, $resp) = @_;
34
35 return unless $osc =~ s/^overlay;//;
36
37 $osc =~ s/^([^;]+)+;//
38 or return;
39
40 if ($1 eq "timeout") {
41 my ($id, $to) = split /;/, $osc, 2;
42 my $ov = $self->{ov}{$id}
43 or return;
44 if (length $to) {
45 $ov->{to}->start (urxvt::NOW + $to);
46 } else {
47 delete $ov->{to};
48 }
49
50 } elsif ($1 eq "simple") {
51 my ($id, $to, $x, $y, $t, $txt) = split /;/, $osc, 6;
52 if ($t eq "h") {
53 $txt = pack "H*", $txt;
54 utf8::decode $txt;
55 }
56 $self->{ov}{$id} = {
57 ov => $self->overlay_simple ($x, $y, $txt),
58 to => urxvt::timer
59 ->new
60 ->start (urxvt::NOW + $to)
61 ->cb(sub {
62 delete $self->{ov}{$id};
63 }),
64 };
65
66 } elsif ($1 eq "destroy") {
67 delete $self->{ov}{$osc};
68 }
69
70 1
71 }
72
73