zsh-workers
 help / color / mirror / code / Atom feed
* bracketed paste
@ 2015-07-15 16:51 Yuri D'Elia
  2015-07-15 17:33 ` Yuri D'Elia
  2015-07-16  5:19 ` Oliver Kiddle
  0 siblings, 2 replies; 51+ messages in thread
From: Yuri D'Elia @ 2015-07-15 16:51 UTC (permalink / raw)
  To: zsh-workers

Did the bracketedpaste widget made into 5.0.8?

The detailed release notes: http://zsh.sourceforge.net/releases.html are
missing, and I'm too lazy to diff ;)

In my current code, I decided to strip any blank from the string before
quoting and inserting into command line.

This has the effect of removing any leading/trailing newlines (or gobs
of whitespace, if you're pasting from a web page) without destroying the
content.

Also, I realized sometimes a final newline was tricking me into thinking
that the command was already enter-ed to the shell (but of course, it
wasn't). Stripping any final newlines is an improvement.

I'd like to do the same using the final widget if possible.


^ permalink raw reply	[flat|nested] 51+ messages in thread
* bracketed paste
@ 2015-11-18 19:57 Yuri D'Elia
  2015-11-19  6:05 ` Bart Schaefer
  0 siblings, 1 reply; 51+ messages in thread
From: Yuri D'Elia @ 2015-11-18 19:57 UTC (permalink / raw)
  To: zsh-workers

If you remember, I sent a patch for urxvt and bracketed paste in Debian
a while ago:

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=787628

I now realized that we could avoid all the escaping madness if we
re-define what bracketed paste should do for us. I briefly checked and
found no use in the wild of bracketed paste (scanning for the escapes in
google and github).

This made me think what I've written before in the bug report: what if
the terminal just encodes into base64 the block to be pasted? What we'd
need to just is just wait for the end sequence, decode the block, and we
have no other issues with break processing. It would even allow to send
binary content in the way (d&d in the terminal, who-ho!).

Heck, I'll write a patch to xterm myself if I'd need to push this through.


^ permalink raw reply	[flat|nested] 51+ messages in thread
* bracketed paste
@ 2011-11-07 22:31 Oliver Kiddle
  2011-11-07 22:42 ` Mikael Magnusson
  0 siblings, 1 reply; 51+ messages in thread
From: Oliver Kiddle @ 2011-11-07 22:31 UTC (permalink / raw)
  To: Zsh workers

Has anyone tried enabling the bracketed paste feature of xterm?

Basically, when you paste text it is preceded by \e[200~ and terminated
with \e[201~. This has the potential to solve some irritations with
paste: undo can undo all the pasted text in one go, pasted tab
characters won't invoke completion and in vi command mode, pasted text
mightn't be treated as vi commands.

To handle this, what I've tried so far is putting \e[?2004h at the end
of PS1 and PS2 to enable it and \e[?2004l in POSTEDIT so it doesn't
remain enabled for other software. I then put together the following
zle widget which is, of course, bound to \e[200~.

bracketed-paste() { 
 local REPLY paste
 local end=$'\e[201~' idx=1
 while (( idx <= $#end )) && read -k 1; do
   paste+="${REPLY/$'\r'/
}"
   [[ $REPLY = $end[idx++] ]] || (( idx = 1 + (#REPLY == #end) ))
 done
 if (( NUMERIC )); then
   LBUFFER+="${(q)paste%$end}"
 else
   LBUFFER+="${paste%$end}"
 fi
}

The main problem I've found is that you can't paste into the mini-
buffer. Is there any way around that?

Does it make sense to include this function in Functions/Zle? It would
still require people to enable bracketed paste in their xterm. Any other
thoughts on what you might do with the pasted text besides pasting it.
$LASTWIDGET might be useful here. The function above quotes the text if
you supply a numeric argument. This can be useful when pasting, e.g.
URLs. In the past, I've used a separate widget that tries to get the
buffer with xclip, xselection or xprop.

Oliver


^ permalink raw reply	[flat|nested] 51+ messages in thread

end of thread, other threads:[~2015-11-19  9:33 UTC | newest]

Thread overview: 51+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-15 16:51 bracketed paste Yuri D'Elia
2015-07-15 17:33 ` Yuri D'Elia
2015-07-15 18:15   ` Mikael Magnusson
2015-07-15 18:43     ` Yuri D'Elia
2015-07-16  5:19 ` Oliver Kiddle
2015-07-16 14:32   ` Yuri D'Elia
2015-07-18  2:33     ` Oliver Kiddle
2015-07-18 11:55       ` Yuri D'Elia
2015-07-18 17:17       ` Bart Schaefer
2015-07-18 23:28         ` Oliver Kiddle
2015-07-19  8:13           ` Unmetafy of getsparam() Bart Schaefer
2015-07-21 20:07             ` Peter Stephenson
2015-07-21 23:08               ` Bart Schaefer
2015-07-23  8:50             ` Peter Stephenson
2015-07-16 20:15   ` bracketed paste Bart Schaefer
2015-07-18 12:05     ` Yuri D'Elia
2015-07-18 18:08       ` Bart Schaefer
2015-07-19  2:50         ` PATCH: highlight pasted text Oliver Kiddle
2015-07-19  8:17           ` Bart Schaefer
2015-07-19 12:13           ` Yuri D'Elia
2015-07-19 17:12             ` Daniel Shahaf
2015-07-19 18:10               ` Bart Schaefer
2015-07-21 15:23                 ` Oliver Kiddle
2015-07-21 17:35                   ` Bart Schaefer
2015-07-23  3:57                     ` Oliver Kiddle
2015-07-19 17:57             ` Oliver Kiddle
2015-07-19 18:09               ` Yuri D'Elia
2015-08-08 21:51               ` Daniel Shahaf
2015-08-14  1:38                 ` Oliver Kiddle
2015-08-14  5:28                   ` Bart Schaefer
2015-07-23  5:00           ` Mikael Magnusson
2015-07-23  6:23             ` Oliver Kiddle
2015-07-24  5:06               ` Bart Schaefer
2015-07-24  5:21                 ` Bart Schaefer
2015-07-24 22:22                   ` Oliver Kiddle
2015-07-24 23:13                     ` Bart Schaefer
2015-07-25  7:49                       ` Oliver Kiddle
2015-07-25 16:46                         ` zle options (was Re: PATCH: highlight pasted text) Bart Schaefer
2015-07-28  9:09                           ` Oliver Kiddle
2015-07-24 19:06                 ` Vim special marks - Re: PATCH: highlight pasted text Oliver Kiddle
2015-07-24 19:45                   ` Bart Schaefer
2015-08-11 11:16                   ` Oliver Kiddle
2015-08-13 23:14             ` Daniel Shahaf
2015-08-13 23:50               ` Bart Schaefer
2015-08-14  2:09                 ` Oliver Kiddle
2015-08-14  5:24                   ` Bart Schaefer
  -- strict thread matches above, loose matches on Subject: below --
2015-11-18 19:57 bracketed paste Yuri D'Elia
2015-11-19  6:05 ` Bart Schaefer
2015-11-19  9:33   ` Yuri D'Elia
2011-11-07 22:31 Oliver Kiddle
2011-11-07 22:42 ` Mikael Magnusson

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).