--- sbbs/src/sbbs3/syncview/syncview.c 2018/04/24 16:41:24 1.1.1.1 +++ sbbs/src/sbbs3/syncview/syncview.c 2018/04/24 16:44:41 1.1.1.2 @@ -7,30 +7,32 @@ #include "keys.h" #include "cterm.h" -#define SCROLL_LINES 1000 +#define SCROLL_LINES 100000 #define BUF_SIZE 1024 +struct cterminal *cterm; void viewscroll(void) { int top; int key; int i; - char *scrollback; struct text_info txtinfo; gettextinfo(&txtinfo); - /* ToDo: Watch this... may be too large for alloca() */ - scrollback=(char *)malloc((txtinfo.screenwidth*2*SCROLL_LINES)+(txtinfo.screenheight*txtinfo.screenwidth*2)); - memcpy(scrollback,cterm.scrollback,txtinfo.screenwidth*2*SCROLL_LINES); - gettext(1,1,txtinfo.screenwidth,txtinfo.screenheight,scrollback+(cterm.backpos)*cterm.width*2); - top=cterm.backpos; + cterm->backpos+=cterm->height; + if(cterm->backpos>cterm->backlines) { + memmove(cterm->scrollback,cterm->scrollback+cterm->width*2*(cterm->backpos-cterm->backlines),cterm->width*2*(cterm->backlines-(cterm->backpos-cterm->backlines))); + cterm->backpos=cterm->backlines; + } + gettext(1,1,txtinfo.screenwidth,txtinfo.screenheight,cterm->scrollback+(cterm->backpos)*cterm->width*2); + top=cterm->backpos; for(i=0;!i;) { if(top<1) top=1; - if(top>cterm.backpos) - top=cterm.backpos; - puttext(1,1,txtinfo.screenwidth,txtinfo.screenheight,scrollback+(txtinfo.screenwidth*2*top)); + if(top>cterm->backpos) + top=cterm->backpos; + puttext(1,1,txtinfo.screenwidth,txtinfo.screenheight,cterm->scrollback+(txtinfo.screenwidth*2*top)); key=getch(); switch(key) { case 0xff: @@ -71,7 +73,6 @@ void viewscroll(void) break; } } - free(scrollback); return; } @@ -99,26 +100,21 @@ int main(int argc, char **argv) FILE *f; char buf[BUF_SIZE*2]; /* Room for lfexpand */ int len; - int speed; + int speed=0; char *scrollbuf; char *infile=NULL; char title[MAX_PATH+1]; int expand=0; + int ansi=0; int i; - textmode(C80); - gettextinfo(&ti); - if((scrollbuf=malloc(SCROLL_LINES*ti.screenwidth*2))==NULL) { - cprintf("Cannot allocate memory\n\n\rPress any key to exit."); - getch(); - return(-1); - } - /* Parse command line */ for(i=1; i