[dev] st: nano-paste fix

From: Martti Kühne <mysatyre_AT_gmail.com>
Date: Wed, 11 Jan 2012 12:33:33 +0100

On Tue, Jan 10, 2012 at 10:04:13PM +0100, Martti Kühne wrote:
> Which reminds me, I just wanted to paste the diffs into st where I'm writing
> this email and it seems copy/pasting doesn't work well with newlines. I might
> be back later or tomorrow with another one. =)

Not sure if this would work better in a different place, although the only case
where things go not to nano's liking is here.

Debugging ttywrite() got me thinking, why is it that pressing Enter will not
result in what would seem logical '\n' but '\r' as well instead?
tty(1) mentions CR, though I'm completely lost if/why that be the right place.

--- st/st.c 2011-11-02 21:24:08.893374099 +0100
+++ st-nanopaste/st.c 2012-01-11 12:13:15.011070888 +0100
_AT_@ -500,7 +500,7 @@
 void
 selnotify(XEvent *e) {
         unsigned long nitems, ofs, rem;
- int format;
+ int format, i;
         unsigned char *data;
         Atom type;
 
_AT_@ -512,6 +512,9 @@
                         fprintf(stderr, "Clipboard allocation failed\n");
                         return;
                 }
+ for(i = 0; i < nitems * format / 8; i++)
+ if(data[i] == '\n')
+ data[i] = '\r';
                 ttywrite((const char *) data, nitems * format / 8);
                 XFree(data);
                 /* number of 32-bit chunks returned */

I'm on sandy now, and I don't see the cursor because somehow the rest of the
line has almost the same color...

cheers!
mar77i
Received on Wed Jan 11 2012 - 12:33:33 CET

This archive was generated by hypermail 2.3.0 : Wed Jan 11 2012 - 12:36:04 CET