zsh-workers
 help / color / mirror / code / Atom feed
* pws-18: Multiline cut'n'paste - second go.
@ 1999-05-14 10:15 Andrej Borsenkow
  1999-05-14 12:13 ` Peter Stephenson
  0 siblings, 1 reply; 3+ messages in thread
From: Andrej Borsenkow @ 1999-05-14 10:15 UTC (permalink / raw)
  To: ZSH workers mailing list

Now Zsh correctly handles multiline input in *single* command (that is, with
PS2) - but not, when every line is a separate command.

Here is what you get when pasting more than one line (zsh in question is in
normal PS1 state):

bor@itsrm2:~%> truss -t read,write,ioctl -r 10 -w 10 -p 22812
read(10, 0x000000FFFFFEE7E4, 1) (sleeping...)
read(10, " c", 1)                               = 1
write(10, " c", 1)                              = 1
read(10, " o", 1)                               = 1
write(10, "\b c o", 3)                          = 3
read(10, " m", 1)                               = 1
write(10, " m", 1)                              = 1
read(10, " p", 1)                               = 1
write(10, " p", 1)                              = 1
read(10, " c", 1)                               = 1
write(10, " c", 1)                              = 1
read(10, " o", 1)                               = 1
write(10, " o", 1)                              = 1
read(10, " n", 1)                               = 1
write(10, " n", 1)                              = 1
read(10, " f", 1)                               = 1
write(10, " f", 1)                              = 1
read(10, "  ", 1)                               = 1
write(10, "  ", 1)                              = 1
read(10, " c", 1)                               = 1
write(10, " c", 1)                              = 1
read(10, " o", 1)                               = 1
write(10, " o", 1)                              = 1
read(10, " r", 1)                               = 1
write(10, " r", 1)                              = 1
read(10, " r", 1)                               = 1
write(10, " r", 1)                              = 1
read(10, " e", 1)                               = 1
write(10, " e", 1)                              = 1
read(10, " c", 1)                               = 1
write(10, " c", 1)                              = 1
read(10, " t", 1)                               = 1
write(10, " t", 1)                              = 1
read(10, " _", 1)                               = 1
write(10, " _", 1)                              = 1
read(10, " a", 1)                               = 1
write(10, " a", 1)                              = 1
read(10, " c", 1)                               = 1
write(10, " c", 1)                              = 1
read(10, " c", 1)                               = 1
write(10, " c", 1)                              = 1
read(10, " e", 1)                               = 1
write(10, " e", 1)                              = 1
read(10, " p", 1)                               = 1
write(10, " p", 1)                              = 1
read(10, " t", 1)                               = 1
write(10, " t", 1)                              = 1
read(10, " =", 1)                               = 1
write(10, " =", 1)                              = 1
read(10, " '", 1)                               = 1
write(10, " '", 1)                              = 1
read(10, " 2", 1)                               = 1
write(10, " 2", 1)                              = 1
read(10, " n", 1)                               = 1
write(10, " n", 1)                              = 1
read(10, " '", 1)                               = 1
write(10, " '", 1)                              = 1
read(10, "\n", 1)                               = 1
write(10, "\r\n", 2)                            = 2
ioctl(10, TCGETA, 0x000000FFFFFEEC6C)           = 0
ioctl(10, TCSETSW, 0x000000000050B1A8)          = 0
!!^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^!!

ioctl(0, I_FIND, "sockmod")                     = 0
ioctl(10, TIOCGSID, 0x000000FFFFFEECAC)         = 0
ioctl(10, TIOCSPGRP, 0x000000FFFFFEECF4)        = 0
ioctl(10, FIONREAD, 0x000000FFFFFEE7BC)         = 0
ioctl(10, TIOCGSID, 0x000000FFFFFEE6FC)         = 0
ioctl(10, TIOCSPGRP, 0x000000FFFFFEE744)        = 0
ioctl(10, TCGETA, 0x000000FFFFFEE6FC)           = 0
ioctl(10, TCSETSW, 0x000000FFFFFEE7C0)          = 0
write(10, 0x0000000000505EB0, 50)               = 50
  \r1B [ 0 m1B [ 2 2 ; 2 7 m1B [ 2 4 m1B [ J1B [ 2 ; 7 m b o r @ i
   t s r m 2 : ~ % >1B [ 2 2 ; 2 7 m
write(10, "1B [ K", 3)                          = 3
read(10, 0x000000FFFFFEE7E4, 1) (sleeping...)

As you see, we get TCSETSW *immediately* after NL was seen (and output).
That throughs away any pending input - so, following FIONREAD is a noop.

/andrej


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

* Re: pws-18: Multiline cut'n'paste - second go.
  1999-05-14 10:15 pws-18: Multiline cut'n'paste - second go Andrej Borsenkow
@ 1999-05-14 12:13 ` Peter Stephenson
  1999-05-29  7:51   ` Bart Schaefer
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Stephenson @ 1999-05-14 12:13 UTC (permalink / raw)
  To: ZSH workers mailing list

"Andrej Borsenkow" wrote:
> Now Zsh correctly handles multiline input in *single* command (that is, with
> PS2) - but not, when every line is a separate command.

I understand the problem (tell me I'm wrong, go on), but I don't really see
what can be done about it. The TCSETSW comes from settyinfo(), probably via
tcsetattr(SHTTY, TCSADRAIN, ...), which is equivalent.  When zle is being
used, the terminal has to be set back to it's ordinary mode for ordinary
commands to run, because there's no way it can know what's being run, which
will cause this; the OSes with this problem simply don't seem to allow
`change the terminal modes without screwing up typeahead' --- if we could
find a way of doing that we're home and dry.  With the previous patch, we
delayed changing the modes till the end of parsing for one complete set of
input because nothing got executed in that time, but now we've got a
complete set of input, time's up.

