From 8a45f054083f5b3dccc3902e1dd88872831cefc1 Mon Sep 17 00:00:00 2001 From: piaip Date: Fri, 8 Jul 2005 16:29:51 +0000 Subject: dbcs aware talk git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@2923 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- mbbsd/io.c | 2 -- mbbsd/talk.c | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 65 insertions(+), 10 deletions(-) diff --git a/mbbsd/io.c b/mbbsd/io.c index 4526620f..4d58e9fd 100644 --- a/mbbsd/io.c +++ b/mbbsd/io.c @@ -732,8 +732,6 @@ strip_nonebig5(unsigned char *str, int maxlen) #ifdef DBCSAWARE_GETDATA -#define ISDBCSAWARE() (cuser.uflag & DBCSAWARE_FLAG) - int getDBCSstatus(unsigned char *s, int pos) { int sts = DBCS_ASCII; diff --git a/mbbsd/talk.c b/mbbsd/talk.c index 2db3999f..5954cdef 100644 --- a/mbbsd/talk.c +++ b/mbbsd/talk.c @@ -1016,14 +1016,24 @@ do_talk_char(talkwin_t * twin, int ch, FILE *flog) return; line = big_picture + twin->curln; --(twin->curcol); + if (twin->curcol < line->len) { - --(line->len); + int delta = 1; +#ifdef DBCSAWARE + if (twin->curcol > 0 && ISDBCSAWARE() && + getDBCSstatus(line->data, twin->curcol) == DBCS_TRAILING) + twin->curcol--, delta++; +#endif + line->len -= delta; save_cursor(); do_move(twin->curcol, twin->curln); for (i = twin->curcol; i < line->len; i++) - ochar(line->data[i] = line->data[i + 1]); - line->data[i] = 0; - ochar(' '); + ochar(line->data[i] = line->data[i + delta]); + while (delta-- > 0) + { + line->data[i++] = 0; + ochar(' '); + } restore_cursor(); } move(twin->curln, twin->curcol); @@ -1031,35 +1041,70 @@ do_talk_char(talkwin_t * twin, int ch, FILE *flog) case Ctrl('D'): line = big_picture + twin->curln; if (twin->curcol < line->len) { - --(line->len); + int delta = 1; +#ifdef DBCSAWARE + if (ISDBCSAWARE() && + getDBCSstatus(line->data, twin->curcol) == DBCS_LEADING) + delta++; +#endif + line->len -= delta; save_cursor(); do_move(twin->curcol, twin->curln); for (i = twin->curcol; i < line->len; i++) - ochar(line->data[i] = line->data[i + 1]); - line->data[i] = 0; - ochar(' '); + ochar(line->data[i] = line->data[i + delta]); + while (delta-- > 0) + { + line->data[i++] = 0; + ochar(' '); + } restore_cursor(); } return; case Ctrl('G'): bell(); return; + case Ctrl('B'): if (twin->curcol > 0) { --(twin->curcol); +#ifdef DBCSAWARE + line = big_picture + twin->curln; + if(twin->curcol > 0 && twin->curcol < line->len && ISDBCSAWARE()) + { + line = big_picture + twin->curln; + if(getDBCSstatus(line->data, twin->curcol) == DBCS_TRAILING) + twin->curcol --; + } +#endif move(twin->curln, twin->curcol); } return; case Ctrl('F'): if (twin->curcol < 79) { ++(twin->curcol); +#ifdef DBCSAWARE + line = big_picture + twin->curln; + if(twin->curcol < 79 && twin->curcol < line->len && ISDBCSAWARE()) + { + line = big_picture + twin->curln; + if(getDBCSstatus(line->data, twin->curcol) == DBCS_TRAILING) + twin->curcol++; + } +#endif move(twin->curln, twin->curcol); } return; + case KEY_TAB: twin->curcol += 8; if (twin->curcol > 80) twin->curcol = 80; +#ifdef DBCSAWARE + line = big_picture + twin->curln; + if(twin->curcol > 0 && twin->curcol < line->len && + getDBCSstatus(line->data, twin->curcol) == DBCS_TRAILING) + twin->curcol--; +#endif move(twin->curln, twin->curcol); return; case Ctrl('A'): @@ -1093,6 +1138,12 @@ do_talk_char(talkwin_t * twin, int ch, FILE *flog) --(twin->curln); move(twin->curln, twin->curcol); } +#ifdef DBCSAWARE + line = big_picture + twin->curln; + if(twin->curcol > 0 && twin->curcol < line->len && + getDBCSstatus(line->data, twin->curcol) == DBCS_TRAILING) + move(twin->curln, --twin->curcol); +#endif break; case Ctrl('N'): line = big_picture + twin->curln; @@ -1102,6 +1153,12 @@ do_talk_char(talkwin_t * twin, int ch, FILE *flog) ++(twin->curln); move(twin->curln, twin->curcol); } +#ifdef DBCSAWARE + line = big_picture + twin->curln; + if(twin->curcol > 0 && twin->curcol < line->len && + getDBCSstatus(line->data, twin->curcol) == DBCS_TRAILING) + move(twin->curln, --twin->curcol); +#endif break; } trim(buf); -- cgit v1.2.3