/* * updateline() - like updateScreen() but only for cursor line * * This determines whether or not we need to call updateScreen() to examine * the entire screen for changes. This occurs if the size of the cursor line * (in rows) hasn't changed. */ void updateline() { int row; int n; screenalloc(); /* allocate screen buffers if size changed */ if (Nextscreen == NULL || RedrawingDisabled) return; screenchar(NULL, 0, 0); /* init cursor position of screenchar() */ outstr(T_CI); /* disable cursor */ row = screenline(Curpos.lnum, Cline_row, (int)Rows - 1); outstr(T_CV); /* enable cursor again */ n = row - Cline_row; if (n != Cline_size) /* line changed size */ { if (n < Cline_size) /* got smaller: delete lines */ s_del(row, Cline_size - n, FALSE); else /* got bigger: insert lines */ s_ins(Cline_row + Cline_size, n - Cline_size, FALSE); updateScreen(VALID_TO_CURSCHAR); } }
void cursupdate() { LPTR *p; int inc, c, nlines; int i; int didinc; if (bufempty()) { /* special case - file is empty */ *Topchar = *Filemem; *Curschar = *Filemem; } else if ( LINEOF(Curschar) < LINEOF(Topchar) ) { nlines = cntllines(Curschar,Topchar); /* if the cursor is above the top of */ /* the screen, put it at the top of the screen.. */ *Topchar = *Curschar; Topchar->index = 0; /* ... and, if we weren't very close to begin with, */ /* we scroll so that the line is close to the middle. */ if ( nlines > Rows/3 ) { for (i=0, p = Topchar; i < Rows/3 ;i++, *Topchar = *p) if ((p = prevline(p)) == NULL) break; } else s_ins(0, nlines-1); updatescreen(); } else if (LINEOF(Curschar) >= LINEOF(Botchar)) { nlines = cntllines(Botchar,Curschar); /* If the cursor is off the bottom of the screen, */ /* put it at the top of the screen.. */ /* ... and back up */ if ( nlines > Rows/3 ) { p = Curschar; for (i=0; i < (2*Rows)/3 ;i++) if ((p = prevline(p)) == NULL) break; *Topchar = *p; } else { scrollup(nlines); } updatescreen(); } Cursrow = Curscol = Cursvcol = 0; for ( p=Topchar; p->linep != Curschar->linep ;p = nextline(p) ) Cursrow += plines(p); Cline_row = Cursrow; Cline_size = plines(p); for (i=0; i <= Curschar->index ;i++) { c = Curschar->linep->s[i]; /* A tab gets expanded, depending on the current column */ if ( c == TAB && !P(P_LS) ) inc = P(P_TS) - (Curscol % P(P_TS)); else inc = chars[(unsigned)(c & 0xff)].ch_size; Curscol += inc; Cursvcol += inc; if ( Curscol >= Columns ) { Curscol -= Columns; Cursrow++; didinc = TRUE; } else didinc = FALSE; } if (didinc) Cursrow--; if (c == TAB && State == NORMAL && !P(P_LS)) { Curscol--; Cursvcol--; } else { Curscol -= inc; Cursvcol -= inc; } if (Curscol < 0) Curscol += Columns; if (set_want_col) { Curswant = Cursvcol; set_want_col = FALSE; } }