-- Leo's gemini proxy

-- Connecting to git.thebackupbox.net:1965...

-- Connected

-- Sending request

-- Meta line: 20 text/gemini

repo: rxvt-unicode-sixel
action: commit
revision:
path_from:
revision_from: be978e3f8ee377e13b455f65b37ea62fe3cdee55:
path_to:
revision_to:

git.thebackupbox.net

rxvt-unicode-sixel

git://git.thebackupbox.net/rxvt-unicode-sixel

commit be978e3f8ee377e13b455f65b37ea62fe3cdee55
Author: Marc Lehmann <schmorp@schmorp.de>
Date:   Tue Jun 19 18:17:56 2012 +0000

    *** empty log message ***

diff --git a/Changes b/Changes

index 134aebb63b2872a283ea815481d646fd99568c2e..

index ..99acd3b96b5bd2fae170d6fbf538089022309e52 100644

--- a/Changes
+++ b/Changes
@@ -20,24 +20,21 @@ TODO: decrqm http://ue.tst.eu/71d7dbd1fcfeaa7d2a4b96eb957d570c.txt
 TODO: perl-shell-window? perl-unix-socket?
 TODO: command line editing when icanon?
 TODO: split ROW into a ROW_fast (0..total*2-1) and ROW macros?
+TODO: catch exceptions when calling perl hooks
+TODO: xdbe

 TODO: DEC PM 4h/4l should toggle jumpscroll on or off (PrivMode_smoothScroll)
 TODO: pack rxvt_fatal messages into the exception object
-TODO: catch exceptions when calling perl hooks
-TODO: find out about overhead of NOTHROW
-TODO: xrender, versiobn check for filters, or use query filters instead?
-TODO: something resets the bg pixmap afetr on_start
 TODO: provide something like % for easy access for parse_keysym
 TODO: description into --help output?
-TODO: xdbe
-TODO: global pixmap cache for load
-TODO: tint, shade, once
-TODO: rotate/transform autoresize, likewise blend, also document
+TODO: tint, shade
 TODO: optimise bg reeval for resize for comon patterns (pixmap bigger than window?)
+TODO: load must not cache, but global image cache
+TODO: manpages for perl extensions
+TODO: ->on MUST pass the extension as firstd agrument, somehow
 9.16
 	- the "so much new stuff you eyes will pop out" release.
         - INCOMPATIBLE CHANGE: renamed urlLauncher resource to url-launcher.
