ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/perl/overlay-osc
Revision: 1.7
Committed: Sat Jul 24 11:58:27 2021 UTC (2 years, 9 months ago) by root
Branch: MAIN
CVS Tags: rxvt-unicode-rel-9_29, rxvt-unicode-rel-9_30, HEAD
Changes since 1.6: +2 -0 lines
Log Message:
*** empty log message ***

File Contents

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