summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2005-07-09 00:29:51 +0800
committerpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2005-07-09 00:29:51 +0800
commit8a45f054083f5b3dccc3902e1dd88872831cefc1 (patch)
tree48b0024c88315d595895b92128068a68c3390f7a
parentb791df282f267b5ed24bd4fb4cad0ddb4601cfa9 (diff)
downloadpttbbs-8a45f054083f5b3dccc3902e1dd88872831cefc1.tar
pttbbs-8a45f054083f5b3dccc3902e1dd88872831cefc1.tar.gz
pttbbs-8a45f054083f5b3dccc3902e1dd88872831cefc1.tar.bz2
pttbbs-8a45f054083f5b3dccc3902e1dd88872831cefc1.tar.lz
pttbbs-8a45f054083f5b3dccc3902e1dd88872831cefc1.tar.xz
pttbbs-8a45f054083f5b3dccc3902e1dd88872831cefc1.tar.zst
pttbbs-8a45f054083f5b3dccc3902e1dd88872831cefc1.zip
dbcs aware talk
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@2923 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r--mbbsd/io.c2
-rw-r--r--mbbsd/talk.c73
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);