-	- remove support for libafterimage.
 	- fix processing of DEC private mode save sequences (patch by Patrick
 	  Hemmer).
 	- fix disabling of cursor blink with the option-popup menu (based on a
@@ -49,20 +46,25 @@ TODO: optimise bg reeval for resize for comon patterns (pixmap bigger than windo
 	  lineSpace is non zero (patch by Stanislav Seletskiy).
         - make it compile with LOCAL_X_IS_UNIX again (reported by
           nickfailure@gmail.com).
-        - update to CVS version of libev, for a whopping 11kb size decrease.
-        - do not ship yet another copy of ecb.h, use the one in libev or
-          libptytty instead.
+        - completely redone background pixmap support - users can now
+          specify arbitrary expressions (And programs) that calculate
+          new terminal backgrounds. see the urxvt-background manpage
+          for details.
+        - perl extensions can now provide commandline switches and resources
+          which show up in -help etc.
+        - iso14755 51 mode window now displays row and column.
+        - implement a -visual switch and move that and -depth to frills, also
+          warn when we can't get the requested visual.
+        - new env variable: RXVT_PERL_LIB.
         - allocate all screen memory in one go and let the virtual memory
           subsystem sort it out. this simplifies code, improves access
           locality, saves a bit of ram and makes things a bit faster, too.
+	- remove support for libafterimage.
+        - update to CVS version of libev, for a whopping 11kb size decrease.
+        - do not ship yet another copy of ecb.h, use the one in libev or
+          libptytty instead.
         - selectively mark some methods as cache-hot/cache cold, which
           might speed up execution but definitely decreases codesize.
-        - new env variable: RXVT_PERL_LIB.
-        - iso14755 51 mode window now displays row and column.
-        - perl extensions can now provide commandline switches and resources
-          which show up in -help etc.
-        - implement a -visual switch and move that and -depth to frills, also
-          warn when we can't get the requested visual.

 9.15 Sat Jan 21 13:36:56 CET 2012
 	- remove "using namespace std" because clang erroneously
diff --git a/config.h.in b/config.h.in

index eef30e0ba3d214afea44f77c24d9202052060ce5..

index ..7755bfc26dd0e445f5b851e6fb4172bc02c03454 100644

--- a/config.h.in
+++ b/config.h.in
@@ -21,6 +21,9 @@
 /* Define if you want your background to use the parent window background */
 #undef ENABLE_TRANSPARENCY

+/* Define if you want to use XDBE */
+#undef ENABLE_XDBE
+
 /* Define if you want european extended codesets */
 #undef ENCODING_EU

diff --git a/configure b/configure

index f528aad14209f7e175dd62c38ccd70774568fc84..

index ..058e774d1b09742922e9f4222a04c57acc06636b 100755

--- a/configure
+++ b/configure
@@ -719,6 +719,7 @@ enable_text_blink
 enable_pointer_blank
 with_term
 with_terminfo
+enable_xdbe
 with_x
 enable_utmp
 enable_wtmp
@@ -1388,6 +1389,7 @@ Optional Features:
   --enable-smart-resize   enable smart growth/shrink behaviour
   --enable-text-blink     enable blinking text
   --enable-pointer-blank  enable pointer blanking when typing or inactive
+  --enable-xdbe           enable support for double buffering
   --enable-utmp           enable utmp (utmpx) support
   --enable-wtmp           enable wtmp (wtmpx) support (requires --enable-utmp)
   --enable-lastlog        enable lastlog support (requires --enable-utmp)
@@ -4664,6 +4666,7 @@ support_8bitctrls=no
 support_iso14755=yes
 support_styles=yes
 support_perl=yes
+support_xdbe=yes
 codesets=all


@@ -4672,6 +4675,7 @@ if test "${enable_everything+set}" = set; then :
   enableval=$enable_everything;
     if test x$enableval = xno; then
        support_frills=no
+       support_xdbe=no
        support_inheritpixmap=no
        support_fading=no
        support_keepscrolling=no
@@ -4696,6 +4700,7 @@ if test "${enable_everything+set}" = set; then :
        support_iso14755=no
        support_styles=no
        support_perl=no
+       support_xdbe=no
        codesets=
     fi
     if test x$enableval = xyes; then
@@ -4724,6 +4729,7 @@ if test "${enable_everything+set}" = set; then :
        support_iso14755=yes
        support_styles=yes
        support_perl=yes
+       support_xdbe=yes
        codesets=all
     fi

@@ -5111,6 +5117,14 @@ _ACEOF
 fi


+# Check whether --enable-xdbe was given.
+if test "${enable_xdbe+set}" = set; then :
+  enableval=$enable_xdbe; if test x$enableval = xyes -o x$enableval = xno; then
+    support_xdbe=$enableval
+  fi
+fi
+
+

 LIBEV_M4_AVOID_LIBRT=1

@@ -7359,6 +7373,10 @@ support_image=no
 if test x$support_inheritpixmap = xyes || test x$support_pixbuf = xyes; then
   support_image=yes
 fi
+if test x$support_xdbe = xyes; then
+  LIBS="$LIBS -lXext"
+fi
+
 if test x$support_xft = xyes || test x$support_image = xyes; then
   rxvt_have_xrender=no
   # Extract the first word of "pkg-config", so it can be a program name with args.
@@ -7737,6 +7755,11 @@ fi



+if test x$support_xdbe = xyes; then
+
+$as_echo "#define ENABLE_XDBE 1" >>confdefs.h
+
+fi
 if test x$support_styles = xyes; then

 $as_echo "#define ENABLE_STYLES 1" >>confdefs.h
diff --git a/configure.ac b/configure.ac

index 679ef103323eba488aaff6510582ea42b7fe6050..

index ..808884fa65f2511de938847fd5649cf95c721326 100644

--- a/configure.ac
+++ b/configure.ac
@@ -97,6 +97,7 @@ support_8bitctrls=no
 support_iso14755=yes
 support_styles=yes
 support_perl=yes
+support_xdbe=yes
 codesets=all

 dnl# --------------------------------------------------------------------------
@@ -109,6 +110,7 @@ AC_ARG_ENABLE(everything,
   [
     if test x$enableval = xno; then
        support_frills=no
+       support_xdbe=no
        support_inheritpixmap=no
        support_fading=no
        support_keepscrolling=no
@@ -133,6 +135,7 @@ AC_ARG_ENABLE(everything,
        support_iso14755=no
        support_styles=no
        support_perl=no
+       support_xdbe=no
        codesets=
     fi
     if test x$enableval = xyes; then
@@ -161,6 +164,7 @@ AC_ARG_ENABLE(everything,
        support_iso14755=yes
        support_styles=yes
        support_perl=yes
+       support_xdbe=yes
        codesets=all
     fi
   ])
@@ -412,6 +416,12 @@ AC_ARG_WITH(terminfo,
     AC_DEFINE_UNQUOTED(RXVT_TERMINFO, "$withval", Set TERMINFO value to the value given by configure) terminfo="$withval"
   fi])

+AC_ARG_ENABLE(xdbe,
+              [  --enable-xdbe           enable support for double buffering],
+  [if test x$enableval = xyes -o x$enableval = xno; then
+    support_xdbe=$enableval
+  fi])
+
 dnl# --------------------------------------------------------------------------

 LIBEV_M4_AVOID_LIBRT=1
@@ -564,6 +574,10 @@ support_image=no
 if test x$support_inheritpixmap = xyes || test x$support_pixbuf = xyes; then
   support_image=yes
 fi
+if test x$support_xdbe = xyes; then
+  LIBS="$LIBS -lXext"
+fi
+
 if test x$support_xft = xyes || test x$support_image = xyes; then
   rxvt_have_xrender=no
   AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
@@ -648,6 +662,9 @@ fi
 AC_SUBST(PIXBUF_CFLAGS)
 AC_SUBST(PIXBUF_LIBS)

+if test x$support_xdbe = xyes; then
+  AC_DEFINE(ENABLE_XDBE, 1, Define if you want to use XDBE)
+fi
 if test x$support_styles = xyes; then
   AC_DEFINE(ENABLE_STYLES, 1, Define if you want bold and italic support)
 fi
diff --git a/doc/rxvt.7.pod b/doc/rxvt.7.pod

index 22ba206a62d3bd6f615b1eec0fa9590e9f9ae3c5..

index ..8351d34aef28039f2ddb5bbde3a0a9009cc30df9 100644

--- a/doc/rxvt.7.pod
+++ b/doc/rxvt.7.pod
@@ -2523,6 +2523,10 @@ and consequently sets C<TERM> to C<rxvt-unicode-256color> by default
 It also results in higher memory usage and can slow down @@RXVT_NAME@@
 dramatically when more than six fonts are in use by a terminal instance.

+=item --enable-xdbe (default: on)
+
+Enable support for the X double buffering extension.
+
 =item --with-name=NAME (default: urxvt)

 Set the basename for the installed binaries, resulting
diff --git a/src/perl/background b/src/perl/background

index f27511d1fa6b7bd9380e713537b3c6834fdcc031..

index ..27636e793e22240ce7e7bd6ed5d0ceb18a45094d 100644

--- a/src/perl/background
+++ b/src/perl/background
@@ -140,6 +140,8 @@ moved around.

 =head2 CYCLES AND CACHING

+=head3 C<load> et al.
+
 As has been mentioned before, the expression might be evaluated multiple
 times. Each time the expression is reevaluated, a new cycle is said to
 have begun. Many operators cache their results till the next cycle.
@@ -173,6 +175,23 @@ Here, a path is selected randomly, and load is only called for one image,
 so keeps only one image in memory. If, on the next evaluation, luck
 decides to use the other path, then it will have to load that image again.

+=head3 C<once { ... }>
+
+Another way to cache expensive operations is to use C<once { ... }>. The
+C<once> operator takes a block of multiple statements enclosed by C<{}>
+and evaluates it only.. once, returning any images the last statement
+returned. Further calls simply produce the values from the cache.
+
+This is most useful for expensive operations, such as C<blur>:
+
+   rootalign once { blur 20, root }
+
+This makes a blurred copy of the root background once, and on subsequent
+calls, just root-aligns it. Since C<blur> is usually quite slow and
+C<rootalign> is quite fast, this trades extra memory (For the cached
+blurred pixmap) with speed (blur only needs to be redone when root
+changes).
+
 =head1 REFERENCE

 =head2 COMMAND LINE SWITCHES
@@ -206,7 +225,7 @@ interval with this switch.

 our %_IMG_CACHE;
 our $HOME;
-our ($self, $old, $new);
+our ($self, $frame);
 our ($x, $y, $w, $h);

 # enforce at least this interval between updates
@@ -215,6 +234,11 @@ our $MIN_INTERVAL = 6/59.951;
 {
    package urxvt::bgdsl; # background language

+   sub FR_PARENT() { 0 } # parent frame, if any - must be #0
+   sub FR_CACHE () { 1 } # cached values
+   sub FR_AGAIN () { 2 } # what this expr is sensitive to
+   sub FR_STATE () { 3 } # watchers etc.
+
    use List::Util qw(min max sum shuffle);

 =head2 PROVIDERS/GENERATORS
@@ -233,15 +257,15 @@ mode.
 Loaded images will be cached for one cycle, and shared between temrinals
 running in the same process (e.g. in C<urxvtd>).

-=item load_uc $path
-
-Load uncached - same as load, but does not cache the image. This function
-is most useufl if you want to optimise a background expression in some
-way.
+#=item load_uc $path
+#
+#Load uncached - same as load, but does not cache the image. This function
+#is most useufl if you want to optimise a background expression in some
+#way.

 =cut

-   sub load_uc($) {
+   sub load($) {
       my ($path) = @_;

       $_IMG_CACHE{$path} || do {
@@ -251,12 +275,6 @@ way.
       }
    }

-   sub load($) {
-      my ($path) = @_;
-
-      $new->{load}{$path} = $old->{load}{$path} || load_uc $path;
-   }
-
 =item root

 Returns the root window pixmap, that is, hopefully, the background image
@@ -268,7 +286,7 @@ reevaluated when the bg image changes.
 =cut

    sub root() {
-      $new->{again}{rootpmap} = 1;
+      $frame->[FR_AGAIN]{rootpmap} = 1;
       $self->new_img_from_root
    }

@@ -474,10 +492,10 @@ bit, align it to the window position and use it as background.

 =cut

-   sub TX() { $new->{again}{position} = 1; $x }
-   sub TY() { $new->{again}{position} = 1; $y }
-   sub TW() { $new->{again}{size}     = 1; $w }
-   sub TH() { $new->{again}{size}     = 1; $h }
+   sub TX() { $frame->[FR_AGAIN]{position} = 1; $x }
+   sub TY() { $frame->[FR_AGAIN]{position} = 1; $y }
+   sub TW() { $frame->[FR_AGAIN]{size}     = 1; $w }
+   sub TH() { $frame->[FR_AGAIN]{size}     = 1; $h }

 =item now

@@ -506,12 +524,12 @@ Like C<again>, but also returns an increasing counter value, starting at
    sub now() { urxvt::NOW }

    sub again($) {
-      $new->{again}{time} = $_[0];
+      $frame->[FR_AGAIN]{time} = $_[0];
    }

    sub counter($) {
-      $new->{again}{time} = $_[0];
-      $self->{counter} + 0
+      $frame->[FR_AGAIN]{time} = $_[0];
+      $frame->[FR_STATE]{counter} + 0
    }

 =back
@@ -821,20 +839,23 @@ The trick is that this code block is only evaluated once - future calls
 will simply return the original image (yes, it should only be used with
 images).

-This can be extremely useful to avoid redoign the same slow operations
+This can be extremely useful to avoid redoing the same slow operations
 again and again- for example, if your background expression takes the root
 background, blurs it and then root-aligns it it would have to blur the
 root background on every window move or resize.

+In fact, urxvt itself encloses the whole expression in some kind of
+C<once> block so it only is reevaluated as required.
+
 Putting the blur into a C<once> block will make sure the blur is only done
 once:

    rootlign once { blur 10, root }

-This leaves the question of how to force reevaluation of the block, in
-case the root background changes: Right now, all once blocks forget that
-they ahve been executed before each time the root background changes (if
-the expression is sensitive to that) or when C<once_again> is called.
+This leaves the question of how to force reevaluation of the block,
+in case the root background changes: If expression inside the block
+is sensitive to some event (root background changes, window geometry
+changes), then it will be reevaluated automatically as needed.

 =item once_again

@@ -844,26 +865,41 @@ next call they will be reevaluated again.
 =cut

    sub once(&) {
-      my $once = $self->{once_cache}{$_[0]+0} ||= do {
-         local $new->{again};
-         my @res = $_[0]();
-         [$new->{again}, \@res]
-      };
-
-      $new->{again} = {
-         %{ $new->{again} },
-         %{ $once->[0] }
+      my $id = $_[0]+0;
+
+      local $frame = $self->{frame_cache}{$id} ||= [$frame];
+
+      unless ($frame->[FR_CACHE]) {
+         $frame->[FR_CACHE] = [ $_[0]() ];
+
+         my $self  = $self;
+         my $frame = $frame;
+         Scalar::Util::weaken $frame;
+         $self->compile_frame ($frame, sub {
+            # clear this frame cache, also for all parents
+            for (my $frame = $frame; $frame; $frame = $frame->[0]) {
+               undef $frame->[FR_CACHE];
+            }
+
+            unless ($self->{term}) {
+               use Data::Dump;
+               ddx $frame;
+               exit;
+            }
+
+            $self->recalculate;
+         });
       };

       # in scalar context we always return the first original result, which
       # is not quite how perl works.
       wantarray
-         ? @{ $once->[1] }
-         : $once->[1][0]
+         ? @{ $frame->[FR_CACHE] }
+         : $frame->[FR_CACHE][0]
    }

    sub once_again() {
-      delete $self->{once_cache};
+      delete $self->{frame_cache};
    }

 =back
@@ -873,7 +909,12 @@ next call they will be reevaluated again.
 }

 sub parse_expr {
-   my $expr = eval "sub {\npackage urxvt::bgdsl;\n#line 0 'background expression'\n$_[0]\n}";
+   my $expr = eval
+      "sub {\n"
+    . "package urxvt::bgdsl;\n"
+    . "#line 0 'background expression'\n"
+    . "$_[0]\n"
+    . "}";
    die if $@;
    $expr
 }
@@ -882,10 +923,59 @@ sub parse_expr {
 sub set_expr {
    my ($self, $expr) = @_;

+   $self->{root} = [];
    $self->{expr} = $expr;
    $self->recalculate;
 }

+# takes a hash of sensitivity indicators and installs watchers
+sub compile_frame {
+   my ($self, $frame, $cb) = @_;
+
+   my $state = $frame->[urxvt::bgdsl::FR_STATE] ||= {};
+   my $again = $frame->[urxvt::bgdsl::FR_AGAIN];
+
+   # don't keep stuff alive
+   Scalar::Util::weaken $state;
+
+   if ($again->{nested}) {
+      $state->{nested} = 1;
+   } else {
+      delete $state->{nested};
+   }
+
+   if (my $interval = $again->{time}) {
+      $state->{time} = [$interval, urxvt::timer->new->after ($interval)->interval ($interval)]
+         if $state->{time}[0] != $interval;
+
+      # callback *might* have changed, although we could just rule that out
+      $state->{time}[1]->cb (sub {
+         ++$state->{counter};
+         $cb->();
+      });
+   } else {
+      delete $state->{time};
+   }
+
+   if ($again->{position}) {
+      $state->{position} = $self->on (position_change => $cb);
+   } else {
+      delete $state->{position};
+   }
+
+   if ($again->{size}) {
+      $state->{size}     = $self->on (size_change     => $cb);
+   } else {
+      delete $state->{size};
+   }
+
+   if ($again->{rootpmap}) {
+      $state->{rootpmap} = $self->on (rootpmap_change => $cb);
+   } else {
+      delete $state->{rootpmap};
+   }
+}
+
 # evaluate the current bg expression
 sub recalculate {
    my ($arg_self) = @_;
@@ -903,67 +993,34 @@ sub recalculate {

    # set environment to evaluate user expression

-   local $self = $arg_self;
+   local $self  = $arg_self;
+   local $HOME  = $ENV{HOME};
+   local $frame = [];

-   local $HOME = $ENV{HOME};
-   local $old = $self->{state};
-   local $new = my $state = $self->{state} = {};
-
-   ($x, $y, $w, $h) =
-      $self->background_geometry ($self->{border});
+   ($x, $y, $w, $h) = $self->background_geometry ($self->{border});

    # evaluate user expression

-   my $img = eval { urxvt::bgdsl::merge $self->{expr}->() };
+   my @img = eval { $self->{expr}->() };
    die $@ if $@;
-   die "background-expr did not return an image.\n" if !UNIVERSAL::isa $img, "urxvt::img";
+   die "background-expr did not return anything.\n" unless @img;
+   die "background-expr: expected image(s), got something else.\n"
+      if grep { !UNIVERSAL::isa $_, "urxvt::img" } @img;

-   # if the expression is sensitive to external events, prepare reevaluation then
+   my $img = urxvt::bgdsl::merge @img;

-   my $again = delete $state->{again};
-
-   $again->{size} = 1
+   $frame->[FR_AGAIN]{size} = 1
       if $img->repeat_mode != urxvt::RepeatNormal;

-   if (my $again = $again->{time}) {
-      my $self = $self;
-      $state->{timer} = $again == $old->{again}
-                        ? $old->{timer}
-                        : urxvt::timer->new->after ($again)->interval ($again)->cb (sub {
-                             ++$self->{counter};
-                             $self->recalculate
-                          });
-   }
-
-   if ($again->{position}) {
-      $self->enable (position_change => sub { $_[0]->recalculate });
-   } else {
-      $self->disable ("position_change");
-   }
-
-   if ($again->{size}) {
-      $self->enable (size_change => sub { $_[0]->recalculate });
-   } else {
-      $self->disable ("size_change");
-   }
-
-   if ($again->{rootpmap}) {
-      $self->enable (rootpmap_change => sub {
-         delete $_[0]{once_cache}; # this will override once-block values from
-         $_[0]->recalculate;
-      });
-   } else {
-      $self->disable ("rootpmap_change");
-   }
+   # if the expression is sensitive to external events, prepare reevaluation then
+   $self->compile_frame ($frame, sub { $arg_self->recalculate });

    # clear stuff we no longer need

-   %$old = ();
-
-   unless (%$again) {
-      delete $self->{state};
-      delete $self->{expr};
-   }
+#   unless (%{ $frame->[FR_STATE] }) {
+#      delete $self->{state};
+#      delete $self->{expr};
+#   }

    # set background pixmap

diff --git a/src/urxvt.pm b/src/urxvt.pm

index 31c9003a9674f82910ad960de1a42ca7f899502c..

index ..65e8f998f34716568e8360e7ba441e51830583e0 100644

--- a/src/urxvt.pm
+++ b/src/urxvt.pm
@@ -114,16 +114,27 @@ It has the following methods and data members:
 Returns the C<urxvt::term> object associated with this instance of the
 extension. This member I<must not> be changed in any way.

-=item $self->enable ($hook_name => $cb, [$hook_name => $cb..])
+=item $self->enable ($hook_name => $cb[, $hook_name => $cb..])

 Dynamically enable the given hooks (named without the C<on_> prefix) for
 this extension, replacing any previous hook. This is useful when you want
 to overwrite time-critical hooks only temporarily.

+To install additional callbacks for the same hook, you cna use the C<on>
+method of the C<urxvt::term> class.
+
 =item $self->disable ($hook_name[, $hook_name..])

 Dynamically disable the given hooks.

+=item $self->x_resource ($pattern)
+
+=item $self->x_resource_boolean ($pattern)
+
+These methods support an additional C<%> prefix when called on an
+extension object - see the description of these methods in the
+C<urxvt::term> class for details.
+
 =back

 =head2 Hooks
@@ -737,7 +748,7 @@ sub invoke {
          if $verbosity >= 10;

       for my $pkg (keys %$cb) {
-         my $retval_ = eval { $cb->{$pkg}->($TERM->{_pkg}{$pkg}, @_) };
+         my $retval_ = eval { $cb->{$pkg}->($TERM->{_pkg}{$pkg} || $TERM, @_) };
          $retval ||= $retval_;

          if ($@) {
@@ -1060,6 +1071,49 @@ Destroy the terminal object (close the window, free resources
 etc.). Please note that @@RXVT_NAME@@ will not exit as long as any event
 watchers (timers, io watchers) are still active.

+=item $guard = $self->on ($hook_name => $cb[, $hook_name => $cb..])
+
+Similar to the extension method C<enable>, but installs additional
+callbacks for the givne hook(s) (existing ones are not replaced), and
+returns a guard object. When the guard object is destroyed the callbacks
+are disabled again.
+
+Note that these callbacks receive the normal paramaters, but the first
+argument (normally the extension) is currently undefined.
+
+=cut
+
+sub urxvt::term::on_disable::DESTROY {
+   my $disable = shift;
+
+   my $self = delete $disable->{""};
+
+   while (my ($htype, $id) = each %$disable) {
+      delete $self->{_hook}[$htype]{$id};
+      $self->set_should_invoke ($htype, -1);
+   }
+}
+
+sub on {
+   my ($self, %hook) = @_;
+
+   my %disable = ( "" => $self );
+
+   while (my ($name, $cb) = each %hook) {
+      my $htype = $HOOKTYPE{uc $name};
+      defined $htype
+         or Carp::croak "unsupported hook type '$name'";
+
+      my $id = $cb+0;
+
+      $self->set_should_invoke ($htype, +1);
+      $disable{$htype} = $id;
+      $self->{_hook}[$htype]{$id} = $cb;
+   }
+
+   bless \%disable, "urxvt::term::on_disable"
+}
+
 =item $term->exec_async ($cmd[, @args])

 Works like the combination of the C<fork>/C<exec> builtins, which executes

-----END OF PAGE-----

-- Response ended

-- Page fetched on Sun Jun 2 09:49:11 2024