From fad6d5dd743843705e3a42da7a80b5bebc009bcb Mon Sep 17 00:00:00 2001 From: piaip Date: Wed, 5 Dec 2007 09:42:10 +0000 Subject: screen: add grayout system git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3637 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- mbbsd/screen.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) (limited to 'mbbsd/screen.c') diff --git a/mbbsd/screen.c b/mbbsd/screen.c index e508ece2..4d9159ba 100644 --- a/mbbsd/screen.c +++ b/mbbsd/screen.c @@ -553,6 +553,69 @@ standend(void) } } +// level: +// -1 - black (not implemented) +// 0 - dark text +// 1 - text +// 2 - no highlight (not implemented) +void +grayout_lines(int y, int end, int level) +{ + register screenline_t *slp = NULL; + char buf[ANSILINELEN]; + int i = 0; + + if (y < 0) y = 0; + if (end > b_lines) end = b_lines; + + for (; y < end; y ++) + { + slp = &big_picture[y]; + + if (slp->len < 1) + continue; + + // tweak slp + slp->data[slp->len] = 0; + slp->mode &= ~STANDOUT; + slp->mode |= MODIFIED; + slp->oldlen = 0; + slp->sso = slp->eso = 0; + slp->smod = 0; + + // make slp->data a pure string + for (i=0; ilen; i++) + { + if (!slp->data[i]) + slp->data[i] = ' '; + } + + slp->len = strip_ansi(buf, (char*)slp->data, STRIP_ALL); + buf[slp->len] = 0; + + switch(level) + { + case 0: // dark text + strcpy((char*)slp->data, ANSI_COLOR(1;30;40)); + strcat((char*)slp->data, buf); + strcat((char*)slp->data, ANSI_RESET ANSI_CLRTOEND); + slp->len = strlen((char*)slp->data); + break; + + case 1: // Plain text + memcpy(slp->data, buf, slp->len + 1); + break; + } + slp->emod = slp->len -1; + } +} + +void grayout_line(int y, int level) +{ + return grayout_lines(y, y+1, level); +} + + static size_t screen_backupsize(int len, const screenline_t *bp) { int i; -- cgit v1.2.3