void refresh() /**/ { unsigned char *s,*t,*sen,*scs = line+cs; char **qbuf; int ln = 0,nvcs,nvln = -1,t0; cost = 0; if (resetneeded) { resetvideo(); resetneeded = 0; if (isset(SINGLELINEZLE) || !termok) vcs = 0; else printf("%s",pmpt); } zleactive = 1; if (isset(SINGLELINEZLE) || !termok) { singlerefresh(); return; } /* first, we generate the video line buffers so we know what to put on the screen. s = ptr into the video buffer. t = ptr into the real buffer. sen = end of the video buffer (eol) */ s = (unsigned char *)(nbuf[ln = 0]+pptlen); t = line; sen = (unsigned char *)(*nbuf+winw); for (; *t; t++) { if (icntrl((char)*t)) if (*t == '\n') { if (t == scs) { nvcs = (char *)s-nbuf[nvln = ln]; scs = (unsigned char *)NULL; } nextline } else if ((char)*t == '\t') { int t1 = (char *)s-nbuf[ln]; if ((t1|7)+1 >= winw) nextline else do *s++ = ' '; while ((++t1) & 7); }
void refresh(void) { static int inlist; /* avoiding recursion */ int canscroll = 0, /* number of lines we are allowed to scroll */ ln = 0, /* current line we're working on */ more_status = 0, /* more stuff in status line */ nvcs = 0, nvln = -1, /* video cursor column and line */ t0 = -1, /* tmp */ tosln = 0; /* tmp in statusline stuff */ unsigned char *s, /* pointer into the video buffer */ *t, /* pointer into the real buffer */ *sen, /* pointer to end of the video buffer (eol) */ *scs; /* pointer to cursor position in real buffer */ char **qbuf; /* tmp */ /* If this is called from listmatches() (indirectly via trashzle()), and * * that was called from the end of refresh(), then we don't need to do * * anything. All this `inlist' code is actually unnecessary, but it * * improves speed a little in a common case. */ if (inlist) return; #ifdef HAVE_SELECT cost = 0; /* reset */ #endif #ifndef WINNT /* Nov 96: <mason> I haven't checked how complete this is. sgtty stuff may or may not work */ oxtabs = ((SGTTYFLAG & SGTABTYPE) == SGTABTYPE); #else WINNT oxtabs = 0; #endif WINNT cleareol = 0; /* unset */ more_start = more_end = 0; /* unset */ if (isset(SINGLELINEZLE) || lines < 3 || (termflags & (TERM_NOUP | TERM_BAD | TERM_UNKNOWN))) termflags |= TERM_SHORT; else termflags &= ~TERM_SHORT; if (resetneeded) { onumscrolls = 0; setterm(); #if defined( TIOCGWINSZ) || defined(WINNT) if (winchanged) { moveto(0, 0); t0 = olnct; /* this is to clear extra lines even when */ winchanged = 0; /* the terminal cannot TCCLEAREOD */ } #endif resetvideo(); resetneeded = 0; /* unset */ oput_rpmpt = 0; /* no right-prompt currently on screen */ /* we probably should only have explicitly set attributes */ tsetcap(TCALLATTRSOFF, 0); tsetcap(TCSTANDOUTEND, 0); tsetcap(TCUNDERLINEEND, 0); if (!clearflag) if (tccan(TCCLEAREOD)) tcout(TCCLEAREOD); else cleareol = 1; /* request: clear to end of line */ if (t0 > -1) olnct = t0; if (termflags & TERM_SHORT) vcs = 0; else if (!clearflag && lpptlen) zwrite(lpptbuf, lpptlen, 1, shout); if (clearflag) { zputc('\r', shout); vcs = 0; moveto(0, pptw); } fflush(shout); clearf = clearflag; } else if (winw != columns || rwinh != lines) resetvideo(); /* now winw equals columns and winh equals lines width comparisons can be made with winw, height comparisons with winh */ if (termflags & TERM_SHORT) { singlerefresh(); return; } if (cs < 0) { #ifdef DEBUG fprintf(stderr, "BUG: negative cursor position\n"); fflush(stderr); #endif cs = 0; } scs = line + cs; numscrolls = 0; /* first, we generate the video line buffers so we know what to put on the screen - also determine final cursor position (nvln, nvcs) */ /* Deemed necessary by PWS 1995/05/15 due to kill-line problems */ if (!*nbuf) *nbuf = (char *)zalloc(winw + 2); s = (unsigned char *)(nbuf[ln = 0] + pptw); t = line; sen = (unsigned char *)(*nbuf + winw); for (; t < line+ll; t++) { if (t == scs) /* if cursor is here, remember it */ nvcs = s - (unsigned char *)(nbuf[nvln = ln]); if (*t == '\n') { /* newline */ nbuf[ln][winw + 1] = '\0'; /* text not wrapped */ nextline } else if (*t == '\t') { /* tab */