Tim Chase
unread,Apr 21, 2020, 3:14:50 PM4/21/20Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Cameron Simpson, vim...@googlegroups.com, v...@vim.org, Tim Chase
On 2020-04-21 08:20, Cameron Simpson wrote:
> On 19Apr2020 22:06, Tim Chase <
v...@tim.thechases.com> wrote:
> >I'm playing around with a curses program and would like it to
> >behave similarly to how vim lets me do
> >
> > $ echo hello | vim -
> >
> >where vim reads data from stdin but then interacts with the
> >terminal directrly. What magic is vim doing here?
>
> Typically stdin, stdout and stderr are all os.dup()s of the
> terminal.
>
> In the above vim's stdin will of course be the pipe but stdout and
> stderr are still attached; it could dup one of them to stdin again
> and proceed.
>
> Or it might just open /dev/tty again after reading stdin if that
> isn't a tty.
Thanks, Cameron & Eli. I tried meandering through the vim source
and, while this is what it looked like it was doing (i.e., using
stderr for input), it made no sense to me. Now it makes more sense.
So now at least I have two possible courses of action (use stderr or
(re)open /dev/tty). Time to try and bludgeon curses into pulling its
input from some place other than stdin. Or possibly re-attaching
stdin to the stderr file descriptor.
Thanks again!
-tim