summaryrefslogtreecommitdiffstats
path: root/src/perl/overlay-osc
diff options
context:
space:
mode:
authorroot <root>2012-09-04 22:41:11 +0000
committerroot <root>2012-09-04 22:41:11 +0000
commitd50a22a63f36f3d4fb5bd2f4d7d0f89f36d84e8f (patch)
tree64566414b54ff274345437c2b02a4f1e73b80e72 /src/perl/overlay-osc
parent5ee396e7ac453f939e8ec74546756dba45906827 (diff)
*** empty log message ***
Diffstat (limited to 'src/perl/overlay-osc')
-rw-r--r--src/perl/overlay-osc73
1 files changed, 73 insertions, 0 deletions
diff --git a/src/perl/overlay-osc b/src/perl/overlay-osc
new file mode 100644
index 0000000..5b06e9a
--- /dev/null
+++ b/src/perl/overlay-osc
@@ -0,0 +1,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
+}
+
+