zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Ray Andrews <rayandrews@eastlink.ca>
Cc: zsh-users@zsh.org
Subject: Re: one time in 20 error
Date: Wed, 30 Nov 2022 16:03:44 -0800	[thread overview]
Message-ID: <CAH+w=7aW9meLuEKSGsKiZMXoAd7KBc9fgakXZnB_t2iphq=BPQ@mail.gmail.com> (raw)
In-Reply-To: <57e8e248-bb1a-663a-8557-e3fc13f671d4@eastlink.ca>

On Wed, Nov 30, 2022 at 5:56 AM Ray Andrews <rayandrews@eastlink.ca> wrote:
>
> Well, so far the 'timeout' is working 100%, still I myself would sorta
> build that in to 'zcurses end'.  While in zcurses,it owns all inputs so
> on quitting the idea that some input would be 'forwarded' to the
> terminal seems strange.

Suppose you have a curses program that's controlled from the keyboard,
and when you type shift-Q that program calls "zcurses end".  Now, you
happen to be a 300-words-per-minute typist, so upon hitting Q you
instinctively begin typing the first word of the next command that you
expect to execute, without waiting for a prompt.  Should zcurses
swallow up all or part of that command because it "owns" the input?

> As you say there are these
> 'generated by the terminal' ... but I don't know anything about such
> things.  Seems to me the terminal receives input, not makes input

Everything about ANSI terminal control is unfortunately "in-band":
There is only one data stream between whatever program is using the
terminal (zsh in this case) and the terminal itself, which
(importantly) includes the keyboard.  All those weird sequences
starting with ^[[ or similar are still sent to (and from!) the
terminal via the same stream as the prompt or the output of "ls" or
your typing or copy-pasting or whatever.  In the "to" direction, the
terminal notices ^[[ followed by something, and interprets it as a
command (change the color, move the cursor, etc.) instead of as
"normal" characters to be displayed.  Some of those commands ask the
terminal for data (tell me the cursor position, tell me where the
mouse was clicked, etc.).  In that case data is sent in the "from"
direction:  the terminal writes ^[[ followed by the requested data,
and the program using the terminal is expected to recognize the ^[[ as
"not normal" and read it -- but there's nothing else to distinguish
that from something that was typed on the keyboard, it's all on the
same stream.  So unless the program is waiting for one of those ^[[
sequences, it responds as if you typed it.

One of Roman's hacks (his skip-csi-sequence function) is to make zsh
ALWAYS be "waiting for" one of those sequences, so as to throw it away
if it wasn't really requested.


  parent reply	other threads:[~2022-12-01  0:04 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-28 17:40 Ray Andrews
2022-11-28 17:54 ` Roman Perepelitsa
2022-11-28 20:34   ` Ray Andrews
2022-11-28 20:46     ` Roman Perepelitsa
2022-11-28 22:16       ` Ray Andrews
2022-11-28 22:24         ` Roman Perepelitsa
2022-11-28 23:18           ` Ray Andrews
2022-11-29  2:48 ` Risto Laitinen
2022-11-29  3:27   ` Ray Andrews
2022-11-29 10:13   ` Roman Perepelitsa
2022-11-29 13:29     ` Ray Andrews
2022-11-30  4:32       ` Bart Schaefer
2022-11-30 13:56         ` Ray Andrews
2022-11-30 14:10           ` Roman Perepelitsa
2022-11-30 20:23             ` Ray Andrews
2022-11-30 23:17               ` Ray Andrews
2022-11-30 23:46                 ` Bart Schaefer
2022-12-01  0:03           ` Bart Schaefer [this message]
2022-12-01  3:20             ` Ray Andrews
2022-12-01  9:19               ` Roman Perepelitsa
2022-12-01 14:35                 ` Ray Andrews
2022-12-01 14:42                   ` Philippe Altherr
2022-12-01 21:19                     ` Ray Andrews

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAH+w=7aW9meLuEKSGsKiZMXoAd7KBc9fgakXZnB_t2iphq=BPQ@mail.gmail.com' \
    --to=schaefer@brasslantern.com \
    --cc=rayandrews@eastlink.ca \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).