repo: rxvt-unicode-sixel
action: commit
revision: 
path_from: 
revision_from: 0701b57e5a40696c9f0051fa051e466ed459f666:
path_to: 
revision_to: 
git.thebackupbox.net
rxvt-unicode-sixel
git clone git://git.thebackupbox.net/rxvt-unicode-sixel
commit 0701b57e5a40696c9f0051fa051e466ed459f666
Author: Emanuele Giaquinta 
Date:   Sat Jul 24 10:20:26 2010 +0000

    Add on_tt_paste perl hook and tt_paste perl binding.

diff --git a/Changes b/Changes
index c65b5e9112b268e9bc7aae723b1dde0dcdea8d52..
index ..82fcfe2687ab944e6f4fe90e9d075a189ed7de9e 100644
--- a/Changes
+++ b/Changes
@@ -21,6 +21,7 @@ TODO: perl-shell-window? perl-unix-socket?

 TODO:        - upgrade to libev-4.00.

+	- new on_tt_paste perl hook and tt_paste perl binding (Emanuele Giaquinta).
 	- fix utmpx detection on upcoming FreeBSD 9.
 	- Use COMPOUND_TEXT encoding for WM_NAME/WM_ICON_NAME value when it
 	  is not fully convertible to STRING (patch by James Cloos).
diff --git a/src/hookinc.h b/src/hookinc.h
index 311056e5d7a61e19782e2aaf25db7079d3f83c37..
index ..18b5c89b580f27a889189ab57697e539c8613481 100644
--- a/src/hookinc.h
+++ b/src/hookinc.h
@@ -54,3 +54,5 @@

   def (BELL)

+  def (TT_PASTE)
+
diff --git a/src/rxvt.h b/src/rxvt.h
index bf1ef2e19266ec1263f49c78cd30a55fb13ac825..
index ..4d92634d3edf7ba34640694c12b1c69a46417a77 100644
--- a/src/rxvt.h
+++ b/src/rxvt.h
@@ -1410,6 +1410,7 @@ struct rxvt_term : zero_initialized, rxvt_vars, rxvt_screen
   }

   // modifies first argument(!)
+  void tt_paste (char *data, unsigned int len) NOTHROW;
   void paste (char *data, unsigned int len) NOTHROW;
   void scr_blank_line (line_t &l, unsigned int col, unsigned int width, rend_t efs) const NOTHROW;
   void scr_blank_screen_mem (line_t &l, rend_t efs) const NOTHROW;
diff --git a/src/rxvtperl.xs b/src/rxvtperl.xs
index 20a898715d79a56f5d0ceacc59a97fe1b0aff67e..
index ..36a0b9634920c40844fd53d8efe5f0bc7ccfb1d2 100644
--- a/src/rxvtperl.xs
+++ b/src/rxvtperl.xs
@@ -1676,6 +1676,14 @@ rxvt_term::tt_write (SV *octets)
 	C_ARGS:
           str, len

+void
+rxvt_term::tt_paste (SV *octets)
+      INIT:
+        STRLEN len;
+        char *str = SvPVbyte (octets, len);
+      C_ARGS:
+        str, len
+
 void
 rxvt_term::cmd_parse (SV *octets)
 	CODE:
diff --git a/src/screen.C b/src/screen.C
index 8259cb70f6bd2007791de03b72eeea8382ff0d9f..
index ..ca85932aa3a0c21a0b1efea6ae5d1467ae7be8bb 100644
--- a/src/screen.C
+++ b/src/screen.C
@@ -2681,7 +2681,7 @@ rxvt_term::selection_check (int check_more) NOTHROW
  * Paste a selection direct to the command fd
  */
 void
-rxvt_term::paste (char *data, unsigned int len) NOTHROW
+rxvt_term::tt_paste (char *data, unsigned int len) NOTHROW
 {
   /* convert normal newline chars into common keyboard Return key sequence */
   for (unsigned int i = 0; i < len; i++)
@@ -2697,6 +2697,15 @@ rxvt_term::paste (char *data, unsigned int len) NOTHROW
     tt_printf ("\e[201~");
 }

+void
+rxvt_term::paste (char *data, unsigned int len) NOTHROW
+{
+  if (HOOK_INVOKE ((this, HOOK_TT_PASTE, DT_STR_LEN, data, len, DT_END)))
+    return;
+
+  tt_paste (data, len);
+}
+
 /* ------------------------------------------------------------------------- */
 /*
  * Respond to a notification that a primary selection has been sent
diff --git a/src/urxvt.pm b/src/urxvt.pm
index b142df657b81d46367048ca218a671dcdfcb109c..
index ..5d904db7c14c251f56b733ea80b582b0008ea578 100644
--- a/src/urxvt.pm
+++ b/src/urxvt.pm
@@ -612,6 +612,13 @@ output.
 Called whenever some data is written to the tty/pty and can be used to
 suppress or filter tty input.

+=item on_tt_paste $term, $octets
+
+Called whenever text is about to be pasted, with the text as argument. You
+can filter/change and paste the text yourself by returning a true value
+and calling C<< $term->tt_paste >> yourself. C<$octets> is
+locale-encoded.
+
 =item on_line_update $term, $row

 Called whenever a line was updated or changed. Can be used to filter
@@ -1551,6 +1558,12 @@ Write the octets given in C<$octets> to the tty (i.e. as program input). To
 pass characters instead of octets, you should convert your strings first
 to the locale-specific encoding using C<< $term->locale_encode >>.

+=item $term->tt_paste ($octets)
+
+Write the octets given in C<$octets> to the tty as a paste, converting NL to
+CR and bracketing the data with control sequences if bracketed paste mode
+is set.
+
 =item $old_events = $term->pty_ev_events ([$new_events])

 Replaces the event mask of the pty watcher by the given event mask. Can

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