Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Cannot invoke widget within zpty, with \C-a nor a



On Tue, 6 Nov 2018 at 16:19, Sebastian Gniazdowski
<sgniazdowski@xxxxxxxxx> 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



Messages sorted by: Reverse Date, Date, Thread, Author