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