zsh-workers
 help / color / mirror / code / Atom feed
* insert-unicode-char
@ 2005-11-24 14:08 Zvi Har'El
  2005-11-24 14:33 ` insert-unicode-char Zvi Har'El
  2005-11-24 14:39 ` insert-unicode-char Peter Stephenson
  0 siblings, 2 replies; 6+ messages in thread
From: Zvi Har'El @ 2005-11-24 14:08 UTC (permalink / raw)
  To: Zsh hackers list

Hi,

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. After I have
finished entering the first one by entering its closing ^Y, the  opening ^Y of
the second character just beeps. I can start another insert-unicode-char
sequence only after typing at least one more character (of course, a
"solution" is to hit any character and to follow it by a backspace ;-)).
I am using the up-to-date zsh-4.3.0-dev-1 (ChangeLog revision 1.2939,
insert-unicode-char revision 1.3) on a RedHat 9 and system.
Best,

Zvi.

-- 
Dr. Zvi Har'El      mailto:rl@math.technion.ac.il    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,  3:47PM


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: insert-unicode-char
  2005-11-24 14:08 insert-unicode-char Zvi Har'El
@ 2005-11-24 14:33 ` Zvi Har'El
  2005-11-24 14:57   ` insert-unicode-char Zvi Har'El
  2005-11-24 14:39 ` insert-unicode-char Peter Stephenson
  1 sibling, 1 reply; 6+ messages in thread
From: Zvi Har'El @ 2005-11-24 14:33 UTC (permalink / raw)
  To: Zsh hackers list

I now checked this also on our solaris systems. The situation is that both
insert-composed-char and insert-unicode-char fail, on the line which tries to
print a unicode esacep sequence. However, on these machines, I get
'zsh: cannot do charset conversion' on such print commands (e.g., print
\\u21 , which should print a bang!), a message which is generated by
Src/utils.c. I am using a LC_CTYPE=en_US.UTF-8 locale, and zsh in configured
with --enable-multibyte (which is a mistary by itself, since on my RedHat
system, this flag is not needed since configure figures it out by itself).

On Thu, 24 Nov 2005 16:08:54 +0200, Zvi Har'El wrote about "insert-unicode-char":
> Hi,
> 
> 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. After I have
> finished entering the first one by entering its closing ^Y, the  opening ^Y of
> the second character just beeps. I can start another insert-unicode-char
> sequence only after typing at least one more character (of course, a
> "solution" is to hit any character and to follow it by a backspace ;-)).
> I am using the up-to-date zsh-4.3.0-dev-1 (ChangeLog revision 1.2939,
> insert-unicode-char revision 1.3) on a RedHat 9 and system.
> Best,
> 
> Zvi.
> 
> -- 
> Dr. Zvi Har'El      mailto:rl@math.technion.ac.il    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,  3:47PM

-- 
Dr. Zvi Har'El      mailto:rl@math.technion.ac.il    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,  4:22PM


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: insert-unicode-char
  2005-11-24 14:08 insert-unicode-char Zvi Har'El
  2005-11-24 14:33 ` insert-unicode-char Zvi Har'El
@ 2005-11-24 14:39 ` Peter Stephenson
  2005-11-24 15:01   ` insert-unicode-char Zvi Har'El
  1 sibling, 1 reply; 6+ messages in thread
From: Peter Stephenson @ 2005-11-24 14:39 UTC (permalink / raw)
  To: Zsh hackers list

