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

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



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*

The result is always:

Pattern match filead, line mismatch (1/3):
 <*ls*
 >rh_widget
 >"^A" rh_widget
 >zsh: command not found: ^A

Note that the 2 middle lines confirm the widget is created and bound to Ctrl-A.

I can change Ctrl-A sequence to just letter "a", and the result is the
same. I've tried also without the first stty command (I was looking
for some needed initialization in Y0* completion tests, that's why
it's there). What can be the cause?

Ctrl-T was invoking TTY "status" command, which on BSD gives system
load. So I've changed to TTY-unused Ctrl-A. I just need to invoke zle
widget so if there is other method (zle -F didn't work) I can use it.

-- 
Sebastian Gniazdowski
News: https://twitter.com/ZdharmaI
IRC: https://kiwiirc.com/client/chat.freenode.net:+6697/#zplugin
Blog: http://zdharma.org
# Tests for region_highlight, true-color support, near-color support

%prep

  if [[ $OSTYPE == cygwin ]]; then
    ZTST_unimplemented='the zsh/zpty module does not work on Cygwin'
  elif zmodload zsh/zpty 2> /dev/null; then
    zpty_start() {
      export PS1= PS2=
      zpty -d
      zpty zsh "${(q)ZTST_testdir}/../Src/zsh -fiV +Z"
    }
    zpty_input() {
      zpty -w zsh "$1" ${${(M)2:#nl}:+$'\n'}
    }
    zpty_line() {
      local REPLY
      integer i
      for (( i = 0; i < ${1:-1}; ++i )); do
        zpty -r zsh REPLY
        print -r -- ${REPLY%%($'\r\n'|$'\n')}
      done
    }
    zpty_stop() {
      # exit twice in case of check_jobs
      zpty -w zsh $'exit\nexit\n'
      # zpty gives no output when piped without these braces (?)
      { zpty -r zsh } | sed $'/[^[:space:]]/!d; s/\r$//;'
      zpty -d
      :
    }
  else
    ZTST_unimplemented='the zsh/zpty module is not available'
  fi

%test

  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*

%clean

  zmodload -ui zsh/zpty

# vim:ft=zsh


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