/* * Enter visual mode */ void vop(void) { register int c; #if 0 char atube[TUBESIZE + LBSIZE]; #endif ttymode f; /* mjm: was register */ if (!CA && UP == NOSTR) { if (initev) { toopen: merror("[Using open mode]"); putNFL(); oop(); return; } error("Visual needs addressible cursor or upline capability"); } if (OS && !EO) { if (initev) goto toopen; error("Can't use visual on a terminal which overstrikes"); } if (!CL) { if (initev) goto toopen; error("Visual requires clear screen capability"); } if (NS && !SF) { if (initev) goto toopen; error("Visual requires scrolling"); } ovbeg(); bastate = VISUAL; c = 0; if (any(peekchar(), "+-^.")) c = ex_getchar(); pastwh(); vsetsiz(isdigit(peekchar()) ? getnum() : value(WINDOW)); setwind(); ex_newline(); vok(atube); if (!inglobal) savevis(); Outchar = vputchar; vmoving = 0; f = ostart(); if (initev == 0) { vcontext(dot, c); vnline(NOSTR); } vmain(); Command = "visual"; ovend(f); }
/* * Repaint the screen, with cursor at curs, aftern an arbitrary change. * Handle notification on large changes. */ void vrepaint(char *curs) { wdot = NOLINE; /* * In open want to notify first. */ noteit(0); vscrap(); /* * Deal with a totally useless display. */ if (vcnt == 0 || vcline < 0 || vcline > vcnt || holdupd && state != VISUAL) { register line *odol = dol; vcnt = 0; if (holdupd) if (state == VISUAL) ignore(peekkey()); else vup1(); holdupd = 0; if (odol == zero) fixzero(); vcontext(dot, '.'); noteit(1); if (noteit(1) == 0 && odol == zero) { CATCH error(catgets(catd, 1, 220, "No lines in buffer")); ENDCATCH linebuf[0] = 0; splitw = 0; } vnline(curs); return; } /* * Have some useful displayed text; refresh it. */ getDOT(); /* * This is for boundary conditions in open mode. */ if (FLAGS(0) & VDIRT) vsync(WTOP); /* * If the current line is after the last displayed line * or the bottom of the screen, then special effort is needed * to get it on the screen. We first try a redraw at the * last line on the screen, hoping it will fill in where @ * lines are now. If this doesn't work, then roll it onto * the screen. */ if (vcline >= vcnt || LINE(vcline) > WBOT) { short oldhold = hold; hold |= HOLDAT, vredraw(LASTLINE), hold = oldhold; if (vcline >= vcnt) { register int i = vcline - vcnt + 1; dot -= i; vcline -= i; vroll(i); } else vsyncCL(); } else vsync(vcline > 0 ? LINE(vcline - 1) : WTOP); /* * Notification on large change for visual * has to be done last or we may lose * the echo area with redisplay. */ noteit(1); /* * Finally. Move the cursor onto the current line. */ vnline(curs); }