diff options
author | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2005-06-11 01:54:47 +0800 |
---|---|---|
committer | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2005-06-11 01:54:47 +0800 |
commit | dda5af373350d4b6649335e4ec8600a0baf2afe7 (patch) | |
tree | 6c09cb2515b2731fed79d66ceb5673279549523f | |
parent | e2b3b3e420075b9b0e61c01eac86b98810976c69 (diff) | |
download | pttbbs-dda5af373350d4b6649335e4ec8600a0baf2afe7.tar pttbbs-dda5af373350d4b6649335e4ec8600a0baf2afe7.tar.gz pttbbs-dda5af373350d4b6649335e4ec8600a0baf2afe7.tar.bz2 pttbbs-dda5af373350d4b6649335e4ec8600a0baf2afe7.tar.lz pttbbs-dda5af373350d4b6649335e4ec8600a0baf2afe7.tar.xz pttbbs-dda5af373350d4b6649335e4ec8600a0baf2afe7.tar.zst pttbbs-dda5af373350d4b6649335e4ec8600a0baf2afe7.zip |
screen.c: edit_out should be managed by edit.c
pmore.c: eliminate nofmt (replaced by other modes) and 0xff header fix
edit.c: broken dbcs support
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@2823 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r-- | mbbsd/edit.c | 82 | ||||
-rw-r--r-- | mbbsd/pmore.c | 8 | ||||
-rw-r--r-- | mbbsd/screen.c | 26 |
3 files changed, 91 insertions, 25 deletions
diff --git a/mbbsd/edit.c b/mbbsd/edit.c index f396ba80..fb085284 100644 --- a/mbbsd/edit.c +++ b/mbbsd/edit.c @@ -1837,6 +1837,88 @@ block_select(void) curr_buf->blockline = curr_buf->currline; } +/** + * Just like outs, but print out '*' instead of 27(decimal) in the given string. + * + * FIXME column could not start from 0 + */ +#ifndef STR_ANSICODE +#define STR_ANSICODE "[0123456789;," +#endif + +void +edit_outs(const char *text) +{ + edit_outs_n(text, scr_cols); +} + +void +edit_outs_n(const char *text, int n) +{ + int column = 0; + + register unsigned char inAnsi = 0; + register unsigned char ch; + +#ifdef DBCSAWARE_EDIT + /* 0 = N/A, 1 = leading byte printed, 2 = ansi in middle */ + register unsigned char isDBCS = 0; +#endif + + while ((ch = *text++) && (++column < t_columns) && n-- > 0) + { + if(inAnsi) + { + outc(ch); + if(strchr(STR_ANSICODE, ch) == 0) + { + inAnsi = 0; + outs(ANSI_RESET); + } + + } + else if(ch == ESC_CHR) + { + inAnsi = 1; +#ifdef DBCSAWARE_EDIT + if(isDBCS == 1) + { + isDBCS = 2; + outs(//ESC_STR "[1D" + ANSI_COLOR(1;33) "?" ANSI_RESET); + } +#endif + outs(ANSI_COLOR(1) "*"); + } + else + { +#ifdef DBCSAWARE_EDIT + if(isDBCS == 1) + isDBCS = 0; + else if (isDBCS == 2) + { + /* ansi in middle. */ + outs(ANSI_COLOR(0;33) "?" ANSI_RESET); + isDBCS = 0; + continue; + } + else + if(IS_BIG5_HI(ch)) + { + isDBCS = 1; + // peak next char + if(n > 0 && *text == ESC_CHR) + continue; + } +#endif + outc(ch); + } + } + + if(inAnsi) + outs(ANSI_RESET); +} + static inline void display_textline_internal(textline_t *p, int i, int min, int max) { diff --git a/mbbsd/pmore.c b/mbbsd/pmore.c index b236d0e6..2412eb39 100644 --- a/mbbsd/pmore.c +++ b/mbbsd/pmore.c @@ -248,10 +248,10 @@ enum { MFDISP_SEP_OLD = MFDISP_SEP_LINE | MFDISP_SEP_WRAP, MFDISP_RAW_NA = 0x00, - MFDISP_RAW_NOFMT, MFDISP_RAW_NOANSI, MFDISP_RAW_PLAIN, MFDISP_RAW_MODES, + // MFDISP_RAW_NOFMT, // this is rarely used sinde we have ansi and plain } MF_DISP_CONST; @@ -683,9 +683,11 @@ pmore_str_strip_ansi(unsigned char *p) // warning: p is NULL terminated memmove(pb, p, strlen(p)+1); p = pb; } - else if (*p < ' ') + else if (*p < ' ' || *p == 0xff) { // control codes, ignore them. + // what is 0xff? old BBS does not handle telnet protocol + // so IACs were inserted. memmove(p, p+1, strlen(p+1)+1); } else @@ -2149,9 +2151,11 @@ pmore(char *fpath, int promptend) case MFDISP_RAW_NA: override_msg = ANSI_COLOR(34) "顯示預設格式化內容"; break; + /* case MFDISP_RAW_NOFMT: override_msg = ANSI_COLOR(31) "省略自動格式化"; break; + */ case MFDISP_RAW_NOANSI: override_msg = ANSI_COLOR(33) "顯示原始 ANSI 控制碼"; break; diff --git a/mbbsd/screen.c b/mbbsd/screen.c index 951cc1fc..175921f1 100644 --- a/mbbsd/screen.c +++ b/mbbsd/screen.c @@ -357,29 +357,6 @@ outc(unsigned char c) #endif } -/** - * Just like outs, but print out '*' instead of 27(decimal) in the given string. - * - * FIXME column could not start from 0 - */ -void -edit_outs(const char *text) -{ - register int column = 0; - register char ch; - while ((ch = *text++) && (++column < t_columns)) - outc(ch == 27 ? '*' : ch); -} - -void -edit_outs_n(const char *text, int n) -{ - register int column = 0; - register char ch; - while ((ch = *text++) && n-- && (++column < t_columns)) - outc(ch == 27 ? '*' : ch); -} - void outs(const char *str) { @@ -540,3 +517,6 @@ void screen_restore(int len, screenline_t *bp, const void *buf) offset+=bp[i].len; } } + +/* vim:tw=4 + */ |