zsh-workers
 help / color / mirror / code / Atom feed
From: Sebastian Gniazdowski <sgniazdowski@gmail.com>
To: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: Cannot invoke widget within zpty, with \C-a nor a
Date: Tue, 6 Nov 2018 18:08:22 +0100	[thread overview]
Message-ID: <CAKc7PVD=j1EmLWDen+YoAKZMBiOr5AcEGJ8h=yRrpbsS5Mc=Wg@mail.gmail.com> (raw)
In-Reply-To: <CAKc7PVA5BKywt0GEgJUWcC57bFqC6emwGthZQPe2YmcnA9HFYg@mail.gmail.com>

On Tue, 6 Nov 2018 at 16:19, Sebastian Gniazdowski
<sgniazdowski@gmail.com> wrote:
>
> Hello,
> I've attached complete test file. The test body is:
>
>   zpty_start
>   zpty_input 'stty 38400 columns 80 rows 24 tabs -icanon -iexten' nl
>   zpty_input 'rh_widget() { BUFFER="ls"; region_highlight+=( 0 4
> "fg=#12569a" ); echo yes; }' nl
>   zpty_input 'zle -N rh_widget' nl
>   zpty_input 'bindkey "\C-a" rh_widget' nl
>   zpty_input 'zle -la | grep rh_widget' nl
>   zpty_input 'bindkey | grep rh_widget' nl
>   zpty_input $'\C-a'
>   zpty_stop
> 0:region_highlight
> *>*ls*

I now see that testing the running of zle widgets is in general
difficult, even with zpty. X03zlebindkey.ztst does only `-s' bindkeys,
which do not run a zle-widget, `zle && true || echo nozle' will
display "nozle". I would believe that this is lost game, as even this
didn't work as expected:

rh_widget() { local FD="$1"; zle -F -w $FD; exec {FD}<&-; BUFFER="ls";
region_highlight+=( 0 4 "fg=#12569a" ); echo yes | tee -a /tmp/reply;
}; zle -N rh_widget
FD=1337; exec {FD}< <( LANG=C sleep 0.5; echo run | tee -a /tmp/reply
); command true; zle -F -w "$FD" rh_widget

... however, it turned out that the `+Z' option passed to zsh-binary
(its meaning: disable Zle) was responsible for not interpreting any
key sequences (and not activating zle -F, however removing +Z didn't
help here actually). I now have the `rh_widget' called after zpty -w
zsh $'\C-a'.

The `region_highlight' tests (brought up because of wanting to test
true/near-color, but also revealed that general `rh' use is untested
and this rather should change) seem to be possible to write.

-- 
Sebastian Gniazdowski
News: https://twitter.com/ZdharmaI
IRC: https://kiwiirc.com/client/chat.freenode.net:+6697/#zplugin
Blog: http://zdharma.org

  reply	other threads:[~2018-11-06 17:08 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-06 15:19 Sebastian Gniazdowski
2018-11-06 17:08 ` Sebastian Gniazdowski [this message]
2018-11-06 17:15   ` Peter Stephenson
2018-11-06 19:53     ` Sebastian Gniazdowski
2018-11-06 19:55       ` Sebastian Gniazdowski

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='CAKc7PVD=j1EmLWDen+YoAKZMBiOr5AcEGJ8h=yRrpbsS5Mc=Wg@mail.gmail.com' \
    --to=sgniazdowski@gmail.com \
    --cc=zsh-workers@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).