sc 5.1 bugfix

Alan Lee Wendt wendt at arizona.edu
Wed Sep 14 05:33:01 AEST 1988


Here's a patch for what is either a bug in sc 5.1 or my curses.  On my
system, if you go to the bottom of the worksheet with 999 down-arrow,
it positions the last line of the worksheet at the middle of the page
and doesn't erase the bottom of the page.  I fixed this by positioning
the last line of the sheet at the last line of the page if necessary,
so now the only lurking bug is if there are fewer visible lines in the
worksheet than there are in the screen, but in that case the bottom of
the screen should be blank anyway.  For 999 right-arrow, it positions
the rightmost worksheet column at the middle screen column and erases
the right-hand side of the page, so I left that alone.

There are also a couple cosmetic changes and some stuff to make the
data area take up less room on my PC.  As the changes are not tested
anywhere but on my system, be careful!

I tried to send this to rgb privately before worldwide distribution,
but the mail bounced, so here it is:

Alan W.


sc version 5.1


*** sc.c	Mon Sep 12 20:38:24 1988
--- newsc.c	Tue Sep 13 01:19:24 1988
***************
*** 46,52 ****
  int FullUpdate;
  int maxrow, maxcol;
  int fwidth[MAXCOLS];
! int precision[MAXCOLS];
  char col_hidden[MAXCOLS];
  char row_hidden[MAXROWS];
  char line[1000];
--- 46,52 ----
  int FullUpdate;
  int maxrow, maxcol;
  int fwidth[MAXCOLS];
! unsigned char precision[MAXCOLS];
  char col_hidden[MAXCOLS];
  char row_hidden[MAXROWS];
  char line[1000];
***************
*** 189,202 ****
  	}
      }
      /* Now - same process on the rows */
      if (strow <= currow) { 
  	for (i = strow, rows = 0, row=RESROW; row<LINES && i<MAXROWS; i++) {
  	    rows++;
! 	    if (row_hidden[i])
! 		continue;
! 	    row++;
  	}
      }
      while (strow + rows - 1 < currow || currow < strow) {
  	FullUpdate++;
  	if (strow - 1 == currow) {    /* How about up one? */
--- 189,202 ----
  	}
      }
      /* Now - same process on the rows */
+     /*  see if the current row is on the screen */
      if (strow <= currow) {
  	for (i = strow, rows = 0, row=RESROW; row<LINES && i<MAXROWS; i++) {
  	    rows++;
! 	    if (!row_hidden[i]) row++;
  	}
      }
+ 
      while (strow + rows - 1 < currow || currow < strow) {
  	FullUpdate++;
  	if (strow - 1 == currow) {    /* How about up one? */
***************
*** 204,225 ****
  	} else if (strow + rows == currow) {   /* Down one? */
  	    strow++;
  	} else {
! 	    /* Try to put the cursor in the center of the screen */
! 	    row = (LINES - RESROW) / 2 + RESROW; 
  	    strow = currow;
  	    for (i=currow-1; i >= 0 && row-1 > RESROW; i--) {
  		strow--;
! 		if (row_hidden[i])
! 		    continue;
! 		row--;
  	    }
  	}
  	/* Now pick up the counts again */
  	for (i = strow, rows = 0, row=RESROW; row<LINES && i<MAXROWS; i++) {
  	    rows++;
! 	    if (row_hidden[i])
! 		continue;
! 	    row++;
  	}
      }
      mxcol = stcol + cols - 1;
--- 204,230 ----
  	} else if (strow + rows == currow) {   /* Down one? */
  	    strow++;
  	} else {
! 	    /*  screen rows:  RESROW   <=    row    <  LINES         */
! 	    /*  file rows:      0      <=    currow <  MAXROWS       */
! 	    /*  strow is file row corresponding to screen row RESROW */
! 	    /*  rows is # of hidden & visible rows on the screen.    */
! 	    /*                0        <=    strow                   */
! 	    /*                               strow + rows < MAXROWS  */
! 	    for (i = MAXROWS - 1, row = LINES; i > 0 && row > RESROW;i--) {
! 		if (row == (LINES - RESROW) / 2 + RESROW || i == currow)
! 		    break;
! 		if (!row_hidden[i]) row--;
! 		}
  	    strow = currow;
  	    for (i=currow-1; i >= 0 && row-1 > RESROW; i--) {
  		strow--;
! 		if (!row_hidden[i]) row--;
  	    }
  	}
  	/* Now pick up the counts again */
  	for (i = strow, rows = 0, row=RESROW; row<LINES && i<MAXROWS; i++) {
  	    rows++;
! 	    if (!row_hidden[i]) row++;
  	}
      }
      mxcol = stcol + cols - 1;



More information about the Comp.sources.bugs mailing list