zsh-users
 help / color / mirror / code / Atom feed
From: "Marc Cornellà" <hello@mcornella.com>
To: Philippe Troin <phil@fifi.org>
Cc: zsh-users@zsh.org
Subject: Re: Detect typed input without swallowing characters
Date: Fri, 11 Feb 2022 10:08:41 +0100	[thread overview]
Message-ID: <CACn48No-sNDR84CjFgGmzeuOvRc7UMUwWm9TEcLgC0afFP=eQQ@mail.gmail.com> (raw)
In-Reply-To: <24180172015e6c9c3bab278c840eabcaa1a3249f.camel@fifi.org>

On Fri, 11 Feb 2022 at 01:04, Philippe Troin <phil@fifi.org> wrote:
>
> You can use zselect, but you have to disable canonical mode with stty,
> otherwise characters are not counted unless you press enter (the
> terminal is set to read a whole line at once).
>
> This function should work:
>
>    type_ahead() {
>      emulate -L zsh
>      local termios=$(stty --save)
>      stty -icanon
>      zselect -t 0 -r 0
>      local ret=$?
>      stty $termios
>      return ret
>    }
>

It does work, thanks! I tried my best at using STTY to avoid having to
reset it afterwards, but it didn't have the desired effect.
See https://github.com/ohmyzsh/ohmyzsh/commit/dbd92a62ce1fc25a6819ae6d0a29dc8b8ec9a7dd

Thanks!

Marc


  reply	other threads:[~2022-02-11  9:09 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-10 21:21 Marc Cornellà
2022-02-11  0:04 ` Philippe Troin
2022-02-11  9:08   ` Marc Cornellà [this message]
2022-02-11 16:15     ` Philippe Troin
2022-02-11 19:08     ` Bart Schaefer

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='CACn48No-sNDR84CjFgGmzeuOvRc7UMUwWm9TEcLgC0afFP=eQQ@mail.gmail.com' \
    --to=hello@mcornella.com \
    --cc=phil@fifi.org \
    --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).