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