Update of /cvsroot/tmux/tmux
In directory vz-cvs-2.sog:/tmp/cvs-serv20175

Modified Files:
        options-table.c screen-write.c tmux.1 tmux.h tty-term.c tty.c 
        window-copy.c 
Log Message:
Sync OpenBSD patchset 914:

Support setting the xterm clipboard when copying from copy mode using
the xterm escape sequence for the purpose (if xterm is configured to
allow it).

Written by and much discussed Ailin Nemui, guidance on
xterm/termcap/terminfo from Thomas Dickey.


Index: tty.c
===================================================================
RCS file: /cvsroot/tmux/tmux/tty.c,v
retrieving revision 1.209
retrieving revision 1.210
diff -u -d -r1.209 -r1.210
--- tty.c       18 May 2011 20:28:43 -0000      1.209
+++ tty.c       22 May 2011 16:23:07 -0000      1.210
@@ -19,8 +19,11 @@
 #include <sys/types.h>
 #include <sys/ioctl.h>
 
+#include <netinet/in.h>
+
 #include <errno.h>
 #include <fcntl.h>
+#include <resolv.h>
 #include <stdlib.h>
 #include <string.h>
 #include <termios.h>
@@ -312,6 +315,13 @@
 }
 
 void
+tty_putcode_ptr2(struct tty *tty, enum tty_code_code code, const void *a, 
const void *b)
+{
+       if (a != NULL && b != NULL)
+               tty_puts(tty, tty_term_ptr2(tty->term, code, a, b));
+}
+
+void
 tty_puts(struct tty *tty, const char *s)
 {
        if (*s == '\0')
@@ -939,6 +949,24 @@
 }
 
 void
+tty_cmd_setselection(struct tty *tty, const struct tty_ctx *ctx)
+{
+       char    *buf;
+       size_t   off;
+
+       if (!tty_term_has(tty->term, TTYC_MS))
+               return;
+
+       off = 4 * ((ctx->num + 2) / 3) + 1; /* storage for base64 */
+       buf = xmalloc(off);
+
+       b64_ntop(ctx->ptr, ctx->num, buf, off);
+       tty_putcode_ptr2(tty, TTYC_MS, "", buf);
+
+       xfree(buf);
+}
+
+void
 tty_cmd_rawstring(struct tty *tty, const struct tty_ctx *ctx)
 {
        u_int    i;

Index: tty-term.c
===================================================================
RCS file: /cvsroot/tmux/tmux/tty-term.c,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -d -r1.48 -r1.49
--- tty-term.c  18 May 2011 20:28:43 -0000      1.48
+++ tty-term.c  22 May 2011 16:23:07 -0000      1.49
@@ -166,6 +166,7 @@
        { TTYC_KUP5, TTYCODE_STRING, "kUP5" },
        { TTYC_KUP6, TTYCODE_STRING, "kUP6" },
        { TTYC_KUP7, TTYCODE_STRING, "kUP7" },
+       { TTYC_MS, TTYCODE_STRING, "Ms" },
        { TTYC_OP, TTYCODE_STRING, "op" },
        { TTYC_REV, TTYCODE_STRING, "rev" },
        { TTYC_RI, TTYCODE_STRING, "ri" },
@@ -494,6 +495,12 @@
 const char *
 tty_term_string2(struct tty_term *term, enum tty_code_code code, int a, int b)
 {
+       return (tparm((char *) tty_term_string(term, code), a, b));
+}
+
+const char *
+tty_term_ptr2(struct tty_term *term, enum tty_code_code code, const void *a, 
const void *b)
+{
        return (tparm((char *) tty_term_string(term, code), a, b, 0, 0, 0, 0, 
0, 0, 0));
 }
 

Index: tmux.1
===================================================================
RCS file: /cvsroot/tmux/tmux/tmux.1,v
retrieving revision 1.313
retrieving revision 1.314
diff -u -d -r1.313 -r1.314
--- tmux.1      18 May 2011 20:35:36 -0000      1.313
+++ tmux.1      22 May 2011 16:23:07 -0000      1.314
@@ -1709,6 +1709,28 @@
 Set the number of buffers; as new buffers are added to the top of the stack,
 old ones are removed from the bottom if necessary to maintain this maximum
 length.
+.It Xo Ic set-clipboard
+.Op Ic on | off
+.Xc
+Attempt to set the terminal clipboard content using the
+\ee]52;...\e007
+.Xr xterm 1
+escape sequences.
+This option is on by default if there is an
+.Em \&Ms
+entry in the
+.Xr terminfo 5
+description for the client terminal.
+Note that this feature needs to be enabled in
+.Xr xterm 1
+by setting the resource:
+.Bd -literal -offset indent
+disallowedWindowOps: 20,21,SetXprop
+.Ed
+.Pp
+Or changing this property from the
+.Xr xterm 1
+interactive menu when required.
 .It Ic escape-time Ar time
 Set the time in milliseconds for which
 .Nm
@@ -2800,6 +2822,21 @@
 .D1 (alias: Ic info )
 Show server information and terminal details.
 .El
+.Sh TERMINFO EXTENSIONS
+.Nm
+understands some extensions to
+.Xr terminfo 5 :
+.Bl -tag -width Ds
+.It Em \&Ms
+This sequence can be used by
+.Nm
+to store the current buffer in the host terminal's selection (clipboard).
+See the
+.Em set-clipboard
+option above and the
+.Xr xterm 1
+man page.
+.El
 .Sh FILES
 .Bl -tag -width "/etc/tmux.confXXX" -compact
 .It Pa ~/.tmux.conf