The only half way out I can see would be to remember the terminal setting
and not change it until an external command, or an internal command doing
I/O, is started.  That's a big and bug-prone thing to do, and if the pasted
commands call something external then you're out of luck anyway.  Maybe
someone can think of a way round.

There are workarounds, although you've probably thought of those: type
{<RETURN> before the paste, and }<RETURN> afterwards, then it's all done
inside PS2; or temporarily turning off zle during pasting.  Even that last
can't be automated, because if zle is running when the, er, paste hits the
fan, then you will at some point need to switch the terminal modes for
running the commands.

-- 
Peter Stephenson <pws@ibmth.df.unipi.it>       Tel: +39 050 844536
WWW:  http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy


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

* Re: pws-18: Multiline cut'n'paste - second go.
  1999-05-14 12:13 ` Peter Stephenson
@ 1999-05-29  7:51   ` Bart Schaefer
  0 siblings, 0 replies; 3+ messages in thread
From: Bart Schaefer @ 1999-05-29  7:51 UTC (permalink / raw)
  To: ZSH workers mailing list

On May 14,  2:13pm, Peter Stephenson wrote:
} Subject: Re: pws-18: Multiline cut'n'paste - second go.
}
} I understand the problem (tell me I'm wrong, go on), but I don't really see
} what can be done about it. The TCSETSW comes from settyinfo(), probably via
} tcsetattr(SHTTY, TCSADRAIN, ...), which is equivalent.  When zle is being
} used, the terminal has to be set back to it's ordinary mode for ordinary
} commands to run, because there's no way it can know what's being run, which
} will cause this; the OSes with this problem simply don't seem to allow
} `change the terminal modes without screwing up typeahead' --- if we could
} find a way of doing that we're home and dry.

If the system supports TIOCSTI, we could consume all the typeahead, change
the terminal mode, and then ioctl() the characters back through the driver.
However, there's a limit on how many bytes you can shove around that way,
and there'd still be some places it didn't work, so I'd just as soon we
don't mess with it.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


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

end of thread, other threads:[~1999-05-29  7:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-05-14 10:15 pws-18: Multiline cut'n'paste - second go Andrej Borsenkow
1999-05-14 12:13 ` Peter Stephenson
1999-05-29  7:51   ` Bart Schaefer

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).