Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: PATCH: query terminal properties on ZLE startup
- X-seq: zsh-workers 53400
- From: Oliver Kiddle <opk@xxxxxxx>
- To: Roman Perepelitsa <roman.perepelitsa@xxxxxxxxx>
- Cc: zsh-workers@xxxxxxx
- Subject: Re: PATCH: query terminal properties on ZLE startup
- Date: Mon, 03 Mar 2025 22:07:10 +0100
- Archived-at: <https://zsh.org/workers/53400>
- In-reply-to: <CAN=4vMrvw_sz65Q5hnCi+e0FLzpMhcY7LCxkMBVNXTc9F4hBGg@mail.gmail.com>
- List-id: <zsh-workers.zsh.org>
- References: <42572-1740099942.836692@_3BM.v5Iz.JqiS> <F07C8421-2663-440A-82AD-0748D39511B1@kba.biglobe.ne.jp> <CAH+w=7a9hye-2BxQUjkHw-=zFo5T7vXjVwQRnKnKEoZ3W0-_ug@mail.gmail.com> <40483-1740433325.086036@2QZo.3hhS.-9FG> <CAH+w=7Zf3vL6BYg0t61uskLmDD_gOwE7XhuwxB9SSwv+z0qOKw@mail.gmail.com> <69272-1740474756.308875@TCCj.PrGv.2vsI> <CAH+w=7ZJNRy2zV7t4wRhzcnW1jn2LgRKbMByCOrtbr9VVM2emw@mail.gmail.com> <5355-1740527169.384113@fufd.0HLy.otw9> <CAN=4vMpHQyTmXBScGZDn+OTc=cDWKSt7vJ_2+hmTe1zViQyU8w@mail.gmail.com> <73847-1740613975.581764@cI3H.WJge.amo7> <CAN=4vMrvw_sz65Q5hnCi+e0FLzpMhcY7LCxkMBVNXTc9F4hBGg@mail.gmail.com>
On 27 Feb, Roman Perepelitsa wrote:
> Regarding timeouts, tmux also queries the terminal on startup.
> Initially, it had a 1-second timeout, which was later increased to 3
> seconds (tmux github issue #2984) and then to 5 seconds (commit
> c767d62). If the terminal responds after the timeout has already
> triggered, the response is passed to the user process--typically a
> shell--causing a mess. I've seen this happen with a 1-second timeout.
The disadvantage of setting a generous timeout up-front is that we'll
never gather any experience to allow us to fine-tune it to strike the
right balance with the default timeout. The failure properties
with tmux are perhaps more severe because the behaviour of the client
application is unpredictable. I'm hopeful that the changes to the key
input code to discard late arriving responses will make it fairly
benign.
If someone comes up with a good name for a query timeout variable I can
write a patch for that (0 can be used for infinite). Should it be in the
.zle namespace?
It would also be possible to make it easier to do things like querying
the cursor position - if that would be useful? It'd be a bit odd to put
results in the .term, namespace for something that'll quickly change
like the cursor position. Maybe a builtin, perhaps an option to zle,
or a new builtin. Any ideas on a name, echotx perhaps? ttyctl has an
appropriate name and doesn't otherwise do a huge amount.
> Another issue to watch for is buffered input that is sent to the TTY
> before zsh starts. A simple test:
>
> 1. Run: sh -c 'sleep 5; zsh -f'
> 2. While sleep is running, paste the following:
>
> echo $$
> exit
> echo $$
>
> 3. Wait for sh to exit.
I mentioned this in the original post. Quoting myself from there:
| When reading responses, it takes care to unget any characters that
| weren't consumed. This does mean that if you managed to type, not only a
| command but the initial part of your input to the command before zle is
| initialised then zsh will have grabbed all that input. I guess we could
| try ungetc(). Type-ahead does get run through the sequence parser. We
| could use a FIONREAD ioctl first to minimise that but it didn't seem
| worth the bother.
I'm assuming you're already living with this disadvantage so don't
consider it too major. I don't think it's ever affected me in the time
I've used the queries.
Thanks.
Oliver
Messages sorted by:
Reverse Date,
Date,
Thread,
Author