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

Re: insert-unicode-char



Thanks, it works!

On Thu, 24 Nov 2005 14:39:09 +0000, Peter Stephenson wrote about "Re: insert-unicode-char":
> "Zvi Har'El" wrote:
> > I am trying to use the new insert-unicode-char in a vi emulation - insetmode,
> > using
> > 
> >         autoload insert-unicode-char
> >         zle -N insert-unicode-char
> >         bindkey -v '^y' insert-unicode-char
> > 
> > It works, accept I cannot enter  two unicode characters in a row.
> 
> Yes, that was an oversight.  It needs an extra flag to check that it's
> really on the second stage rather than the first, otherwise it gets
> confused by back-to-back uses.
> 
> Index: Functions/Zle/insert-unicode-char
> ===================================================================
> RCS file: /cvsroot/zsh/zsh/Functions/Zle/insert-unicode-char,v
> retrieving revision 1.3
> diff -u -r1.3 insert-unicode-char
> --- Functions/Zle/insert-unicode-char	24 Nov 2005 10:25:34 -0000	1.3
> +++ Functions/Zle/insert-unicode-char	24 Nov 2005 14:35:35 -0000
> @@ -1,7 +1,10 @@
>  # Make hex integers appear as 0x...
>  setopt localoptions cbases
>  
> -if [[ $LASTWIDGET = insert-unicode-char ]]; then
> +integer -g _insert_unicode_ready
> +
> +if [[ $LASTWIDGET = insert-unicode-char && $_insert_unicode_ready -eq 1 ]]
> +then
>    # Second call; we should have a usable prefix.
>    # If we don't, give up.
>    (( ${+NUMERIC} )) || return 1
> @@ -9,9 +12,11 @@
>    local -i 16 -Z 10 arg=$NUMERIC
>    # ...and use print to turn this into a Unicode character.
>    LBUFFER+="$(print -n "\U${arg##0x}")"
> +  _insert_unicode_ready=0
>  else
>    # Set the base to 16...
>    zle argument-base 16
>    # ...wait for user to type hex keys then call this widget again.
>    zle universal-argument
> +  _insert_unicode_ready=1
>  fi
> 
> -- 
> Peter Stephenson <pws@xxxxxxx>                  Software Engineer
> CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
> Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070
> 
> 
> This message has been scanned for viruses by BlackSpider MailControl - www.blackspider.com

-- 
Dr. Zvi Har'El      mailto:rl@xxxxxxxxxxxxxxxxxxx    Department of Mathematics
tel:+972-54-4227607 icq:179294841    Technion - Israel Institute of Technology
fax:+972-4-8293388  http://www.math.technion.ac.il/~rl/    Haifa 32000, ISRAEL
"If you can't say somethin' nice, don't say nothin' at all." -- Thumper (1942)
                          Thursday, 22 Heshvan 5766, 24 November 2005,  5:01PM



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