*** empty log message ***
authorroot <root>
Fri, 10 Oct 2008 00:11:40 +0000 (00:11 +0000)
committerroot <root>
Fri, 10 Oct 2008 00:11:40 +0000 (00:11 +0000)
src/command.C
src/perl/overlay-osc [new file with mode: 0644]
src/rxvt.h
src/urxvt.pm

index bea25165e9f030f5d41938b4dcd6361b18c3c115..f508ee8f785af90310250d968c96bdf873c6246a 100644 (file)
@@ -3274,6 +3274,7 @@ rxvt_term::process_xterm_seq (int op, const char *str, char resp)
 
   if (HOOK_INVOKE ((this, HOOK_OSC_SEQ, DT_INT, op, DT_STR, str, DT_END)))
     return;
+  fprintf (stderr, "op %d<%s>\n", op, str);//D
 
   switch (op)
     {
@@ -3511,8 +3512,7 @@ rxvt_term::process_xterm_seq (int op, const char *str, char resp)
 
 #if ENABLE_PERL
       case URxvt_perl:
-        if (HOOK_INVOKE ((this, HOOK_OSC_SEQ_PERL, DT_STR, str, DT_END)))
-          ; // no responses yet
+        HOOK_INVOKE ((this, HOOK_OSC_SEQ_PERL, DT_STR, str, DT_STR_LEN, &resp, 1, DT_END));
         break;
 #endif
     }
diff --git a/src/perl/overlay-osc b/src/perl/overlay-osc
new file mode 100644 (file)
index 0000000..88918f1
--- /dev/null
@@ -0,0 +1,57 @@
+#! perl
+
+# allows programs to open popups
+# printf "\033]777;overlay;action;args\007"
+#
+# action "simple;<id>;<x>;<y>;<h|t>;<text>"
+#   printf "\033]777;overlay;simple;ov1;0;0;t;test\007"
+#
+## action "complex;<id>;<x>;<y>;<w>;<h>;<rstyle>;<border>;<h|t>;<text>"
+
+# action "timeout;<id>;<seconds>"
+#   printf "\033]777;overlay;timeout;ov1;6\007"
+
+# action "destroy;<id>"
+
+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
+}
+
+
index 7a652b30246427e11c52d5dcd354fe86652f5324..3978d25c2810b8e4d88673101e8f7083f4ee1030 100644 (file)
@@ -421,7 +421,7 @@ enum {
   URxvt_view_up          = 720,
   URxvt_view_down        = 721,
 
-  URxvt_perl             = 777,
+  URxvt_perl             = 777,     // for use by perl extensions, starts with "extension-name;"
 };
 
 /* Words starting with `Color_' are colours.  Others are counts */
index 93d9db5b5c90242379358f25aff2d7b585b9fd87..75d8e7fdff9766ef22679043c110acbeea3564e2 100644 (file)
@@ -543,29 +543,42 @@ It is called before lines are scrolled out (so rows 0 .. min ($lines - 1,
 $nrow - 1) represent the lines to be scrolled out). C<$saved> is the total
 number of lines that will be in the scrollback buffer.
 
-=item on_osc_seq $term, $op, $args
+=item on_osc_seq $term, $op, $args, $resp
 
 Called on every OSC sequence and can be used to suppress it or modify its
-behaviour.  The default should be to return an empty list. A true value
+behaviour. The default should be to return an empty list. A true value
 suppresses execution of the request completely. Make sure you don't get
-confused by recursive invocations when you output an osc sequence within
+confused by recursive invocations when you output an OSC sequence within
 this callback.
 
 C<on_osc_seq_perl> should be used for new behaviour.
 
-=item on_osc_seq_perl $term, $string
+=item on_osc_seq_perl $term, $args, $resp
 
 Called whenever the B<ESC ] 777 ; string ST> command sequence (OSC =
 operating system command) is processed. Cursor position and other state
 information is up-to-date when this happens. For interoperability, the
-string should start with the extension name and a colon, to distinguish
-it from commands for other extensions, and this might be enforced in the
-future.
+string should start with the extension name (sans -osc) and a semicolon,
+to distinguish it from commands for other extensions, and this might be
+enforced in the future.
+
+For example, C<overlay-osc> uses this:
+
+   sub on_osc_seq_perl {
+      my ($self, $osc, $resp) = @_;
+
+      return unless $osc =~ s/^overlay;//;
+
+      ... process remaining $osc string
+   }
 
 Be careful not ever to trust (in a security sense) the data you receive,
 as its source can not easily be controlled (e-mail content, messages from
 other users on the same system etc.).
 
+For responses, C<$resp> contains the end-of-args separator used by the
+sender.
+
 =item on_add_lines $term, $string
 
 Called whenever text is about to be output, with the text as argument. You
@@ -595,8 +608,8 @@ you cannot just toggle rendition bits, but only set them.
 
 =item on_refresh_begin $term
 
-Called just before the screen gets redrawn. Can be used for overlay
-or similar effects by modify terminal contents in refresh_begin, and
+Called just before the screen gets redrawn. Can be used for overlay or
+similar effects by modifying the terminal contents in refresh_begin, and
 restoring them in refresh_end. The built-in overlay and selection display
 code is run after this hook, and takes precedence.