[hackers] [st] Add bracketed paste mode || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Mon, 23 Sep 2013 09:26:40 +0200

commit 630a282ff83579df713760c344e8d3a1f413aade
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
Date: Mon Sep 23 09:22:47 2013 +0200

    Add bracketed paste mode
    
    This patch enables bracketed paste mode (
    http://invisible-island.net/xterm/ctlseqs/ctlseqs.html#Bracketed%20Paste%20Mode
    ).
    
    It's mainly useful for text editors to disable line wrapping and auto
    indentation when text is being pasted, rather than typed from keyboard.
    
    On the emulator side, it is supported by at least xterm, urxvt,
    gnome-terminal, putty, iterm2; and I have a patch for konsole.
    
    On the application side, vim can be configured easily to handle this, and
    I have pending patches for mcedit and joe. Probably many others also
    support it.

diff --git a/st.c b/st.c
index 3321c31..df58e9e 100644
--- a/st.c
+++ b/st.c
_AT_@ -132,6 +132,7 @@ enum term_mode {
         MODE_FOCUS = 65536,
         MODE_MOUSEX10 = 131072,
         MODE_MOUSEMANY = 262144,
+ MODE_BRCKTPASTE = 524288,
         MODE_MOUSE = MODE_MOUSEBTN|MODE_MOUSEMOTION|MODE_MOUSEX10\
                           |MODE_MOUSEMANY,
 };
_AT_@ -1013,7 +1014,11 @@ selnotify(XEvent *e) {
                         *repl++ = ' ';
                 }
 
+ if(IS_SET(MODE_BRCKTPASTE))
+ ttywrite("[200~", 6);
                 ttywrite((const char *)data, nitems * format / 8);
+ if(IS_SET(MODE_BRCKTPASTE))
+ ttywrite("[201~", 6);
                 XFree(data);
                 /* number of 32-bit chunks returned */
                 ofs += nitems * format / 32;
_AT_@ -1868,6 +1873,9 @@ tsetmode(bool priv, bool set, int *args, int narg) {
                         case 1048:
                                 tcursor((set) ? CURSOR_SAVE : CURSOR_LOAD);
                                 break;
+ case 2004: /* 2004: bracketed paste mode */
+ MODBIT(term.mode, set, MODE_BRCKTPASTE);
+ break;
                         /* Not implemented mouse modes. See comments there. */
                         case 1001: /* mouse highlight mode; can hang the
                                       terminal by design when implemented. */
Received on Mon Sep 23 2013 - 09:26:40 CEST

This archive was generated by hypermail 2.3.0 : Mon Sep 23 2013 - 09:36:16 CEST