ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/perl/overlay-osc
Revision: 1.5
Committed: Sun Jun 10 17:39:54 2012 UTC (11 years, 11 months ago) by root
Branch: MAIN
Changes since 1.4: +1 -1 lines
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 root 1.1 #! perl
2    
3 root 1.4 =head1 NAME
4    
5     overlay-osc - implement OSC to manage overlays
6    
7 root 1.5 =head1 DESCRIPTION
8 root 1.4
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 root 1.1 # allows programs to open popups
16     # printf "\033]777;overlay;action;args\007"
17     #
18 root 1.2 # action "simple;<id>;<timeout>;<x>;<y>;<h|t>;<text>"
19 root 1.3 # printf "\033]777;overlay;simple;ov1;5;0;0;t;test\007"
20 root 1.1 #
21    
22     # action "timeout;<id>;<seconds>"
23     # printf "\033]777;overlay;timeout;ov1;6\007"
24    
25     # action "destroy;<id>"
26 root 1.2 # 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 root 1.1
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 root 1.2 my ($id, $to, $x, $y, $t, $txt) = split /;/, $osc, 6;
52 root 1.1 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 root 1.2 ->start (urxvt::NOW + $to)
61 root 1.1 ->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