"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@csr.com>                  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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: insert-unicode-char
  2005-11-24 14:33 ` insert-unicode-char Zvi Har'El
@ 2005-11-24 14:57   ` Zvi Har'El
  2005-11-25 11:10     ` insert-unicode-char Peter Stephenson
  0 siblings, 1 reply; 6+ messages in thread
From: Zvi Har'El @ 2005-11-24 14:57 UTC (permalink / raw)
  To: Zsh hackers list

Another remark: In the solaris 9 system, I have two copies of libiconv
installed: one in /usr/lib (the solaris native), and one in /usr/local/lib
(from GNU libiconv-1.10), and the latter directory is in the LD_LIBRARY_PATH
both in installation time and in run time, and ldd =zsh shows that it uses
/usr/local/lib/libiconv.so.2. On the Redhat system, where unicode esacpe
sequences work, I am using glibc.

On Thu, 24 Nov 2005 16:33:05 +0200, Zvi Har'El wrote about "Re: insert-unicode-char":
> I now checked this also on our solaris systems. The situation is that both
> insert-composed-char and insert-unicode-char fail, on the line which tries to
> print a unicode esacep sequence. However, on these machines, I get
> 'zsh: cannot do charset conversion' on such print commands (e.g., print
> \\u21 , which should print a bang!), a message which is generated by
> Src/utils.c. I am using a LC_CTYPE=en_US.UTF-8 locale, and zsh in configured
> with --enable-multibyte (which is a mistary by itself, since on my RedHat
> system, this flag is not needed since configure figures it out by itself).
> 
> On Thu, 24 Nov 2005 16:08:54 +0200, Zvi Har'El wrote about "insert-unicode-char":
> > Hi,
> > 
> > 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. After I have
> > finished entering the first one by entering its closing ^Y, the  opening ^Y of
> > the second character just beeps. I can start another insert-unicode-char
> > sequence only after typing at least one more character (of course, a
> > "solution" is to hit any character and to follow it by a backspace ;-)).
> > I am using the up-to-date zsh-4.3.0-dev-1 (ChangeLog revision 1.2939,
> > insert-unicode-char revision 1.3) on a RedHat 9 and system.
> > Best,
> > 
> > Zvi.
> > 
> > -- 
> > Dr. Zvi Har'El      mailto:rl@math.technion.ac.il    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,  3:47PM
> 
> -- 
> Dr. Zvi Har'El      mailto:rl@math.technion.ac.il    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,  4:22PM

-- 
Dr. Zvi Har'El      mailto:rl@math.technion.ac.il    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,  4:35PM


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: insert-unicode-char
  2005-11-24 14:39 ` insert-unicode-char Peter Stephenson
@ 2005-11-24 15:01   ` Zvi Har'El
  0 siblings, 0 replies; 6+ messages in thread
From: Zvi Har'El @ 2005-11-24 15:01 UTC (permalink / raw)
  To: Peter Stephenson; +Cc: Zsh hackers list

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@csr.com>                  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@math.technion.ac.il    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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: insert-unicode-char
  2005-11-24 14:57   ` insert-unicode-char Zvi Har'El
@ 2005-11-25 11:10     ` Peter Stephenson
  0 siblings, 0 replies; 6+ messages in thread
From: Peter Stephenson @ 2005-11-25 11:10 UTC (permalink / raw)
  To: zsh-workers

"Zvi Har'El" <rl@math.technion.ac.il> wrote:
> Another remark: In the solaris 9 system, I have two copies of libiconv
> installed: one in /usr/lib (the solaris native), and one in /usr/local/lib
> (from GNU libiconv-1.10), and the latter directory is in the LD_LIBRARY_PATH
> both in installation time and in run time, and ldd =zsh shows that it uses
> /usr/local/lib/libiconv.so.2. On the Redhat system, where unicode esacpe
> sequences work, I am using glibc.
> 
> On Thu, 24 Nov 2005 16:33:05 +0200, Zvi Har'El wrote:
>> I now checked this also on our solaris systems. The situation is that both
>> insert-composed-char and insert-unicode-char fail, on the line which tries to
>> print a unicode esacep sequence. However, on these machines, I get
>> 'zsh: cannot do charset conversion' on such print commands (e.g., print
>> \\u21 , which should print a bang!), a message which is generated by
>> Src/utils.c. I am using a LC_CTYPE=en_US.UTF-8 locale, and zsh in configured
>> with --enable-multibyte (which is a mistary by itself, since on my RedHat
>> system, this flag is not needed since configure figures it out by itself).

It's quite possible that the multiple libiconvs are significant, since it
works OK on Solaris 8 here.  The error message and the configuration
suggest this call is failing:

    	    	    cd = iconv_open(nl_langinfo(CODESET), "UCS-4BE");

although it's possible it's not using the iconv code at all for
some reason, which would happen if neither HAVE_ICONV nor any of
the alternative conversion types were available.  The dependence
on the shared library might conceivably be indirect.

We don't have a Solaris 9 for trying out multibyte mode on, but I know that
Solaris 8 doesn't set __STDC_ISO_10646__, which we're using to detect
the capabilities automatically---it saves a lot of configuration
probing.  It sounds like it probably isn't set in your case, otherwise
the shell would use wctomb() rather than iconv, avoiding the other problem.

With enough automated tests for things like the effect of wctomb() we
could probably avoid all this, but that's hard work.

-- 
Peter Stephenson <pws@csr.com>                  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


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2005-11-25 11:10 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-11-24 14:08 insert-unicode-char Zvi Har'El
2005-11-24 14:33 ` insert-unicode-char Zvi Har'El
2005-11-24 14:57   ` insert-unicode-char Zvi Har'El
2005-11-25 11:10     ` insert-unicode-char Peter Stephenson
2005-11-24 14:39 ` insert-unicode-char Peter Stephenson
2005-11-24 15:01   ` insert-unicode-char Zvi Har'El

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).