creps@silver.bacs.indiana.edu (Steve Creps) (01/24/88)
I went back and had some more trouble after changing the routine I mentioned in my last message. Then I realized that the PC Curses code itself was dependent on _maxy and _maxx being equal to the number of lines or columns in a window. That meant I had to go through all the code replacing these variables as appropriate. Thank goodness for fgrep! After recompiling the Curses library with these changes, the program I'm porting worked well. Patches follow my .signature. - - - - - - - - - Steve Creps on the VAX 8650 running Ultrix 2.0-1 at Indiana University. creps@silver.bacs.indiana.edu, ...iuvax!silver!creps, creps@iubacs.bitnet "F-14 Tomcat! There IS no substitute." *** old/boxes.c --- boxes.c ************** *** 36,42 int i; if (ymax == 0) ! ymax = win->_maxy; if (xmax == 0) xmax = win->_maxx; --- 36,42 ----- int i; if (ymax == 0) ! ymax = win->_maxy - 1; if (xmax == 0) xmax = win->_maxx - 1; ************** *** 38,44 if (ymax == 0) ymax = win->_maxy; if (xmax == 0) ! xmax = win->_maxx; if (ymin >= win->_maxy || ymax > win->_maxy || xmin >= win->_maxx || xmax > win->_maxx || --- 38,44 ----- if (ymax == 0) ymax = win->_maxy - 1; if (xmax == 0) ! xmax = win->_maxx - 1; if (ymin >= win->_maxy || ymax > win->_maxy || xmin >= win->_maxx || xmax > win->_maxx || *** old/charadd.c --- charadd.c ************** *** 51,57 int ts = win->_tabsize; ch &= 0xff; /* kill any sing-extend */ ! if (y > win->_maxy || x > win->_maxx || y < 0 || x < 0) return(ERR); switch (ch) { --- 51,57 ----- int ts = win->_tabsize; ch &= 0xff; /* kill any sing-extend */ ! if (y >= win->_maxy || x >= win->_maxx || y < 0 || x < 0) return(ERR); switch (ch) { ************** *** 95,101 win->_maxchng[y] = x; } /* if */ win->_line[y][x++] = ch; ! if (x > win->_maxx) /* wrap around test */ { x = 0; if ((y = newline(win, y)) < 0) --- 95,101 ----- win->_maxchng[y] = x; } /* if */ win->_line[y][x++] = ch; ! if (x >= win->_maxx) /* wrap around test */ { x = 0; if ((y = newline(win, y)) < 0) *** old/chardel.c --- chardel.c ************** *** 28,34 int *end; short y = win->_cury; short x = win->_curx; ! short maxx = win->_maxx; end = &win->_line[y][maxx]; temp1 = &win->_line[y][x]; --- 28,34 ----- int *end; short y = win->_cury; short x = win->_curx; ! short maxx = win->_maxx - 1; end = &win->_line[y][maxx]; temp1 = &win->_line[y][x]; *** old/charins.c --- charins.c ************** *** 28,34 int *end; int x = win->_curx; int y = win->_cury; ! int maxx = win->_maxx; if((c < ' ') && (c == '\n' || c == '\r' || c == '\t' || c == '\b')) return(waddch(win, c)); --- 28,34 ----- int *end; int x = win->_curx; int y = win->_cury; ! int maxx = win->_maxx - 1; if((c < ' ') && (c == '\n' || c == '\r' || c == '\t' || c == '\b')) return(waddch(win, c)); *** old/clrtobot.c --- clrtobot.c ************** *** 35,41 for (y = win->_cury; y <= win->_regbottom; y++) { minx = _NO_CHANGE; ! end = &win->_line[y][win->_maxx]; for (ptr = &win->_line[y][startx]; ptr <= end; ptr++) { if (*ptr != blank) --- 35,41 ----- for (y = win->_cury; y <= win->_regbottom; y++) { minx = _NO_CHANGE; ! end = &win->_line[y][win->_maxx - 1]; for (ptr = &win->_line[y][startx]; ptr <= end; ptr++) { if (*ptr != blank) *** old/clrtoeol.c --- clrtoeol.c ************** *** 34,40 x = win->_curx; blank = ' ' | (win->_attrs & ATR_MSK); ! end = &win->_line[y][win->_maxx]; minx = _NO_CHANGE; maxx = &win->_line[y][x]; for (ptr = maxx; ptr <= end; ptr++) --- 34,40 ----- x = win->_curx; blank = ' ' | (win->_attrs & ATR_MSK); ! end = &win->_line[y][win->_maxx - 1]; minx = _NO_CHANGE; maxx = &win->_line[y][x]; for (ptr = maxx; ptr <= end; ptr++) *** old/linedel.c --- linedel.c ************** *** 35,41 { win->_line[y] = win->_line[y+1]; win->_minchng[y] = 0; ! win->_maxchng[y] = win->_maxx; } win->_minchng[y] = 0; win->_maxchng[y] = win->_maxx; --- 35,41 ----- { win->_line[y] = win->_line[y+1]; win->_minchng[y] = 0; ! win->_maxchng[y] = win->_maxx - 1; } win->_minchng[y] = 0; win->_maxchng[y] = win->_maxx - 1; ************** *** 38,44 win->_maxchng[y] = win->_maxx; } win->_minchng[y] = 0; ! win->_maxchng[y] = win->_maxx; win->_line[win->_regbottom] = temp; for (end = &(temp[win->_maxx]); temp <= end;) *temp++ = blank; --- 38,44 ----- win->_maxchng[y] = win->_maxx - 1; } win->_minchng[y] = 0; ! win->_maxchng[y] = win->_maxx - 1; win->_line[win->_regbottom] = temp; for (end = &(temp[win->_maxx - 1]); temp <= end;) *temp++ = blank; ************** *** 40,46 win->_minchng[y] = 0; win->_maxchng[y] = win->_maxx; win->_line[win->_regbottom] = temp; ! for (end = &(temp[win->_maxx]); temp <= end;) *temp++ = blank; return(OK); } /* wdeleteln */ --- 40,46 ----- win->_minchng[y] = 0; win->_maxchng[y] = win->_maxx - 1; win->_line[win->_regbottom] = temp; ! for (end = &(temp[win->_maxx - 1]); temp <= end;) *temp++ = blank; return(OK); } /* wdeleteln */ *** old/lineins.c --- lineins.c ************** *** 33,39 { win->_line[y] = win->_line[y-1]; win->_minchng[y] = 0; ! win->_maxchng[y] = win->_maxx; } /* for */ win->_line[win->_cury] = temp; for (end = &temp[win->_maxx]; temp <= end; temp++) --- 33,39 ----- { win->_line[y] = win->_line[y-1]; win->_minchng[y] = 0; ! win->_maxchng[y] = win->_maxx - 1; } /* for */ win->_line[win->_cury] = temp; for (end = &temp[win->_maxx - 1]; temp <= end; temp++) ************** *** 36,42 win->_maxchng[y] = win->_maxx; } /* for */ win->_line[win->_cury] = temp; ! for (end = &temp[win->_maxx]; temp <= end; temp++) *temp = blank; win->_minchng[win->_cury] = 0; win->_maxchng[win->_cury] = win->_maxx; --- 36,42 ----- win->_maxchng[y] = win->_maxx - 1; } /* for */ win->_line[win->_cury] = temp; ! for (end = &temp[win->_maxx - 1]; temp <= end; temp++) *temp = blank; win->_minchng[win->_cury] = 0; win->_maxchng[win->_cury] = win->_maxx - 1; ************** *** 39,45 for (end = &temp[win->_maxx]; temp <= end; temp++) *temp = blank; win->_minchng[win->_cury] = 0; ! win->_maxchng[win->_cury] = win->_maxx; return(OK); } /* winsertln */ --- 39,45 ----- for (end = &temp[win->_maxx - 1]; temp <= end; temp++) *temp = blank; win->_minchng[win->_cury] = 0; ! win->_maxchng[win->_cury] = win->_maxx - 1; return(OK); } /* winsertln */ *** old/move.c --- move.c ************** *** 23,29 int y; int x; { ! if ((x < 0)||(x > win->_maxx)||(y < win->_regtop)||(y >win->_regbottom)) return(ERR); win->_curx = x; win->_cury = y; --- 23,29 ----- int y; int x; { ! if ((x < 0)||(x >= win->_maxx)||(y < win->_regtop)||(y >win->_regbottom)) return(ERR); win->_curx = x; win->_cury = y; *** old/newwin.c --- newwin.c ************** *** 59,66 win->_curx = 0; win->_cury = 0; ! win->_maxy = num_lines - 1; ! win->_maxx = num_columns - 1; win->_begy = begy; win->_begx = begx; win->_flags = 0; --- 59,66 ----- win->_curx = 0; win->_cury = 0; ! win->_maxy = num_lines; ! win->_maxx = num_columns; win->_begy = begy; win->_begx = begx; win->_flags = 0; ************** *** 157,164 if ( begy < orig->_begy || begx < orig->_begx || ! (begy + num_lines) > (orig->_begy + orig->_maxy) || ! (begx + num_columns) > (orig->_begx + orig->_maxx) ) return((WINDOW *) ERR); --- 157,164 ----- if ( begy < orig->_begy || begx < orig->_begx || ! (begy + num_lines) >= (orig->_begy + orig->_maxy) || ! (begx + num_columns) >= (orig->_begx + orig->_maxx) ) return((WINDOW *) ERR); ************** *** 163,169 return((WINDOW *) ERR); if (num_lines == 0) ! num_lines = orig->_maxy - (begy - orig->_begy); if (num_columns == 0) num_columns = orig->_maxx - (begx - orig->_begx); if ((win = makenew(num_lines, num_columns, begy, begx)) == (WINDOW *) ERR) --- 163,169 ----- return((WINDOW *) ERR); if (num_lines == 0) ! num_lines = orig->_maxy - 1 - (begy - orig->_begy); if (num_columns == 0) num_columns = orig->_maxx - 1 - (begx - orig->_begx); if ((win = makenew(num_lines, num_columns, begy, begx)) == (WINDOW *) ERR) ************** *** 165,171 if (num_lines == 0) num_lines = orig->_maxy - (begy - orig->_begy); if (num_columns == 0) ! num_columns = orig->_maxx - (begx - orig->_begx); if ((win = makenew(num_lines, num_columns, begy, begx)) == (WINDOW *) ERR) return((WINDOW *) ERR); --- 165,171 ----- if (num_lines == 0) num_lines = orig->_maxy - 1 - (begy - orig->_begy); if (num_columns == 0) ! num_columns = orig->_maxx - 1 - (begx - orig->_begx); if ((win = makenew(num_lines, num_columns, begy, begx)) == (WINDOW *) ERR) return((WINDOW *) ERR); *** old/overlay.c --- overlay.c ************** *** 33,40 int last_line; int last_col; ! last_col = min(win1->_maxx, win2->_maxx); ! last_line = min(win1->_maxy, win2->_maxy); attrs = win2->_attrs & ATR_MSK; minchng = win2->_minchng; maxchng = win2->_maxchng; --- 33,40 ----- int last_line; int last_col; ! last_col = min(win1->_maxx, win2->_maxx) - 1; ! last_line = min(win1->_maxy, win2->_maxy) - 1; attrs = win2->_attrs & ATR_MSK; minchng = win2->_minchng; maxchng = win2->_maxchng; ************** *** 95,102 int last_col; last_col = min(win1->_maxx, win2->_maxx); ! last_line = min(win1->_maxy, win2->_maxy); ! attrs = win2->_attrs & ATR_MSK; minchng = win2->_minchng; maxchng = win2->_maxchng; --- 95,102 ----- int last_line; int last_col; ! last_col = min(win1->_maxx, win2->_maxx) - 1; ! last_line = min(win1->_maxy, win2->_maxy) - 1; attrs = win2->_attrs & ATR_MSK; minchng = win2->_minchng; maxchng = win2->_maxchng; *** old/refresh.c --- refresh.c ************** *** 53,59 begy = win->_begy; begx = win->_begx; ! for (i=0, j=begy; i <= win->_maxy; i++, j++) { if (win->_minchng[i] != _NO_CHANGE) { --- 53,59 ----- begy = win->_begy; begx = win->_begx; ! for (i=0, j=begy; i < win->_maxy; i++, j++) { if (win->_minchng[i] != _NO_CHANGE) { *** old/scrreg.c --- scrreg.c ************** *** 30,36 && (win->_cury <= bottom) && ! (bottom <= win->_maxy) ) { win->_regtop = top; --- 30,36 ----- && (win->_cury <= bottom) && ! (bottom < win->_maxy) ) { win->_regtop = top; *** old/strget.c --- strget.c ************** *** 152,158 x += 2; else /* normal char */ x++; ! if (x > w->_maxx) /* go to next line? */ x = 0; } /* while */ if (!(w->_curx)) /* if step-over newline */ --- 152,158 ----- x += 2; else /* normal char */ x++; ! if (x >= w->_maxx) /* go to next line? */ x = 0; } /* while */ if (!(w->_curx)) /* if step-over newline */ ************** *** 156,162 x = 0; } /* while */ if (!(w->_curx)) /* if step-over newline */ ! nbs = w->_maxx+1 - x; else /* in-line tab */ nbs = w->_curx - x; /* positions to erase */ } /* if */ --- 156,162 ----- x = 0; } /* while */ if (!(w->_curx)) /* if step-over newline */ ! nbs = w->_maxx - x; else /* in-line tab */ nbs = w->_curx - x; /* positions to erase */ } /* if */ ************** *** 168,175 (w->_cury) /* if not on top line */ { mvwaddch(w,w->_cury-1,w->_maxx,' '); /* put space at line end */ ! wmove(w,w->_cury-1,w->_maxx); /* and go there again */ ! } /* else */ } /* while */ wrefresh(w); /* redraw screen */ --- 168,175 ----- else if (w->_cury) /* if not on top line */ { ! mvwaddch(w,w->_cury-1,w->_maxx - 1,' ');/* put space at line end */ ! wmove(w,w->_cury-1,w->_maxx - 1); /* and go there again */ } /* else */ } /* while */ *** old/windel.c --- windel.c ************** *** 27,33 { int i; ! if (! (win->_flags & _SUBWIN)) /* subwindow uses 'parent's' lines */ { for (i = 0; i <= win->_maxy && win->_line[i]; i++) free(win->_line[i]); --- 27,33 ----- if (! (win->_flags & _SUBWIN)) /* subwindow uses 'parent's' lines */ { ! for (i = 0; i < win->_maxy && win->_line[i]; i++) free(win->_line[i]); } free(win->_minchng); *** old/winerase.c --- winerase.c ************** *** 33,39 for (y = win->_regtop; y <= win->_regbottom; y++) /* clear all lines */ { start = win->_line[y]; ! end = &start[win->_maxx]; while (start <= end) /* clear all line */ *start++ = blank; win->_minchng[y] = 0; --- 33,39 ----- for (y = win->_regtop; y <= win->_regbottom; y++) /* clear all lines */ { start = win->_line[y]; ! end = &start[win->_maxx - 1]; while (start <= end) /* clear all line */ *start++ = blank; win->_minchng[y] = 0; ************** *** 37,43 while (start <= end) /* clear all line */ *start++ = blank; win->_minchng[y] = 0; ! win->_maxchng[y] = win->_maxx; } win->_cury = win->_regtop; /* cursor home */ win->_curx = 0; --- 37,43 ----- while (start <= end) /* clear all line */ *start++ = blank; win->_minchng[y] = 0; ! win->_maxchng[y] = win->_maxx - 1; } win->_cury = win->_regtop; /* cursor home */ win->_curx = 0; *** old/winmove.c --- winmove.c ************** *** 23,29 WINDOW *win; int begy, begx; { ! if ((begy + win->_maxy) > (LINES-1) || (begx + win->_maxx) > (COLS-1)) return(ERR); win->_begy = begy; win->_begx = begx; --- 23,29 ----- WINDOW *win; int begy, begx; { ! if ((begy + win->_maxy) >= (LINES-1) || (begx + win->_maxx) >= (COLS-1)) return(ERR); win->_begy = begy; win->_begx = begx; *** old/winscrol.c --- winscrol.c ************** *** 40,46 { win->_line[i] = win->_line[i+1]; /* re-arrange line pointers */ win->_minchng[i] = 0; ! win->_maxchng[i] = win->_maxx; } for (ptr = temp; ptr - temp <= win->_maxx; ptr++) *ptr = blank; /* make a blank line */ --- 40,46 ----- { win->_line[i] = win->_line[i+1]; /* re-arrange line pointers */ win->_minchng[i] = 0; ! win->_maxchng[i] = win->_maxx - 1; } for (ptr = temp; ptr - temp < win->_maxx; ptr++) *ptr = blank; /* make a blank line */ ************** *** 42,48 win->_minchng[i] = 0; win->_maxchng[i] = win->_maxx; } ! for (ptr = temp; ptr - temp <= win->_maxx; ptr++) *ptr = blank; /* make a blank line */ win->_line[win->_regbottom] = temp; if (win->_cury > win->_regtop) /* if not on top line */ --- 42,48 ----- win->_minchng[i] = 0; win->_maxchng[i] = win->_maxx - 1; } ! for (ptr = temp; ptr - temp < win->_maxx; ptr++) *ptr = blank; /* make a blank line */ win->_line[win->_regbottom] = temp; if (win->_cury > win->_regtop) /* if not on top line */ ************** *** 48,52 = temp; if (win->_cury > win->_regtop) /* if not on top line */ win->_cury--; /* cursor scrolls too */ ! win->_minchng[win->_regbottom] = 0; win->_maxchng[win->_regbottom] = win->_maxx; --- 48,52 ----- if (win->_cury > win->_regtop) /* if not on top line */ win->_cury--; /* cursor scrolls too */ win->_minchng[win->_regbottom] = 0; ! win->_maxchng[win->_regbottom] = win->_maxx - 1; } /* scroll */