repo: rxvt-unicode-sixel
action: commit
revision: 
path_from: 
revision_from: 88e7b0bd0edfd962841a6f905799f3a2e6f29bfe:
path_to: 
revision_to: 
git.thebackupbox.net
rxvt-unicode-sixel
git clone git://git.thebackupbox.net/rxvt-unicode-sixel
commit 88e7b0bd0edfd962841a6f905799f3a2e6f29bfe
Author: Marc Lehmann 
Date:   Tue Jun 12 10:45:53 2012 +0000

    *** empty log message ***

diff --git a/Changes b/Changes
index ec24c04554182833a8702607213bc0c552990341..
index ..134aebb63b2872a283ea815481d646fd99568c2e 100644
--- a/Changes
+++ b/Changes
@@ -31,7 +31,7 @@ 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
+TODO: tint, shade, once
 TODO: rotate/transform autoresize, likewise blend, also document
 TODO: optimise bg reeval for resize for comon patterns (pixmap bigger than window?)
 9.16
diff --git a/src/perl/background b/src/perl/background
index 201e1f91d15fe30ac4ac56143710467aa62840a7..
index ..b5190b3fece74c4fc5fd0608081f678180a6a926 100644
--- a/src/perl/background
+++ b/src/perl/background
@@ -204,7 +204,8 @@ interval with this switch.

 =cut

-our %_IMGCACHE;
+our %_IMG_CACHE;
+our %_ONCE_CACHE;
 our $HOME;
 our ($self, $old, $new);
 our ($x, $y, $w, $h);
@@ -252,7 +253,7 @@ reevaluated when the bg image changes.

    sub root() {
       $new->{rootpmap_sensitive} = 1;
-      die "root op not supported, exg, we need you";
+      $self->new_img_from_root
    }

 =item solid $colour
@@ -286,8 +287,6 @@ multiple copies of the same image to apply different effects to.
       $_[0]->clone
    }

-=back
-
 =head2 TILING MODES

 The following operators modify the tiling mode of an image, that is, the
@@ -632,6 +631,30 @@ transparency as long as the window isn't in front of other windows.
       move -TX, -TY, $_[0]
    }

+=item rotate $center_x, $center_y, $degrees, $new_width, $new_height
+
+Rotates the image by C<$degrees> degrees, counter-clockwise, around the
+pointer at C<$center_x> and C<$center_y> (specified as factor of image
+width/height), generating a new image with width C<$new_width> and height
+C<$new_height>.
+
+#TODO# new width, height, maybe more operators?
+
+Example: rotate the image by 90 degrees
+
+=cut
+
+   sub rotate($$$$$$) {
+      my $img = pop;
+      $img->rotate (
+         $_[0] * $img->w,
+         $_[1] * $img->h,
+         $_[2] * (3.14159265 / 180),
+         $_[3],
+         $_[4],
+      )
+   }
+
 =back

 =head2 COLOUR MODIFICATIONS
@@ -723,28 +746,52 @@ low values for radius (<5).
       $img->blur ($_[0], @_ >= 2 ? $_[1] : $_[0])
    }

-=item rotate $new_width, $new_height, $center_x, $center_y, $degrees
+=back

-Rotates the image by C<$degrees> degrees, counter-clockwise, around the
-pointer at C<$center_x> and C<$center_y> (specified as factor of image
-width/height), generating a new image with width C<$new_width> and height
-C<$new_height>.
+=head2 OTHER STUFF

-#TODO# new width, height, maybe more operators?
+Anything that didn't fit any of the other categories, even after appliyng
+force and closing our eyes.

-Example: rotate the image by 90 degrees
+=over 4
+
+=item once { ... }
+
+This function takes a code block as argument, that is, one or more
+statements enclosed by braces.
+
+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
+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.
+
+Putting the blur into a C 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 is called.
+
+=item once_again
+
+Resets all C block as if they had never been called, i.e. on the
+next call they will be reevaluated again.

 =cut

