summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorscw <scw@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2004-03-31 21:00:48 +0800
committerscw <scw@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2004-03-31 21:00:48 +0800
commit32c410ff238cdc4a576caa4d53921b5d251be1ca (patch)
treebbfbf4d93d742082fbd20d6500fdead1aee917bd
parente3ec53ea454c8bc4038ad941cf3a06e79e893448 (diff)
downloadpttbbs-32c410ff238cdc4a576caa4d53921b5d251be1ca.tar
pttbbs-32c410ff238cdc4a576caa4d53921b5d251be1ca.tar.gz
pttbbs-32c410ff238cdc4a576caa4d53921b5d251be1ca.tar.bz2
pttbbs-32c410ff238cdc4a576caa4d53921b5d251be1ca.tar.lz
pttbbs-32c410ff238cdc4a576caa4d53921b5d251be1ca.tar.xz
pttbbs-32c410ff238cdc4a576caa4d53921b5d251be1ca.tar.zst
pttbbs-32c410ff238cdc4a576caa4d53921b5d251be1ca.zip
Multibyte shifting for paging display.
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@1654 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r--mbbsd/more.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/mbbsd/more.c b/mbbsd/more.c
index 0bdb361c..bc29a29a 100644
--- a/mbbsd/more.c
+++ b/mbbsd/more.c
@@ -54,10 +54,10 @@ more_readln(int fd, unsigned char *buf)
int ch;
unsigned char *data, *tail, *cc;
- int len, bytes, in_ansi;
+ int len, bytes, in_ansi, in_big5;
int size, head, ansilen;
- len = bytes = in_ansi = ansilen = 0;
+ len = bytes = in_ansi = in_big5 = ansilen = 0;
tail = buf + ANSILINELEN - 1;
size = more_size;
head = more_head;
@@ -102,12 +102,27 @@ more_readln(int fd, unsigned char *buf)
*buf++ = ch;
if (!strchr(STR_ANSICODE, ch))
in_ansi = 0;
+ } else if (in_big5) {
+ ++len;
+ *buf++ = ch;
+ in_big5 = 0;
} else if (isprint2(ch)) {
len++;
*buf++ = ch;
+ if (ch >= 0xa4 && ch <= 0xf9) /* first byte of big5 encoding */
+ in_big5 = 1;
}
} while (len < t_columns && buf < tail);
- if(len==t_columns && head<size && *data=='\n') {
+
+ if (in_big5) {
+ strcpy(buf - 1, "\033[1;34m>\033[m");
+ buf += 10;
+ --head;
+ --data;
+ --bytes;
+ }
+
+ if (len == t_columns && head < size && *data == '\n') {
/* XXX: not handle head==size, should read data */
/* no extra newline dirty hack for exact 80byte line */
data++; bytes++; head++;