freebsd-ports/shells/zsh+euc_hack/files/patch-Src::Zle::zle_move.c
Akinori MUSHA f1f99beceb Add zsh+euc, Zsh with EUC encoding support.
This is just an experimental hack and cannot happily be merged into
the upstream.  Zsh's line editor apparently needs a rewrite in order
to support multi-byte encodings because it strongly relies on the
single-byte character scheme.

These patches are mostly based on the work by ono@ono.org (Thanks!):

	http://www.ono.org/software/zsh-euc/

What I did over this is disable the hack for non-EUC locales.  Maybe
the patches can be moved to shells/zsh in the future, but it's
premature for the moment.

Notes:
- forward-char, backward-char and backward-delete-char with no numeric
  argument should work properly with this hack.
- Completion and redisplay should work fine.
- There can be some trivial side-effects.
- JIS X0201-Roman and JIS X0208-Kanji are supported.
- JIS X0201-Katakana and JIS X0212 Kanji are NOT supported.
- Only tested with the EUC-JP (ja_JP.eucJP) locale.  I'm not sure if
  it works for GB 2312/CNS 11643-1/KS X 1001.  Any feedbacks is
  welcome, especially a patch if it does not work. :)
2002-05-11 21:48:26 +00:00

38 lines
710 B
C

--- Src/Zle/zle_move.c.orig Sat Jul 3 22:18:00 1999
+++ Src/Zle/zle_move.c Thu May 9 17:55:46 2002
@@ -159,6 +159,17 @@
int
forwardchar(char **args)
{
+#ifdef ZSH_EUC
+ if (locale_is_euc) {
+ if (zmult == 1) {
+ if (_mbmap_euc[line[cs]] & _MB1 &&
+ cs+1 <= ll &&
+ _mbmap_euc[line[cs+1]] & _MB2) {
+ cs++;
+ }
+ }
+ }
+#endif
cs += zmult;
if (cs > ll)
cs = ll;
@@ -171,6 +182,17 @@
int
backwardchar(char **args)
{
+#ifdef ZSH_EUC
+ if (locale_is_euc) {
+ if (zmult == 1) {
+ if (_mbmap_euc[line[cs-1]] & _MB2 &&
+ cs-2 >=0 &&
+ _mbmap_euc[line[cs-2]] & _MB1) {
+ cs--;
+ }
+ }
+ }
+#endif
cs -= zmult;
if (cs > ll)
cs = ll;