-   sub rotate($$$$$$) {
-      my $img = pop;
-      $img->rotate (
-         $_[0],
-         $_[1],
-         $_[2] * $img->w,
-         $_[3] * $img->h,
-         $_[4] * (3.14159265 / 180),
-      )
+   sub once(&) {
+      $_ONCE_CACHE{$_[0]+0} ||= $_[0]()
+   }
+
+   sub once_again() {
+      %_ONCE_CACHE = ();
    }

 =back
diff --git a/src/rxvtd.C b/src/rxvtd.C
index dd7eb60e9a716d834886e56af6f204841a4f6837..
index ..8152fe082d3ed286de790710ab3e8ab9d56f24e3 100644
--- a/src/rxvtd.C
+++ b/src/rxvtd.C
@@ -228,6 +228,9 @@ main (int argc, char *argv[])
   ptytty::init ();

   static char opt_fork, opt_opendisplay, opt_quiet;
+#if ENABLE_PERL
+  static char *opt_eval;
+#endif
 #if ENABLE_MLOCK
   static char opt_lock;
 #endif
@@ -243,6 +246,10 @@ main (int argc, char *argv[])
 #if ENABLE_MLOCK
       else if (!strcmp (argv [i], "-m") || !strcmp (argv [i], "--mlock"))
         opt_lock = 1;
+#endif
+#if ENABLE_PERL
+      else if (!strcmp (argv [i], "-e") || !strcmp (argv [i], "--eval"))
+        opt_eval = argv [++i];
 #endif
       else
         {
@@ -253,6 +260,14 @@ main (int argc, char *argv[])

   rxvt_init ();

+#if ENABLE_PERL
+  if (opt_eval)
+    {
+      rxvt_perl.init ();
+      rxvt_perl.eval (opt_eval);
+    }
+#endif
+
   // optionally open display and never release it.
   if (opt_opendisplay)
     if (const char *dpy = getenv ("DISPLAY"))
diff --git a/src/rxvtimg.C b/src/rxvtimg.C
index 5ef695276009238c205dfa6822f1c5fa73ba806c..
index ..3540e43dbe5b5d81359d507fc22fbf2544f6b067 100644
--- a/src/rxvtimg.C
+++ b/src/rxvtimg.C
@@ -522,7 +522,7 @@ rxvt_img::sub_rect (int x, int y, int width, int height)
 }

 rxvt_img *
-rxvt_img::transform (int new_width, int new_height, double matrix[9])
+rxvt_img::transform (double matrix[9], int new_width, int new_height)
 {
   rxvt_img *img = new rxvt_img (s, format, 0, 0, new_width, new_height, repeat);
   img->alloc ();
@@ -565,7 +565,7 @@ rxvt_img::scale (int new_width, int new_height)
   int old_repeat_mode = repeat;
   repeat = RepeatPad; // not right, but xrender can't properly scale it seems

-  rxvt_img *img = transform (new_width, new_height, matrix);
+  rxvt_img *img = transform (matrix, new_width, new_height);

   repeat = old_repeat_mode;
   img->repeat = repeat;
@@ -574,7 +574,7 @@ rxvt_img::scale (int new_width, int new_height)
 }

 rxvt_img *
-rxvt_img::rotate (int new_width, int new_height, int x, int y, double phi)
+rxvt_img::rotate (int x, int y, double phi, int new_width, int new_height)
 {
   double s = sin (phi);
   double c = cos (phi);
@@ -585,7 +585,7 @@ rxvt_img::rotate (int new_width, int new_height, int x, int y, double phi)
     0,  0,                  1
   };

-  return transform (new_width, new_height, matrix);
+  return transform (matrix, new_width, new_height);
 }

 rxvt_img *