Index: options-table.c
===================================================================
RCS file: /cvsroot/tmux/tmux/options-table.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- options-table.c     18 May 2011 20:30:14 -0000      1.9
+++ options-table.c     22 May 2011 16:23:07 -0000      1.10
@@ -74,6 +74,11 @@
          .default_num = 0 /* overridden in main() */
        },
 
+       { .name = "set-clipboard",
+         .type = OPTIONS_TABLE_FLAG,
+         .default_num = 1
+       },
+
        { .name = NULL }
 };
 
@@ -359,7 +364,8 @@
 
        { .name = "terminal-overrides",
          .type = OPTIONS_TABLE_STRING,
-         .default_str = "*88col*:colors=88,*256col*:colors=256,xterm*:XT"
+         .default_str = "*88col*:colors=88,*256col*:colors=256"
+                        ",xterm*:XT:Ms=\\E]52;%p1%s;%p2%s\\007"
        },
 
        { .name = "update-environment",

Index: screen-write.c
===================================================================
RCS file: /cvsroot/tmux/tmux/screen-write.c,v
retrieving revision 1.96
retrieving revision 1.97
diff -u -d -r1.96 -r1.97
--- screen-write.c      18 Apr 2011 21:06:49 -0000      1.96
+++ screen-write.c      22 May 2011 16:23:07 -0000      1.97
@@ -1195,6 +1195,18 @@
 }
 
 void
+screen_write_setselection(struct screen_write_ctx *ctx, u_char *str, u_int len)
+{
+       struct tty_ctx  ttyctx;
+
+       screen_write_initctx(ctx, &ttyctx, 0);
+       ttyctx.ptr = str;
+       ttyctx.num = len;
+
+       tty_write(tty_cmd_setselection, &ttyctx);
+}
+
+void
 screen_write_rawstring(struct screen_write_ctx *ctx, u_char *str, u_int len)
 {
        struct tty_ctx           ttyctx;

Index: window-copy.c
===================================================================
RCS file: /cvsroot/tmux/tmux/window-copy.c,v
retrieving revision 1.132
retrieving revision 1.133
diff -u -d -r1.132 -r1.133
--- window-copy.c       18 May 2011 20:35:36 -0000      1.132
+++ window-copy.c       22 May 2011 16:23:07 -0000      1.133
@@ -1345,6 +1345,9 @@
        }
        off--;  /* remove final \n */
 
+       if (options_get_number(&global_options, "set-clipboard"))
+               screen_write_setselection(&wp->ictx.ctx, buf, off);
+
        /* Add the buffer to the stack. */
        limit = options_get_number(&global_options, "buffer-limit");
        paste_add(&global_buffers, buf, off, limit);

Index: tmux.h
===================================================================
RCS file: /cvsroot/tmux/tmux/tmux.h,v
retrieving revision 1.624
retrieving revision 1.625
diff -u -d -r1.624 -r1.625
--- tmux.h      18 May 2011 20:35:36 -0000      1.624
+++ tmux.h      22 May 2011 16:23:07 -0000      1.625
@@ -304,6 +304,7 @@
        TTYC_KUP5,
        TTYC_KUP6,
        TTYC_KUP7,
+       TTYC_MS,        /* modify xterm(1) selection */
        TTYC_OP,        /* orig_pair, op */
        TTYC_REV,       /* enter_reverse_mode, mr */
        TTYC_RI,        /* scroll_reverse, sr */
@@ -1409,6 +1410,7 @@
 void   tty_putcode(struct tty *, enum tty_code_code);
 void   tty_putcode1(struct tty *, enum tty_code_code, int);
 void   tty_putcode2(struct tty *, enum tty_code_code, int, int);
+void   tty_putcode_ptr2(struct tty *, enum tty_code_code, const void *, const 
void *);
 void   tty_puts(struct tty *, const char *);
 void   tty_putc(struct tty *, u_char);
 void   tty_pututf8(struct tty *, const struct grid_utf8 *);
@@ -1440,6 +1442,7 @@
 void   tty_cmd_linefeed(struct tty *, const struct tty_ctx *);
 void   tty_cmd_utf8character(struct tty *, const struct tty_ctx *);
 void   tty_cmd_reverseindex(struct tty *, const struct tty_ctx *);
+void   tty_cmd_setselection(struct tty *, const struct tty_ctx *);
 void   tty_cmd_rawstring(struct tty *, const struct tty_ctx *);
 
 /* tty-term.c */
@@ -1452,6 +1455,8 @@
 const char     *tty_term_string1(struct tty_term *, enum tty_code_code, int);
 const char     *tty_term_string2(
                     struct tty_term *, enum tty_code_code, int, int);
+const char     *tty_term_ptr2(
+                    struct tty_term *, enum tty_code_code, const void *, const 
void *);
 int             tty_term_number(struct tty_term *, enum tty_code_code);
 int             tty_term_flag(struct tty_term *, enum tty_code_code);
 
@@ -1820,6 +1825,7 @@
 void    screen_write_clearscreen(struct screen_write_ctx *);
 void    screen_write_cell(struct screen_write_ctx *,
             const struct grid_cell *, const struct utf8_data *);
+void    screen_write_setselection(struct screen_write_ctx *, u_char *, u_int);
 void    screen_write_rawstring(struct screen_write_ctx *, u_char *, u_int);
 
 /* screen-redraw.c */


------------------------------------------------------------------------------
What Every C/C++ and Fortran developer Should Know!
Read this article and learn how Intel has extended the reach of its 
next-generation tools to help Windows* and Linux* C/C++ and Fortran 
developers boost performance applications - including clusters. 
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
tmux-cvs mailing list
tmux-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-cvs

Reply via email to