#! perl # allows programs to open popups # printf "\033]777;overlay;action;args\007" # # action "simple;;;;;" # printf "\033]777;overlay;simple;ov1;0;0;t;test\007" # ## action "complex;;;;;;;;;" # action "timeout;;" # printf "\033]777;overlay;timeout;ov1;6\007" # action "destroy;" 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, $x, $y, $t, $txt) = split /;/, $osc, 5; 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 + 60) ->cb(sub { delete $self->{ov}{$id}; }), }; } elsif ($1 eq "destroy") { delete $self->{ov}{$osc}; } 1 }