/* * 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); }
oop() { register char *ic; #ifndef u370 char atube[TUBESIZE + LBSIZE]; #endif ttymode f; /* mjm: was register */ int resize; if (resize = setjmp(venv)) { setsize(); initev = (char *)0; inopen = 0; addr1 = addr2 = dot; } (void)signal(SIGWINCH, winch); ovbeg(); if (peekchar() == '/') { ignore(compile(getchar(), 1)); savere(scanre); if (execute(0, dot) == 0) error("Fail|Pattern not found on addressed line"); ic = loc1; if (ic > linebuf && *ic == 0) ic--; } else { getDOT(); ic = vskipwh(linebuf); } newline(); /* * If overstrike then have to HARDOPEN * else if can move cursor up off current line can use CRTOPEN (~~vi1) * otherwise (ugh) have to use ONEOPEN (like adm3) */ if (OS && !EO) bastate = HARDOPEN; else if (CA || UP) bastate = CRTOPEN; else bastate = ONEOPEN; setwind(); /* * To avoid bombing on glass-crt's when the line is too long * pretend that such terminals are 160 columns wide. * If a line is too wide for display, we will dynamically * switch to hardcopy open mode. */ if (state != CRTOPEN) WCOLS = TUBECOLS; if (!inglobal) savevis(); vok(atube); if (state != CRTOPEN) COLUMNS = WCOLS; Outchar = vputchar; f = ostart(); if (state == CRTOPEN) { if (outcol == UKCOL) outcol = 0; vmoveitup(1, 1); } else outline = destline = WBOT; vshow(dot, NOLINE); vnline(ic); vmain(); if (state != CRTOPEN) vclean(); Command = "open"; ovend(f); (void)signal(SIGWINCH, SIG_DFL); }
/* * Do a z operation. * Code here is rather long, and very uninteresting. */ void vzop(int hadcnt, int cnt, register int c) { register line *addr; if (state != VISUAL) { /* * Z from open; always like a z=. * This code is a mess and should be cleaned up. */ vmoveitup(1, 1); vgoto(outline, 0); ostop(normf); setoutt(); addr2 = dot; vclear(); destline = WECHO; zop2(Xhadcnt ? Xcnt : value(WINDOW) - 1, '='); if (state == CRTOPEN) putnl(); putNFL(); termreset(); Outchar = vputchar; ignore(ostart()); vcnt = 0; outline = destline = 0; vjumpto(dot, cursor, 0); return; } if (hadcnt) { addr = zero + cnt; if (addr < one) addr = one; if (addr > dol) addr = dol; markit(addr); } else switch (c) { case '+': addr = dot + vcnt - vcline; break; case '^': addr = dot - vcline - 1; forbid (addr < one); c = '-'; break; default: addr = dot; break; } switch (c) { case '.': case '-': break; case '^': forbid (addr <= one); break; case '+': forbid (addr >= dol); /* fall into ... */ case CR: case NL: c = CR; break; default: beep(); return; } vmoving = 0; vjumpto(addr, NOSTR, c); }