From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6700 invoked from network); 21 Oct 2001 15:43:05 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 21 Oct 2001 15:43:05 -0000 Received: (qmail 209 invoked by alias); 21 Oct 2001 15:42:57 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 16090 Received: (qmail 192 invoked from network); 21 Oct 2001 15:42:56 -0000 Date: Sun, 21 Oct 2001 11:42:54 -0400 From: Clint Adams To: zsh-workers@sunsite.dk Subject: multibyte backwarddeletechar Message-ID: <20011021114254.A17952@dman.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i I don't intend to commit this patch as-is. This causes backward-delete-char to delete entire multibyte characters (valid in the current locale) rather than their component octets. For consistency's sake, similar hacks would apply to backward-char backward-delete-char delete-char forward-char transpose-chars vi-find-next-char vi-backward-char vi-backward-delete-char vi-forward-char Should these be replacements or a set of new widgets? Index: zshconfig.ac =================================================================== RCS file: /cvsroot/zsh/zsh/zshconfig.ac,v retrieving revision 1.20 diff -u -r1.20 zshconfig.ac --- zshconfig.ac 2001/10/10 16:02:24 1.20 +++ zshconfig.ac 2001/10/21 15:23:42 @@ -476,7 +476,7 @@ limits.h fcntl.h libc.h sys/utsname.h sys/resource.h \ locale.h errno.h stdlib.h unistd.h sys/capability.h \ utmp.h utmpx.h sys/types.h pwd.h grp.h poll.h sys/mman.h \ - netinet/in_systm.h pcre.h) + netinet/in_systm.h pcre.h wchar.h) if test $dynamic = yes; then AC_CHECK_HEADERS(dlfcn.h) AC_CHECK_HEADERS(dl.h) @@ -938,7 +938,8 @@ brk sbrk \ pathconf sysconf \ tgetent tigetflag tigetnum tigetstr setupterm \ - pcre_compile pcre_study pcre_exec) + pcre_compile pcre_study pcre_exec \ + mbtowc) AC_FUNC_STRCOLL dnl Check if tgetent accepts NULL (and will allocate its own termcap buffer) Index: Src/Zle/zle_misc.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_misc.c,v retrieving revision 1.6 diff -u -r1.6 zle_misc.c --- Src/Zle/zle_misc.c 2001/09/03 01:39:20 1.6 +++ Src/Zle/zle_misc.c 2001/10/21 15:23:46 @@ -29,6 +29,9 @@ #include "zle.mdh" #include "zle_misc.pro" +#ifdef HAVE_MBTOWC +# include +#endif /* insert a metafied string, with repetition and suffix removal */ @@ -105,6 +108,10 @@ int backwarddeletechar(char **args) { +#ifdef HAVE_MBTOWC + int i, j, k; + wchar_t pwc; +#endif if (zmult < 0) { int ret; zmult = -zmult; @@ -112,7 +119,19 @@ zmult = -zmult; return ret; } +#ifdef HAVE_MBTOWC + for(i=(zmult > cs) ? cs : zmult;i>0;i--) { + for(j=MB_CUR_MAX;j>0;j--) { + k = mbtowc(&pwc, (char *)line+cs-j, j); + if (k==j) { + backdel(j); + j = 0; + } + } + } +#else backdel(zmult > cs ? cs : zmult); +#endif return 0; }