-- 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: f21c88e4e4317601612b65ef622d22483d3872a4:
path_to:
revision_to:

git.thebackupbox.net

rxvt-unicode-sixel

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

commit f21c88e4e4317601612b65ef622d22483d3872a4
Author: Marc Lehmann <schmorp@schmorp.de>
Date:   Mon Feb 21 07:12:03 2011 +0000

    refactor

diff --git a/src/rxvttoolkit.C b/src/rxvttoolkit.C

index bd35046f33dfc26b8fbe0b72172e77a5b44e9131..

index ..bf99325f56ef0b308407e7a5f8e38ca5f48432ac 100644

--- a/src/rxvttoolkit.C
+++ b/src/rxvttoolkit.C
@@ -894,8 +894,8 @@ rxvt_color::fade (rxvt_screen *screen, int percent, rxvt_color &result, const rg
   );
 }

-rxvt_selection::rxvt_selection (rxvt_display *disp, int selnum, Time tm, Window win, Atom prop, sel_cb cb, void *ptr)
-: display (disp), request_time (tm), request_win (win), request_prop (prop), request_cb (cb), user_data (ptr)
+rxvt_selection::rxvt_selection (rxvt_display *disp, int selnum, Time tm, Window win, Atom prop, rxvt_term *term, void *cb_sv)
+: display (disp), request_time (tm), request_win (win), request_prop (prop), term (term), cb_sv (cb_sv)
 {
   assert (selnum >= Sel_Primary && selnum <= Sel_Clipboard);

@@ -933,6 +933,26 @@ rxvt_selection::~rxvt_selection ()
   stop ();
 }

+void
+rxvt_selection::finish (char *data, unsigned int len)
+{
+  if (term)
+    {
+      if (data)
+        term->paste (data, len);
+
+      term->selection_req = 0;
+      delete this;
+    }
+#if ENABLE_PERL
+  else
+    {
+      stop ();
+      abort (); //TODO
+    }
+#endif
+}
+
 void
 rxvt_selection::stop ()
 {
@@ -1114,8 +1134,7 @@ bailout:

   if (selection_wait == Sel_normal)
     {
-      stop ();
-      request_cb (data, data_len, this);
+      finish (data, data_len);
       free (data);
     }
 }
@@ -1126,8 +1145,7 @@ rxvt_selection::timer_cb (ev::timer &w, int revents)
   if (selection_wait == Sel_incr)
     rxvt_warn ("data loss: timeout on INCR selection paste, ignoring.\n");

-  stop ();
-  request_cb (NULL, 0, this);
+  finish ();
 }

 void
diff --git a/src/rxvttoolkit.h b/src/rxvttoolkit.h

index 89028a19e5e441693d5f84dcfa127e52a3142907..

index ..fa9fa6a4e5d07c9007871a9d62814f184aed95a9 100644

--- a/src/rxvttoolkit.h
+++ b/src/rxvttoolkit.h
@@ -365,32 +365,31 @@ struct rxvt_color
 #define Sel_CompoundText        0x10    /* last request was COMPOUND_TEXT */
 #define Sel_UTF8String          0x20    /* last request was UTF8_STRING */

-typedef void (*sel_cb)(char *data, unsigned int len, struct rxvt_selection *rs);
-
 struct rxvt_selection
 {
-  rxvt_selection (rxvt_display *disp, int selnum, Time tm, Window win, Atom prop, sel_cb cb, void *ptr);
+  rxvt_selection (rxvt_display *disp, int selnum, Time tm, Window win, Atom prop, rxvt_term *term, void *cb_sv = 0);
   void run ();
   ~rxvt_selection ();

-  void *user_data;
-
-private:
+  rxvt_term *term; // terminal to paste to, may be 0
+  void *cb_sv;     // perl callback, may be 0
+
   rxvt_display *display;
   Time request_time;
   Window request_win;
   Atom request_prop;
-  sel_cb request_cb;

   unsigned char selection_wait;
   unsigned char selection_type;

+private:
   char *incr_buf;
   size_t incr_buf_size, incr_buf_fill;

   void timer_cb (ev::timer &w, int revents); ev::timer timer_ev;
   void x_cb (XEvent &xev); xevent_watcher x_ev;

+  void finish (char *data = 0, unsigned int len = 0);
   void stop ();
   bool request (Atom target, int selnum);
   void handle_selection (Window win, Atom prop, bool delete_prop);
diff --git a/src/screen.C b/src/screen.C

index 3ff280b6e3ecf1bcd276839a376f2adc0ebb80b2..

index ..6cfea1d01e00aa733b11134b479d60e31a44aa47 100644

--- a/src/screen.C
+++ b/src/screen.C
@@ -2742,18 +2742,6 @@ rxvt_term::paste (char *data, unsigned int len) NOTHROW
  *     will auto fallback to CUT_BUFFER0
  * EXT: button 2 release
  */
-
-static void
-selection_cb (char *data, unsigned int len, rxvt_selection *rs)
-{
-  rxvt_term *term = (rxvt_term *)rs->user_data;
-
-  if (data)
-    term->paste (data, len);
-  delete rs;
-  term->selection_req = 0;
-}
-
 void
 rxvt_term::selection_request (Time tm, int selnum) NOTHROW
 {
@@ -2767,7 +2755,7 @@ rxvt_term::selection_request (Time tm, int selnum) NOTHROW
     }
   else if (!selection_req)
     {
-      selection_req = new rxvt_selection (display, selnum, tm, vt, xa[XA_VT_SELECTION], selection_cb, this);
+      selection_req = new rxvt_selection (display, selnum, tm, vt, xa[XA_VT_SELECTION], this);
       selection_req->run ();
     }
 }

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

-- Response ended

-- Page fetched on Sun Jun 2 13:09:18 2024