Index: develop/zsh/config.h.in diff -u develop/zsh/config.h.in:1.1.1.4 develop/zsh/config.h.in:1.8 --- develop/zsh/config.h.in:1.1.1.4 Tue Mar 22 16:52:42 2005 +++ develop/zsh/config.h.in Tue Mar 22 16:55:38 2005 @@ -27,6 +27,9 @@ /* The default prefix for temporary files */ #define DEFAULT_TMPPREFIX "/tmp/zsh" +/* zsh euc completion */ +#define ZSH_EUC 1 + /***** end of user configuration section *****/ /***** shouldn't have to change anything below here *****/ Index: develop/zsh/configure.ac diff -u develop/zsh/configure.ac:1.1.1.4 develop/zsh/configure.ac:1.3 --- develop/zsh/configure.ac:1.1.1.4 Tue Mar 22 16:52:42 2005 +++ develop/zsh/configure.ac Tue Mar 22 16:55:39 2005 @@ -2450,6 +2450,9 @@ /* The default prefix for temporary files */ #define DEFAULT_TMPPREFIX "/tmp/zsh" +/* zsh euc completion */ +#define ZSH_EUC 1 + /***** end of user configuration section *****/ /***** shouldn't have to change anything below here *****/ Index: develop/zsh/Src/Zle/compmatch.c diff -u develop/zsh/Src/Zle/compmatch.c:1.1.1.3 develop/zsh/Src/Zle/compmatch.c:1.4 --- develop/zsh/Src/Zle/compmatch.c:1.1.1.3 Mon Sep 6 19:33:55 2004 +++ develop/zsh/Src/Zle/compmatch.c Mon Sep 6 19:36:32 2004 @@ -1313,6 +1313,9 @@ while (la && lb) { if (*sa != *sb) { /* Different characters, try the matchers. */ +#ifdef ZSH_EUC +ono: +#endif for (t = 0, ms = bmatchers; ms && !t; ms = ms->next) { mp = ms->matcher; if (mp && !mp->flags && mp->wlen > 0 && mp->llen > 0 && @@ -1358,7 +1361,13 @@ } if (!t) break; - } else { +#ifdef ZSH_EUC + } else if ((_mbmap_euc[*(unsigned char*)sa] & _MB1) && + (_mbmap_euc[*((unsigned char*)sa+1)] & _MB2) && + *(sa+1) != *(sb+1)) { + goto ono; +#endif + } else { /* Same character, just take it. */ if (rr <= 1) { char *or = rs; @@ -1584,6 +1593,7 @@ if (check_cmdata(md, sfx)) return ret; +#ifndef ZSH_EUC /* * Look for a common prefix. If we do include metafied * characters, at this stage we still need the overall length @@ -1592,6 +1602,28 @@ for (l = 0, p = str, q = md->str; l < len && l < md->len && p[ind] == q[ind]; l++, p += add, q += add) {} +#else + if (sfx) + for (l = 0, p = str, q = md->str; + l < len && l < md->len && p[ind] == q[ind]; + l++, p += add, q += add); + else + for (l = 0, p = str, q = md->str;;) { + if (!(l < len && l < md->len)) + break; + + if ((_mbmap_euc[*(unsigned char*)p] & _MB1) && (_mbmap_euc[*((unsigned char*)p+1)] & _MB2)) { + if (*p == *q && *(p+1) == *(q+1)) { + l+=2, p+=2, q+=2; + } else + break; + } else { + if (*p != *q) + break; + l++, p++, q++; + } + } +#endif /* Make sure we don't end in the middle of a Meta sequence. */ if (add == 1) { Index: develop/zsh/Src/Zle/zle.h diff -u develop/zsh/Src/Zle/zle.h:1.1.1.1 develop/zsh/Src/Zle/zle.h:1.2 --- develop/zsh/Src/Zle/zle.h:1.1.1.1 Wed May 28 12:12:14 2003 +++ develop/zsh/Src/Zle/zle.h Wed May 28 12:21:25 2003 @@ -194,3 +194,8 @@ /* Invalidate the completion list. */ #define invalidatelist() runhookdef(INVALIDATELISTHOOK, NULL) + +#ifdef ZSH_EUC +#define _MB1 0x01 +#define _MB2 0x02 +#endif Index: develop/zsh/Src/Zle/zle_main.c diff -u develop/zsh/Src/Zle/zle_main.c:1.1.1.5 develop/zsh/Src/Zle/zle_main.c:1.6 --- develop/zsh/Src/Zle/zle_main.c:1.1.1.5 Tue Mar 22 16:52:46 2005 +++ develop/zsh/Src/Zle/zle_main.c Tue Mar 22 16:55:39 2005 @@ -1528,3 +1528,179 @@ return 0; } + +#ifdef ZSH_EUC +/**/ +mod_export unsigned char _mbmap_euc[256] = { +/* first byte 0x8e,0xa0 - 0xf4 */ +/* second byte 0xa0 - 0xfe */ +/* 0 - 7f all 0 */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +/* 80 81 82 83 */ + 0, 0, 0, 0, +/* 84 85 86 87 */ + 0, 0, 0, 0, +/* 88 89 8a 8b */ + 0, 0, 0, 0, +/* 8c 8d 8e 8f */ + 0, 0, _MB1, 0, +/* 90 - 9f all 0 */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +/* a0 a1 a2 a3 */ + _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, +/* a4 a5 a6 a7 */ + _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, +/* a8 a9 aa ab */ + _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, +/* ac ad ae af */ + _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, +/* b0 b1 b2 b3 */ + _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, +/* b4 b5 b6 b7 */ + _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, +/* b8 b9 ba bb */ + _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, +/* bc bd be bf */ + _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, +/* c0 c1 c2 c3 */ + _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, +/* c4 c5 c6 c7 */ + _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, +/* c8 c9 ca cb */ + _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, +/* cc cd ce cf */ + _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, +/* d0 d1 d2 d3 */ + _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, +/* d4 d5 d6 d7 */ + _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, +/* d8 d9 da db */ + _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, +/* dc dd de df */ + _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, +/* e0 e1 e2 e3 */ + _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, +/* e4 e5 e6 e7 */ + _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, +/* e8 e9 ea eb */ + _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, +/* ec ed ee ef */ + _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, +/* f0 f1 f2 f3 */ + _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, +/* f4 f5 f6 f7 */ + _MB1|_MB2, _MB2, _MB2, _MB2, +/* f8 f9 fa fb */ + _MB2, _MB2, _MB2, _MB2, +/* fc fd fe ff */ + _MB2, _MB2, _MB2, 0, +}; + +unsigned short _mbmap_sjis[256] = { +/* first byte 0x81-0x9f,0xe0 - 0xfc */ +/* second byte 0x40-0x7e,0x80 - 0xfc */ +/* 0 - 3f all 0 */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +/* 40 41 42 43 */ + _MB2, _MB2, _MB2, _MB2, +/* 44 45 46 47 */ + _MB2, _MB2, _MB2, _MB2, +/* 48 49 4a 4b */ + _MB2, _MB2, _MB2, _MB2, +/* 4c 4d 4e 4f */ + _MB2, _MB2, _MB2, _MB2, +/* 50 51 52 53 */ + _MB2, _MB2, _MB2, _MB2, +/* 54 55 56 57 */ + _MB2, _MB2, _MB2, _MB2, +/* 58 59 5a 5b */ + _MB2, _MB2, _MB2, _MB2, +/* 5c 5d 5e 5f */ + _MB2, _MB2, _MB2, _MB2, +/* 60 61 62 63 */ + _MB2, _MB2, _MB2, _MB2, +/* 64 65 66 67 */ + _MB2, _MB2, _MB2, _MB2, +/* 68 69 6a 6b */ + _MB2, _MB2, _MB2, _MB2, +/* 6c 6d 6e 6f */ + _MB2, _MB2, _MB2, _MB2, +/* 70 71 72 73 */ + _MB2, _MB2, _MB2, _MB2, +/* 74 75 76 77 */ + _MB2, _MB2, _MB2, _MB2, +/* 78 79 7a 7b */ + _MB2, _MB2, _MB2, _MB2, +/* 7c 7d 7e 7f */ + _MB2, _MB2, _MB2, 0, +/* 80 81 82 83 */ + _MB2, _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, +/* 84 85 86 87 */ + _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, +/* 88 89 8a 8b */ + _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, +/* 8c 8d 8e 8f */ + _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, +/* 90 91 92 93 */ + _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, +/* 94 95 96 97 */ + _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, +/* 98 99 9a 9b */ + _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, +/* 9c 9d 9e 9f */ + _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, +/* a0 a1 a2 a3 */ + _MB2, _MB2, _MB2, _MB2, +/* a4 a5 a6 a7 */ + _MB2, _MB2, _MB2, _MB2, +/* a8 a9 aa ab */ + _MB2, _MB2, _MB2, _MB2, +/* ac ad ae af */ + _MB2, _MB2, _MB2, _MB2, +/* b0 b1 b2 b3 */ + _MB2, _MB2, _MB2, _MB2, +/* b4 b5 b6 b7 */ + _MB2, _MB2, _MB2, _MB2, +/* b8 b9 ba bb */ + _MB2, _MB2, _MB2, _MB2, +/* bc bd be bf */ + _MB2, _MB2, _MB2, _MB2, +/* c0 c1 c2 c3 */ + _MB2, _MB2, _MB2, _MB2, +/* c4 c5 c6 c7 */ + _MB2, _MB2, _MB2, _MB2, +/* c8 c9 ca cb */ + _MB2, _MB2, _MB2, _MB2, +/* cc cd ce cf */ + _MB2, _MB2, _MB2, _MB2, +/* d0 d1 d2 d3 */ + _MB2, _MB2, _MB2, _MB2, +/* d4 d5 d6 d7 */ + _MB2, _MB2, _MB2, _MB2, +/* d8 d9 da db */ + _MB2, _MB2, _MB2, _MB2, +/* dc dd de df */ + _MB2, _MB2, _MB2, _MB2, +/* e0 e1 e2 e3 */ + _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, +/* e4 e5 e6 e7 */ + _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, +/* e8 e9 ea eb */ + _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, +/* ec ed ee ef */ + _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, +/* f0 f1 f2 f3 */ + _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, +/* f4 f5 f6 f7 */ + _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, +/* f8 f9 fa fb */ + _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, +/* fc fd fe ff */ + _MB1|_MB2, 0, 0, 0, +}; + +#endif Index: develop/zsh/Src/Zle/zle_misc.c diff -u develop/zsh/Src/Zle/zle_misc.c:1.1.1.3 develop/zsh/Src/Zle/zle_misc.c:1.4 --- develop/zsh/Src/Zle/zle_misc.c:1.1.1.3 Mon Sep 6 19:33:54 2004 +++ develop/zsh/Src/Zle/zle_misc.c Mon Sep 6 19:36:32 2004 @@ -94,6 +94,12 @@ return ret; } if (cs + zmult <= ll) { +#ifdef ZSH_EUC + if (zmult == 1 && + _mbmap_euc[line[cs]] & _MB1 && + _mbmap_euc[line[cs+1]] & _MB2) + cs += 1; +#endif cs += zmult; backdel(zmult); return 0; Index: develop/zsh/Src/Zle/zle_move.c diff -u develop/zsh/Src/Zle/zle_move.c:1.1.1.3 develop/zsh/Src/Zle/zle_move.c:1.5 --- develop/zsh/Src/Zle/zle_move.c:1.1.1.3 Mon Sep 6 19:33:54 2004 +++ develop/zsh/Src/Zle/zle_move.c Mon Sep 6 20:14:08 2004 @@ -159,6 +159,15 @@ int forwardchar(UNUSED(char **args)) { +#ifdef ZSH_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 +180,15 @@ int backwardchar(UNUSED(char **args)) { +#ifdef ZSH_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; Index: develop/zsh/Src/Zle/zle_refresh.c diff -u develop/zsh/Src/Zle/zle_refresh.c:1.1.1.3 develop/zsh/Src/Zle/zle_refresh.c:1.4 --- develop/zsh/Src/Zle/zle_refresh.c:1.1.1.3 Mon Sep 6 19:33:54 2004 +++ develop/zsh/Src/Zle/zle_refresh.c Mon Sep 6 19:36:32 2004 @@ -709,7 +709,11 @@ static void refreshline(int ln) { - char *nl, *ol, *p1; /* line buffer pointers */ +#ifdef ZSH_EUC + unsigned char *nl, *ol, *p1; /* line buffer pointers */ +#else + char *nl, *ol, *p1; /* line buffer pointers */ +#endif int ccs = 0, /* temporary count for cursor position */ char_ins = 0, /* number of characters inserted/deleted */ col_cleareol, /* clear to end-of-line from this column */ @@ -815,7 +819,27 @@ for (;;) { if (*nl && *ol && nl[1] == ol[1]) /* skip only if second chars match */ /* skip past all matching characters */ +#ifndef ZSH_EUC for (; *nl && (*nl == *ol); nl++, ol++, ccs++) ; +#else + for (; *nl && (*nl == *ol); nl++, ol++, ccs++) { + if (_mbmap_euc[*nl] & _MB1) { + if (*(ol+1) == '\0') + continue; + if (_mbmap_euc[*(nl+1)] & _MB2) { + if (*(nl+1) != *(ol+1)) + break; + else { + nl++; + ol++; + ccs++; + } + } else if (*(nl+1) == '\0') { + continue; + } + } + } +#endif if (!*nl) { if (ccs == winw && hasam && char_ins > 0 && ins_last Index: develop/zsh/Src/Zle/zle_utils.c diff -u develop/zsh/Src/Zle/zle_utils.c:1.1.1.3 develop/zsh/Src/Zle/zle_utils.c:1.4 --- develop/zsh/Src/Zle/zle_utils.c:1.1.1.3 Mon Sep 6 19:33:54 2004 +++ develop/zsh/Src/Zle/zle_utils.c Mon Sep 6 19:36:32 2004 @@ -203,6 +203,15 @@ mod_export void backdel(int ct) { +#ifdef ZSH_EUC + if (ct == 1) { + if (_mbmap_euc[line[cs-1]] & _MB2 && + cs-2 >=0 && + _mbmap_euc[line[cs-2]] & _MB1) { + ct = 2; + } + } +#endif shiftchars(cs -= ct, ct); }