repo: rxvt-unicode-sixel action: commit revision: path_from: revision_from: 0701b57e5a40696c9f0051fa051e466ed459f666: path_to: revision_to:
commit 0701b57e5a40696c9f0051fa051e466ed459f666 Author: Emanuele GiaquintaDate: 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
--- 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
--- 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
--- 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
--- 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
--- 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
--- 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-----