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