summaryrefslogtreecommitdiffstats
path: root/mbbsd/screen.c
diff options
context:
space:
mode:
authorvictor <victor@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2005-08-15 18:09:51 +0800
committervictor <victor@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2005-08-15 18:09:51 +0800
commita8cfec296b543e31bf596b61c86473d094afc5fc (patch)
tree8766f9f2d9ac385652ae4a07d217ae906a6aa32d /mbbsd/screen.c
parent7cf467de869336579256b535fa605b0aa53b991c (diff)
downloadpttbbs-a8cfec296b543e31bf596b61c86473d094afc5fc.tar
pttbbs-a8cfec296b543e31bf596b61c86473d094afc5fc.tar.gz
pttbbs-a8cfec296b543e31bf596b61c86473d094afc5fc.tar.bz2
pttbbs-a8cfec296b543e31bf596b61c86473d094afc5fc.tar.lz
pttbbs-a8cfec296b543e31bf596b61c86473d094afc5fc.tar.xz
pttbbs-a8cfec296b543e31bf596b61c86473d094afc5fc.tar.zst
pttbbs-a8cfec296b543e31bf596b61c86473d094afc5fc.zip
screen-resize awareness between screen_backup() and screen_restore().
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3038 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd/screen.c')
-rw-r--r--mbbsd/screen.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/mbbsd/screen.c b/mbbsd/screen.c
index b9b57b90..b7bde5ff 100644
--- a/mbbsd/screen.c
+++ b/mbbsd/screen.c
@@ -15,7 +15,6 @@ static int scrollcnt, tc_col, tc_line;
#define MODIFIED (1) /* if line has been modifed, screen output */
#define STANDOUT (2) /* if this line has a standout region */
-
void
initscr(void)
{
@@ -522,11 +521,15 @@ standend(void)
}
}
-// XXX race: signal handler write to screen, data larger than allocated buf
-void screen_backup(int len, const screenline_t *bp, void *buf)
+void screen_backup(int len, const screenline_t *bp, screen_backup_t *old)
{
int i;
size_t offset=0;
+ void *buf = old->raw_memory;
+
+ old->col = t_columns;
+ old->row = t_lines;
+
for(i=0;i<len;i++) {
memcpy((char*)buf+offset, &bp[i], ((char*)&bp[i].data-(char*)&bp[i]));
offset+=((char*)&bp[i].data-(char*)&bp[i]);
@@ -544,10 +547,21 @@ size_t screen_backupsize(int len, const screenline_t *bp)
return sum;
}
-void screen_restore(int len, screenline_t *bp, const void *buf)
+void screen_restore(int len, screenline_t *bp, const screen_backup_t *old)
{
int i;
size_t offset=0;
+ void *buf = old->raw_memory;
+
+ // TODO try to be more user friendly.
+ if (old->col > t_columns || old->row > t_lines) {
+ move(1, 0);
+ clrtobot();
+ move(2, 2);
+ outs("偵測到視窗改變大小,畫面繪製將會暫時失效");
+ return;
+ }
+
for(i=0;i<len;i++) {
memcpy(&bp[i], (char*)buf+offset, ((char*)&bp[i].data-(char*)&bp[i]));
offset+=((char*)&bp[i].data-(char*)&bp[i]);