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

multibyte backwarddeletechar



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 <wchar.h>
+#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;
 }
 



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