diff --git a/src/rxvtimg.h b/src/rxvtimg.h
index 12de11bf9d9f39f0f90816b13a4970b7a320381a..
index ..0f70fa06d23cc8f9a71ee6702c433ef709d54099 100644
--- a/src/rxvtimg.h
+++ b/src/rxvtimg.h
@@ -95,9 +95,9 @@ public:
   rxvt_img *blur (int rh, int rv);
   rxvt_img *clone ();
   rxvt_img *sub_rect (int x, int y, int width, int height);
-  rxvt_img *transform (int new_width, int new_height, double matrix[9]);
+  rxvt_img *transform (double matrix[9], int new_width = 0, int new_height = 0);
   rxvt_img *scale (int new_width, int new_height);
-  rxvt_img *rotate (int new_width, int new_height, int x, int y, double phi);
+  rxvt_img *rotate (int x, int y, double phi, int new_width = 0, int new_height = 0);
   rxvt_img *convert_format (XRenderPictFormat *format, const rxvt_color &bg);
   rxvt_img *blend (rxvt_img *img, double factor);

diff --git a/src/rxvtperl.h b/src/rxvtperl.h
index 0920e1f30d4a6664180eff351835f4fcf35adda2..
index ..0e50e8fb733b552238964001108f522e185286d1 100644
--- a/src/rxvtperl.h
+++ b/src/rxvtperl.h
@@ -53,7 +53,9 @@ struct rxvt_perl_interp

   ~rxvt_perl_interp ();

+  void init ();
   void init (rxvt_term *term);
+  void eval (const char *str);
   bool invoke (rxvt_term *term, hook_type htype, ...);
   void line_update (rxvt_term *term);
   void selection_finish (rxvt_selection *sel, char *data, unsigned int len);
diff --git a/src/rxvtperl.xs b/src/rxvtperl.xs
index 83db4c0431bba95e56e1b7273a19cc70fb2bb25f..
index ..315fde838bcc2ee9927dd2a2abd9c194013b79e7 100644
--- a/src/rxvtperl.xs
+++ b/src/rxvtperl.xs
@@ -345,7 +345,7 @@ rxvt_perl_interp::~rxvt_perl_interp ()
 }

 void
-rxvt_perl_interp::init (rxvt_term *term)
+rxvt_perl_interp::init ()
 {
   if (!perl)
     {
@@ -385,6 +385,12 @@ rxvt_perl_interp::init (rxvt_term *term)

       rxvt_pop_locale ();
     }
+}
+
+void
+rxvt_perl_interp::init (rxvt_term *term)
+{
+  init ();

   if (perl && !term->perl.self)
     {
@@ -395,6 +401,12 @@ rxvt_perl_interp::init (rxvt_term *term)
     }
 }

+void
+rxvt_perl_interp::eval (const char *str)
+{
+  eval_pv (str, 1);
+}
+
 void
 rxvt_perl_interp::usage (rxvt_term *term, int type)
 {
@@ -2041,7 +2053,6 @@ rxvt_term::has_render ()
 	OUTPUT:
         RETVAL

-# TODO: ugly
 void
 rxvt_term::background_geometry (bool border = false)
 	PPCODE:
@@ -2236,20 +2247,20 @@ rxvt_img *
 rxvt_img::blur (int rh, int rv)

 rxvt_img *
-rxvt_img::transform (int new_width, int new_height, NV p11, NV p12, NV p13, NV p21, NV p22, NV p23, NV p31, NV p32, NV p33)
+rxvt_img::transform (NV p11, NV p12, NV p13, NV p21, NV p22, NV p23, NV p31, NV p32, NV p33, int new_width = 0, int new_height = 0)
 	INIT:
         double matrix[9] = {
           p11, p12, p13,
           p21, p22, p23,
           p31, p32, p33
         };
-	C_ARGS: new_width, new_height, matrix
+	C_ARGS: matrix, new_width, new_height

 rxvt_img *
 rxvt_img::scale (int new_width, int new_height)

 rxvt_img *
-rxvt_img::rotate (int new_width, int new_height, int x, int y, NV phi)
+rxvt_img::rotate (int x, int y, NV phi, int new_width = 0, int new_height = 0)

 #endif

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