diff options
author | scw <scw@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2005-01-21 16:11:41 +0800 |
---|---|---|
committer | scw <scw@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2005-01-21 16:11:41 +0800 |
commit | 737556248c371c1a1f4302df7da2b0f3121ba7f2 (patch) | |
tree | 6194c448ba87e1d99728405cf4ef1f939f48583c /mbbsd/screen.c | |
parent | 853dedc529d17b8aaab3433040737ac5b60e9440 (diff) | |
download | pttbbs-737556248c371c1a1f4302df7da2b0f3121ba7f2.tar pttbbs-737556248c371c1a1f4302df7da2b0f3121ba7f2.tar.gz pttbbs-737556248c371c1a1f4302df7da2b0f3121ba7f2.tar.bz2 pttbbs-737556248c371c1a1f4302df7da2b0f3121ba7f2.tar.lz pttbbs-737556248c371c1a1f4302df7da2b0f3121ba7f2.tar.xz pttbbs-737556248c371c1a1f4302df7da2b0f3121ba7f2.tar.zst pttbbs-737556248c371c1a1f4302df7da2b0f3121ba7f2.zip |
Refactoring screen.c and adding function GetCurrentLine().
Adding redoscr() and use it in gomoku to reduce refresh size.
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@2418 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd/screen.c')
-rw-r--r-- | mbbsd/screen.c | 47 |
1 files changed, 36 insertions, 11 deletions
diff --git a/mbbsd/screen.c b/mbbsd/screen.c index 0e3e2af0..3232b1af 100644 --- a/mbbsd/screen.c +++ b/mbbsd/screen.c @@ -39,6 +39,14 @@ getyx(int *y, int *x) *x = cur_col; } +static inline +screenline_t* GetCurrentLine(){ + register int i = cur_ln + roll; + if(i >= scr_lns) + i -= scr_lns; + return &big_picture[i]; +} + static void rel_move(int was_col, int was_ln, int new_col, int new_ln) { @@ -130,6 +138,30 @@ redoscr() oflush(); } +void redoln() +{ + screenline_t *slp = GetCurrentLine(); + int len, mode; + + len = slp->len; + rel_move(tc_col, tc_line, 0, cur_ln); + if (len) + { + if ((mode = slp->mode) & STANDOUT) + standoutput((char*)slp->data, 0, len, slp->sso, slp->eso); + else + output((char*)slp->data, len); + + slp->mode = mode & ~(MODIFIED); + + slp->oldlen = tc_col = len; + } + else + clrtoeol(); + rel_move(tc_col, tc_line, cur_col, cur_ln); + oflush(); +} + void refresh() { @@ -220,13 +252,10 @@ clear() void clrtoeol() { - register screenline_t *slp; + register screenline_t *slp = GetCurrentLine(); register int ln; standing = NA; - if ((ln = cur_ln + roll) >= scr_lns) - ln -= scr_lns; - slp = &big_picture[ln]; if (cur_col <= slp->sso) slp->mode &= ~STANDOUT; @@ -272,13 +301,9 @@ clrtobot() void outc(unsigned char c) { - register screenline_t *slp; + register screenline_t *slp = GetCurrentLine(); register int i; - if ((i = cur_ln + roll) >= scr_lns) - i -= scr_lns; - slp = &big_picture[i]; - if (c == '\n' || c == '\r') { if (standing) { slp->eso = MAX(slp->eso, cur_col); @@ -440,7 +465,7 @@ standout() if (!standing && strtstandoutlen) { register screenline_t *slp; - slp = &big_picture[((cur_ln + roll) % scr_lns)]; + slp = GetCurrentLine(); standing = YEA; slp->sso = slp->eso = cur_col; slp->mode |= STANDOUT; @@ -453,7 +478,7 @@ standend() if (standing && strtstandoutlen) { register screenline_t *slp; - slp = &big_picture[((cur_ln + roll) % scr_lns)]; + slp = GetCurrentLine(); standing = NA; slp->eso = MAX(slp->eso, cur_col); } |