zsh-workers
 help / color / mirror / code / Atom feed
* multibyte backwarddeletechar
@ 2001-10-21 15:42 Clint Adams
  2001-10-21 17:13 ` Bart Schaefer
  2001-10-22  0:57 ` Geoff Wing
  0 siblings, 2 replies; 11+ messages in thread
From: Clint Adams @ 2001-10-21 15:42 UTC (permalink / raw)
  To: zsh-workers

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;
 }
 


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

end of thread, other threads:[~2001-10-24 13:57 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-10-21 15:42 multibyte backwarddeletechar Clint Adams
2001-10-21 17:13 ` Bart Schaefer
2001-10-21 18:21   ` Clint Adams
2001-10-22  0:57 ` Geoff Wing
2001-10-22  1:50   ` Clint Adams
2001-10-22  3:23     ` Geoff Wing
2001-10-22 11:27       ` Clint Adams
2001-10-22  5:20   ` Borsenkow Andrej
2001-10-22 11:32     ` Clint Adams
2001-10-22 12:02       ` Borsenkow Andrej
2001-10-24 13:57         ` Clint Adams

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