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 /mbbsd/edit.c | |
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
Diffstat (limited to 'mbbsd/edit.c')
-rw-r--r-- | mbbsd/edit.c | 82 |
1 files changed, 82 insertions, 0 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) { |